From 5d7825fbd4b2dc9a819ccab6fd039dcf1c3cb77e Mon Sep 17 00:00:00 2001 From: "toshok%hungry.com" Date: Mon, 30 Aug 1999 08:02:10 +0000 Subject: [PATCH] if MAP_ANON is available, use it (instead of mmap'ing /dev/zero.) --- ef/gc/src/smpage.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ef/gc/src/smpage.c b/ef/gc/src/smpage.c index 8bf75f028d0..2c484c4c161 100644 --- a/ef/gc/src/smpage.c +++ b/ef/gc/src/smpage.c @@ -324,12 +324,19 @@ sm_InitPages(SMPageMgr* pm, SMPageCount minPages, SMPageCount maxPages) SMPageCount size = maxPages; int zero_fd; +#ifdef MAP_ANON + zero_fd = -1; +#else zero_fd = open("/dev/zero", O_RDWR); +#endif while (addr == NULL) { /* let the system place the heap */ addr = (SMPage*)mmap(0, size << SM_PAGE_BITS, PROT_READ | PROT_WRITE, +#ifdef MAP_ANON + MAP_ANON | +#endif MAP_PRIVATE, zero_fd, 0); if (addr == (SMPage*)MAP_FAILED) { @@ -340,6 +347,11 @@ sm_InitPages(SMPageMgr* pm, SMPageCount minPages, SMPageCount maxPages) } } } + +#ifndef MAP_ANON + close(zero_fd); +#endif + SM_ASSERT(SM_IS_ALIGNED(addr, SM_PAGE_BITS)); pm->memoryBase = addr; pm->pageCount = size;