From: Taylor R. Campbell Date: Mon, 22 Jan 2007 07:47:39 +0000 (+0000) Subject: Specialize mmap_heap_malloc on OS X to pass MAP_FIXED always. X-Git-Tag: 20090517-FFI~753 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=e82e37bd69703e4ca5910ba8689bd6396af0e0c1;p=mit-scheme.git Specialize mmap_heap_malloc on OS X to pass MAP_FIXED always. This conditional is ugly; perhaps it ought to be refactored. However, after the change to the configuration script to add the linker option reserving low address space, this is necessary for anything to work at all on OS X for the moment. --- diff --git a/v7/src/microcode/ux.c b/v7/src/microcode/ux.c index 25fb13780..05b8d94e5 100644 --- a/v7/src/microcode/ux.c +++ b/v7/src/microcode/ux.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ux.c,v 1.30 2007/01/05 21:19:25 cph Exp $ +$Id: ux.c,v 1.31 2007/01/22 07:47:39 riastradh Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -708,6 +708,14 @@ mmap_heap_malloc (unsigned long requested_length) unsigned long ps = (UX_getpagesize ()); request = (((requested_length + (ps - 1)) / ps) * ps); } +#ifdef __APPLE__ + /* On OS X, we reserved the __PAGEZERO segment up to 0x4000000 by a */ + /* magic linker command, but it works only if we request MAP_FIXED. */ + /* (The third argument to `mmap_heap_malloc_1' specifies this.) */ + /* Since OS X does no address space randomization and has no /proc/ */ + /* directory, there's no need to try `find_suitable_address'. */ + result = (mmap_heap_malloc_1 (min_result, request, true)); +#else switch (find_suitable_address (request, min_result, max_result, @@ -725,6 +733,7 @@ mmap_heap_malloc (unsigned long requested_length) result = (mmap_heap_malloc_1 (min_result, request, false)); break; } +#endif if (result != 0) { if ((((unsigned long) result) >= min_result)