int w32_major_version;
int w32_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)
w32_major_version = version.info.major;
w32_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;
return (unsigned char *) (tmp * align);
}
-/* Force zero initialized variables to be placed in the .data segment;
- MSVC 5.0 otherwise places them in .bss, which breaks the dumping code. */
-#pragma data_seg(".data")
-
/* Info for keeping track of our heap. */
unsigned char *data_region_base = NULL;
unsigned char *data_region_end = NULL;
unsigned long end = 1 << VALBITS; /* 256MB */
void *ptr = NULL;
-#if NTHEAP_PROBE_BASE /* This is never normally defined */
+#define NTHEAP_PROBE_BASE 1
+#if NTHEAP_PROBE_BASE
/* Try various addresses looking for one the kernel will let us have. */
while (!ptr && (base < end))
{
MEM_RESERVE,
PAGE_NOACCESS);
if (!tmp)
- exit (1);
+ w32_fatal_reload_error ("Reserving upper heap address space.");
/* We read in the data for the .bss section from the executable
first and map in the heap from the executable second to prevent
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 ();
}
/* Round the heap up to the given alignment. */
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