зеркало из https://github.com/mozilla/pjs.git
if MAP_ANON is available, use it (instead of mmap'ing /dev/zero.)
This commit is contained in:
Родитель
17e776b21a
Коммит
5d7825fbd4
|
@ -324,12 +324,19 @@ sm_InitPages(SMPageMgr* pm, SMPageCount minPages, SMPageCount maxPages)
|
||||||
SMPageCount size = maxPages;
|
SMPageCount size = maxPages;
|
||||||
int zero_fd;
|
int zero_fd;
|
||||||
|
|
||||||
|
#ifdef MAP_ANON
|
||||||
|
zero_fd = -1;
|
||||||
|
#else
|
||||||
zero_fd = open("/dev/zero", O_RDWR);
|
zero_fd = open("/dev/zero", O_RDWR);
|
||||||
|
#endif
|
||||||
|
|
||||||
while (addr == NULL) {
|
while (addr == NULL) {
|
||||||
/* let the system place the heap */
|
/* let the system place the heap */
|
||||||
addr = (SMPage*)mmap(0, size << SM_PAGE_BITS,
|
addr = (SMPage*)mmap(0, size << SM_PAGE_BITS,
|
||||||
PROT_READ | PROT_WRITE,
|
PROT_READ | PROT_WRITE,
|
||||||
|
#ifdef MAP_ANON
|
||||||
|
MAP_ANON |
|
||||||
|
#endif
|
||||||
MAP_PRIVATE,
|
MAP_PRIVATE,
|
||||||
zero_fd, 0);
|
zero_fd, 0);
|
||||||
if (addr == (SMPage*)MAP_FAILED) {
|
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));
|
SM_ASSERT(SM_IS_ALIGNED(addr, SM_PAGE_BITS));
|
||||||
pm->memoryBase = addr;
|
pm->memoryBase = addr;
|
||||||
pm->pageCount = size;
|
pm->pageCount = size;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче