From: Chris Hanson Date: Thu, 16 Aug 2012 05:16:37 +0000 (-0700) Subject: Fix broken memory allocation on 32-bit OS X. X-Git-Tag: release-9.2.0~233 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=6abf46dcd5be687fa1707f07f7f3594c6cbf943d;p=mit-scheme.git Fix broken memory allocation on 32-bit OS X. --- diff --git a/src/microcode/ux.c b/src/microcode/ux.c index 513c008db..417e45a62 100644 --- a/src/microcode/ux.c +++ b/src/microcode/ux.c @@ -765,6 +765,20 @@ mmap_heap_malloc_try (unsigned long address, unsigned long request, int flags) /* Try to use our low addresses even if the OS has a tendency to choose high ones. (What if we're on a 64-bit system? Why do we care?) */ +#ifdef __x86_64__ +# define MMAP_EXTRA_FLAGS 0 +#else +#ifdef MAP_TRYFIXED +# define MMAP_EXTRA_FLAGS MAP_TRYFIXED +#else +#if defined(USE_MAP_FIXED) && defined(MAP_FIXED) +# define MMAP_EXTRA_FLAGS MAP_FIXED +#else +# define MMAP_EXTRA_FLAGS 0 +#endif +#endif +#endif + static void * mmap_heap_malloc_search (unsigned long request, unsigned long min_result, @@ -772,9 +786,9 @@ mmap_heap_malloc_search (unsigned long request, { (void)max_result; /* ignore */ -#ifdef MAP_TRYFIXED +#if MMAP_EXTRA_FLAGS != 0 { - void * addr = (mmap_heap_malloc_try (min_result, request, MAP_TRYFIXED)); + void * addr = (mmap_heap_malloc_try (min_result, request, MMAP_EXTRA_FLAGS)); return (addr ? addr : (mmap_heap_malloc_try (0, request, 0))); } #else diff --git a/src/microcode/ux.h b/src/microcode/ux.h index 5356b93cf..5c875454c 100644 --- a/src/microcode/ux.h +++ b/src/microcode/ux.h @@ -129,6 +129,9 @@ USA. #ifdef HAVE_SYS_MMAN_H # include #endif +#ifdef __APPLE__ +# define USE_MAP_FIXED 1 +#endif /* GNU C library defines environ if __USE_GNU is defined. */ #ifndef __USE_GNU