Mercurial > hg > xemacs-beta
comparison src/ntheap.c @ 814:a634e3b7acc8
[xemacs-hg @ 2002-04-14 12:41:59 by ben]
latest changes
TODO.ben-mule-21-5: Update.
make-docfile.c: Add basic support for handling ISO 2022 doc strings -- we parse
the basic charset designation sequences so we know whether we're
in ASCII and have to pay attention to end quotes and such.
Reformat code according to coding standards.
abbrev.el: Add `global-abbrev-mode', which turns on or off abbrev-mode in all
buffers. Added `defining-abbrev-turns-on-abbrev-mode' -- if
non-nil, defining an abbrev through an interactive function will
automatically turn on abbrev-mode, either globally or locally
depending on the command. This is the "what you'd expect"
behavior.
indent.el: general function for indenting a balanced expression in a
mode-correct way. Works similar to indent-region in that a mode
can specify a specific command to do the whole operation; if not,
figure out the region using forward-sexp and indent each line
using indent-according-to-mode.
keydefs.el: Removed.
Modify M-C-backslash to do indent-region-or-balanced-expression.
Make S-Tab just insert a TAB char, like it's meant to do.
make-docfile.el: Now that we're using the call-process-in-lisp, we need to load
an extra file win32-native.el because we're running a bare temacs.
menubar-items.el: Totally redo the Cmds menu so that most used commands appear
directly on the menu and less used commands appear in submenus.
The old way may have been very pretty, but rather impractical.
process.el: Under Windows, don't ever use old-call-process-internal, even
in batch mode. We can do processes in batch mode.
subr.el: Someone recoded truncate-string-to-width, saying "the FSF version
is too complicated and does lots of hard-to-understand stuff" but
the resulting recoded version was *totally* wrong! it
misunderstood the basic point of this function, which is work in
*columns* not chars. i dumped ours and copied the version from
FSF 21.1. Also added truncate-string-with-continuation-dots,
since this idiom is used often.
config.inc.samp, xemacs.mak: Separate out debug and optimize flags.
Remove all vestiges of USE_MINIMAL_TAGBITS,
USE_INDEXED_LRECORD_IMPLEMENTATION, and GUNG_HO, since those
ifdefs have long been removed.
Make error-checking support actually work.
Some rearrangement of config.inc.samp to make it more logical.
Remove callproc.c and ntproc.c from xemacs.mak, no longer used.
Make pdump the default.
lisp.h: Add support for strong type-checking of Bytecount, Bytebpos,
Charcount, Charbpos, and others, by making them classes,
overloading the operators to provide integer-like operation and
carefully controlling what operations are allowed. Not currently
enabled in C++ builds because there are still a number of compile
errors, and it won't really work till we merge in my "8-bit-Mule"
workspace, in which I make use of the new types Charxpos,
Bytexpos, Memxpos, representing a "position" either in a buffer or
a string. (This is especially important in the extent code.)
abbrev.c, alloc.c, eval.c, buffer.c, buffer.h, editfns.c, fns.c, text.h: Warning fixes, some of them related to new C++ strict type
checking of Bytecount, Charbpos, etc.
dired.c: Caught an actual error due to strong type checking -- char len
being passed when should be byte len.
alloc.c, backtrace.h, bytecode.c, bytecode.h, eval.c, sysdep.c: Further optimize Ffuncall:
-- process arg list at compiled-function creation time, converting
into an array for extra-quick access at funcall time.
-- rewrite funcall_compiled_function to use it, and inline this
function.
-- change the order of check for magic stuff in
SPECBIND_FAST_UNSAFE to be faster.
-- move the check for need to garbage collect into the allocation
code, so only a single flag needs to be checked in funcall.
buffer.c, symbols.c: add debug funs to check on mule optimization info in buffers and
strings.
eval.c, emacs.c, text.c, regex.c, scrollbar-msw.c, search.c: Fix evil crashes due to eistrings not properly reinitialized under
pdump. Redo a bit some of the init routines; convert some
complex_vars_of() into simple vars_of(), because they didn't need
complex processing.
callproc.c, emacs.c, event-stream.c, nt.c, process.c, process.h, sysdep.c, sysdep.h, syssignal.h, syswindows.h, ntproc.c: Delete. Hallelujah, praise the Lord, there is no god
but Allah!!!
fix so that processes can be invoked in bare temacs -- thereby
eliminating any need for callproc.c. (currently only eliminated
under NT.) remove all crufty and unnecessary old process code in
ntproc.c and elsewhere. move non-callproc-specific stuff (mostly
environment) into process.c, so callproc.c can be left out under
NT.
console-tty.c, doc.c, file-coding.c, file-coding.h, lstream.c, lstream.h: fix doc string handling so it works with Japanese, etc docs.
change handling of "character mode" so callers don't have to
manually set it (quite error-prone).
event-msw.c: spacing fixes.
lread.c: eliminate unused crufty vintage-19 "FSF defun hack" code.
lrecord.h: improve pdump description docs.
buffer.c, ntheap.c, unexnt.c, win32.c, emacs.c: Mule-ize some unexec and startup code. It was pseudo-Mule-ized
before by simply always calling the ...A versions of functions,
but that won't cut it -- eventually we want to be able to run
properly even if XEmacs has been installed in a Japanese
directory. (The current problem is the timing of the loading of
the Unicode tables; this will eventually be fixed.) Go through and
fix various other places where the code was not Mule-clean.
Provide a function mswindows_get_module_file_name() to get our own
name without resort to PATH_MAX and such. Add a big comment in
main() about the problem with Unicode table load timing that I
just alluded to.
emacs.c: When error-checking is enabled (interpreted as "user is developing
XEmacs"), don't ask user to "pause to read messages" when a fatal
error has occurred, because it will wedge if we are in an inner
modal loop (typically when a menu is popped up) and make us unable
to get a useful stack trace in the debugger.
text.c: Correct update_entirely_ascii_p_flag to actually work.
lisp.h, symsinit.h: declarations for above changes.
author | ben |
---|---|
date | Sun, 14 Apr 2002 12:43:31 +0000 |
parents | 943eaba38521 |
children | 4542b72c005e |
comparison
equal
deleted
inserted
replaced
813:9541922fb765 | 814:a634e3b7acc8 |
---|---|
24 /* Synced with FSF Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> | 24 /* Synced with FSF Emacs 19.34.6 by Marc Paquette <marcpa@cam.org> |
25 (Note: Sync messages from Marc Paquette may indicate | 25 (Note: Sync messages from Marc Paquette may indicate |
26 incomplete synching, so beware.) | 26 incomplete synching, so beware.) |
27 */ | 27 */ |
28 | 28 |
29 /* This file has been Mule-ized, Ben Wing, 4-13-02. */ | |
30 | |
29 #include <config.h> | 31 #include <config.h> |
30 #include "lisp.h" | 32 #include "lisp.h" |
31 | 33 |
34 #include "sysdep.h" | |
32 #include "syswindows.h" | 35 #include "syswindows.h" |
33 | 36 |
34 /* This gives us the page size and the size of the allocation unit on NT. */ | 37 /* This gives us the page size and the size of the allocation unit on NT. */ |
35 SYSTEM_INFO sysinfo_cache; | 38 SYSTEM_INFO sysinfo_cache; |
36 unsigned long syspage_mask = 0; | 39 unsigned long syspage_mask = 0; |
47 GetSystemInfo (&sysinfo_cache); | 50 GetSystemInfo (&sysinfo_cache); |
48 syspage_mask = sysinfo_cache.dwPageSize - 1; | 51 syspage_mask = sysinfo_cache.dwPageSize - 1; |
49 } | 52 } |
50 | 53 |
51 /* Round ADDRESS up to be aligned with ALIGN. */ | 54 /* Round ADDRESS up to be aligned with ALIGN. */ |
52 unsigned char * | 55 UChar_Binary * |
53 round_to_next (unsigned char *address, unsigned long align) | 56 round_to_next (UChar_Binary *address, unsigned long align) |
54 { | 57 { |
55 unsigned long tmp; | 58 unsigned long tmp; |
56 | 59 |
57 tmp = (unsigned long) address; | 60 tmp = (unsigned long) address; |
58 tmp = (tmp + align - 1) / align; | 61 tmp = (tmp + align - 1) / align; |
59 | 62 |
60 return (unsigned char *) (tmp * align); | 63 return (UChar_Binary *) (tmp * align); |
61 } | 64 } |
62 | 65 |
63 /* Info for keeping track of our heap. */ | 66 /* Info for keeping track of our heap. */ |
64 unsigned char *data_region_base = UNINIT_PTR; | 67 UChar_Binary *data_region_base = UNINIT_PTR; |
65 unsigned char *data_region_end = UNINIT_PTR; | 68 UChar_Binary *data_region_end = UNINIT_PTR; |
66 unsigned char *real_data_region_end = UNINIT_PTR; | 69 UChar_Binary *real_data_region_end = UNINIT_PTR; |
67 unsigned long data_region_size = UNINIT_LONG; | 70 unsigned long data_region_size = UNINIT_LONG; |
68 unsigned long reserved_heap_size = UNINIT_LONG; | 71 unsigned long reserved_heap_size = UNINIT_LONG; |
69 | 72 |
70 /* The start of the data segment. */ | 73 /* The start of the data segment. */ |
71 unsigned char * | 74 UChar_Binary * |
72 get_data_start (void) | 75 get_data_start (void) |
73 { | 76 { |
74 return data_region_base; | 77 return data_region_base; |
75 } | 78 } |
76 | 79 |
77 /* The end of the data segment. */ | 80 /* The end of the data segment. */ |
78 unsigned char * | 81 UChar_Binary * |
79 get_data_end (void) | 82 get_data_end (void) |
80 { | 83 { |
81 return data_region_end; | 84 return data_region_end; |
82 } | 85 } |
83 | 86 |
84 static unsigned char * | 87 static UChar_Binary * |
85 allocate_heap (void) | 88 allocate_heap (void) |
86 { | 89 { |
87 /* The base address for our GNU malloc heap is chosen in conjunction | 90 /* The base address for our GNU malloc heap is chosen in conjunction |
88 with the link settings for temacs.exe which control the stack size, | 91 with the link settings for temacs.exe which control the stack size, |
89 the initial default process heap size and the executable image base | 92 the initial default process heap size and the executable image base |
143 get_reserved_heap_size (), | 146 get_reserved_heap_size (), |
144 MEM_RESERVE, | 147 MEM_RESERVE, |
145 PAGE_NOACCESS); | 148 PAGE_NOACCESS); |
146 #endif | 149 #endif |
147 | 150 |
148 return (unsigned char*) ptr; | 151 return (UChar_Binary *) ptr; |
149 } | 152 } |
150 | 153 |
151 | 154 |
152 /* Emulate Unix sbrk. */ | 155 /* Emulate Unix sbrk. */ |
153 void * | 156 void * |
172 | 175 |
173 /* If size is negative, shrink the heap by decommitting pages. */ | 176 /* If size is negative, shrink the heap by decommitting pages. */ |
174 if (size < 0) | 177 if (size < 0) |
175 { | 178 { |
176 int new_size; | 179 int new_size; |
177 unsigned char *new_data_region_end; | 180 UChar_Binary *new_data_region_end; |
178 | 181 |
179 size = -size; | 182 size = -size; |
180 | 183 |
181 /* Sanity checks. */ | 184 /* Sanity checks. */ |
182 if ((data_region_end - size) < data_region_base) | 185 if ((data_region_end - size) < data_region_base) |
183 return NULL; | 186 return NULL; |
184 | 187 |
185 /* We can only decommit full pages, so allow for | 188 /* We can only decommit full pages, so allow for |
186 partial deallocation [cga]. */ | 189 partial deallocation [cga]. */ |
187 new_data_region_end = (data_region_end - size); | 190 new_data_region_end = (data_region_end - size); |
188 new_data_region_end = (unsigned char *) | 191 new_data_region_end = (UChar_Binary *) |
189 ((long) (new_data_region_end + syspage_mask) & ~syspage_mask); | 192 ((long) (new_data_region_end + syspage_mask) & ~syspage_mask); |
190 new_size = real_data_region_end - new_data_region_end; | 193 new_size = real_data_region_end - new_data_region_end; |
191 real_data_region_end = new_data_region_end; | 194 real_data_region_end = new_data_region_end; |
192 if (new_size > 0) | 195 if (new_size > 0) |
193 { | 196 { |
212 return NULL; | 215 return NULL; |
213 data_region_end += size; | 216 data_region_end += size; |
214 | 217 |
215 /* We really only commit full pages, so record where | 218 /* We really only commit full pages, so record where |
216 the real end of committed memory is [cga]. */ | 219 the real end of committed memory is [cga]. */ |
217 real_data_region_end = (unsigned char *) | 220 real_data_region_end = (UChar_Binary *) |
218 ((long) (data_region_end + syspage_mask) & ~syspage_mask); | 221 ((long) (data_region_end + syspage_mask) & ~syspage_mask); |
219 } | 222 } |
220 | 223 |
221 return result; | 224 return result; |
222 } | 225 } |
223 | 226 |
224 #if !defined (CANNOT_DUMP) && !defined(HEAP_IN_DATA) && !defined(PDUMP) | 227 #if !defined (CANNOT_DUMP) && !defined (HEAP_IN_DATA) && !defined (PDUMP) |
225 | 228 |
226 /* Recreate the heap from the data that was dumped to the executable. | 229 /* Recreate the heap from the data that was dumped to the executable. |
227 EXECUTABLE_PATH tells us where to find the executable. */ | 230 EXECUTABLE_PATH tells us where to find the executable. */ |
228 void | 231 void |
229 recreate_heap (char *executable_path) | 232 recreate_heap (Extbyte *executable_path) |
230 { | 233 { |
231 /* First reserve the upper part of our heap. (We reserve first | 234 /* First reserve the upper part of our heap. (We reserve first |
232 because there have been problems in the past where doing the | 235 because there have been problems in the past where doing the |
233 mapping first has loaded DLLs into the VA space of our heap.) */ | 236 mapping first has loaded DLLs into the VA space of our heap.) */ |
234 | 237 |
235 /* Query the region at the end of the committed heap */ | 238 /* Query the region at the end of the committed heap */ |
236 void *tmp; | 239 void *tmp; |
237 MEMORY_BASIC_INFORMATION info; | 240 MEMORY_BASIC_INFORMATION info; |
238 DWORD size; | 241 DWORD size; |
239 unsigned char* base = get_heap_end (); | 242 UChar_Binary *base = get_heap_end (); |
240 unsigned char* end = base + get_reserved_heap_size () - get_committed_heap_size (); | 243 UChar_Binary *end = |
244 base + get_reserved_heap_size () - get_committed_heap_size (); | |
241 VirtualQuery (base, &info, sizeof (info)); | 245 VirtualQuery (base, &info, sizeof (info)); |
242 if (info.State != MEM_FREE) | 246 if (info.State != MEM_FREE) |
243 { | 247 { |
244 /* Oops, something has already reserved or commited it, nothing we can do but exit */ | 248 /* Oops, something has already reserved or commited it, nothing |
245 char buf[256]; | 249 we can do but exit */ |
246 sprintf (buf, | 250 Extbyte buf[256]; |
247 "XEmacs cannot start because the memory region required by the heap is not available.\n" | 251 sprintf (buf, |
248 "(BaseAddress = 0x%lx, AllocationBase = 0x%lx, Size = 0x%lx, State = %s, Type = %s)", | 252 "XEmacs cannot start because the memory region required " |
249 info.BaseAddress, info.AllocationBase, info.RegionSize, | 253 "by the heap is not available.\n" |
250 info.State == MEM_COMMIT ? "COMMITED" : "RESERVED", | 254 "(BaseAddress = 0x%lx, AllocationBase = 0x%lx, " |
251 info.Type == MEM_IMAGE ? "IMAGE" : info.Type == MEM_MAPPED ? "MAPPED" : "PRIVATE"); | 255 "Size = 0x%lx, State = %s, Type = %s)", |
252 MessageBoxA (NULL, buf, "XEmacs", MB_OK | MB_ICONSTOP); | 256 info.BaseAddress, info.AllocationBase, info.RegionSize, |
253 exit(1); | 257 info.State == MEM_COMMIT ? "COMMITED" : "RESERVED", |
254 } | 258 info.Type == MEM_IMAGE ? "IMAGE" : |
259 info.Type == MEM_MAPPED ? "MAPPED" : "PRIVATE"); | |
260 MessageBoxA (NULL, buf, "XEmacs", MB_OK | MB_ICONSTOP); | |
261 exit(1); | |
262 } | |
255 | 263 |
256 /* Now try and reserve as much as possible */ | 264 /* Now try and reserve as much as possible */ |
257 size = min (info.RegionSize, (DWORD) (end - base)); | 265 size = min (info.RegionSize, (DWORD) (end - base)); |
258 tmp = VirtualAlloc (base, size, MEM_RESERVE, PAGE_NOACCESS); | 266 tmp = VirtualAlloc (base, size, MEM_RESERVE, PAGE_NOACCESS); |
259 if (!tmp) | 267 if (!tmp) |
260 { | 268 { |
261 /* Can't reserve it, nothing we can do but exit */ | 269 /* Can't reserve it, nothing we can do but exit */ |
262 char buf[256]; | 270 Extbyte buf[256]; |
263 sprintf (buf, | 271 sprintf (buf, |
264 "XEmacs cannot start because it couldn't reserve space required for the heap.\n" | 272 "XEmacs cannot start because it couldn't reserve space " |
265 "(VirtualAlloc at 0x%lx of 0x%lx failed (%d))", base, size, GetLastError()); | 273 "required for the heap.\n" |
266 MessageBoxA (NULL, buf, "XEmacs", MB_OK | MB_ICONSTOP); | 274 "(VirtualAlloc at 0x%lx of 0x%lx failed (%d))", |
267 exit (1); | 275 base, size, GetLastError()); |
268 } | 276 MessageBoxA (NULL, buf, "XEmacs", MB_OK | MB_ICONSTOP); |
277 exit (1); | |
278 } | |
269 | 279 |
270 /* We read in the data for the .bss section from the executable | 280 /* We read in the data for the .bss section from the executable |
271 first and map in the heap from the executable second to prevent | 281 first and map in the heap from the executable second to prevent |
272 any funny interactions between file I/O and file mapping. */ | 282 any funny interactions between file I/O and file mapping. */ |
273 read_in_bss (executable_path); | 283 read_in_bss (executable_path); |