commit d961c9de742f7597a8be30bec6a55ea09e00e9b0 Author: Michael Albinus Date: Sat Oct 24 08:09:20 2026 +0200 * lisp/net/ange-ftp.el (ange-ftp-file-modtime): Use `seconds-to-time'. diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index 0503e27a8d1..ed88d22cb4c 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el @@ -3564,24 +3564,23 @@ Value is (0 0) if the modification time cannot be determined." (ange-ftp-skip-msgs (concat ange-ftp-skip-msgs "\\|^226")) (res (ange-ftp-send-cmd (car parsed) (cadr parsed) (list 'quote "mdtm" (cadr (cdr parsed))))) - (line (cdr res)) - (modtime '(0 0))) + (line (cdr res))) ;; MDTM should return "213 YYYYMMDDhhmmss" GMT on success ;; following the Internet draft for FTP extensions. ;; Bob@rattlesnake.com reports that is returns something different ;; for at least one FTP server. So, let's use the response only ;; if it matches the Internet draft. - (when (string-match-p "^213 [0-9]\\{14\\}$" line) - (setq modtime - (encode-time - (string-to-number (substring line 16 18)) - (string-to-number (substring line 14 16)) - (string-to-number (substring line 12 14)) - (string-to-number (substring line 10 12)) - (string-to-number (substring line 8 10)) - (string-to-number (substring line 4 8)) - 0))) - modtime)) + (if (string-match-p "^213 [0-9]\\{14\\}$" line) + (seconds-to-time + (encode-time + (string-to-number (substring line 16 18)) + (string-to-number (substring line 14 16)) + (string-to-number (substring line 12 14)) + (string-to-number (substring line 10 12)) + (string-to-number (substring line 8 10)) + (string-to-number (substring line 4 8)) + 0)) + (seconds-to-time 0)))) (defun ange-ftp-verify-visited-file-modtime (buf) (let ((name (buffer-file-name buf))) commit 7e7ed59fa33544a91efb525966de1a073a1196c0 Author: Paul Eggert Date: Tue Oct 13 09:34:25 2026 -0700 REL_ALLOC → GMALLOC_REL_ALLOC Suggested by Eli Zaretskii (Bug#81992#65). * msdos/sed2v2.inp (GMALLOC_REL_ALLOC): Renamed from REL_ALLOC. All uses changed. diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index 4a592a781d7..7b944c8dbb6 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -89,7 +89,7 @@ HAVE_PROCFS The /proc filesystem is supported. ** Compile-time options ** -REL_ALLOC Compile in the relocatable memory allocator ralloc.c. +GMALLOC_REL_ALLOC Compile in the relocatable memory allocator ralloc.c. Also compile gmalloc.c, which is an old copy of GNU malloc etc. This is used only on MS-DOS. subprocesses System can use subprocesses (for M-x shell for example). diff --git a/msdos/autogen/config.in b/msdos/autogen/config.in index 11f5c4c5964..a5c4c26acb3 100644 --- a/msdos/autogen/config.in +++ b/msdos/autogen/config.in @@ -1376,9 +1376,9 @@ along with GNU Emacs. If not, see . */ /* Define to 1 if readlink fails to recognize a trailing slash. */ #undef READLINK_TRAILING_SLASH_BUG -/* Define REL_ALLOC if you want to use the relocating allocator for buffer - space. */ -#undef REL_ALLOC +/* Define GMALLOC_REL_ALLOC if you want to use the relocating allocator + for buffer space. */ +#undef GMALLOC_REL_ALLOC /* Define to 1 if stat needs help when passed a directory name with a trailing slash */ diff --git a/msdos/sed2v2.inp b/msdos/sed2v2.inp index 59704d467d4..26afc44eab6 100644 --- a/msdos/sed2v2.inp +++ b/msdos/sed2v2.inp @@ -100,7 +100,7 @@ /^#include /i\ /* Define to 1 to use the relocating allocator for buffer space,\ along with gmalloc.c. */\ -#define REL_ALLOC 1 +#define GMALLOC_REL_ALLOC 1 s/^#undef STACK_DIRECTION *$/#define STACK_DIRECTION -1/ s/^#undef EMACS_CONFIGURATION *$/#define EMACS_CONFIGURATION "i386-pc-msdosdjgpp"/ diff --git a/msdos/sedalloc.inp b/msdos/sedalloc.inp index e7f37c8d499..4e9b44ab9e9 100644 --- a/msdos/sedalloc.inp +++ b/msdos/sedalloc.inp @@ -1,5 +1,5 @@ # -sedalloc.inp----------------------------------------------------------- -# Configuration script for REL_ALLOC in src/config.h +# Configuration script for GMALLOC_REL_ALLOC in src/config.h # ---------------------------------------------------------------------- # # Copyright (C) 2008-2026 Free Software Foundation, Inc. @@ -15,4 +15,4 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # ---------------------------------------------------------------------- -/^#define REL_ALLOC *1 *$/s|^.*$|/* #undef REL_ALLOC */| +/^#define GMALLOC_REL_ALLOC *1 *$/s|^.*$|/* #undef GMALLOC_REL_ALLOC */| diff --git a/src/alloc.c b/src/alloc.c index 49189d2685a..fc50e6c1f08 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -269,7 +269,7 @@ static struct gcstat objects, both dead and alive. This number is always kept up-to-date. */ static ptrdiff_t hash_table_allocated_bytes = 0; -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC /* Points to memory space allocated as "spare", to be freed if we run out of memory. We keep one large block, four cons-blocks, and two string blocks. */ @@ -482,7 +482,7 @@ struct Lisp_Finalizer doomed_finalizers; Malloc ************************************************************************/ -#if defined SIGDANGER || defined REL_ALLOC +#if defined SIGDANGER || defined GMALLOC_REL_ALLOC /* Function malloc calls this if it finds we are near exhausting storage. */ @@ -518,7 +518,7 @@ buffer_memory_full (ptrdiff_t nbytes) relocating allocator, treat this like any other failing malloc. */ -#ifndef REL_ALLOC +#ifndef GMALLOC_REL_ALLOC memory_full (nbytes); #else /* This used to call error, but if we've run out of memory, we could @@ -875,7 +875,7 @@ static_assert (POWER_OF_2 (BLOCK_ALIGN)); /* Use aligned_alloc if it or a simple substitute is available. */ -#if defined HAVE_ALIGNED_ALLOC || defined REL_ALLOC +#if defined HAVE_ALIGNED_ALLOC || defined GMALLOC_REL_ALLOC # define USE_ALIGNED_ALLOC 1 #elif defined HAVE_POSIX_MEMALIGN # define USE_ALIGNED_ALLOC 1 @@ -4011,7 +4011,7 @@ memory_full (size_t nbytes) Vmemory_full = Qt; consing_until_gc = min (consing_until_gc, memory_full_cons_threshold); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC /* The first time we get here, free the spare memory. */ for (int i = 0; i < countof (spare_memory); i++) if (spare_memory[i]) @@ -4042,7 +4042,7 @@ memory_full_up (void) memory_full (SIZE_MAX); } -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC /* If we released our reserve (due to running out of memory), and we have a fair amount free once again, @@ -7256,7 +7256,7 @@ init_alloc_once_for_pdumper (void) mem_init (); init_finalizer_list (&finalizers); init_finalizer_list (&doomed_finalizers); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC refill_memory_reserve (); #endif } diff --git a/src/buffer.c b/src/buffer.c index 0dbcb27a119..6a980e6e75f 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -2618,12 +2618,12 @@ results, see Info node `(elisp)Swapping Text'. */) swapfield (own_text, struct buffer_text); eassert (current_buffer->text == ¤t_buffer->own_text); eassert (other_buffer->text == &other_buffer->own_text); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC r_alloc_reset_variable ((void **) ¤t_buffer->own_text.beg, (void **) &other_buffer->own_text.beg); r_alloc_reset_variable ((void **) &other_buffer->own_text.beg, (void **) ¤t_buffer->own_text.beg); -#endif /* REL_ALLOC */ +#endif swapfield (pt, ptrdiff_t); swapfield (pt_byte, ptrdiff_t); @@ -4636,7 +4636,7 @@ alloc_buffer_text (struct buffer *b, ptrdiff_t nbytes) block_input (); #if defined USE_MMAP_FOR_BUFFERS p = mmap_alloc ((void **) &b->text->beg, nbytes); -#elif defined REL_ALLOC +#elif defined GMALLOC_REL_ALLOC p = r_alloc ((void **) &b->text->beg, nbytes); #else p = xmalloc (nbytes); @@ -4672,7 +4672,7 @@ enlarge_buffer_text (struct buffer *b, ptrdiff_t delta) #if defined USE_MMAP_FOR_BUFFERS p = mmap_realloc ((void **) &b->text->beg, new_nbytes); -#elif defined REL_ALLOC +#elif defined GMALLOC_REL_ALLOC p = r_re_alloc ((void **) &b->text->beg, new_nbytes); #else p = xrealloc (b->text->beg, new_nbytes); @@ -4706,7 +4706,7 @@ free_buffer_text (struct buffer *b) { #if defined USE_MMAP_FOR_BUFFERS mmap_free ((void **) &b->text->beg); -#elif defined REL_ALLOC +#elif defined GMALLOC_REL_ALLOC r_alloc_free ((void **) &b->text->beg); #else xfree (b->text->beg); diff --git a/src/buffer.h b/src/buffer.h index 3b3d467bb8c..4071f7f2d20 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -239,7 +239,7 @@ struct ts_linecol struct buffer_text { - /* Actual address of buffer contents. If REL_ALLOC is defined, + /* Actual address of buffer contents. If GMALLOC_REL_ALLOC is defined, this address might change when blocks are relocated which can e.g. happen when malloc is called. So, don't pass a pointer into a buffer's text to functions that malloc. */ diff --git a/src/charset.c b/src/charset.c index 971dafc2b9d..89e54f7a4ed 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1604,10 +1604,10 @@ maybe_unify_char (int c, Lisp_Object val) return c; CHECK_CHARSET_GET_CHARSET (val, charset); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC /* The call to load_charset below can allocate memory, which screws callers of this function through STRING_CHAR_* macros that hold C - pointers to buffer text, if REL_ALLOC is used. */ + pointers to buffer text, if GMALLOC_REL_ALLOC is used. */ r_alloc_inhibit_buffer_relocation (1); #endif load_charset (charset, 1); @@ -1625,7 +1625,7 @@ maybe_unify_char (int c, Lisp_Object val) if (unified > 0) c = unified; } -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC r_alloc_inhibit_buffer_relocation (0); #endif return c; diff --git a/src/dosfns.c b/src/dosfns.c index 41ca98c8c49..1965ffd3c59 100644 --- a/src/dosfns.c +++ b/src/dosfns.c @@ -272,7 +272,7 @@ init_dosfns (void) _go32_dpmi_registers dpmiregs; unsigned long xbuf = _go32_info_block.linear_address_of_transfer_buffer; -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC extern void get_lim_data (void); get_lim_data (); /* why the hell isn't this called elsewhere? */ @@ -534,7 +534,7 @@ system_process_attributes (Lisp_Object pid) int i; Lisp_Object cmd_str, decoded_cmd, tem; double pmem; -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC extern unsigned long ret_lim_data (); #endif @@ -569,9 +569,9 @@ system_process_attributes (Lisp_Object pid) INT_TO_INTEGER ((unsigned long) sbrk (0) / 1024)), attrs); attrs = Fcons (Fcons (Qetime, tem), attrs); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC /* ret_lim_data is in vm-limit.c, which is compiled only if - REL_ALLOC. */ + GMALLOC_REL_ALLOC. */ pmem = (double)((unsigned long) sbrk (0)) / ret_lim_data () * 100.0; if (pmem > 100) #endif diff --git a/src/emacs.c b/src/emacs.c index e16c1254990..07343663b4f 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1622,7 +1622,7 @@ android_emacs_init (int argc, char **argv, char *dump_file) emacs_backtrace (-1); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC /* Arrange to get warning messages as memory fills up. */ memory_warnings (0, malloc_warning); diff --git a/src/insdel.c b/src/insdel.c index 6a262bd9137..80c66e7f741 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -511,7 +511,7 @@ make_gap_larger (ptrdiff_t nbytes_added) Vinhibit_quit = tem; } -#if defined USE_MMAP_FOR_BUFFERS || defined REL_ALLOC +#if defined USE_MMAP_FOR_BUFFERS || defined GMALLOC_REL_ALLOC /* Make the gap NBYTES_REMOVED bytes shorter. */ @@ -572,7 +572,7 @@ make_gap_smaller (ptrdiff_t nbytes_removed) Vinhibit_quit = tem; } -#endif /* USE_MMAP_FOR_BUFFERS || REL_ALLOC */ +#endif /* USE_MMAP_FOR_BUFFERS || GMALLOC_REL_ALLOC */ void make_gap (ptrdiff_t nbytes_added) @@ -594,7 +594,7 @@ make_gap (ptrdiff_t nbytes_added) * We chose /64 because it already brings almost the best performance while * limiting the potential wasted memory to 1.5%. */ make_gap_larger (max (nbytes_added, (Z - BEG) / 64)); -#if defined USE_MMAP_FOR_BUFFERS || defined REL_ALLOC +#if defined USE_MMAP_FOR_BUFFERS || defined GMALLOC_REL_ALLOC else make_gap_smaller (-nbytes_added); #endif diff --git a/src/lisp.h b/src/lisp.h index a523b1e2f45..1092550f34e 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4441,7 +4441,7 @@ extern AVOID buffer_memory_full (ptrdiff_t); extern bool survives_gc_p (Lisp_Object); extern void mark_object (Lisp_Object); extern void mark_objects (Lisp_Object *, ptrdiff_t); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC extern void refill_memory_reserve (void); #endif extern void mark_c_stack (char const *, char const *); @@ -4672,14 +4672,14 @@ void *hash_table_alloc_bytes (ptrdiff_t nbytes) ATTRIBUTE_DEALLOC (hash_table_free_bytes, 1) ATTRIBUTE_RETURNS_NONNULL; /* Defined in gmalloc.c. */ -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC extern size_t __malloc_extra_blocks; extern void *aligned_alloc (size_t, size_t) ATTRIBUTE_MALLOC_SIZE ((2)) ATTRIBUTE_DEALLOC_FREE; extern void malloc_enable_thread (void); #endif -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC /* Defined in ralloc.c. */ extern void *r_alloc (void **, size_t) ATTRIBUTE_ALLOC_SIZE ((2)); extern void r_alloc_free (void **); diff --git a/src/msdos.c b/src/msdos.c index 5f28105cdb4..0f6e65e7138 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -106,7 +106,7 @@ extern int spawnve (int, const char *, char *const [], char *const []); #include "careadlinkat.h" #include "allocator.h" -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC /* If other `malloc' than ours is used, force our `sbrk' behave like Unix programs expect (resize memory blocks to keep them contiguous). @@ -116,7 +116,7 @@ extern int spawnve (int, const char *, char *const [], char *const []); int _crt0_startup_flags = _CRT0_FLAG_UNIX_SBRK; -#endif /* not REL_ALLOC */ +#endif /* Return the current timestamp in milliseconds since midnight. */ static unsigned long diff --git a/src/pdumper.c b/src/pdumper.c index 2d6ca125fc6..d47ce96c7d3 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -508,7 +508,7 @@ struct dump_context Lisp_Object old_post_gc_hook; Lisp_Object old_process_environment; -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC bool blocked_ralloc; #endif @@ -3677,7 +3677,7 @@ dump_unwind_cleanup (void *data) struct dump_context *ctx = data; if (ctx->fd >= 0) emacs_close (ctx->fd); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC if (ctx->blocked_ralloc) r_alloc_inhibit_buffer_relocation (0); #endif @@ -4160,7 +4160,7 @@ types. */) record_unwind_protect_ptr (dump_unwind_cleanup, ctx); block_input (); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC r_alloc_inhibit_buffer_relocation (1); ctx->blocked_ralloc = true; #endif diff --git a/src/search.c b/src/search.c index 2b721a4367a..2a2f568046c 100644 --- a/src/search.c +++ b/src/search.c @@ -83,7 +83,7 @@ matcher_overflow (void) static void freeze_buffer_relocation (void) { -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC /* Prevent ralloc.c from relocating the current buffer while searching it. */ r_alloc_inhibit_buffer_relocation (1); @@ -2029,7 +2029,7 @@ boyer_moore (EMACS_INT n, unsigned char *base_pat, if (i + direction == 0) { ptrdiff_t position, start, end; -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC ptrdiff_t cursor_off; #endif @@ -2037,14 +2037,14 @@ boyer_moore (EMACS_INT n, unsigned char *base_pat, position = pos_byte + cursor - p2 + ((direction > 0) ? 1 - len_byte : 0); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC /* set_search_regs might call malloc, which could cause ralloc.c relocate buffer text. We need to update pointers into buffer text due to that. */ cursor_off = cursor - p2; #endif set_search_regs (position, len_byte); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC p_limit = BYTE_POS_ADDR (limit); p2 = BYTE_POS_ADDR (pos_byte); cursor = p2 + cursor_off; diff --git a/src/xml.c b/src/xml.c index a159aca3591..085aaa55338 100644 --- a/src/xml.c +++ b/src/xml.c @@ -207,7 +207,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, } buftext = BYTE_POS_ADDR (istart_byte); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC /* Prevent ralloc.c from relocating the current buffer while libxml2 functions below read its text. */ r_alloc_inhibit_buffer_relocation (1); @@ -224,7 +224,7 @@ parse_region (Lisp_Object start, Lisp_Object end, Lisp_Object base_url, XML_PARSE_NONET|XML_PARSE_NOWARNING| XML_PARSE_NOBLANKS |XML_PARSE_NOERROR); -#ifdef REL_ALLOC +#ifdef GMALLOC_REL_ALLOC r_alloc_inhibit_buffer_relocation (0); #endif /* If the assertion below fails, malloc was called inside the above commit c2a6aa0150423e67387ad9ed04d3805b94c51c48 Author: Paul Eggert Date: Tue Oct 13 09:27:58 2026 -0700 Simplify vm-limit.c by assuming REL_ALLOC * src/vm-limit.c (real_morecore, check_memory_limits): Simplify by assuming REL_ALLOC is defined, which it always is now in this file (Bug#81992). diff --git a/src/vm-limit.c b/src/vm-limit.c index 63a93fd5e05..a578ca9a3c3 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c @@ -47,9 +47,7 @@ extern void *(*__morecore) (ptrdiff_t); extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void); /* From ralloc.c. */ -#ifdef REL_ALLOC extern void *(*real_morecore) (ptrdiff_t); -#endif /* Level number of warnings already issued. @@ -130,10 +128,6 @@ ret_lim_data (void) static void check_memory_limits (void) { -#ifndef REL_ALLOC - void *(*real_morecore) (ptrdiff_t) = 0; -#endif - char *cp; size_t five_percent; size_t data_size; commit 1eefcc405b41886ab9aab65d12207a4fe7a73040 Author: Paul Eggert Date: Fri Oct 23 22:23:15 2026 -0700 SYSTEM_MALLOC → !defined REL_ALLOC SYSTEM_MALLOC was confusing. Problem reported by Eli Zaretskii (Bug#81992#56). Replace uses with !defined REL_ALLOC, which is equivalent. * msdos/sed2v2.inp, msdos/sedalloc.inp: (SYSTEM_MALLOC): Remove. * src/alloc.c (refill_memory_reserve): Define only if REL_ALLOC, to simplify the declaration’s odd use of ‘static’. All uses changed. * src/gmalloc.c (__malloc_extra_blocks) [SYSTEM_MALLOC]: * src/ralloc.c (r_alloc_init) [SYSTEM_MALLOC]: Simplify by assuming !SYSTEM_MALLOC, as this file is compiled only when not using system malloc. * src/lisp.h (SYSTEM_MALLOC): Remove. All uses replaced by !defined REL_ALLOC. diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index c52af45597f..4a592a781d7 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -90,7 +90,8 @@ HAVE_PROCFS The /proc filesystem is supported. ** Compile-time options ** REL_ALLOC Compile in the relocatable memory allocator ralloc.c. -SYSTEM_MALLOC Use the system library's malloc. + Also compile gmalloc.c, which is an old copy of GNU malloc etc. + This is used only on MS-DOS. subprocesses System can use subprocesses (for M-x shell for example). Defined by default, only MSDOS undefines it. DEBUG_LISP_OBJECT_TYPE Define it in lisp.h enable compile time checks @@ -360,7 +361,6 @@ SETUP_SLAVE_PTY SIGNALS_VIA_CHARACTERS STDC_HEADERS SYSTEM_PURESIZE_EXTRA -SYSTEM_MALLOC TAB3 TABDLY TERM diff --git a/config.bat b/config.bat index 7ff159fdf60..eb00e7f4de5 100644 --- a/config.bat +++ b/config.bat @@ -179,7 +179,7 @@ sed -e "/#define EMACS_CONFIG_FEATURES/s/^.*$/#define EMACS_CONFIG_FEATURES \"LI set libxml=1 :xmlDone rm -f junk.c junk junk.exe -Rem See if they requested a SYSTEM_MALLOC build +Rem See if they requested a build with the system malloc. if "%sys_malloc%" == "" Goto cfgDone rm -f config.tmp ren config.h2 config.tmp diff --git a/msdos/sed2v2.inp b/msdos/sed2v2.inp index 68f83003e73..59704d467d4 100644 --- a/msdos/sed2v2.inp +++ b/msdos/sed2v2.inp @@ -98,10 +98,8 @@ /^#undef restrict/s/^.*$/#define restrict __restrict/ /^#include /i\ -/* Define to 0 to not use the system malloc, and to use gmalloc.c instead. */ -#define SYSTEM_MALLOC 0\ -\ -/* Define to 1 to use the relocating allocator for buffer space. */\ +/* Define to 1 to use the relocating allocator for buffer space,\ + along with gmalloc.c. */\ #define REL_ALLOC 1 s/^#undef STACK_DIRECTION *$/#define STACK_DIRECTION -1/ diff --git a/msdos/sedalloc.inp b/msdos/sedalloc.inp index 6f2903c76b3..e7f37c8d499 100644 --- a/msdos/sedalloc.inp +++ b/msdos/sedalloc.inp @@ -1,5 +1,5 @@ # -sedalloc.inp----------------------------------------------------------- -# Configuration script for SYSTEM_MALLOC/REL_ALLOC in src/config.h +# Configuration script for REL_ALLOC in src/config.h # ---------------------------------------------------------------------- # # Copyright (C) 2008-2026 Free Software Foundation, Inc. @@ -15,5 +15,4 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # ---------------------------------------------------------------------- -/^#define SYSTEM_MALLOC *0 *$/s/0/1/ /^#define REL_ALLOC *1 *$/s|^.*$|/* #undef REL_ALLOC */| diff --git a/src/alloc.c b/src/alloc.c index 6149336026a..49189d2685a 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -269,7 +269,7 @@ static struct gcstat objects, both dead and alive. This number is always kept up-to-date. */ static ptrdiff_t hash_table_allocated_bytes = 0; -#if !SYSTEM_MALLOC +#ifdef REL_ALLOC /* Points to memory space allocated as "spare", to be freed if we run out of memory. We keep one large block, four cons-blocks, and two string blocks. */ @@ -334,9 +334,6 @@ static void mark_terminals (void); static void gc_sweep (void); static void mark_buffer (struct buffer *); -#if !defined REL_ALLOC || SYSTEM_MALLOC -static void refill_memory_reserve (void); -#endif static void compact_small_strings (void); static void free_large_strings (void); extern Lisp_Object which_symbols (Lisp_Object, EMACS_INT) EXTERNALLY_VISIBLE; @@ -485,7 +482,7 @@ struct Lisp_Finalizer doomed_finalizers; Malloc ************************************************************************/ -#if defined SIGDANGER || !SYSTEM_MALLOC +#if defined SIGDANGER || defined REL_ALLOC /* Function malloc calls this if it finds we are near exhausting storage. */ @@ -878,7 +875,7 @@ static_assert (POWER_OF_2 (BLOCK_ALIGN)); /* Use aligned_alloc if it or a simple substitute is available. */ -#if defined HAVE_ALIGNED_ALLOC || !SYSTEM_MALLOC +#if defined HAVE_ALIGNED_ALLOC || defined REL_ALLOC # define USE_ALIGNED_ALLOC 1 #elif defined HAVE_POSIX_MEMALIGN # define USE_ALIGNED_ALLOC 1 @@ -4014,7 +4011,7 @@ memory_full (size_t nbytes) Vmemory_full = Qt; consing_until_gc = min (consing_until_gc, memory_full_cons_threshold); -#if !SYSTEM_MALLOC +#ifdef REL_ALLOC /* The first time we get here, free the spare memory. */ for (int i = 0; i < countof (spare_memory); i++) if (spare_memory[i]) @@ -4045,6 +4042,8 @@ memory_full_up (void) memory_full (SIZE_MAX); } +#ifdef REL_ALLOC + /* If we released our reserve (due to running out of memory), and we have a fair amount free once again, try to set aside another reserve in case we run out once more. @@ -4055,7 +4054,6 @@ memory_full_up (void) void refill_memory_reserve (void) { -#if !SYSTEM_MALLOC if (spare_memory[0] == 0) spare_memory[0] = malloc (SPARE_MEMORY); if (spare_memory[1] == 0) @@ -4078,8 +4076,8 @@ refill_memory_reserve (void) false, MEM_TYPE_SPARE); if (spare_memory[0] && spare_memory[1] && spare_memory[5]) Vmemory_full = Qnil; -#endif } +#endif /************************************************************************ C Stack Marking @@ -7258,7 +7256,9 @@ init_alloc_once_for_pdumper (void) mem_init (); init_finalizer_list (&finalizers); init_finalizer_list (&doomed_finalizers); +#ifdef REL_ALLOC refill_memory_reserve (); +#endif } void diff --git a/src/dosfns.c b/src/dosfns.c index 714e13efbed..41ca98c8c49 100644 --- a/src/dosfns.c +++ b/src/dosfns.c @@ -272,7 +272,7 @@ init_dosfns (void) _go32_dpmi_registers dpmiregs; unsigned long xbuf = _go32_info_block.linear_address_of_transfer_buffer; -#if !SYSTEM_MALLOC +#ifdef REL_ALLOC extern void get_lim_data (void); get_lim_data (); /* why the hell isn't this called elsewhere? */ @@ -534,7 +534,7 @@ system_process_attributes (Lisp_Object pid) int i; Lisp_Object cmd_str, decoded_cmd, tem; double pmem; -#if !SYSTEM_MALLOC +#ifdef REL_ALLOC extern unsigned long ret_lim_data (); #endif @@ -569,9 +569,9 @@ system_process_attributes (Lisp_Object pid) INT_TO_INTEGER ((unsigned long) sbrk (0) / 1024)), attrs); attrs = Fcons (Fcons (Qetime, tem), attrs); -#if !SYSTEM_MALLOC - /* ret_lim_data is on vm-limit.c, which is not compiled in under - SYSTEM_MALLOC. */ +#ifdef REL_ALLOC + /* ret_lim_data is in vm-limit.c, which is compiled only if + REL_ALLOC. */ pmem = (double)((unsigned long) sbrk (0)) / ret_lim_data () * 100.0; if (pmem > 100) #endif diff --git a/src/emacs.c b/src/emacs.c index cd8dbc70f20..e16c1254990 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1622,15 +1622,14 @@ android_emacs_init (int argc, char **argv, char *dump_file) emacs_backtrace (-1); -#if !SYSTEM_MALLOC +#ifdef REL_ALLOC /* Arrange to get warning messages as memory fills up. */ memory_warnings (0, malloc_warning); /* Call malloc at least once, to run malloc_initialize_hook. Also call realloc and free for consistency. */ free (realloc (malloc (4), 4)); - -#endif /* not SYSTEM_MALLOC */ +#endif #ifdef MSDOS set_binary_mode (STDIN_FILENO, O_BINARY); diff --git a/src/gmalloc.c b/src/gmalloc.c index 17901ebbdcc..2ccca92eb6f 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -336,9 +336,6 @@ int __malloc_initialized; /* Number of extra blocks to get each time we ask for more core. This reduces the frequency of calling `(*__morecore)'. */ -#if SYSTEM_MALLOC -static -#endif size_t __malloc_extra_blocks; /* Number of info entries. */ diff --git a/src/lisp.h b/src/lisp.h index c6ebbc272ed..a523b1e2f45 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4433,9 +4433,6 @@ extern void parse_str_as_multibyte (const unsigned char *, ptrdiff_t, ptrdiff_t *, ptrdiff_t *); /* Defined in alloc.c. */ -#ifndef SYSTEM_MALLOC -# define SYSTEM_MALLOC 1 /* Typically 1, but might be 0 if MSDOS. */ -#endif extern intptr_t garbage_collection_inhibited; extern void malloc_warning (const char *); extern AVOID memory_full (size_t); @@ -4444,7 +4441,7 @@ extern AVOID buffer_memory_full (ptrdiff_t); extern bool survives_gc_p (Lisp_Object); extern void mark_object (Lisp_Object); extern void mark_objects (Lisp_Object *, ptrdiff_t); -#if defined REL_ALLOC && !SYSTEM_MALLOC +#ifdef REL_ALLOC extern void refill_memory_reserve (void); #endif extern void mark_c_stack (char const *, char const *); @@ -4675,7 +4672,7 @@ void *hash_table_alloc_bytes (ptrdiff_t nbytes) ATTRIBUTE_DEALLOC (hash_table_free_bytes, 1) ATTRIBUTE_RETURNS_NONNULL; /* Defined in gmalloc.c. */ -#if !SYSTEM_MALLOC +#ifdef REL_ALLOC extern size_t __malloc_extra_blocks; extern void *aligned_alloc (size_t, size_t) ATTRIBUTE_MALLOC_SIZE ((2)) ATTRIBUTE_DEALLOC_FREE; diff --git a/src/msdos.c b/src/msdos.c index 0b2fa2e40ea..5f28105cdb4 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -106,7 +106,7 @@ extern int spawnve (int, const char *, char *const [], char *const []); #include "careadlinkat.h" #include "allocator.h" -#if !SYSTEM_MALLOC +#ifdef REL_ALLOC /* If other `malloc' than ours is used, force our `sbrk' behave like Unix programs expect (resize memory blocks to keep them contiguous). @@ -114,13 +114,9 @@ extern int spawnve (int, const char *, char *const [], char *const []); because that's what `gmalloc' expects to get. */ #include -#ifdef REL_ALLOC int _crt0_startup_flags = _CRT0_FLAG_UNIX_SBRK; -#else /* not REL_ALLOC */ -int _crt0_startup_flags = (_CRT0_FLAG_UNIX_SBRK | _CRT0_FLAG_FILL_SBRK_MEMORY); -#endif /* not REL_ALLOC */ -#endif /* not SYSTEM_MALLOC */ +#endif /* not REL_ALLOC */ /* Return the current timestamp in milliseconds since midnight. */ static unsigned long diff --git a/src/ralloc.c b/src/ralloc.c index 7203f37ffc1..68894a4b21f 100644 --- a/src/ralloc.c +++ b/src/ralloc.c @@ -1138,7 +1138,6 @@ r_alloc_init (void) r_alloc_initialized = 1; page_size = PAGE; -#if !SYSTEM_MALLOC real_morecore = __morecore; __morecore = r_alloc_sbrk; @@ -1150,17 +1149,13 @@ r_alloc_init (void) emacs_abort (); extra_bytes = PAGE_ROUNDUP (50000); -#endif -#if !SYSTEM_MALLOC /* Give GNU malloc's morecore some hysteresis so that we move all the relocatable blocks much less often. The number used to be 64, but alloc.c would override that with 32 in code that was removed when SYNC_INPUT became the only input handling mode. */ __malloc_extra_blocks = 32; -#endif -#if !SYSTEM_MALLOC first_heap->end = (void *) PAGE_ROUNDUP (first_heap->start); /* The extra call to real_morecore guarantees that the end of the @@ -1178,7 +1173,6 @@ r_alloc_init (void) memset (first_heap->start, 0, (char *) first_heap->end - (char *) first_heap->start); virtual_break_value = break_value = first_heap->bloc_start = first_heap->end; -#endif use_relocatable_buffers = 1; } commit 42710b197feda93460d2d3c72ae092f4fa442cd3 Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 Help the compiler optimize away spare_memory * src/alloc.c (spare_memory) [SYSTEM_MALLOC]: Remove, as it contains only null pointers (Bug#81992). All uses removed. diff --git a/src/alloc.c b/src/alloc.c index e9e7eabaff0..6149336026a 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -269,11 +269,13 @@ static struct gcstat objects, both dead and alive. This number is always kept up-to-date. */ static ptrdiff_t hash_table_allocated_bytes = 0; +#if !SYSTEM_MALLOC /* Points to memory space allocated as "spare", to be freed if we run out of memory. We keep one large block, four cons-blocks, and two string blocks. */ static char *spare_memory[7]; +#endif /* Amount of spare memory to keep in large reserve block, or to see whether this much is available when malloc fails on a larger request. */ @@ -4012,6 +4014,7 @@ memory_full (size_t nbytes) Vmemory_full = Qt; consing_until_gc = min (consing_until_gc, memory_full_cons_threshold); +#if !SYSTEM_MALLOC /* The first time we get here, free the spare memory. */ for (int i = 0; i < countof (spare_memory); i++) if (spare_memory[i]) @@ -4024,6 +4027,7 @@ memory_full (size_t nbytes) lisp_free (spare_memory[i]); spare_memory[i] = 0; } +#endif } /* This used to call error, but if we've run out of memory, we could commit 63475b077d49c62281425d117790eef2fd1fc0bc Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 Simplify SYSTEM_MALLOC vs GNU_MALLOC SYSTEM_MALLOC == !GNU_MALLOC, so simplify by removing the latter and by moving the REL_ALLOC defn into msdos/* (Bug#81992). * configure.ac (system_malloc): Remove. All uses removed. (SYSTEM_MALLOC, REL_ALLOC): Remove; now defined elsewhere. * msdos/sed2v2.inp, msdos/sedalloc.inp: Adjust to configure.ac changes. * src/lisp.h (SYSTEM_MALLOC): Default to 1. * src/msdos.c: Assume GNU_MALLOC. diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index 77b4887969f..c52af45597f 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -124,7 +124,6 @@ EMACS_INT EMACS_UINT GC_MARK_SECONDARY_STACK GC_SETJMP_WORKS -GNU_MALLOC HAVE_ALLOCA HAVE_ALLOCA_H HAVE_ALSA diff --git a/configure.ac b/configure.ac index c137157fde4..98896f7795b 100644 --- a/configure.ac +++ b/configure.ac @@ -3228,16 +3228,6 @@ m4_divert_push([KILL]) m4_ifdef([gl_STDALIGN_H], [], [m4_include([m4/stdalign.m4])]) m4_divert_pop([KILL]) -system_malloc=yes - -if test "${system_malloc}" = "yes"; then - AC_DEFINE([SYSTEM_MALLOC], [1], - [Define to 1 to use the system memory allocator, even if it is not - Doug Lea style.]) -fi - -REL_ALLOC=no - use_mmap_for_buffers=no case "$opsys" in mingw32) use_mmap_for_buffers=yes ;; @@ -7162,12 +7152,6 @@ if test "$emacs_cv_statement_expressions" = yes; then [Define to 1 if statement expressions work.]) fi -if test "${REL_ALLOC}" = "yes" ; then - AC_DEFINE([REL_ALLOC], [1], - [Define REL_ALLOC if you want to use the relocating allocator for - buffer space.]) -fi - if test "$opsys" = "cygwin"; then CYGWIN_OBJ="cygw32.o" else diff --git a/msdos/sed2v2.inp b/msdos/sed2v2.inp index 91a2eae1688..68f83003e73 100644 --- a/msdos/sed2v2.inp +++ b/msdos/sed2v2.inp @@ -97,8 +97,12 @@ /^#undef my_strftime/s/^.*$/#define my_strftime nstrftime/ /^#undef restrict/s/^.*$/#define restrict __restrict/ -/^#undef GNU_MALLOC *$/s/^.*$/#define GNU_MALLOC 1/ -/^#undef REL_ALLOC *$/s/^.*$/#define REL_ALLOC 1/ +/^#include /i\ +/* Define to 0 to not use the system malloc, and to use gmalloc.c instead. */ +#define SYSTEM_MALLOC 0\ +\ +/* Define to 1 to use the relocating allocator for buffer space. */\ +#define REL_ALLOC 1 s/^#undef STACK_DIRECTION *$/#define STACK_DIRECTION -1/ s/^#undef EMACS_CONFIGURATION *$/#define EMACS_CONFIGURATION "i386-pc-msdosdjgpp"/ diff --git a/msdos/sedalloc.inp b/msdos/sedalloc.inp index 616087c15b7..6f2903c76b3 100644 --- a/msdos/sedalloc.inp +++ b/msdos/sedalloc.inp @@ -15,10 +15,5 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # ---------------------------------------------------------------------- -/^#define GNU_MALLOC *1 *$/s|^.*$|/* #undef GNU_MALLOC */| -/^#define REL_ALLOC.*$/a\ -\ -/* Inserted by the --with-system-malloc switch to config.bat. */\ -#define SYSTEM_MALLOC 1 +/^#define SYSTEM_MALLOC *0 *$/s/0/1/ /^#define REL_ALLOC *1 *$/s|^.*$|/* #undef REL_ALLOC */| - diff --git a/src/lisp.h b/src/lisp.h index 4b3573b3bc4..c6ebbc272ed 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4433,6 +4433,9 @@ extern void parse_str_as_multibyte (const unsigned char *, ptrdiff_t, ptrdiff_t *, ptrdiff_t *); /* Defined in alloc.c. */ +#ifndef SYSTEM_MALLOC +# define SYSTEM_MALLOC 1 /* Typically 1, but might be 0 if MSDOS. */ +#endif extern intptr_t garbage_collection_inhibited; extern void malloc_warning (const char *); extern AVOID memory_full (size_t); diff --git a/src/msdos.c b/src/msdos.c index e56b9923055..0b2fa2e40ea 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -108,8 +108,6 @@ extern int spawnve (int, const char *, char *const [], char *const []); #if !SYSTEM_MALLOC -#ifdef GNU_MALLOC - /* If other `malloc' than ours is used, force our `sbrk' behave like Unix programs expect (resize memory blocks to keep them contiguous). If `sbrk' from `ralloc.c' is NOT used, also zero-out sbrk'ed memory, @@ -121,7 +119,6 @@ int _crt0_startup_flags = _CRT0_FLAG_UNIX_SBRK; #else /* not REL_ALLOC */ int _crt0_startup_flags = (_CRT0_FLAG_UNIX_SBRK | _CRT0_FLAG_FILL_SBRK_MEMORY); #endif /* not REL_ALLOC */ -#endif /* GNU_MALLOC */ #endif /* not SYSTEM_MALLOC */ commit 66f400b99c63086c4f382833169f059b9b172133 Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 ; Move malloc_enable_thread into #if diff --git a/src/lisp.h b/src/lisp.h index 9e70ba9d4e8..4b3573b3bc4 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4676,8 +4676,8 @@ void *hash_table_alloc_bytes (ptrdiff_t nbytes) extern size_t __malloc_extra_blocks; extern void *aligned_alloc (size_t, size_t) ATTRIBUTE_MALLOC_SIZE ((2)) ATTRIBUTE_DEALLOC_FREE; -#endif extern void malloc_enable_thread (void); +#endif #ifdef REL_ALLOC /* Defined in ralloc.c. */ commit 8ed45b878c146c5f267caa8bb3f53781598aaa0c Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 ; Comment that gmalloc.c etc used only on MS-DOS diff --git a/src/gmalloc.c b/src/gmalloc.c index 724a3355843..17901ebbdcc 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -1,4 +1,4 @@ -/* Declarations for `malloc' and friends. +/* Declarations for malloc and friends, used only on MS-DOS. Copyright (C) 1990-1993, 1995-1996, 1999, 2002-2007, 2013-2026 Free Software Foundation, Inc. Written May 1989 by Mike Haertel. diff --git a/src/ralloc.c b/src/ralloc.c index 08aee36c2dd..7203f37ffc1 100644 --- a/src/ralloc.c +++ b/src/ralloc.c @@ -1,4 +1,4 @@ -/* Block-relocating memory allocator. +/* Block-relocating memory allocator, used only on MS-DOS. Copyright (C) 1993, 1995, 2000-2026 Free Software Foundation, Inc. This file is part of GNU Emacs. diff --git a/src/vm-limit.c b/src/vm-limit.c index 3ba99ecee67..63a93fd5e05 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c @@ -1,4 +1,4 @@ -/* Functions for memory limit warnings. +/* Functions for memory limit warnings, used only on MS-DOS. Copyright (C) 1990, 1992, 2001-2026 Free Software Foundation, Inc. This file is part of GNU Emacs. commit 6e221b44c30c77278f9bcb24a6827ade4563c213 Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 Omit unneeded SYSTEM_MALLOC pthread tests * configure.ac (emacs_cv_pthread_lib): Remove test for SYSTEM_MALLOC that is no longer needed now that SYSTEM_MALLOC is always true for configure.ac (Bug#81992). * src/emacs.c (main): Remove test for !SYSTEM_MALLOC && HAVE_PTHREAD that is no longer needed now that SYSTEM_MALLOC is always true for pthread platforms. diff --git a/configure.ac b/configure.ac index 7b2004a2fb7..c137157fde4 100644 --- a/configure.ac +++ b/configure.ac @@ -3277,11 +3277,6 @@ if test "$ac_cv_header_pthread_h" && test "$opsys" != "mingw32"; then status += pthread_create (&th, 0, 0, 0); status += pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask); status += pthread_kill (th, 0); - #if !SYSTEM_MALLOC - /* Test for pthread_atfork only if gmalloc uses it, - as older-style hosts like MirBSD 10 lack it. */ - status += pthread_atfork (noop, noop, noop); - #endif return status;]])], [emacs_cv_pthread_lib=$emacs_pthread_lib]) LIBS=$OLD_LIBS diff --git a/src/emacs.c b/src/emacs.c index 4ad8dd69ad2..cd8dbc70f20 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1936,14 +1936,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem daemon_name = xstrdup (dname_arg); } -#if defined HAVE_PTHREAD && !SYSTEM_MALLOC - /* Do not make gmalloc thread-safe when creating bootstrap-emacs, as - that causes an infinite recursive loop with FreeBSD. See - Bug#14569. */ - if (!noninteractive || !will_dump_p ()) - malloc_enable_thread (); -#endif - init_signals (); noninteractive1 = noninteractive; commit 74879d9f769101f14a5b664ae1615feefea30d35 Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 defined SYSTEM_MALLOC → SYSTEM_MALLOC In all uses of SYSTEM_MALLOC, test whether it is nonzero, not whether it is defined. This makes no difference now, as it is defined only to 1 and the C preprocessor works the same either way. But the change can help future patches which will define SYSTEM_MALLOC to 0 in some cases (Bug#81992). diff --git a/configure.ac b/configure.ac index f1f8eec61af..7b2004a2fb7 100644 --- a/configure.ac +++ b/configure.ac @@ -3277,7 +3277,7 @@ if test "$ac_cv_header_pthread_h" && test "$opsys" != "mingw32"; then status += pthread_create (&th, 0, 0, 0); status += pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask); status += pthread_kill (th, 0); - #ifndef SYSTEM_MALLOC + #if !SYSTEM_MALLOC /* Test for pthread_atfork only if gmalloc uses it, as older-style hosts like MirBSD 10 lack it. */ status += pthread_atfork (noop, noop, noop); diff --git a/src/alloc.c b/src/alloc.c index b6b70fc906b..e9e7eabaff0 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -332,7 +332,7 @@ static void mark_terminals (void); static void gc_sweep (void); static void mark_buffer (struct buffer *); -#if !defined REL_ALLOC || defined SYSTEM_MALLOC +#if !defined REL_ALLOC || SYSTEM_MALLOC static void refill_memory_reserve (void); #endif static void compact_small_strings (void); @@ -483,7 +483,7 @@ struct Lisp_Finalizer doomed_finalizers; Malloc ************************************************************************/ -#if defined SIGDANGER || (!defined SYSTEM_MALLOC) +#if defined SIGDANGER || !SYSTEM_MALLOC /* Function malloc calls this if it finds we are near exhausting storage. */ @@ -876,7 +876,7 @@ static_assert (POWER_OF_2 (BLOCK_ALIGN)); /* Use aligned_alloc if it or a simple substitute is available. */ -#if defined HAVE_ALIGNED_ALLOC || !defined SYSTEM_MALLOC +#if defined HAVE_ALIGNED_ALLOC || !SYSTEM_MALLOC # define USE_ALIGNED_ALLOC 1 #elif defined HAVE_POSIX_MEMALIGN # define USE_ALIGNED_ALLOC 1 @@ -4051,7 +4051,7 @@ memory_full_up (void) void refill_memory_reserve (void) { -#if !defined SYSTEM_MALLOC +#if !SYSTEM_MALLOC if (spare_memory[0] == 0) spare_memory[0] = malloc (SPARE_MEMORY); if (spare_memory[1] == 0) diff --git a/src/dosfns.c b/src/dosfns.c index 189eaec408b..714e13efbed 100644 --- a/src/dosfns.c +++ b/src/dosfns.c @@ -272,7 +272,7 @@ init_dosfns (void) _go32_dpmi_registers dpmiregs; unsigned long xbuf = _go32_info_block.linear_address_of_transfer_buffer; -#ifndef SYSTEM_MALLOC +#if !SYSTEM_MALLOC extern void get_lim_data (void); get_lim_data (); /* why the hell isn't this called elsewhere? */ @@ -534,7 +534,7 @@ system_process_attributes (Lisp_Object pid) int i; Lisp_Object cmd_str, decoded_cmd, tem; double pmem; -#ifndef SYSTEM_MALLOC +#if !SYSTEM_MALLOC extern unsigned long ret_lim_data (); #endif @@ -569,7 +569,7 @@ system_process_attributes (Lisp_Object pid) INT_TO_INTEGER ((unsigned long) sbrk (0) / 1024)), attrs); attrs = Fcons (Fcons (Qetime, tem), attrs); -#ifndef SYSTEM_MALLOC +#if !SYSTEM_MALLOC /* ret_lim_data is on vm-limit.c, which is not compiled in under SYSTEM_MALLOC. */ pmem = (double)((unsigned long) sbrk (0)) / ret_lim_data () * 100.0; diff --git a/src/emacs.c b/src/emacs.c index 9c3bdef3c44..4ad8dd69ad2 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1622,7 +1622,7 @@ android_emacs_init (int argc, char **argv, char *dump_file) emacs_backtrace (-1); -#if !defined SYSTEM_MALLOC +#if !SYSTEM_MALLOC /* Arrange to get warning messages as memory fills up. */ memory_warnings (0, malloc_warning); @@ -1936,7 +1936,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem daemon_name = xstrdup (dname_arg); } -#if defined HAVE_PTHREAD && !defined SYSTEM_MALLOC +#if defined HAVE_PTHREAD && !SYSTEM_MALLOC /* Do not make gmalloc thread-safe when creating bootstrap-emacs, as that causes an infinite recursive loop with FreeBSD. See Bug#14569. */ diff --git a/src/gmalloc.c b/src/gmalloc.c index e8e2a400227..724a3355843 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -336,7 +336,7 @@ int __malloc_initialized; /* Number of extra blocks to get each time we ask for more core. This reduces the frequency of calling `(*__morecore)'. */ -#ifdef SYSTEM_MALLOC +#if SYSTEM_MALLOC static #endif size_t __malloc_extra_blocks; diff --git a/src/lisp.h b/src/lisp.h index 735a270e3a2..9e70ba9d4e8 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4441,7 +4441,7 @@ extern AVOID buffer_memory_full (ptrdiff_t); extern bool survives_gc_p (Lisp_Object); extern void mark_object (Lisp_Object); extern void mark_objects (Lisp_Object *, ptrdiff_t); -#if defined REL_ALLOC && !defined SYSTEM_MALLOC +#if defined REL_ALLOC && !SYSTEM_MALLOC extern void refill_memory_reserve (void); #endif extern void mark_c_stack (char const *, char const *); @@ -4672,7 +4672,7 @@ void *hash_table_alloc_bytes (ptrdiff_t nbytes) ATTRIBUTE_DEALLOC (hash_table_free_bytes, 1) ATTRIBUTE_RETURNS_NONNULL; /* Defined in gmalloc.c. */ -#ifndef SYSTEM_MALLOC +#if !SYSTEM_MALLOC extern size_t __malloc_extra_blocks; extern void *aligned_alloc (size_t, size_t) ATTRIBUTE_MALLOC_SIZE ((2)) ATTRIBUTE_DEALLOC_FREE; diff --git a/src/msdos.c b/src/msdos.c index ddfb0451395..e56b9923055 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -106,7 +106,7 @@ extern int spawnve (int, const char *, char *const [], char *const []); #include "careadlinkat.h" #include "allocator.h" -#ifndef SYSTEM_MALLOC +#if !SYSTEM_MALLOC #ifdef GNU_MALLOC diff --git a/src/ralloc.c b/src/ralloc.c index db0d5befd98..08aee36c2dd 100644 --- a/src/ralloc.c +++ b/src/ralloc.c @@ -1138,7 +1138,7 @@ r_alloc_init (void) r_alloc_initialized = 1; page_size = PAGE; -#if !defined SYSTEM_MALLOC +#if !SYSTEM_MALLOC real_morecore = __morecore; __morecore = r_alloc_sbrk; @@ -1152,7 +1152,7 @@ r_alloc_init (void) extra_bytes = PAGE_ROUNDUP (50000); #endif -#if !defined SYSTEM_MALLOC +#if !SYSTEM_MALLOC /* Give GNU malloc's morecore some hysteresis so that we move all the relocatable blocks much less often. The number used to be 64, but alloc.c would override that with 32 in code that was @@ -1160,7 +1160,7 @@ r_alloc_init (void) __malloc_extra_blocks = 32; #endif -#if !defined SYSTEM_MALLOC +#if !SYSTEM_MALLOC first_heap->end = (void *) PAGE_ROUNDUP (first_heap->start); /* The extra call to real_morecore guarantees that the end of the commit 1971a440f28dcf131ccdbb6f1880a37337857240 Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 ; Remove obsolete TODO re gmalloc.c diff --git a/etc/TODO b/etc/TODO index 2ee6b0e8eb1..da8e19c5e84 100644 --- a/etc/TODO +++ b/etc/TODO @@ -1802,13 +1802,6 @@ as long as we stick to the features provided in sendmail.el. (Probably obsolete, as Emacs 24 switched to message.el as the default mail composer.) -** Replace gmalloc.c -Replace it with the modified Doug Lea code from the current GNU libc -so that the special mmapping of buffers can be removed -- that -apparently loses under Solaris, at least. [fx has mostly done this.] - -(Obsolete, since gmalloc.c is nowadays only used on MS-DOS.) - ** Eliminate the etc/DOC file altogether We could try and eliminate the DOC file altogether. See https://lists.gnu.org/r/emacs-devel/2021-05/msg00237.html commit c5177dfbc1fcda69f3c7e98c0e490e7b7b6e28cd Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 Omit configure-time check for sbrk * configure.ac (sbrk): Remove test, as there is no need for it on non-MS-DOS platforms (Bug#81992). * src/gmalloc.c (gdefault_morecore): Assume sbrk, since DJGPP has it and this file is used only with DJGPP. diff --git a/configure.ac b/configure.ac index 8d471abcbdd..f1f8eec61af 100644 --- a/configure.ac +++ b/configure.ac @@ -3230,9 +3230,6 @@ m4_divert_pop([KILL]) system_malloc=yes -dnl This must be before the test of $ac_cv_func_sbrk below. -AC_CHECK_FUNCS_ONCE([sbrk]) - if test "${system_malloc}" = "yes"; then AC_DEFINE([SYSTEM_MALLOC], [1], [Define to 1 to use the system memory allocator, even if it is not diff --git a/src/gmalloc.c b/src/gmalloc.c index 37d6075de5d..e8e2a400227 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -1474,11 +1474,9 @@ extern void *__sbrk (ptrdiff_t increment); static void * gdefault_morecore (ptrdiff_t increment) { -#ifdef HAVE_SBRK void *result = (void *) __sbrk (increment); if (result != (void *) -1) return result; -#endif return NULL; } commit bec5a635b5e6410ccde49bd8febc3a75fdbb9adb Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 Omit configure-time check for aligned_alloc decl * configure.ac (aligned_alloc): Remove check for decl, as there is no need for the check on non-MS-DOS platforms (Bug#81992). * src/lisp.h (aligned_alloc): Declare only if using gmalloc.c. diff --git a/configure.ac b/configure.ac index 6c22ee7a98a..8d471abcbdd 100644 --- a/configure.ac +++ b/configure.ac @@ -5907,7 +5907,6 @@ fi dnl No need to check for posix_memalign if aligned_alloc works. AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break]) -AC_CHECK_DECLS([aligned_alloc], [], [], [[#include ]]) # Dump loading. Android lacks posix_madvise. AC_CHECK_FUNCS([posix_madvise madvise]) diff --git a/src/lisp.h b/src/lisp.h index fcfedb216ec..735a270e3a2 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4674,8 +4674,6 @@ void *hash_table_alloc_bytes (ptrdiff_t nbytes) /* Defined in gmalloc.c. */ #ifndef SYSTEM_MALLOC extern size_t __malloc_extra_blocks; -#endif -#if !HAVE_DECL_ALIGNED_ALLOC extern void *aligned_alloc (size_t, size_t) ATTRIBUTE_MALLOC_SIZE ((2)) ATTRIBUTE_DEALLOC_FREE; #endif commit 8a133a28f3873c8ce869d274b922c6eeb8a517c2 Author: Paul Eggert Date: Fri Oct 23 22:20:49 2026 -0700 Remove GMALLOC_OBJ, RALLOC_OBJ, VMLIMIT_OBJ macros * config.bat, msdos/sed1v2.inp, configure.ac: Put gmalloc.o, vm-limit.o, ralloc.o into MSDOS_OBJ instead of into individual variables GMALLOC_OBJ, VMLIMIT_OBJ, RALLOC_OBJ, as they are now compiled only on MS-DOS and there is no need to separate them out (Bug#81992). diff --git a/config.bat b/config.bat index c52410929ef..7ff159fdf60 100644 --- a/config.bat +++ b/config.bat @@ -203,9 +203,9 @@ rm -f makefile.tmp :src5 if "%sys_malloc%" == "" goto src5a -sed -e "/^GMALLOC_OBJ *=/s/gmalloc.o//" makefile.tmp -sed -e "/^VMLIMIT_OBJ *=/s/vm-limit.o//" makefile.tmp2 -sed -e "/^RALLOC_OBJ *=/s/ralloc.o//" Makefile +sed -e "/^MSDOS_OBJ *=/s/gmalloc.o//" makefile.tmp +sed -e "/^MSDOS_OBJ *=/s/vm-limit.o//" makefile.tmp2 +sed -e "/^MSDOS_OBJ *=/s/ralloc.o//" Makefile rm -f makefile.tmp makefile.tmp2 :src5a diff --git a/configure.ac b/configure.ac index 4e7ae400e37..6c22ee7a98a 100644 --- a/configure.ac +++ b/configure.ac @@ -3233,18 +3233,11 @@ system_malloc=yes dnl This must be before the test of $ac_cv_func_sbrk below. AC_CHECK_FUNCS_ONCE([sbrk]) -GMALLOC_OBJ= if test "${system_malloc}" = "yes"; then AC_DEFINE([SYSTEM_MALLOC], [1], [Define to 1 to use the system memory allocator, even if it is not Doug Lea style.]) - VMLIMIT_OBJ= -else - GMALLOC_OBJ=gmalloc.o - VMLIMIT_OBJ=vm-limit.o fi -AC_SUBST([GMALLOC_OBJ]) -AC_SUBST([VMLIMIT_OBJ]) REL_ALLOC=no @@ -7178,15 +7171,11 @@ if test "$emacs_cv_statement_expressions" = yes; then [Define to 1 if statement expressions work.]) fi -RALLOC_OBJ= if test "${REL_ALLOC}" = "yes" ; then AC_DEFINE([REL_ALLOC], [1], [Define REL_ALLOC if you want to use the relocating allocator for buffer space.]) - - test "$system_malloc" != "yes" && RALLOC_OBJ=ralloc.o fi -AC_SUBST([RALLOC_OBJ]) if test "$opsys" = "cygwin"; then CYGWIN_OBJ="cygw32.o" diff --git a/msdos/sed1v2.inp b/msdos/sed1v2.inp index e9a87733bc7..5631dd80fce 100644 --- a/msdos/sed1v2.inp +++ b/msdos/sed1v2.inp @@ -133,7 +133,7 @@ s/ *@WEBP_LIBS@// /^HAIKU_CFLAGS *=/s/@HAIKU_CFLAGS@// /^CYGWIN_OBJ *=/s/@CYGWIN_OBJ@// /^WINDOW_SYSTEM_OBJ *=/s/@WINDOW_SYSTEM_OBJ@// -/^MSDOS_OBJ *=/s/= */= dosfns.o msdos.o w16select.o/ +/^MSDOS_OBJ *=/s/= */= vm-limit.o gmalloc.o ralloc.o dosfns.o msdos.o w16select.o/ /^NS_OBJ *=/s/@NS_OBJ@// /^NS_OBJC_OBJ *=/s/@NS_OBJC_OBJ@// /^GNU_OBJC_CFLAGS*=/s/=.*$/=/ @@ -163,9 +163,6 @@ s/ *@WEBP_LIBS@// /^XRANDR_CFLAGS *=/s/@XRANDR_CFLAGS@// /^XINERAMA_LIBS *=/s/@XINERAMA_LIBS@// /^XINERAMA_CFLAGS *=/s/@XINERAMA_CFLAGS@// -/^GMALLOC_OBJ *=/s/@GMALLOC_OBJ@/gmalloc.o/ -/^VMLIMIT_OBJ *=/s/@VMLIMIT_OBJ@/vm-limit.o/ -/^RALLOC_OBJ *=/s/@RALLOC_OBJ@/ralloc.o/ /^BUILD_DETAILS *=/s/@BUILD_DETAILS@// /^CANNOT_DUMP *=/s/@CANNOT_DUMP@/no/ /^W32_OBJ *=/s/@W32_OBJ@// diff --git a/src/Makefile.in b/src/Makefile.in index 9ed81df0a6e..e473da24f86 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -304,6 +304,7 @@ CYGWIN_OBJ=@CYGWIN_OBJ@ WINDOW_SYSTEM_OBJ=@WINDOW_SYSTEM_OBJ@ ## dosfns.o msdos.o w16select.o if MSDOS. +## vm-limit.o gmalloc.o ralloc.o can also be prepended if MSDOS. MSDOS_OBJ = ## w16select.o termcap.o if MSDOS && HAVE_X_WINDOWS. MSDOS_X_OBJ = @@ -486,20 +487,11 @@ SOME_MACHINE_OBJECTS = dosfns.o msdos.o \ haikuterm.o haikufns.o haikumenu.o haikufont.o androidterm.o androidfns.o \ androidfont.o androidselect.c androidvfs.c sfntfont-android.c sfntfont.c -## gmalloc.o if !SYSTEM_MALLOC, else empty. -GMALLOC_OBJ=@GMALLOC_OBJ@ - -## vm-limit.o if !SYSTEM_MALLOC, else empty. -VMLIMIT_OBJ=@VMLIMIT_OBJ@ - -## ralloc.o if !SYSTEM_MALLOC && REL_ALLOC, else empty. -RALLOC_OBJ=@RALLOC_OBJ@ - ## List of object files that make-docfile should not be told about. -otherobj= $(TERMCAP_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) $(WIDGET_OBJ) $(LIBOBJS) +otherobj= $(TERMCAP_OBJ) $(WIDGET_OBJ) $(LIBOBJS) -## All object files linked into temacs. $(VMLIMIT_OBJ) should be first. -ALLOBJS = $(VMLIMIT_OBJ) $(obj) $(otherobj) +## All object files linked into temacs. +ALLOBJS = $(obj) $(otherobj) # Must be first, before dep inclusion! ifneq ($(HAVE_BE_APP),yes) commit 28f85db3f4ceb71a9a0333ad0358a6e77936e36f Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 Simplify data_start for the MS-DOS case vm-limit.c is used only on MS-DOS, so remove configury for other platforms that never use vm-limit.c (Bug#81992). * configure.ac (HAVE_DATA_START): Remove. * src/conf_post.h (DATA_START) [MSDOS]: Remove. * src/vm-limit.c (data_start): Simplify for the MS-DOS case. diff --git a/configure.ac b/configure.ac index 8c8c7007e0c..4e7ae400e37 100644 --- a/configure.ac +++ b/configure.ac @@ -3242,19 +3242,6 @@ if test "${system_malloc}" = "yes"; then else GMALLOC_OBJ=gmalloc.o VMLIMIT_OBJ=vm-limit.o - - AC_CACHE_CHECK([for data_start], [emacs_cv_data_start], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[extern char data_start[]; char ch;]], - [[return data_start < &ch;]])], - [emacs_cv_data_start=yes], - [emacs_cv_data_start=no])]) - if test $emacs_cv_data_start = yes; then - AC_DEFINE([HAVE_DATA_START], [1], - [Define to 1 if data_start is the address of the start - of the main data segment.]) - fi fi AC_SUBST([GMALLOC_OBJ]) AC_SUBST([VMLIMIT_OBJ]) diff --git a/src/conf_post.h b/src/conf_post.h index 06a441a3ce7..75f7e41830a 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -152,9 +152,6 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */ /* End of stuff related to MS-DOS and Gnulib. */ # define emacs_raise(sig) msdos_fatal_signal (sig) - -/* DATA_START is needed by vm-limit.c. */ -# define DATA_START (&etext + 1) #endif /* MSDOS */ #if defined HAVE_NTGUI && !defined DebPrint diff --git a/src/vm-limit.c b/src/vm-limit.c index 33c873dd446..3ba99ecee67 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c @@ -35,17 +35,7 @@ extern int etext; /* Start of data. It is OK if this is approximate; it's used only as a heuristic. */ -#ifdef DATA_START -# define data_start ((char *) DATA_START) -#else -extern char data_start[]; -# ifndef HAVE_DATA_START -/* Initialize to nonzero, so that it's put into data and not bss. - Link this file's object code first, so that this symbol is near the - start of data. */ -char data_start[1] = { 1 }; -# endif -#endif +#define data_start ((char *) (&etext + 1)) #ifdef HAVE_MALLOC_H # include commit 77b118d40d167e373ca3cdea71ec3759ec8616f0 Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 GNU_MALLOC used only on MS-DOS * configure.ac (GNU_MALLOC): Remove. All uses removed. Not needed here, since it is used only on MS-DOS (Bug#81992). diff --git a/configure.ac b/configure.ac index aff03c9e6b1..8c8c7007e0c 100644 --- a/configure.ac +++ b/configure.ac @@ -3189,10 +3189,6 @@ to configure.]) fi fi -# Do not use GNU malloc, as it is used only in the MS-DOS port, -# which is configured via config.bat, not via this file. -GNU_MALLOC=no - AC_CHECK_ALIGNOF([EMACS_INT], [[#include #include @@ -7195,11 +7191,6 @@ if test "$emacs_cv_statement_expressions" = yes; then [Define to 1 if statement expressions work.]) fi -if test "${GNU_MALLOC}" = "yes" ; then - AC_DEFINE([GNU_MALLOC], [1], - [Define to 1 if you want to use the GNU memory allocator.]) -fi - RALLOC_OBJ= if test "${REL_ALLOC}" = "yes" ; then AC_DEFINE([REL_ALLOC], [1], commit d105de31370fdbdda92be1b2acbf5652cb3d163c Author: Paul Eggert Date: Tue Oct 13 09:20:34 2026 -0700 gmalloc used only on MS-DOS Simplify configure.ac a bit, given that gmalloc is used only on MS-DOS, and the system malloc is used everywhere (Bug#81992). * configure.ac (GNU_MALLOC, REL_ALLOC): Now always no. Do not bother outputting them at the end, as they’re always no. (GNU_MALLOC_reason): Remove; no longer needed. (gl_ALIGNASOF): Do not call or redefine; no longer needed. (system_malloc): Now always yes. diff --git a/configure.ac b/configure.ac index f3cfe108b11..aff03c9e6b1 100644 --- a/configure.ac +++ b/configure.ac @@ -3189,9 +3189,9 @@ to configure.]) fi fi -# Does the opsystem file prohibit the use of the GNU malloc? -# Assume not, until told otherwise. -GNU_MALLOC=yes +# Do not use GNU malloc, as it is used only in the MS-DOS port, +# which is configured via config.bat, not via this file. +GNU_MALLOC=no AC_CHECK_ALIGNOF([EMACS_INT], [[#include @@ -3232,43 +3232,8 @@ m4_divert_push([KILL]) m4_ifdef([gl_STDALIGN_H], [], [m4_include([m4/stdalign.m4])]) m4_divert_pop([KILL]) -dnl Check for alignas now rather than waiting for gl_INIT to do it, -dnl as the system_malloc=no test below needs $gl_cv_header_working_stdalign_h. -dnl Do not simply call gl_INIT here, as the ac_cv_func_pthread_sigmask=yes -dnl assignment below affects how gl_INIT works. -dnl Instead, call gl_ALIGNASOF, the only part of gl_INIT needed here. -dnl Then make gl_ALIGNASOF a no-op so gl_INIT does not duplicate its code. -gl_ALIGNASOF -AC_DEFUN([gl_ALIGNASOF]) - system_malloc=yes -# If it appears as if the system malloc can't be trusted to return -# adequately positioned memory, enable the GNU malloc, which more -# consistently provides allocations at low addresses, as is required for -# the pdumper to load dump files at a representable location. -AS_CASE([$emacs_cv_struct_alignment%$gl_cv_header_working_stdalign_h%$with_wide_int%$ac_cv_alignof_EMACS_INT%$with_pdumper], - [*%*%*%*%*%*], - [AC_MSG_ERROR([configuration values cannot contain '%'])], - - dnl There is no problem in most situations, i.e.: - [dnl if emacs_cv_struct_alignment - yes%* \ - dnl or if gl_cv_header_working_stdalign_h - | *%yes*%*%*%* \ - dnl or if with_wide_int (as in practice tag bits are high-order) - | *%*%yes%*%* \ - dnl or if EMACS_INT's alignment is at least 8. - | *%*%*%8%* | *%*%*%[1-9]?*%*], - [], - - dnl Otherwise, if using the portable dumper, enable GNU malloc. - [*%yes], - [system_malloc=no - AC_MSG_WARN([The GNU memory manager will be enabled as your system - does not guarantee that the portable dumper can allocate memory - at a suitably low address.])]) - dnl This must be before the test of $ac_cv_func_sbrk below. AC_CHECK_FUNCS_ONCE([sbrk]) @@ -3277,9 +3242,6 @@ if test "${system_malloc}" = "yes"; then AC_DEFINE([SYSTEM_MALLOC], [1], [Define to 1 to use the system memory allocator, even if it is not Doug Lea style.]) - GNU_MALLOC=no - GNU_MALLOC_reason=" - (The GNU allocators don't work with this system configuration.)" VMLIMIT_OBJ= else GMALLOC_OBJ=gmalloc.o @@ -3301,9 +3263,7 @@ fi AC_SUBST([GMALLOC_OBJ]) AC_SUBST([VMLIMIT_OBJ]) -if test x"${REL_ALLOC}" = x; then - REL_ALLOC=${GNU_MALLOC} -fi +REL_ALLOC=no use_mmap_for_buffers=no case "$opsys" in @@ -3314,7 +3274,6 @@ AC_FUNC_MMAP if test $use_mmap_for_buffers = yes; then AC_DEFINE([USE_MMAP_FOR_BUFFERS], [1], [Define to use mmap to allocate buffer text.]) - REL_ALLOC=no fi LIBS="$LIBS_SYSTEM $LIBS" @@ -7514,8 +7473,6 @@ Configured for '${canonical}'. Where should the build process find the source code? ${srcdir} What compiler should emacs be built with? ${CC} ${CFLAGS} - Should Emacs use the GNU version of malloc? ${GNU_MALLOC}${GNU_MALLOC_reason} - Should Emacs use a relocating allocator for buffers? ${REL_ALLOC} Should Emacs use mmap(2) for buffer allocation? $use_mmap_for_buffers What window system should Emacs use? ${window_system} What toolkit should Emacs use? ${USE_X_TOOLKIT} commit e1bb0d54e0df53e2e4cde398e1c30b97e99d157f Author: Paul Eggert Date: Tue Oct 13 09:20:33 2026 -0700 Remove GC_MALLOC_CHECK etc They aren’t needed for gmalloc operation. Suggested by Eli Zaretskii (Bug#81992#11). * admin/make-emacs: Remove --malloc-check and --no-mcheck options. Do not define GC_MALLOC_CHECK, GC_PROTECT_MALLOC_STATE, or GC_MCHECK. All uses removed outside of MS-DOS-only files. diff --git a/admin/make-emacs b/admin/make-emacs index bf45ba2f479..2509234ba2e 100755 --- a/admin/make-emacs +++ b/admin/make-emacs @@ -46,8 +46,6 @@ "no-optim" => \$no_optim, "check-lisp-type" => \$check_lisp_type, "gprof" => \$profile, - "malloc-check" => \$malloc_check, - "no-mcheck" => \$no_mcheck, "alias" => \$aliasing, "boot" => \$boot, "wall" => \$wall, @@ -73,16 +71,13 @@ --optim no debug defines --gprof make Emacs for profiling --check-lisp-type define CHECK_LISP_OBJECT_TYPE - --malloc-check define GC_MALLOC_CHECK - --no-mcheck don't define GC_MCHECK --wall compile with -Wall --gcc3 use GCC 3.0 (30% slower compilation, slower code) --trace-selection print traces in xselect.c --trace-move print traces for move_it* functions --stabs use -gstabs instead -g -Default is to compile with warnings, with -DGC_MCHECK=1, and -with -DGLYPH_DEBUG=1. +Default is to compile with warnings and with -DGLYPH_DEBUG=1. USAGE exit 1; @@ -143,9 +138,6 @@ } $defs = "$defs -DCHECK_LISP_OBJECT_TYPE" if $check_lisp_type; -$defs = "$defs -DGC_MALLOC_CHECK=1 -DGC_PROTECT_MALLOC_STATE=1" if $malloc_check; -$defs = "$defs -DGC_MCHECK=1" unless $no_mcheck; - $defs = "$defs -DTRACE_SELECTION" if $trace_selection; $defs = "$defs -DDEBUG_TRACE_MOVE" if $trace_move; diff --git a/src/alloc.c b/src/alloc.c index c38543c9812..b6b70fc906b 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -124,14 +124,6 @@ along with GNU Emacs. If not, see . */ # define GC_CHECK_MARKED_OBJECTS 0 #endif -/* GC_MALLOC_CHECK defined means perform validity checks of malloc'd - memory. Can do this only if using gmalloc.c and if not checking - marked objects. */ - -#if defined SYSTEM_MALLOC || GC_CHECK_MARKED_OBJECTS -#undef GC_MALLOC_CHECK -#endif - #include #include @@ -380,12 +372,6 @@ deadp (Lisp_Object x) return BASE_EQ (x, dead_object ()); } -#ifdef GC_MALLOC_CHECK - -enum mem_type allocated_mem_type; - -#endif /* GC_MALLOC_CHECK */ - /* A node in the red-black tree describing allocated memory containing Lisp data. Each such block is recorded with its start and end address when it is allocated, and removed from the tree when it @@ -838,10 +824,6 @@ lisp_malloc (ptrdiff_t nbytes, bool clearit, enum mem_type type) { register void *val; -#ifdef GC_MALLOC_CHECK - allocated_mem_type = type; -#endif - val = clearit ? calloc (1, nbytes) : malloc (nbytes); #if ! USE_LSB_TAG @@ -861,11 +843,8 @@ lisp_malloc (ptrdiff_t nbytes, bool clearit, enum mem_type type) } #endif -#ifndef GC_MALLOC_CHECK if (val && type != MEM_TYPE_NON_LISP) mem_insert (val, (char *) val + nbytes, type); -#endif - if (!val) memory_full (nbytes); MALLOC_PROBE (nbytes); @@ -881,13 +860,9 @@ lisp_free (void *block) if (pdumper_object_p (block)) return; -#ifndef GC_MALLOC_CHECK struct mem_node *m = mem_find (block); -#endif free (block); -#ifndef GC_MALLOC_CHECK mem_delete (m); -#endif } /***** Allocation of aligned blocks of memory to store Lisp data. *****/ @@ -1024,10 +999,6 @@ lisp_align_malloc (ptrdiff_t nbytes, enum mem_type type) eassert (nbytes <= BLOCK_BYTES); -#ifdef GC_MALLOC_CHECK - allocated_mem_type = type; -#endif - if (!free_ablock) { int i; @@ -1091,12 +1062,8 @@ lisp_align_malloc (ptrdiff_t nbytes, enum mem_type type) = (struct ablocks *) (2 + (intptr_t) ABLOCKS_BUSY (abase)); val = free_ablock; free_ablock = free_ablock->x.next_free; - -#ifndef GC_MALLOC_CHECK if (type != MEM_TYPE_NON_LISP) mem_insert (val, (char *) val + nbytes, type); -#endif - MALLOC_PROBE (nbytes); eassert (0 == ((uintptr_t) val) % BLOCK_ALIGN); @@ -1109,9 +1076,7 @@ lisp_align_free (void *block) struct ablock *ablock = block; struct ablocks *abase = ABLOCK_ABASE (ablock); -#ifndef GC_MALLOC_CHECK mem_delete (mem_find (block)); -#endif /* Put on free list. */ ablock->x.next_free = free_ablock; ASAN_POISON_ABLOCK (ablock); @@ -2853,12 +2818,8 @@ static struct vector_block * allocate_vector_block (void) { struct vector_block *block = xmalloc (sizeof *block); - -#ifndef GC_MALLOC_CHECK mem_insert (block->data, block->data + VECTOR_BLOCK_BYTES, MEM_TYPE_VECTOR_BLOCK); -#endif - block->next = vector_blocks; vector_blocks = block; return block; @@ -3242,9 +3203,7 @@ sweep_vectors (void) if (free_this_block) { *bprev = block->next; -#ifndef GC_MALLOC_CHECK mem_delete (mem_find (block->data)); -#endif xfree (block); } else @@ -4195,13 +4154,7 @@ mem_insert (void *start, void *end, enum mem_type type) } /* Create a new node. */ -#ifdef GC_MALLOC_CHECK - x = malloc (sizeof *x); - if (x == NULL) - emacs_abort (); -#else x = xmalloc (sizeof *x); -#endif x->start = start; x->end = end; x->type = type; @@ -4418,12 +4371,7 @@ mem_delete (struct mem_node *z) if (y->color == MEM_BLACK) mem_delete_fixup (x); - -#ifdef GC_MALLOC_CHECK - free (y); -#else xfree (y); -#endif } commit 374a0bca276bb24f4fdcd81b708244284480e526 Author: Paul Eggert Date: Tue Oct 13 09:20:33 2026 -0700 Remove HAVE_SYS_VLIMIT_H * configure.ac (HAVE_SYS_VLIMIT_H): Remove. All uses removed. It was needed when we compiled vm-limit.c on some non MS-DOS systems, but we now compile it only on MS-DOS (Bug#81992). diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index d9915d27e43..77b4887969f 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -304,7 +304,6 @@ HAVE_SYS_TIME_H HAVE_SYS_TYPES_H HAVE_SYS_UN_H HAVE_SYS_UTSNAME_H -HAVE_SYS_VLIMIT_H HAVE_SYS_WAIT_H HAVE_TERM_H HAVE_TIFF diff --git a/configure.ac b/configure.ac index e520cbb2156..f3cfe108b11 100644 --- a/configure.ac +++ b/configure.ac @@ -3285,7 +3285,6 @@ else GMALLOC_OBJ=gmalloc.o VMLIMIT_OBJ=vm-limit.o - AC_CHECK_HEADERS([sys/vlimit.h]) AC_CACHE_CHECK([for data_start], [emacs_cv_data_start], [AC_LINK_IFELSE( [AC_LANG_PROGRAM( diff --git a/src/vm-limit.c b/src/vm-limit.c index dbc6fa762ee..33c873dd446 100644 --- a/src/vm-limit.c +++ b/src/vm-limit.c @@ -31,10 +31,6 @@ extern int etext; #ifdef HAVE_SYS_RESOURCE_H # include # include -#else -# if HAVE_SYS_VLIMIT_H -# include /* Obsolete, says glibc */ -# endif #endif /* Start of data. It is OK if this is approximate; it's used only as commit e40b03df5709ec0881572563416b24a53638428d Author: Paul Eggert Date: Fri Oct 23 20:55:32 2026 -0700 Work around Darwin issue with signals and threads Problem reported by Umar Ahmad (Bug#82089). The following changes occur only if FORWARD_SIGNAL_TO_MAIN_THREAD: * src/sysdep.c (running_in_main_thread): New function, which works around Darwin’s problems with signals arriving early to workqueue threads. (deliver_process_signal, deliver_thread_signal, handle_sigsegv): Use it. diff --git a/src/sysdep.c b/src/sysdep.c index 9b1c123b0bf..66903436314 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -1713,6 +1713,36 @@ emacs_sigaction_init (struct sigaction *action, signal_handler_t handler) #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD static pthread_t main_thread_id; + +static bool +running_in_main_thread (void) +{ + bool pthread_ok = true; + + /* On Darwin, pthread_self is not async-signal-safe, as required by + POSIX.1-2008 TC1/2013 and later, because pthread_self can crash if + a signal arrives during startup of a workqueue thread (workqueue + threads are not POSIX threads). Work around the issue in a + system-dependent way. */ +# ifdef DARWIN_OS + long int volatile *thread; /* A thread's first member is a long sig. */ +# if defined __aarch64__ || defined __arm64__ + __asm__ volatile ("mrs %0, TPIDRRO_EL0" : "=r"(thread)); + pthread_ok = thread && *thread; +# elif defined __x86_64__ + __asm__ volatile ("movq %%gs:0x0, %0" : "=r"(thread)); + pthread_ok = !!thread; +# elif defined __i386__ + __asm__ volatile ("movl %%gs:0x0, %0" : "=r"(thread)); + pthread_ok = !!thread; +# else +# error "Please port to this Darwin platform" +# endif +# endif + + return pthread_ok && pthread_equal (pthread_self (), main_thread_id); +} + #endif /* SIG has arrived at the current process. Deliver it to the main @@ -1736,7 +1766,7 @@ deliver_process_signal (int sig, signal_handler_t handler) bool on_main_thread = true; #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD - if (! pthread_equal (pthread_self (), main_thread_id)) + if (!running_in_main_thread ()) { sigset_t blocked; sigemptyset (&blocked); @@ -1768,7 +1798,7 @@ deliver_thread_signal (int sig, signal_handler_t handler) int old_errno = errno; #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD - if (! pthread_equal (pthread_self (), main_thread_id)) + if (!running_in_main_thread ()) { thread_backtrace_npointers = backtrace (thread_backtrace_buffer, BACKTRACE_LIMIT_MAX); @@ -1922,7 +1952,7 @@ handle_sigsegv (int sig, siginfo_t *siginfo, void *arg) bool fatal = gc_in_progress; #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD - if (!fatal && !pthread_equal (pthread_self (), main_thread_id)) + if (!fatal && !running_in_main_thread ()) fatal = true; #endif commit 877447d534449631488e8ba230a295feb328664b Author: Johan Myréen Date: Fri Oct 23 11:01:05 2026 +0300 Automatically raise Emacs server frame on Wayland * src/pgtkterm.c (pgtk_raise_frame): Raise the frame specified by the Wayland activation token, if any. * lisp/server.el (server--process-filter-1): Use Wayland activation token, if any, to indicate to the server which frame to activate. (Bug#81989) diff --git a/lisp/server.el b/lisp/server.el index b912b185275..efdbfac577c 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -1190,6 +1190,8 @@ The following commands are accepted by the client: (unless (consp server--process-filter-pending) (sit-for time))) +(declare-function pgtk-backend-display-class "pgtk-fns.c") + (cl-defun server--process-filter-1 (proc string) (server-log (concat "Received " string) proc) ;; First things first: let's check the authentication. @@ -1452,6 +1454,23 @@ The following commands are accepted by the client: (setq tty-name nil tty-type nil) (server-select-display display)))) + ;; As a focus stealing prevention security measure, a + ;; Wayland application must present the compositor with an + ;; "activation token" before requesting to "activate" the + ;; frame. The token comes from the invoking program (e.g. a + ;; file manager), and is passed to emacsclient in an + ;; environment variable. Copy the token to the + ;; `activation-token' frame parameter of the server frame + ;; for the pgtk_raise_frame function. (Bug #80926) + (when (and + (fboundp #'pgtk-backend-display-class) + (string= "GdkWaylandDisplay" (pgtk-backend-display-class))) + (let* ((token + (getenv-internal "XDG_ACTIVATION_TOKEN" (process-get proc 'env)))) + (if (not token) + (server-log "No XDG_ACTIVATION_TOKEN token received.\n") + (set-frame-parameter frame 'activation-token token)))) + (process-put proc 'continuation (lambda () diff --git a/src/pgtkterm.c b/src/pgtkterm.c index e318bb78199..89a3b013e7a 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c @@ -410,8 +410,27 @@ pgtk_raise_frame (struct frame *f) It does not work for child frames on X, and it does not work on Wayland too. */ block_input (); + + /* If the frame is a Wayland window, get the activation token from the + 'activation-token' frame parameter, and pass it to GDK. On + Wayland, the "startup id" is the activation token, and the Wayland + specific backend function sends the token to the compositor using + the XDG Activation protocol. */ if (FRAME_VISIBLE_P (f)) - gdk_window_raise (gtk_widget_get_window (FRAME_WIDGET (f))); + { + GdkWindow *window = gtk_widget_get_window (FRAME_WIDGET (f)); + if (GDK_IS_WAYLAND_WINDOW (window)) + { + Lisp_Object tmp = Fframe_parameter (selected_frame, Qactivation_token); + + if (STRINGP (tmp)) + { + gchar *token = SSDATA (tmp); + gdk_window_set_startup_id (window, token); + } + } + gdk_window_raise (window); + } unblock_input (); } @@ -7501,6 +7520,7 @@ syms_of_pgtkterm (void) DEFSYM (Qmove, "move"); DEFSYM (Qlink, "link"); DEFSYM (Qprivate, "private"); + DEFSYM (Qactivation_token, "activation-token"); Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier)); Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier));