Commit 12799d0f authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺
Browse files

Have Autoconf test for _NSGetEnviron presence

parent 081376c3
......@@ -78,9 +78,8 @@ getEnvironmentPrim = do
mapM peekFilePath arr
getCEnviron :: IO (Ptr CString)
#if darwin_HOST_OS
-- You should not access _environ directly on Darwin in a bundle/shared library.
#if HAVE__NSGETENVIRON
-- You should not access @char **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
getCEnviron = nsGetEnviron >>= peek
......@@ -88,7 +87,6 @@ foreign import ccall unsafe "_NSGetEnviron"
nsGetEnviron :: IO (Ptr (Ptr CString))
#else
getCEnviron = peek c_environ_p
foreign import ccall unsafe "&environ"
c_environ_p :: Ptr (Ptr CString)
#endif
......
......@@ -69,8 +69,8 @@ getEnvironmentPrim = do
mapM B.packCString arr
getCEnviron :: IO (Ptr CString)
#if darwin_HOST_OS
-- You should not access _environ directly on Darwin in a bundle/shared library.
#if HAVE__NSGETENVIRON
-- You should not access @char **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
getCEnviron = nsGetEnviron >>= peek
......
......@@ -40,6 +40,10 @@ AC_CHECK_FUNCS([readdir_r])
dnl not available on android so check for it
AC_CHECK_FUNCS([telldir seekdir])
dnl When available, _NSGetEnviron() (defined in <crt_externs.h>) is
dnl the preferred way to access environ(7)
AC_CHECK_FUNCS([_NSGetEnviron])
dnl This is e.g. available as a GNU extension in glibc 2.11+
AC_CHECK_DECLS([execvpe])
AC_CHECK_FUNCS([execvpe])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment