diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-07-15 08:06:25 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-07-15 08:06:25 +0000 |
commit | 921fde55c32eecb4087ca59b41982b7e5c4731d1 (patch) | |
tree | f3a4add7cdcb203f128eab7cb66360443823bb2f /libc/stdlib/malloc-standard | |
parent | 288a56c4a2ddb87a61fe11a3c1d3a95a01b70878 (diff) |
Use MAP_PRIVATE whenever __ARCH_HAS_MMU__ is set.
Only use MAP_SHARED when mmu-less.
Diffstat (limited to 'libc/stdlib/malloc-standard')
-rw-r--r-- | libc/stdlib/malloc-standard/malloc.c | 4 | ||||
-rw-r--r-- | libc/stdlib/malloc-standard/malloc.h | 13 |
2 files changed, 13 insertions, 4 deletions
diff --git a/libc/stdlib/malloc-standard/malloc.c b/libc/stdlib/malloc-standard/malloc.c index 8d132a43e..51e02a240 100644 --- a/libc/stdlib/malloc-standard/malloc.c +++ b/libc/stdlib/malloc-standard/malloc.c @@ -406,7 +406,7 @@ static void* __malloc_alloc(size_t nb, mstate av) /* Don't try if size wraps around 0 */ if ((unsigned long)(size) > (unsigned long)(nb)) { - mm = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE)); + mm = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE)); if (mm != (char*)(MORECORE_FAILURE)) { @@ -526,7 +526,7 @@ static void* __malloc_alloc(size_t nb, mstate av) /* Don't try if size wraps around 0 */ if ((unsigned long)(size) > (unsigned long)(nb)) { - brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE)); + brk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE)); if (brk != (char*)(MORECORE_FAILURE)) { diff --git a/libc/stdlib/malloc-standard/malloc.h b/libc/stdlib/malloc-standard/malloc.h index 46858332d..0b8bbef31 100644 --- a/libc/stdlib/malloc-standard/malloc.h +++ b/libc/stdlib/malloc-standard/malloc.h @@ -350,8 +350,17 @@ extern pthread_mutex_t __malloc_lock; #define MAP_ANONYMOUS MAP_ANON #endif -#define MMAP(addr, size, prot, flags) \ - (mmap((addr), (size), (prot), (flags)|MAP_ANONYMOUS, -1, 0)) +#ifdef __ARCH_HAS_MMU__ + +#define MMAP(addr, size, prot) \ + (mmap((addr), (size), (prot), MAP_PRIVATE|MAP_ANONYMOUS, 0, 0)) + +#else + +#define MMAP(addr, size, prot) \ + (mmap((addr), (size), (prot), MAP_SHARED|MAP_ANONYMOUS, 0, 0)) + +#endif /* ----------------------- Chunk representations ----------------------- */ |