diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-12 20:58:35 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-12 20:58:35 +0000 |
commit | cb2eca0f91ae8012b96999f3b2ff3e023af4d364 (patch) | |
tree | 8c5a828e1955b5d83a071b06d73bb403c9a54e78 /llvm/lib/Support/Unix | |
parent | c2467c4e9b7997bcab43e858b4448e2c6e0d9224 (diff) | |
download | bcm5719-llvm-cb2eca0f91ae8012b96999f3b2ff3e023af4d364.tar.gz bcm5719-llvm-cb2eca0f91ae8012b96999f3b2ff3e023af4d364.zip |
Remove the program class.
It was only used to implement ExecuteAndWait and ExecuteNoWait. Expose just
those two functions and make Execute and Wait implementations details.
llvm-svn: 183864
Diffstat (limited to 'llvm/lib/Support/Unix')
-rw-r--r-- | llvm/lib/Support/Unix/Program.inc | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc index aa03d48438e..0d6543a8a8c 100644 --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -47,13 +47,9 @@ namespace llvm { using namespace sys; -Program::Program() : Data_(0) {} - -Program::~Program() {} - // This function just uses the PATH environment variable to find the program. Path -Program::FindProgramByName(const std::string& progName) { +sys::FindProgramByName(const std::string& progName) { // Check some degenerate cases if (progName.length() == 0) // no program @@ -180,10 +176,11 @@ static void SetMemoryLimits (unsigned size) #endif } -bool -Program::Execute(const Path &path, const char **args, const char **envp, - const Path **redirects, unsigned memoryLimit, - std::string *ErrMsg) { +} + +static bool Execute(void *&Data, const Path &path, const char **args, + const char **envp, const Path **redirects, + unsigned memoryLimit, std::string *ErrMsg) { // If this OS has posix_spawn and there is no memory limit being implied, use // posix_spawn. It is more efficient than fork/exec. #ifdef HAVE_POSIX_SPAWN @@ -231,7 +228,7 @@ Program::Execute(const Path &path, const char **args, const char **envp, if (Err) return !MakeErrMsg(ErrMsg, "posix_spawn failed", Err); - Data_ = reinterpret_cast<void*>(PID); + Data = reinterpret_cast<void*>(PID); return true; } #endif @@ -293,20 +290,17 @@ Program::Execute(const Path &path, const char **args, const char **envp, break; } - Data_ = reinterpret_cast<void*>(child); + Data = reinterpret_cast<void*>(child); return true; } -int -Program::Wait(const sys::Path &path, - unsigned secondsToWait, - std::string* ErrMsg) -{ +static int Wait(void *&Data, const sys::Path &path, unsigned secondsToWait, + std::string *ErrMsg) { #ifdef HAVE_SYS_WAIT_H struct sigaction Act, Old; - if (Data_ == 0) { + if (Data == 0) { MakeErrMsg(ErrMsg, "Process not started!"); return -1; } @@ -324,7 +318,7 @@ Program::Wait(const sys::Path &path, // Parent process: Wait for the child process to terminate. int status; - uint64_t pid = reinterpret_cast<uint64_t>(Data_); + uint64_t pid = reinterpret_cast<uint64_t>(Data); pid_t child = static_cast<pid_t>(pid); while (waitpid(pid, &status, 0) != child) if (secondsToWait && errno == EINTR) { @@ -397,17 +391,19 @@ Program::Wait(const sys::Path &path, #endif } -error_code Program::ChangeStdinToBinary(){ +namespace llvm { + +error_code sys::ChangeStdinToBinary(){ // Do nothing, as Unix doesn't differentiate between text and binary. return make_error_code(errc::success); } -error_code Program::ChangeStdoutToBinary(){ +error_code sys::ChangeStdoutToBinary(){ // Do nothing, as Unix doesn't differentiate between text and binary. return make_error_code(errc::success); } -error_code Program::ChangeStderrToBinary(){ +error_code sys::ChangeStderrToBinary(){ // Do nothing, as Unix doesn't differentiate between text and binary. return make_error_code(errc::success); } |