#include "Unix.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/Config/config.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/Errc.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
-#include <llvm/Config/config.h>
#if HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#define _RESTRICT_KYWD
#endif
#include <spawn.h>
+
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
-#if !defined(__APPLE__) || defined(TARGET_OS_IPHONE)
+
+#if defined(__APPLE__) && !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
+#define USE_NSGETENVIRON 1
+#else
+#define USE_NSGETENVIRON 0
+#endif
+
+#if !USE_NSGETENVIRON
extern char **environ;
#else
#include <crt_externs.h> // _NSGetEnviron
if (sys::fs::can_execute(FilePath.c_str()))
return std::string(FilePath.str()); // Found the executable!
}
- return std::errc::no_such_file_or_directory;
+ return errc::no_such_file_or_directory;
}
static bool RedirectIO(const StringRef *Path, int FD, std::string* ErrMsg) {
}
if (!envp)
-#if !defined(__APPLE__) || defined(TARGET_OS_IPHONE)
+#if !USE_NSGETENVIRON
envp = const_cast<const char **>(environ);
#else
// environ is missing in dylibs.
ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait,
bool WaitUntilTerminates, std::string *ErrMsg) {
-#ifdef HAVE_SYS_WAIT_H
struct sigaction Act, Old;
assert(PI.Pid && "invalid pid to wait on, process not started?");
// signal during execution as opposed to failing to execute.
WaitResult.ReturnCode = -2;
}
-#else
- if (ErrMsg)
- *ErrMsg = "Program::Wait is not implemented on this platform yet!";
- ProcessInfo WaitResult;
- WaitResult.ReturnCode = -2;
-#endif
return WaitResult;
}
OS << Contents;
if (OS.has_error())
- return std::make_error_code(std::errc::io_error);
+ return make_error_code(errc::io_error);
return EC;
}