Fix the build on OS X
authorIan Lynagh <igloo@earth.li>
Fri, 7 Aug 2009 15:21:51 +0000 (15:21 +0000)
committerIan Lynagh <igloo@earth.li>
Fri, 7 Aug 2009 15:21:51 +0000 (15:21 +0000)
includes/rts/FileLock.h
rts/Adjustor.c
rts/PosixSource.h

index 9a35ecc..ab59173 100644 (file)
@@ -9,6 +9,10 @@
 #ifndef RTS_FILELOCK_H
 #define RTS_FILELOCK_H
 
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
 int  lockFile(int fd, dev_t dev, ino_t ino, int for_writing);
 int  unlockFile(int fd);
 
index aa7a809..dcae59b 100644 (file)
@@ -43,10 +43,20 @@ Haskell side.
 #include "Stable.h"
 
 #if defined(USE_LIBFFI_FOR_ADJUSTORS)
-
 #include "ffi.h"
 #include <string.h>
+#endif
+
+#if defined(i386_HOST_ARCH) && defined(darwin_HOST_OS)
+extern void adjustorCode(void);
+#elif defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH)
+// from AdjustorAsm.s
+// not declared as a function so that AIX-style
+// fundescs can never get in the way.
+extern void *adjustorCode;
+#endif
 
+#if defined(USE_LIBFFI_FOR_ADJUSTORS)
 void
 freeHaskellFunctionPtr(void* ptr)
 {
@@ -423,7 +433,6 @@ createAdjustor(int cconv, StgStablePtr hptr,
         AdjustorStub *adjustorStub = allocateExec(sizeof(AdjustorStub),&code);
         adjustor = adjustorStub;
 
-        extern void adjustorCode(void);
         int sz = totalArgumentSize(typeString);
         
         adjustorStub->call[0] = 0xe8;
@@ -915,11 +924,6 @@ TODO: Depending on how much allocation overhead stgMallocBytes uses for
         AdjustorStub *adjustorStub;
         int sz = 0, extra_sz, total_sz;
 
-            // from AdjustorAsm.s
-            // not declared as a function so that AIX-style
-            // fundescs can never get in the way.
-        extern void *adjustorCode;
-        
 #ifdef FUNDESCS
         adjustorStub = stgMallocBytes(sizeof(AdjustorStub), "createAdjustor");
 #else
@@ -1154,7 +1158,6 @@ if ( *(unsigned char*)ptr != 0xe8 ) {
  }
  freeStablePtr(((StgStablePtr*)ptr)[1]);
 #elif defined(powerpc_HOST_ARCH) || defined(powerpc64_HOST_ARCH)
- extern void* adjustorCode;
  if ( ((AdjustorStub*)ptr)->code != (StgFunPtr) &adjustorCode ) {
    errorBelch("freeHaskellFunctionPtr: not for me, guv! %p\n", ptr);
    return;
index cd1aeea..b3da60f 100644 (file)
@@ -9,6 +9,8 @@
 #ifndef POSIXSOURCE_H
 #define POSIXSOURCE_H
 
+#include <ghcplatform.h>
+
 #define _POSIX_SOURCE   1
 #define _POSIX_C_SOURCE 199506L
 #define _XOPEN_SOURCE   500
 
 /* Let's be ISO C99 too... */
 
+#if defined(darwin_HOST_OS)
+/* If we don't define this the including sysctl breaks with things like
+    /usr/include/bsm/audit.h:224:0:
+         error: syntax error before 'u_char'
+*/
+#define _DARWIN_C_SOURCE 1
+#endif
+
 #endif /* POSIXSOURCE_H */