Skip to content
Snippets Groups Projects
Commit 12799d0f authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel :man_dancing:
Browse files

Have Autoconf test for _NSGetEnviron presence

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