Merge branch 'master' of http://darcs.haskell.org/packages/base into ghc-generics
[ghc-base.git] / include / HsBase.h
index 56a660e..c8fabba 100644 (file)
@@ -201,6 +201,10 @@ __hscore_sigdelset( sigset_t * set, int s )
 INLINE int
 __hscore_sigismember( sigset_t * set, int s )
 { return sigismember(set,s); }
+
+INLINE int
+__hscore_utime( const char *file, const struct utimbuf *timep )
+{ return utime(file,timep); }
 #endif
 
 // This is used by dph:Data.Array.Parallel.Arr.BUArr, and shouldn't be
@@ -620,6 +624,11 @@ INLINE HsInt sizeof_fd_set(void) { return sizeof(fd_set); }
 extern void hsFD_ZERO(fd_set *fds);
 #endif
 
+INLINE int __hscore_select(int nfds, fd_set *readfds, fd_set *writefds,
+                           fd_set *exceptfds, struct timeval *timeout) {
+       return (select(nfds,readfds,writefds,exceptfds,timeout));
+}
+
 // gettimeofday()-related
 
 #if !defined(__MINGW32__)
@@ -643,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; }