diff options
| author | John Wiegley | 2016-01-18 22:56:34 -0800 |
|---|---|---|
| committer | John Wiegley | 2016-01-18 22:56:34 -0800 |
| commit | 140016558bcb462692d8b9f2f3f866e0f337d218 (patch) | |
| tree | 3fd4a50444d4fff74510e2430c572a8e3fd0e4dd /src | |
| parent | 7823745acbe9b87eea2db4ef434e379fc903ec35 (diff) | |
| parent | 3ae7934fad7cc3bbd844123bf2143f376dbfab79 (diff) | |
| download | emacs-140016558bcb462692d8b9f2f3f866e0f337d218.tar.gz emacs-140016558bcb462692d8b9f2f3f866e0f337d218.zip | |
Merge from origin/emacs-25
3ae7934 ; * etc/NEWS: Mark entries that don't need further treatment.
6165c36 * lisp/files.el (dir-locals--all-files): Respect absolute file-names
2ffdf15 * lisp/help-fns.el (describe-variable): Fix a left-over parenthesis
71ecd62 * lisp/dired-x.el (dired-omit-here-always): Use add-dir-local-variable
f0b82b3 * lisp/files.el (dir-locals--all-files): Use completion instead of wildcards
86e4513 Fix incompatbilities with MS-Windows 2000 and older
4e96521 Mention in PROBLEMS an issue with MS-Windows NT4
15c23aa Ensure 8-byte aligned memory allocation on MS-Windows 9X
39afa42 Fix tests for active region in hideif.el
05df666 Fix interactive specs in some hideif.el commands
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 23 | ||||
| -rw-r--r-- | src/w32.h | 1 | ||||
| -rw-r--r-- | src/w32fns.c | 42 | ||||
| -rw-r--r-- | src/w32heap.c | 89 |
4 files changed, 125 insertions, 30 deletions
| @@ -484,6 +484,7 @@ typedef DWORD (WINAPI *GetAdaptersInfo_Proc) ( | |||
| 484 | 484 | ||
| 485 | int (WINAPI *pMultiByteToWideChar)(UINT,DWORD,LPCSTR,int,LPWSTR,int); | 485 | int (WINAPI *pMultiByteToWideChar)(UINT,DWORD,LPCSTR,int,LPWSTR,int); |
| 486 | int (WINAPI *pWideCharToMultiByte)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOOL); | 486 | int (WINAPI *pWideCharToMultiByte)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOOL); |
| 487 | DWORD multiByteToWideCharFlags; | ||
| 487 | 488 | ||
| 488 | /* ** A utility function ** */ | 489 | /* ** A utility function ** */ |
| 489 | static BOOL | 490 | static BOOL |
| @@ -1550,8 +1551,8 @@ codepage_for_filenames (CPINFO *cp_info) | |||
| 1550 | int | 1551 | int |
| 1551 | filename_to_utf16 (const char *fn_in, wchar_t *fn_out) | 1552 | filename_to_utf16 (const char *fn_in, wchar_t *fn_out) |
| 1552 | { | 1553 | { |
| 1553 | int result = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, fn_in, -1, | 1554 | int result = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, fn_in, |
| 1554 | fn_out, MAX_PATH); | 1555 | -1, fn_out, MAX_PATH); |
| 1555 | 1556 | ||
| 1556 | if (!result) | 1557 | if (!result) |
| 1557 | { | 1558 | { |
| @@ -1641,8 +1642,8 @@ filename_from_ansi (const char *fn_in, char *fn_out) | |||
| 1641 | { | 1642 | { |
| 1642 | wchar_t fn_utf16[MAX_PATH]; | 1643 | wchar_t fn_utf16[MAX_PATH]; |
| 1643 | int codepage = codepage_for_filenames (NULL); | 1644 | int codepage = codepage_for_filenames (NULL); |
| 1644 | int result = pMultiByteToWideChar (codepage, MB_ERR_INVALID_CHARS, fn_in, -1, | 1645 | int result = pMultiByteToWideChar (codepage, multiByteToWideCharFlags, fn_in, |
| 1645 | fn_utf16, MAX_PATH); | 1646 | -1, fn_utf16, MAX_PATH); |
| 1646 | 1647 | ||
| 1647 | if (!result) | 1648 | if (!result) |
| 1648 | { | 1649 | { |
| @@ -9104,14 +9105,14 @@ check_windows_init_file (void) | |||
| 9104 | "not unpacked properly.\nSee the README.W32 file in the " | 9105 | "not unpacked properly.\nSee the README.W32 file in the " |
| 9105 | "top-level Emacs directory for more information.", | 9106 | "top-level Emacs directory for more information.", |
| 9106 | init_file_name, load_path); | 9107 | init_file_name, load_path); |
| 9107 | needed = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, buffer, | 9108 | needed = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 9108 | -1, NULL, 0); | 9109 | buffer, -1, NULL, 0); |
| 9109 | if (needed > 0) | 9110 | if (needed > 0) |
| 9110 | { | 9111 | { |
| 9111 | wchar_t *msg_w = alloca ((needed + 1) * sizeof (wchar_t)); | 9112 | wchar_t *msg_w = alloca ((needed + 1) * sizeof (wchar_t)); |
| 9112 | 9113 | ||
| 9113 | pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, buffer, -1, | 9114 | pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, buffer, |
| 9114 | msg_w, needed); | 9115 | -1, msg_w, needed); |
| 9115 | needed = pWideCharToMultiByte (CP_ACP, 0, msg_w, -1, | 9116 | needed = pWideCharToMultiByte (CP_ACP, 0, msg_w, -1, |
| 9116 | NULL, 0, NULL, NULL); | 9117 | NULL, 0, NULL, NULL); |
| 9117 | if (needed > 0) | 9118 | if (needed > 0) |
| @@ -9298,6 +9299,7 @@ maybe_load_unicows_dll (void) | |||
| 9298 | (MultiByteToWideChar_Proc)GetProcAddress (ret, "MultiByteToWideChar"); | 9299 | (MultiByteToWideChar_Proc)GetProcAddress (ret, "MultiByteToWideChar"); |
| 9299 | pWideCharToMultiByte = | 9300 | pWideCharToMultiByte = |
| 9300 | (WideCharToMultiByte_Proc)GetProcAddress (ret, "WideCharToMultiByte"); | 9301 | (WideCharToMultiByte_Proc)GetProcAddress (ret, "WideCharToMultiByte"); |
| 9302 | multiByteToWideCharFlags = MB_ERR_INVALID_CHARS; | ||
| 9301 | return ret; | 9303 | return ret; |
| 9302 | } | 9304 | } |
| 9303 | else | 9305 | else |
| @@ -9327,6 +9329,11 @@ maybe_load_unicows_dll (void) | |||
| 9327 | pointers; no need for the LoadLibrary dance. */ | 9329 | pointers; no need for the LoadLibrary dance. */ |
| 9328 | pMultiByteToWideChar = MultiByteToWideChar; | 9330 | pMultiByteToWideChar = MultiByteToWideChar; |
| 9329 | pWideCharToMultiByte = WideCharToMultiByte; | 9331 | pWideCharToMultiByte = WideCharToMultiByte; |
| 9332 | /* On NT 4.0, though, MB_ERR_INVALID_CHARS is not supported. */ | ||
| 9333 | if (w32_major_version < 5) | ||
| 9334 | multiByteToWideCharFlags = 0; | ||
| 9335 | else | ||
| 9336 | multiByteToWideCharFlags = MB_ERR_INVALID_CHARS; | ||
| 9330 | return LoadLibrary ("Gdi32.dll"); | 9337 | return LoadLibrary ("Gdi32.dll"); |
| 9331 | } | 9338 | } |
| 9332 | } | 9339 | } |
| @@ -183,6 +183,7 @@ typedef int (WINAPI *MultiByteToWideChar_Proc)(UINT,DWORD,LPCSTR,int,LPWSTR,int) | |||
| 183 | typedef int (WINAPI *WideCharToMultiByte_Proc)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOOL); | 183 | typedef int (WINAPI *WideCharToMultiByte_Proc)(UINT,DWORD,LPCWSTR,int,LPSTR,int,LPCSTR,LPBOOL); |
| 184 | extern MultiByteToWideChar_Proc pMultiByteToWideChar; | 184 | extern MultiByteToWideChar_Proc pMultiByteToWideChar; |
| 185 | extern WideCharToMultiByte_Proc pWideCharToMultiByte; | 185 | extern WideCharToMultiByte_Proc pWideCharToMultiByte; |
| 186 | extern DWORD multiByteToWideCharFlags; | ||
| 186 | 187 | ||
| 187 | extern void init_environment (char **); | 188 | extern void init_environment (char **); |
| 188 | extern void check_windows_init_file (void); | 189 | extern void check_windows_init_file (void); |
diff --git a/src/w32fns.c b/src/w32fns.c index f3806a992a0..01f5d6f3ae0 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -6984,12 +6984,12 @@ value of DIR as in previous invocations; this is standard Windows behavior. */) | |||
| 6984 | if (errno == ENOENT && filename_buf_w[MAX_PATH - 1] != 0) | 6984 | if (errno == ENOENT && filename_buf_w[MAX_PATH - 1] != 0) |
| 6985 | report_file_error ("filename too long", default_filename); | 6985 | report_file_error ("filename too long", default_filename); |
| 6986 | } | 6986 | } |
| 6987 | len = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, | 6987 | len = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 6988 | SSDATA (prompt), -1, NULL, 0); | 6988 | SSDATA (prompt), -1, NULL, 0); |
| 6989 | if (len > 32768) | 6989 | if (len > 32768) |
| 6990 | len = 32768; | 6990 | len = 32768; |
| 6991 | prompt_w = alloca (len * sizeof (wchar_t)); | 6991 | prompt_w = alloca (len * sizeof (wchar_t)); |
| 6992 | pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, | 6992 | pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 6993 | SSDATA (prompt), -1, prompt_w, len); | 6993 | SSDATA (prompt), -1, prompt_w, len); |
| 6994 | } | 6994 | } |
| 6995 | else | 6995 | else |
| @@ -7002,12 +7002,12 @@ value of DIR as in previous invocations; this is standard Windows behavior. */) | |||
| 7002 | if (errno == ENOENT && filename_buf_a[MAX_PATH - 1] != 0) | 7002 | if (errno == ENOENT && filename_buf_a[MAX_PATH - 1] != 0) |
| 7003 | report_file_error ("filename too long", default_filename); | 7003 | report_file_error ("filename too long", default_filename); |
| 7004 | } | 7004 | } |
| 7005 | len = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, | 7005 | len = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 7006 | SSDATA (prompt), -1, NULL, 0); | 7006 | SSDATA (prompt), -1, NULL, 0); |
| 7007 | if (len > 32768) | 7007 | if (len > 32768) |
| 7008 | len = 32768; | 7008 | len = 32768; |
| 7009 | prompt_w = alloca (len * sizeof (wchar_t)); | 7009 | prompt_w = alloca (len * sizeof (wchar_t)); |
| 7010 | pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, | 7010 | pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 7011 | SSDATA (prompt), -1, prompt_w, len); | 7011 | SSDATA (prompt), -1, prompt_w, len); |
| 7012 | len = pWideCharToMultiByte (CP_ACP, 0, prompt_w, -1, NULL, 0, NULL, NULL); | 7012 | len = pWideCharToMultiByte (CP_ACP, 0, prompt_w, -1, NULL, 0, NULL, NULL); |
| 7013 | if (len > 32768) | 7013 | if (len > 32768) |
| @@ -7489,10 +7489,10 @@ a ShowWindow flag: | |||
| 7489 | current_dir = ENCODE_FILE (current_dir); | 7489 | current_dir = ENCODE_FILE (current_dir); |
| 7490 | /* Cannot use filename_to_utf16/ansi with DOCUMENT, since it could | 7490 | /* Cannot use filename_to_utf16/ansi with DOCUMENT, since it could |
| 7491 | be a URL that is not limited to MAX_PATH chararcters. */ | 7491 | be a URL that is not limited to MAX_PATH chararcters. */ |
| 7492 | doclen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, | 7492 | doclen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 7493 | SSDATA (document), -1, NULL, 0); | 7493 | SSDATA (document), -1, NULL, 0); |
| 7494 | doc_w = xmalloc (doclen * sizeof (wchar_t)); | 7494 | doc_w = xmalloc (doclen * sizeof (wchar_t)); |
| 7495 | pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, | 7495 | pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 7496 | SSDATA (document), -1, doc_w, doclen); | 7496 | SSDATA (document), -1, doc_w, doclen); |
| 7497 | if (use_unicode) | 7497 | if (use_unicode) |
| 7498 | { | 7498 | { |
| @@ -7507,12 +7507,12 @@ a ShowWindow flag: | |||
| 7507 | int len; | 7507 | int len; |
| 7508 | 7508 | ||
| 7509 | parameters = ENCODE_SYSTEM (parameters); | 7509 | parameters = ENCODE_SYSTEM (parameters); |
| 7510 | len = pMultiByteToWideChar (CP_ACP, MB_ERR_INVALID_CHARS, | 7510 | len = pMultiByteToWideChar (CP_ACP, multiByteToWideCharFlags, |
| 7511 | SSDATA (parameters), -1, NULL, 0); | 7511 | SSDATA (parameters), -1, NULL, 0); |
| 7512 | if (len > 32768) | 7512 | if (len > 32768) |
| 7513 | len = 32768; | 7513 | len = 32768; |
| 7514 | params_w = alloca (len * sizeof (wchar_t)); | 7514 | params_w = alloca (len * sizeof (wchar_t)); |
| 7515 | pMultiByteToWideChar (CP_ACP, MB_ERR_INVALID_CHARS, | 7515 | pMultiByteToWideChar (CP_ACP, multiByteToWideCharFlags, |
| 7516 | SSDATA (parameters), -1, params_w, len); | 7516 | SSDATA (parameters), -1, params_w, len); |
| 7517 | params_w[len - 1] = 0; | 7517 | params_w[len - 1] = 0; |
| 7518 | } | 7518 | } |
| @@ -8959,7 +8959,7 @@ add_tray_notification (struct frame *f, const char *icon, const char *tip, | |||
| 8959 | later versions support up to 128. */ | 8959 | later versions support up to 128. */ |
| 8960 | if (nidw.cbSize == MYNOTIFYICONDATAW_V1_SIZE) | 8960 | if (nidw.cbSize == MYNOTIFYICONDATAW_V1_SIZE) |
| 8961 | { | 8961 | { |
| 8962 | tiplen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, | 8962 | tiplen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 8963 | tip, utf8_mbslen_lim (tip, 63), | 8963 | tip, utf8_mbslen_lim (tip, 63), |
| 8964 | tipw, 64); | 8964 | tipw, 64); |
| 8965 | if (tiplen >= 63) | 8965 | if (tiplen >= 63) |
| @@ -8967,7 +8967,7 @@ add_tray_notification (struct frame *f, const char *icon, const char *tip, | |||
| 8967 | } | 8967 | } |
| 8968 | else | 8968 | else |
| 8969 | { | 8969 | { |
| 8970 | tiplen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, | 8970 | tiplen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 8971 | tip, utf8_mbslen_lim (tip, 127), | 8971 | tip, utf8_mbslen_lim (tip, 127), |
| 8972 | tipw, 128); | 8972 | tipw, 128); |
| 8973 | if (tiplen >= 127) | 8973 | if (tiplen >= 127) |
| @@ -8986,7 +8986,7 @@ add_tray_notification (struct frame *f, const char *icon, const char *tip, | |||
| 8986 | { | 8986 | { |
| 8987 | int slen; | 8987 | int slen; |
| 8988 | 8988 | ||
| 8989 | slen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, | 8989 | slen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 8990 | msg, utf8_mbslen_lim (msg, 255), | 8990 | msg, utf8_mbslen_lim (msg, 255), |
| 8991 | msgw, 256); | 8991 | msgw, 256); |
| 8992 | if (slen >= 255) | 8992 | if (slen >= 255) |
| @@ -8999,7 +8999,7 @@ add_tray_notification (struct frame *f, const char *icon, const char *tip, | |||
| 8999 | } | 8999 | } |
| 9000 | wcscpy (nidw.szInfo, msgw); | 9000 | wcscpy (nidw.szInfo, msgw); |
| 9001 | nidw.uTimeout = timeout; | 9001 | nidw.uTimeout = timeout; |
| 9002 | slen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS, | 9002 | slen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags, |
| 9003 | title, utf8_mbslen_lim (title, 63), | 9003 | title, utf8_mbslen_lim (title, 63), |
| 9004 | titlew, 64); | 9004 | titlew, 64); |
| 9005 | if (slen >= 63) | 9005 | if (slen >= 63) |
| @@ -9670,6 +9670,12 @@ static PVOID except_addr; | |||
| 9670 | 9670 | ||
| 9671 | /* Stack overflow recovery. */ | 9671 | /* Stack overflow recovery. */ |
| 9672 | 9672 | ||
| 9673 | /* MinGW headers don't declare this (should be in malloc.h). Also, | ||
| 9674 | the function is not present pre-W2K, so make the call through | ||
| 9675 | a function pointer. */ | ||
| 9676 | typedef int (__cdecl *_resetstkoflw_proc) (void); | ||
| 9677 | static _resetstkoflw_proc resetstkoflw; | ||
| 9678 | |||
| 9673 | /* Re-establish the guard page at stack limit. This is needed because | 9679 | /* Re-establish the guard page at stack limit. This is needed because |
| 9674 | when a stack overflow is detected, Windows removes the guard bit | 9680 | when a stack overflow is detected, Windows removes the guard bit |
| 9675 | from the guard page, so if we don't re-establish that protection, | 9681 | from the guard page, so if we don't re-establish that protection, |
| @@ -9677,12 +9683,14 @@ static PVOID except_addr; | |||
| 9677 | void | 9683 | void |
| 9678 | w32_reset_stack_overflow_guard (void) | 9684 | w32_reset_stack_overflow_guard (void) |
| 9679 | { | 9685 | { |
| 9680 | /* MinGW headers don't declare this (should be in malloc.h). */ | 9686 | if (resetstkoflw == NULL) |
| 9681 | _CRTIMP int __cdecl _resetstkoflw (void); | 9687 | resetstkoflw = |
| 9682 | 9688 | (_resetstkoflw_proc)GetProcAddress (GetModuleHandle ("msvcrt.dll"), | |
| 9689 | "_resetstkoflw"); | ||
| 9683 | /* We ignore the return value. If _resetstkoflw fails, the next | 9690 | /* We ignore the return value. If _resetstkoflw fails, the next |
| 9684 | stack overflow will crash the program. */ | 9691 | stack overflow will crash the program. */ |
| 9685 | (void)_resetstkoflw (); | 9692 | if (resetstkoflw != NULL) |
| 9693 | (void)resetstkoflw (); | ||
| 9686 | } | 9694 | } |
| 9687 | 9695 | ||
| 9688 | static void | 9696 | static void |
| @@ -9927,6 +9935,8 @@ globals_of_w32fns (void) | |||
| 9927 | 9935 | ||
| 9928 | after_deadkey = -1; | 9936 | after_deadkey = -1; |
| 9929 | 9937 | ||
| 9938 | resetstkoflw = NULL; | ||
| 9939 | |||
| 9930 | /* MessageBox does not work without this when linked to comctl32.dll 6.0. */ | 9940 | /* MessageBox does not work without this when linked to comctl32.dll 6.0. */ |
| 9931 | InitCommonControls (); | 9941 | InitCommonControls (); |
| 9932 | 9942 | ||
diff --git a/src/w32heap.c b/src/w32heap.c index 54646bfbe3e..3d1c5ff50a2 100644 --- a/src/w32heap.c +++ b/src/w32heap.c | |||
| @@ -258,9 +258,18 @@ init_heap (void) | |||
| 258 | } | 258 | } |
| 259 | #endif | 259 | #endif |
| 260 | 260 | ||
| 261 | the_malloc_fn = malloc_after_dump; | 261 | if (os_subtype == OS_9X) |
| 262 | the_realloc_fn = realloc_after_dump; | 262 | { |
| 263 | the_free_fn = free_after_dump; | 263 | the_malloc_fn = malloc_after_dump_9x; |
| 264 | the_realloc_fn = realloc_after_dump_9x; | ||
| 265 | the_free_fn = free_after_dump_9x; | ||
| 266 | } | ||
| 267 | else | ||
| 268 | { | ||
| 269 | the_malloc_fn = malloc_after_dump; | ||
| 270 | the_realloc_fn = realloc_after_dump; | ||
| 271 | the_free_fn = free_after_dump; | ||
| 272 | } | ||
| 264 | } | 273 | } |
| 265 | else | 274 | else |
| 266 | { | 275 | { |
| @@ -291,9 +300,18 @@ init_heap (void) | |||
| 291 | exit (-1); | 300 | exit (-1); |
| 292 | } | 301 | } |
| 293 | heap = s_pfn_Rtl_Create_Heap (0, data_region_base, 0, 0, NULL, ¶ms); | 302 | heap = s_pfn_Rtl_Create_Heap (0, data_region_base, 0, 0, NULL, ¶ms); |
| 294 | the_malloc_fn = malloc_before_dump; | 303 | |
| 295 | the_realloc_fn = realloc_before_dump; | 304 | if (os_subtype == OS_9X) |
| 296 | the_free_fn = free_before_dump; | 305 | { |
| 306 | fprintf (stderr, "Cannot dump Emacs on Windows 9X; exiting.\n"); | ||
| 307 | exit (-1); | ||
| 308 | } | ||
| 309 | else | ||
| 310 | { | ||
| 311 | the_malloc_fn = malloc_before_dump; | ||
| 312 | the_realloc_fn = realloc_before_dump; | ||
| 313 | the_free_fn = free_before_dump; | ||
| 314 | } | ||
| 297 | } | 315 | } |
| 298 | 316 | ||
| 299 | /* Update system version information to match current system. */ | 317 | /* Update system version information to match current system. */ |
| @@ -504,6 +522,65 @@ free_before_dump (void *ptr) | |||
| 504 | } | 522 | } |
| 505 | } | 523 | } |
| 506 | 524 | ||
| 525 | /* On Windows 9X, HeapAlloc may return pointers that are not aligned | ||
| 526 | on 8-byte boundary, alignment which is required by the Lisp memory | ||
| 527 | management. To circumvent this problem, manually enforce alignment | ||
| 528 | on Windows 9X. */ | ||
| 529 | |||
| 530 | void * | ||
| 531 | malloc_after_dump_9x (size_t size) | ||
| 532 | { | ||
| 533 | void *p = malloc_after_dump (size + 8); | ||
| 534 | void *pa; | ||
| 535 | if (p == NULL) | ||
| 536 | return p; | ||
| 537 | pa = (void*)(((intptr_t)p + 8) & ~7); | ||
| 538 | *((void**)pa-1) = p; | ||
| 539 | return pa; | ||
| 540 | } | ||
| 541 | |||
| 542 | void * | ||
| 543 | realloc_after_dump_9x (void *ptr, size_t size) | ||
| 544 | { | ||
| 545 | if (FREEABLE_P (ptr)) | ||
| 546 | { | ||
| 547 | void *po = *((void**)ptr-1); | ||
| 548 | void *p; | ||
| 549 | void *pa; | ||
| 550 | p = realloc_after_dump (po, size + 8); | ||
| 551 | if (p == NULL) | ||
| 552 | return p; | ||
| 553 | pa = (void*)(((intptr_t)p + 8) & ~7); | ||
| 554 | if (ptr != NULL && | ||
| 555 | (char*)pa - (char*)p != (char*)ptr - (char*)po) | ||
| 556 | { | ||
| 557 | /* Handle the case where alignment in pre-realloc and | ||
| 558 | post-realloc blocks does not match. */ | ||
| 559 | MoveMemory (pa, (void*)((char*)p + ((char*)ptr - (char*)po)), size); | ||
| 560 | } | ||
| 561 | *((void**)pa-1) = p; | ||
| 562 | return pa; | ||
| 563 | } | ||
| 564 | else | ||
| 565 | { | ||
| 566 | /* Non-freeable pointers have no alignment-enforcing header | ||
| 567 | (since dumping is not allowed on Windows 9X). */ | ||
| 568 | void* p = malloc_after_dump_9x (size); | ||
| 569 | if (p != NULL) | ||
| 570 | CopyMemory (p, ptr, size); | ||
| 571 | return p; | ||
| 572 | } | ||
| 573 | } | ||
| 574 | |||
| 575 | void | ||
| 576 | free_after_dump_9x (void *ptr) | ||
| 577 | { | ||
| 578 | if (FREEABLE_P (ptr)) | ||
| 579 | { | ||
| 580 | free_after_dump (*((void**)ptr-1)); | ||
| 581 | } | ||
| 582 | } | ||
| 583 | |||
| 507 | #ifdef ENABLE_CHECKING | 584 | #ifdef ENABLE_CHECKING |
| 508 | void | 585 | void |
| 509 | report_temacs_memory_usage (void) | 586 | report_temacs_memory_usage (void) |