From a747e5935d64a2ccdb8a68da69b736b5a17604d4 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 19 Feb 2015 19:50:52 +0000 Subject: Checking if TARGET_OS_IPHONE is defined isn't good enough for 10.7 and earlier. Older versions of the TargetConditionals header always defined TARGET_OS_IPHONE to something (0 or 1), so we need to test not only for the existence but also if it is 1. This resolves PR22631. llvm-svn: 229904 --- llvm/lib/Support/Unix/Program.inc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Support/Unix/Program.inc') diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc index 2ed5597e4ad..baf2767ad58 100644 --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -42,10 +42,18 @@ #define _RESTRICT_KYWD #endif #include + #if defined(__APPLE__) #include #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 // _NSGetEnviron @@ -220,7 +228,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program, const char **args, } if (!envp) -#if !defined(__APPLE__) || defined(TARGET_OS_IPHONE) +#if !USE_NSGETENVIRON envp = const_cast(environ); #else // environ is missing in dylibs. -- cgit v1.2.3