comparison src/ntheap.c @ 209:41ff10fd062f r20-4b3

Import from CVS: tag r20-4b3
author cvs
date Mon, 13 Aug 2007 10:04:58 +0200
parents 15872534500d
children c5d627a313b1
comparison
equal deleted inserted replaced
208:f427b8ec4379 209:41ff10fd062f
19 02111-1307, USA. 19 02111-1307, USA.
20 20
21 Geoff Voelker (voelker@cs.washington.edu) 7-29-94 */ 21 Geoff Voelker (voelker@cs.washington.edu) 7-29-94 */
22 22
23 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */ 23 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
24 /* Synced with FSF Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
24 25
25 #include "config.h" 26 #include "config.h"
26 27
27 #include <stdlib.h> 28 #include <stdlib.h>
28 #include <stdio.h> 29 #include <stdio.h>
39 int etext; 40 int etext;
40 41
41 /* The major and minor versions of NT. */ 42 /* The major and minor versions of NT. */
42 int nt_major_version; 43 int nt_major_version;
43 int nt_minor_version; 44 int nt_minor_version;
45
46 /* Distinguish between Windows NT and Windows 95. */
47 int os_subtype;
44 48
45 /* Cache information describing the NT system for later use. */ 49 /* Cache information describing the NT system for later use. */
46 void 50 void
47 cache_system_info (void) 51 cache_system_info (void)
48 { 52 {
59 63
60 /* Cache the version of the operating system. */ 64 /* Cache the version of the operating system. */
61 version.data = GetVersion (); 65 version.data = GetVersion ();
62 nt_major_version = version.info.major; 66 nt_major_version = version.info.major;
63 nt_minor_version = version.info.minor; 67 nt_minor_version = version.info.minor;
68
69 if (version.info.platform & 0x8000)
70 os_subtype = OS_WIN95;
71 else
72 os_subtype = OS_NT;
64 73
65 /* Cache page size, allocation unit, processor type, etc. */ 74 /* Cache page size, allocation unit, processor type, etc. */
66 GetSystemInfo (&sysinfo_cache); 75 GetSystemInfo (&sysinfo_cache);
67 syspage_mask = sysinfo_cache.dwPageSize - 1; 76 syspage_mask = sysinfo_cache.dwPageSize - 1;
68 } 77 }
269 /* We read in the data for the .bss section from the executable 278 /* We read in the data for the .bss section from the executable
270 first and map in the heap from the executable second to prevent 279 first and map in the heap from the executable second to prevent
271 any funny interactions between file I/O and file mapping. */ 280 any funny interactions between file I/O and file mapping. */
272 read_in_bss (executable_path); 281 read_in_bss (executable_path);
273 map_in_heap (executable_path); 282 map_in_heap (executable_path);
274 } 283
275 284 /* Update system version information to match current system. */
285 cache_system_info ();
286 }
276 #endif /* CANNOT_DUMP */ 287 #endif /* CANNOT_DUMP */
277 288
278 /* Round the heap up to the given alignment. */ 289 /* Round the heap up to the given alignment. */
279 void 290 void
280 round_heap (unsigned long align) 291 round_heap (unsigned long align)
286 need_to_alloc = needs_to_be - (unsigned long) get_heap_end (); 297 need_to_alloc = needs_to_be - (unsigned long) get_heap_end ();
287 298
288 if (need_to_alloc) 299 if (need_to_alloc)
289 sbrk (need_to_alloc); 300 sbrk (need_to_alloc);
290 } 301 }
302
303 #if (_MSC_VER >= 1000)
304
305 /* MSVC 4.2 invokes these functions from mainCRTStartup to initialize
306 a heap via HeapCreate. They are normally defined by the runtime,
307 but we override them here so that the unnecessary HeapCreate call
308 is not performed. */
309
310 int __cdecl
311 _heap_init (void)
312 {
313 /* Stepping through the assembly indicates that mainCRTStartup is
314 expecting a nonzero success return value. */
315 return 1;
316 }
317
318 void __cdecl
319 _heap_term (void)
320 {
321 return;
322 }
323
324 #endif