[commit: ghc] master: Rejigger OSMem.my_mmap to allow building on Mac (bc43d23)
git at git.haskell.org
git at git.haskell.org
Thu Aug 6 19:58:58 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/bc43d23aa8a63ce64c2eeb5a2c74fb58c8f21356/ghc
>---------------------------------------------------------------
commit bc43d23aa8a63ce64c2eeb5a2c74fb58c8f21356
Author: Richard Eisenberg <eir at cis.upenn.edu>
Date: Thu Aug 6 14:37:53 2015 -0400
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.
>---------------------------------------------------------------
bc43d23aa8a63ce64c2eeb5a2c74fb58c8f21356
rts/posix/OSMem.c | 59 +++++++++++++++++++++++++++++--------------------------
1 file changed, 31 insertions(+), 28 deletions(-)
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index 125ae10..976b5f5 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 ||
More information about the ghc-commits
mailing list