diff 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
line wrap: on
line diff
--- a/src/ntheap.c	Mon Aug 13 10:03:54 2007 +0200
+++ b/src/ntheap.c	Mon Aug 13 10:04:58 2007 +0200
@@ -21,6 +21,7 @@
    Geoff Voelker (voelker@cs.washington.edu) 7-29-94 */
 
 /* Adapted for XEmacs by David Hobley <david@spook-le0.cia.com.au> */
+/* Synced with FSF Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> */
 
 #include "config.h"
 
@@ -42,6 +43,9 @@
 int nt_major_version;
 int nt_minor_version;
 
+/* Distinguish between Windows NT and Windows 95.  */
+int os_subtype;
+
 /* Cache information describing the NT system for later use.  */
 void
 cache_system_info (void)
@@ -62,6 +66,11 @@
   nt_major_version = version.info.major;
   nt_minor_version = version.info.minor;
 
+  if (version.info.platform & 0x8000)
+    os_subtype = OS_WIN95;
+  else
+    os_subtype = OS_NT;
+
   /* Cache page size, allocation unit, processor type, etc.  */
   GetSystemInfo (&sysinfo_cache);
   syspage_mask = sysinfo_cache.dwPageSize - 1;
@@ -271,8 +280,10 @@
      any funny interactions between file I/O and file mapping.  */
   read_in_bss (executable_path);
   map_in_heap (executable_path);
+
+  /* Update system version information to match current system.  */
+  cache_system_info ();
 }
-
 #endif /* CANNOT_DUMP */
 
 /* Round the heap up to the given alignment.  */
@@ -288,3 +299,26 @@
   if (need_to_alloc) 
     sbrk (need_to_alloc);
 }
+
+#if (_MSC_VER >= 1000)
+
+/* 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