From e82e37bd69703e4ca5910ba8689bd6396af0e0c1 Mon Sep 17 00:00:00 2001 From: "Taylor R. Campbell" Date: Mon, 22 Jan 2007 07:47:39 +0000 Subject: [PATCH] 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. --- v7/src/microcode/ux.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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) -- 2.25.1