summaryrefslogtreecommitdiff
path: root/lib/Support/Unix
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-12 20:58:35 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-12 20:58:35 +0000
commit9f1d9fd1964d82f3e801efb71518144492cdf290 (patch)
treefb6a689c0275a2c77086b695db3b5065ce454bf2 /lib/Support/Unix
parent7e17024400941889b6fe1b178e5374f75c34d9ab (diff)
downloadllvm-9f1d9fd1964d82f3e801efb71518144492cdf290.tar.gz
llvm-9f1d9fd1964d82f3e801efb71518144492cdf290.tar.bz2
llvm-9f1d9fd1964d82f3e801efb71518144492cdf290.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183864 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix')
-rw-r--r--lib/Support/Unix/Program.inc38
1 files changed, 17 insertions, 21 deletions
diff --git a/lib/Support/Unix/Program.inc b/lib/Support/Unix/Program.inc
index aa03d48438..0d6543a8a8 100644
--- a/lib/Support/Unix/Program.inc
+++ b/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);
}