avoid platform dependencies: my_uintptr_t ==> StgWord
authorSimon Marlow <simonmar@microsoft.com>
Mon, 17 Sep 2007 12:01:56 +0000 (12:01 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Mon, 17 Sep 2007 12:01:56 +0000 (12:01 +0000)
rts/posix/OSMem.c

index 6e8337b..12cb43d 100644 (file)
 #include <sys/types.h>
 #include <sys/mman.h>
 
-/* no C99 header stdint.h on OpenBSD? */
-#if defined(openbsd_HOST_OS)
-typedef unsigned long my_uintptr_t;
-#else
-#include <stdint.h>
-typedef uintptr_t my_uintptr_t;
-#endif
-
 lnat getPageSize (void)
 {
     static lnat pageSize = 0;
@@ -38,13 +30,13 @@ lnat getPageSize (void)
 
 void setExecutable (void *p, lnat len, rtsBool exec)
 {
-    my_uintptr_t pageSize = getPageSize();
+    StgWord pageSize = getPageSize();
 
     /* malloced memory isn't executable by default on OpenBSD */
-    my_uintptr_t mask             = ~(pageSize - 1);
-    my_uintptr_t startOfFirstPage = ((my_uintptr_t)p          ) & mask;
-    my_uintptr_t startOfLastPage  = ((my_uintptr_t)p + len - 1) & mask;
-    my_uintptr_t size             = startOfLastPage - startOfFirstPage + pageSize;
+    StgWord mask             = ~(pageSize - 1);
+    StgWord startOfFirstPage = ((StgWord)p          ) & mask;
+    StgWord startOfLastPage  = ((StgWord)p + len - 1) & mask;
+    StgWord size             = startOfLastPage - startOfFirstPage + pageSize;
     if (mprotect((void*)startOfFirstPage, (size_t)size, 
                 (exec ? PROT_EXEC : 0) | PROT_READ | PROT_WRITE) != 0) {
        barf("makeExecutable: failed to protect 0x%p\n", p);