X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/2b0c7330457b8ca42375c92ada7dc7cefb0fa9fb..fb39b937b0628f4592b07d0aa61a41cf696abd30:/src/w32heap.c diff --git a/src/w32heap.c b/src/w32heap.c index bbdabd2350..dc65198f90 100644 --- a/src/w32heap.c +++ b/src/w32heap.c @@ -1,5 +1,5 @@ -/* Heap management routines for GNU Emacs on the Microsoft W32 API. - Copyright (C) 1994, 2001-2011 Free Software Foundation, Inc. +/* Heap management routines for GNU Emacs on the Microsoft Windows API. + Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -22,7 +22,6 @@ along with GNU Emacs. If not, see . */ #include #include -#include #include "w32heap.h" #include "lisp.h" /* for VALMASK */ @@ -66,7 +65,7 @@ cache_system_info (void) w32_minor_version = version.info.minor; if (version.info.platform & 0x8000) - os_subtype = OS_WIN95; + os_subtype = OS_9X; else os_subtype = OS_NT; @@ -79,7 +78,7 @@ cache_system_info (void) GetVersionEx (&osinfo_cache); w32_build_number = osinfo_cache.dwBuildNumber; - if (os_subtype == OS_WIN95) + if (os_subtype == OS_9X) w32_build_number &= 0xffff; } @@ -114,6 +113,7 @@ get_data_end (void) return data_region_end; } +#if !USE_LSB_TAG static char * allocate_heap (void) { @@ -140,9 +140,31 @@ allocate_heap (void) return ptr; } +#else /* USE_LSB_TAG */ +static char * +allocate_heap (void) +{ + unsigned long size = 0x80000000; /* start by asking for 2GB */ + void *ptr = NULL; + + while (!ptr && size > 0x00100000) + { + reserved_heap_size = size; + ptr = VirtualAlloc (NULL, + get_reserved_heap_size (), + MEM_RESERVE, + PAGE_NOACCESS); + size -= 0x00800000; /* if failed, decrease request by 8MB */ + } + + return ptr; +} +#endif /* USE_LSB_TAG */ -/* Emulate Unix sbrk. */ +/* Emulate Unix sbrk. Note that ralloc.c expects the return value to + be the address of the _start_ (not end) of the new block in case of + success, and zero (not -1) in case of failure. */ void * sbrk (unsigned long increment) { @@ -236,7 +258,7 @@ init_heap (void) exit (1); } -#if !defined (USE_LISP_UNION_TYPE) && !defined (USE_LSB_TAG) +#if !USE_LSB_TAG /* Ensure that the addresses don't use the upper tag bits since the Lisp type goes there. */ if (((unsigned long) data_region_base & ~VALMASK) != 0) @@ -273,27 +295,3 @@ round_heap (unsigned long align) if (need_to_alloc) sbrk (need_to_alloc); } - -#if (_MSC_VER >= 1000 && _MSC_VER < 1300 && !defined (USE_CRT_DLL)) - -/* MSVC 4.2 invokes these functions from mainCRTStartup to initialize - a heap via HeapCreate. They are normally defined by the runtime, - but we override them here so that the unnecessary HeapCreate call - is not performed. */ - -int __cdecl -_heap_init (void) -{ - /* Stepping through the assembly indicates that mainCRTStartup is - expecting a nonzero success return value. */ - return 1; -} - -void __cdecl -_heap_term (void) -{ - return; -} - -#endif -