annotate src/w32heap.c @ 67969:3ca8b2234237

* mh-customize.el: Sync docstrings with manual for faces and sort them alphabetically. (mh-faces): Move below mh-hooks. (mh-folder-faces, mh-index-faces, mh-letter-faces) (mh-show-faces, mh-speed-faces): Delete. Organize faces like hooks. (mh-speed-update-interval): Fix group (mh-speedbar, not mh-speed). (facemenu-unlisted-faces): Might as well ignore all MH-E faces. (mh-folder-body-face, mh-folder-cur-msg-face) (mh-folder-cur-msg-number-face, mh-folder-date-face) (mh-folder-followup-face, mh-folder-msg-number-face) (mh-folder-deleted-face, mh-folder-refiled-face) (mh-folder-subject-face, mh-folder-address-face) (mh-folder-scan-format-face, mh-folder-to-face) (mh-index-folder-face, mh-show-cc-face, mh-show-date-face) (mh-show-header-face, mh-show-pgg-good-face) (mh-show-pgg-unknown-face, mh-show-pgg-bad-face) (mh-show-to-face, mh-show-from-face, mh-show-subject-face): Delete. (mh-folder-cur-msg): Unused. Delete. (mh-folder-address): Use defface; inherit from mh-folder-subject. (mh-folder-body, mh-folder-cur-msg-number, mh-folder-date): Inherit from mh-folder-msg-number. (mh-folder-deleted): Use defface. Inherit from mh-folder-msg-number. (mh-folder-sent-to-me-hint): New face. Inherit from mh-folder-date. (mh-folder-sent-to-me-sender): Rename from mh-folder-scan-format. Use defface. Inherit from mh-folder-followup. (mh-show-xface): Inherit from mh-show-from and highlight. (bw-face-generation, bw-toggle-faces) (bw-new-face-to-old, bw-old-face-to-new): New (tempoarary) variables, functions for toggling between old and new faces. * mh-e.el (font-lock-auto-fontify, font-lock-defaults): Hide in eval-when-compile. We should probably do this throughout. (mh-scan-good-msg-regexp, mh-scan-deleted-msg-regexp) (mh-scan-refiled-msg-regexp, mh-scan-cur-msg-number-regexp) (mh-scan-date-regexp, mh-scan-rcpt-regexp, mh-scan-body-regexp) (mh-scan-subject-regexp): Sync docstrings with manual (mh-scan-format-regexp): Rename to mh-scan-sent-to-me-sender-regexp. Drop date parenthesized expression. Make expression more like the others (anchored at the beginning of line). Sync docstrings with manual. (mh-folder-font-lock-keywords): Use faces directly rather than -face variables. Use mh-scan-sent-to-me-sender-regexp instead of mh-scan-format-regexp, and within that expression, use faces mh-folder-sent-to-me-hint and mh-folder-sent-to-me-sender instead of mh-folder-date-face and mh-folder-scan-format-face which were misleading. * mh-mime.el (mh-mime-security-button-face): Use faces directly rather than -face variables. * mh-utils.el (mh-show-font-lock-keywords): Use faces directly rather than -face variables. (mh-face-foreground-compat, mh-face-background-compat): New macros. (mh-face-display-function): Use mh-face-foreground-compat and mh-face-background-compat to use inherited attributes of mh-show-xface on Emacs 22 while still working on Emacs 21.
author Bill Wohler <wohler@newt.com>
date Sun, 01 Jan 2006 18:51:18 +0000
parents a0d1312ede66
children 3bd95f4f2941 2d92f5c9d6ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16884
36babc489b0c Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents: 16593
diff changeset
1 /* Heap management routines for GNU Emacs on the Microsoft W32 API.
64770
a0d1312ede66 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64084
diff changeset
2 Copyright (C) 1994, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12452
diff changeset
4 This file is part of GNU Emacs.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12452
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12452
diff changeset
7 it under the terms of the GNU General Public License as published by
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12452
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12452
diff changeset
9 any later version.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12452
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12452
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12452
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12452
diff changeset
14 GNU General Public License for more details.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
14186
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12452
diff changeset
16 You should have received a copy of the GNU General Public License
ee40177f6c68 Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents: 12452
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
64084
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63088
diff changeset
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63088
diff changeset
19 Boston, MA 02110-1301, USA.
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 Geoff Voelker (voelker@cs.washington.edu) 7-29-94
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
42469
64341c22fb4c Include <config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 33215
diff changeset
24 #ifdef HAVE_CONFIG_H
64341c22fb4c Include <config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 33215
diff changeset
25 #include <config.h>
64341c22fb4c Include <config.h>.
Pavel Janík <Pavel@Janik.cz>
parents: 33215
diff changeset
26 #endif
12452
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
27
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 #include <stdlib.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 #include <stdio.h>
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
16593
4ed80eda6fac Use new names for w32 files
Geoff Voelker <voelker@cs.washington.edu>
parents: 16588
diff changeset
31 #include "w32heap.h"
15143
d7d0413e95e2 Include lisp.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
32 #include "lisp.h" /* for VALMASK */
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33
31111
14beb147ec06 [!USE_CRT_DLL]: Don't define _heap_init and _heap_term
Andrew Innes <andrewi@gnu.org>
parents: 24886
diff changeset
34 #define RVA_TO_PTR(rva) ((unsigned char *)((DWORD)(rva) + (DWORD)GetModuleHandle (NULL)))
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
35
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 /* This gives us the page size and the size of the allocation unit on NT. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 SYSTEM_INFO sysinfo_cache;
24886
fb9574318fa0 w32heap.c (osinfo_cache): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 24103
diff changeset
38
fb9574318fa0 w32heap.c (osinfo_cache): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 24103
diff changeset
39 /* This gives us version, build, and platform identification. */
fb9574318fa0 w32heap.c (osinfo_cache): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 24103
diff changeset
40 OSVERSIONINFO osinfo_cache;
fb9574318fa0 w32heap.c (osinfo_cache): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 24103
diff changeset
41
12452
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
42 unsigned long syspage_mask = 0;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 /* These are defined to get Emacs to compile, but are not used. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 int edata;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 int etext;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 /* The major and minor versions of NT. */
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15228
diff changeset
49 int w32_major_version;
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15228
diff changeset
50 int w32_minor_version;
33215
38e1998861ff (w32_build_number): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 31111
diff changeset
51 int w32_build_number;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52
19708
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
53 /* Distinguish between Windows NT and Windows 95. */
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
54 int os_subtype;
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
55
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 /* Cache information describing the NT system for later use. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 void
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 cache_system_info (void)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 {
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
60 union
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 {
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
62 struct info
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 char major;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 char minor;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 short platform;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 } info;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 DWORD data;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 } version;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 /* Cache the version of the operating system. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 version.data = GetVersion ();
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15228
diff changeset
73 w32_major_version = version.info.major;
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 15228
diff changeset
74 w32_minor_version = version.info.minor;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75
19708
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
76 if (version.info.platform & 0x8000)
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
77 os_subtype = OS_WIN95;
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
78 else
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
79 os_subtype = OS_NT;
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
80
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 /* Cache page size, allocation unit, processor type, etc. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 GetSystemInfo (&sysinfo_cache);
12452
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
83 syspage_mask = sysinfo_cache.dwPageSize - 1;
24886
fb9574318fa0 w32heap.c (osinfo_cache): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 24103
diff changeset
84
fb9574318fa0 w32heap.c (osinfo_cache): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 24103
diff changeset
85 /* Cache os info. */
fb9574318fa0 w32heap.c (osinfo_cache): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 24103
diff changeset
86 osinfo_cache.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
fb9574318fa0 w32heap.c (osinfo_cache): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 24103
diff changeset
87 GetVersionEx (&osinfo_cache);
33215
38e1998861ff (w32_build_number): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 31111
diff changeset
88
38e1998861ff (w32_build_number): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 31111
diff changeset
89 w32_build_number = osinfo_cache.dwBuildNumber;
38e1998861ff (w32_build_number): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 31111
diff changeset
90 if (os_subtype == OS_WIN95)
38e1998861ff (w32_build_number): New variable.
Andrew Innes <andrewi@gnu.org>
parents: 31111
diff changeset
91 w32_build_number &= 0xffff;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93
18506
bcc706aedcea Add pragma to force zero initialized
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
94 /* Emulate getpagesize. */
bcc706aedcea Add pragma to force zero initialized
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
95 int
bcc706aedcea Add pragma to force zero initialized
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
96 getpagesize (void)
bcc706aedcea Add pragma to force zero initialized
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
97 {
bcc706aedcea Add pragma to force zero initialized
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
98 return sysinfo_cache.dwPageSize;
bcc706aedcea Add pragma to force zero initialized
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
99 }
bcc706aedcea Add pragma to force zero initialized
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
100
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
101 /* Info for managing our preload heap, which is essentially a fixed size
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
102 data area in the executable. */
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
103 PIMAGE_SECTION_HEADER preload_heap_section;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 /* Info for keeping track of our heap. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 unsigned char *data_region_base = NULL;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 unsigned char *data_region_end = NULL;
12452
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
108 unsigned char *real_data_region_end = NULL;
11943
ea533622fb8b (reserved_heap_size,allocate_heap): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11385
diff changeset
109 unsigned long reserved_heap_size = 0;
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 /* The start of the data segment. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 unsigned char *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 get_data_start (void)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 return data_region_base;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 /* The end of the data segment. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 unsigned char *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 get_data_end (void)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 return data_region_end;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124
11943
ea533622fb8b (reserved_heap_size,allocate_heap): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11385
diff changeset
125 static char *
ea533622fb8b (reserved_heap_size,allocate_heap): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11385
diff changeset
126 allocate_heap (void)
ea533622fb8b (reserved_heap_size,allocate_heap): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11385
diff changeset
127 {
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
128 /* Try to get as much as possible of the address range from the end of
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
129 the preload heap section up to the usable address limit. Since GNU
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
130 malloc can handle gaps in the memory it gets from sbrk, we can
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
131 simply set the sbrk pointer to the base of the new heap region. */
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
132 unsigned long base =
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
133 ROUND_UP ((RVA_TO_PTR (preload_heap_section->VirtualAddress)
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
134 + preload_heap_section->Misc.VirtualSize),
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
135 get_allocation_unit ());
15143
d7d0413e95e2 Include lisp.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 14186
diff changeset
136 unsigned long end = 1 << VALBITS; /* 256MB */
15208
01588278fceb (allocate_heap): Bump heap base up to 27MB to
Geoff Voelker <voelker@cs.washington.edu>
parents: 15143
diff changeset
137 void *ptr = NULL;
11943
ea533622fb8b (reserved_heap_size,allocate_heap): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11385
diff changeset
138
15208
01588278fceb (allocate_heap): Bump heap base up to 27MB to
Geoff Voelker <voelker@cs.washington.edu>
parents: 15143
diff changeset
139 while (!ptr && (base < end))
01588278fceb (allocate_heap): Bump heap base up to 27MB to
Geoff Voelker <voelker@cs.washington.edu>
parents: 15143
diff changeset
140 {
01588278fceb (allocate_heap): Bump heap base up to 27MB to
Geoff Voelker <voelker@cs.washington.edu>
parents: 15143
diff changeset
141 reserved_heap_size = end - base;
01588278fceb (allocate_heap): Bump heap base up to 27MB to
Geoff Voelker <voelker@cs.washington.edu>
parents: 15143
diff changeset
142 ptr = VirtualAlloc ((void *) base,
01588278fceb (allocate_heap): Bump heap base up to 27MB to
Geoff Voelker <voelker@cs.washington.edu>
parents: 15143
diff changeset
143 get_reserved_heap_size (),
01588278fceb (allocate_heap): Bump heap base up to 27MB to
Geoff Voelker <voelker@cs.washington.edu>
parents: 15143
diff changeset
144 MEM_RESERVE,
01588278fceb (allocate_heap): Bump heap base up to 27MB to
Geoff Voelker <voelker@cs.washington.edu>
parents: 15143
diff changeset
145 PAGE_NOACCESS);
01588278fceb (allocate_heap): Bump heap base up to 27MB to
Geoff Voelker <voelker@cs.washington.edu>
parents: 15143
diff changeset
146 base += 0x00100000; /* 1MB increment */
01588278fceb (allocate_heap): Bump heap base up to 27MB to
Geoff Voelker <voelker@cs.washington.edu>
parents: 15143
diff changeset
147 }
15228
ae9888a75348 (allocate_heap): Clean up conditional.
Richard M. Stallman <rms@gnu.org>
parents: 15208
diff changeset
148
15208
01588278fceb (allocate_heap): Bump heap base up to 27MB to
Geoff Voelker <voelker@cs.washington.edu>
parents: 15143
diff changeset
149 return ptr;
11943
ea533622fb8b (reserved_heap_size,allocate_heap): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11385
diff changeset
150 }
ea533622fb8b (reserved_heap_size,allocate_heap): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11385
diff changeset
151
ea533622fb8b (reserved_heap_size,allocate_heap): Defined.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11385
diff changeset
152
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 /* Emulate Unix sbrk. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 void *
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155 sbrk (unsigned long increment)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 void *result;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 long size = (long) increment;
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
159
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 result = data_region_end;
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
161
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 /* If size is negative, shrink the heap by decommitting pages. */
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
163 if (size < 0)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 {
12452
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
165 int new_size;
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
166 unsigned char *new_data_region_end;
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
167
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 size = -size;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 /* Sanity checks. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 if ((data_region_end - size) < data_region_base)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 return NULL;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
174 /* We can only decommit full pages, so allow for
12452
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
175 partial deallocation [cga]. */
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
176 new_data_region_end = (data_region_end - size);
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
177 new_data_region_end = (unsigned char *)
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
178 ((long) (new_data_region_end + syspage_mask) & ~syspage_mask);
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
179 new_size = real_data_region_end - new_data_region_end;
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
180 real_data_region_end = new_data_region_end;
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
181 if (new_size > 0)
12452
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
182 {
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
183 /* Decommit size bytes from the end of the heap. */
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
184 if (using_dynamic_heap
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
185 && !VirtualFree (real_data_region_end, new_size, MEM_DECOMMIT))
12452
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
186 return NULL;
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
187 }
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 data_region_end -= size;
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
190 }
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 /* If size is positive, grow the heap by committing reserved pages. */
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
192 else if (size > 0)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 /* Sanity checks. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 if ((data_region_end + size) >
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
196 (data_region_base + get_reserved_heap_size ()))
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 return NULL;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 /* Commit more of our heap. */
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
200 if (using_dynamic_heap
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
201 && VirtualAlloc (data_region_end, size, MEM_COMMIT,
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
202 PAGE_READWRITE) == NULL)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 return NULL;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 data_region_end += size;
12452
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
205
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
206 /* We really only commit full pages, so record where
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
207 the real end of committed memory is [cga]. */
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
208 real_data_region_end = (unsigned char *)
bd304be0b491 Include config.h.
Geoff Voelker <voelker@cs.washington.edu>
parents: 11943
diff changeset
209 ((long) (data_region_end + syspage_mask) & ~syspage_mask);
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 }
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
211
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 return result;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
215 /* Initialize the internal heap variables used by sbrk. When running in
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
216 preload phase (ie. in the undumped executable), we rely entirely on a
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
217 fixed size heap section included in the .exe itself; this is
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
218 preserved during dumping, and truncated to the size actually used.
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
219
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
220 When running in the dumped executable, we reserve as much as possible
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
221 of the address range that is addressable by Lisp object pointers, to
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
222 supplement what is left of the preload heap. Although we cannot rely
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
223 on the dynamically allocated arena being contiguous with the static
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
224 heap area, it is not a problem because sbrk can pretend that the gap
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
225 was allocated by something else; GNU malloc detects when there is a
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
226 jump in the sbrk values, and starts a new heap block. */
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 void
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
228 init_heap ()
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 {
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
230 PIMAGE_DOS_HEADER dos_header;
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
231 PIMAGE_NT_HEADERS nt_header;
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
232
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
233 dos_header = (PIMAGE_DOS_HEADER) RVA_TO_PTR (0);
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
234 nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) +
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
235 dos_header->e_lfanew);
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
236 preload_heap_section = find_section ("EMHEAP", nt_header);
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
238 if (using_dynamic_heap)
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
239 {
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
240 data_region_base = allocate_heap ();
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
241 if (!data_region_base)
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
242 {
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
243 printf ("Error: Could not reserve dynamic heap area.\n");
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
244 exit (1);
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
245 }
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246
55661
272f0851d05e [USE_LSB_TAG]: Don't check heap location.
Jason Rumney <jasonr@gnu.org>
parents: 52401
diff changeset
247 #if defined (NO_UNION_TYPE) && !defined (USE_LSB_TAG)
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
248 /* Ensure that the addresses don't use the upper tag bits since
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
249 the Lisp type goes there. */
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
250 if (((unsigned long) data_region_base & ~VALMASK) != 0)
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
251 {
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
252 printf ("Error: The heap was allocated in upper memory.\n");
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
253 exit (1);
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
254 }
55661
272f0851d05e [USE_LSB_TAG]: Don't check heap location.
Jason Rumney <jasonr@gnu.org>
parents: 52401
diff changeset
255 #endif
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
256 data_region_end = data_region_base;
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
257 real_data_region_end = data_region_end;
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
258 }
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
259 else
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
260 {
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
261 data_region_base = RVA_TO_PTR (preload_heap_section->VirtualAddress);
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
262 data_region_end = data_region_base;
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
263 real_data_region_end = data_region_end;
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
264 reserved_heap_size = preload_heap_section->Misc.VirtualSize;
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
265 }
19708
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
266
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
267 /* Update system version information to match current system. */
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
268 cache_system_info ();
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 }
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 /* Round the heap up to the given alignment. */
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 void
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 round_heap (unsigned long align)
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 {
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 unsigned long needs_to_be;
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 unsigned long need_to_alloc;
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
277
24103
4adfa5300fd8 (RVA_TO_PTR): Redefine to convert RVA to address in
Andrew Innes <andrewi@gnu.org>
parents: 23171
diff changeset
278 needs_to_be = (unsigned long) ROUND_UP (get_heap_end (), align);
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 need_to_alloc = needs_to_be - (unsigned long) get_heap_end ();
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
280
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
281 if (need_to_alloc)
9803
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 sbrk (need_to_alloc);
fa698fd10c05 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 }
19708
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
284
48046
e81472bb5044 Don't redefine _heap_init and _heap_term on MSVC 7 build environments. Patch
Juanma Barranquero <lekktu@gmail.com>
parents: 42469
diff changeset
285 #if (_MSC_VER >= 1000 && _MSC_VER < 1300 && !defined(USE_CRT_DLL))
19708
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
286
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
287 /* MSVC 4.2 invokes these functions from mainCRTStartup to initialize
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
288 a heap via HeapCreate. They are normally defined by the runtime,
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
289 but we override them here so that the unnecessary HeapCreate call
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
290 is not performed. */
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
291
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
292 int __cdecl
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
293 _heap_init (void)
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
294 {
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
295 /* Stepping through the assembly indicates that mainCRTStartup is
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
296 expecting a nonzero success return value. */
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
297 return 1;
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
298 }
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
299
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
300 void __cdecl
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
301 _heap_term (void)
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
302 {
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
303 return;
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
304 }
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
305
16e69fbdbf0f (os_subtype): New variable.
Geoff Voelker <voelker@cs.washington.edu>
parents: 18506
diff changeset
306 #endif
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 48046
diff changeset
307
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 48046
diff changeset
308 /* arch-tag: 9a6a9860-040d-422d-8905-450dd535cd9c
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 48046
diff changeset
309 (do not change this comment) */