From 47ac5d859493ae0cd8dd02e1b4848f993acc3d5c Mon Sep 17 00:00:00 2001 From: Max Bolingbroke Date: Wed, 6 Apr 2011 07:57:40 +0100 Subject: [PATCH] Use _NSGetEnviron on OS X: fixes #2458 --- include/HsBase.h | 7 +++++++ 1 file changed, 7 insertions(+) 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 +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; } -- 1.7.10.4