summaryrefslogtreecommitdiff
path: root/rts/posix
diff options
context:
space:
mode:
authorRichard Eisenberg <eir@cis.upenn.edu>2015-08-06 14:37:53 -0400
committerRichard Eisenberg <eir@cis.upenn.edu>2015-08-06 16:01:03 -0400
commitbc43d23aa8a63ce64c2eeb5a2c74fb58c8f21356 (patch)
tree73b22ed3ea3aa5929cba306ade944ef683af217b /rts/posix
parentaa230540f5868263740fd7d2f31505a39e2fcb4e (diff)
downloadhaskell-bc43d23aa8a63ce64c2eeb5a2c74fb58c8f21356.tar.gz
Rejigger OSMem.my_mmap to allow building on Mac
Previously, the prot and flags variables were set but never used on Mac (darwin). This caused a warning, and the build setup stopped compilation. This commit is intended simply to omit these variables when building with darwin_HOST_OS set. No change in behavior on any platform is intended.
Diffstat (limited to 'rts/posix')
-rw-r--r--rts/posix/OSMem.c59
1 files changed, 31 insertions, 28 deletions
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index 125ae10367..976b5f5c54 100644
--- a/rts/posix/OSMem.c
+++ b/rts/posix/OSMem.c
@@ -106,35 +106,8 @@ static void *
my_mmap (void *addr, W_ size, int operation)
{
void *ret;
- int prot, flags;
- if (operation & MEM_COMMIT)
- prot = PROT_READ | PROT_WRITE;
- else
- prot = PROT_NONE;
- if (operation == MEM_RESERVE)
- flags = MAP_NORESERVE;
- else if (operation == MEM_COMMIT)
- flags = MAP_FIXED;
- else
- flags = 0;
-
-#if defined(solaris2_HOST_OS) || defined(irix_HOST_OS)
- {
- if (operation & MEM_RESERVE)
- {
- int fd = open("/dev/zero",O_RDONLY);
- ret = mmap(addr, size, prot, flags | MAP_PRIVATE, fd, 0);
- close(fd);
- }
- else
- {
- ret = mmap(addr, size, prot, flags | MAP_PRIVATE, -1, 0);
- }
- }
-#elif hpux_HOST_OS
- ret = mmap(addr, size, prot, flags | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
-#elif darwin_HOST_OS
+#if darwin_HOST_OS
// Without MAP_FIXED, Apple's mmap ignores addr.
// With MAP_FIXED, it overwrites already mapped regions, whic
// mmap(0, ... MAP_FIXED ...) is worst of all: It unmaps the program text
@@ -169,6 +142,35 @@ my_mmap (void *addr, W_ size, int operation)
VM_PROT_READ|VM_PROT_WRITE);
}
+#else
+
+ int prot, flags;
+ if (operation & MEM_COMMIT)
+ prot = PROT_READ | PROT_WRITE;
+ else
+ prot = PROT_NONE;
+ if (operation == MEM_RESERVE)
+ flags = MAP_NORESERVE;
+ else if (operation == MEM_COMMIT)
+ flags = MAP_FIXED;
+ else
+ flags = 0;
+
+#if defined(solaris2_HOST_OS) || defined(irix_HOST_OS)
+ {
+ if (operation & MEM_RESERVE)
+ {
+ int fd = open("/dev/zero",O_RDONLY);
+ ret = mmap(addr, size, prot, flags | MAP_PRIVATE, fd, 0);
+ close(fd);
+ }
+ else
+ {
+ ret = mmap(addr, size, prot, flags | MAP_PRIVATE, -1, 0);
+ }
+ }
+#elif hpux_HOST_OS
+ ret = mmap(addr, size, prot, flags | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
#elif linux_HOST_OS
ret = mmap(addr, size, prot, flags | MAP_ANON | MAP_PRIVATE, -1, 0);
if (ret == (void *)-1 && errno == EPERM) {
@@ -191,6 +193,7 @@ my_mmap (void *addr, W_ size, int operation)
#else
ret = mmap(addr, size, prot, flags | MAP_ANON | MAP_PRIVATE, -1, 0);
#endif
+#endif
if (ret == (void *)-1) {
if (errno == ENOMEM ||