[commit: base] master: Use _NSGetEnviron on OS X: fixes #2458 (47ac5d8)
Max Bolingbroke
batterseapower at hotmail.com
Wed Apr 6 08:57:45 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/base
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/47ac5d859493ae0cd8dd02e1b4848f993acc3d5c
>---------------------------------------------------------------
commit 47ac5d859493ae0cd8dd02e1b4848f993acc3d5c
Author: Max Bolingbroke <batterseapower at hotmail.com>
Date: Wed Apr 6 07:57:40 2011 +0100
Use _NSGetEnviron on OS X: fixes #2458
>---------------------------------------------------------------
include/HsBase.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/HsBase.h b/include/HsBase.h
index 9bc5f28..c8fabba 100644
--- a/include/HsBase.h
+++ b/include/HsBase.h
@@ -652,10 +652,17 @@ INLINE void setTimevalTicks(struct timeval *p, HsWord64 usecs)
}
#endif /* !defined(__MINGW32__) */
+#if darwin_HOST_OS
+// You should not access _environ directly on Darwin in a bundle/shared library.
+// See #2458 and http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man7/environ.7.html
+#include <crt_externs.h>
+INLINE char **__hscore_environ() { return *(_NSGetEnviron()); }
+#else
/* ToDo: write a feature test that doesn't assume 'environ' to
* be in scope at link-time. */
extern char** environ;
INLINE char **__hscore_environ() { return environ; }
+#endif
/* lossless conversions between pointers and integral types */
INLINE void * __hscore_from_uintptr(uintptr_t n) { return (void *)n; }
More information about the Cvs-libraries
mailing list