fi])
doug_lea_malloc=$emacs_cv_var_doug_lea_malloc
-hybrid_malloc=
system_malloc=yes
dnl This must be before the test of $ac_cv_func_sbrk below.
AC_CHECK_FUNCS_ONCE([sbrk])
GMALLOC_OBJ=
-HYBRID_MALLOC=
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
GNU_MALLOC_reason="
(The GNU allocators don't work with this system configuration.)"
VMLIMIT_OBJ=
-elif test "$hybrid_malloc" = yes; then
- AC_DEFINE([HYBRID_MALLOC], [1],
- [Define to use gmalloc before dumping and the system malloc after.])
- HYBRID_MALLOC=1
- GNU_MALLOC=no
- GNU_MALLOC_reason=" (only before dumping)"
- GMALLOC_OBJ=gmalloc.o
- VMLIMIT_OBJ=
else
test "$doug_lea_malloc" != "yes" && GMALLOC_OBJ=gmalloc.o
VMLIMIT_OBJ=vm-limit.o
of the main data segment.])
fi
fi
-AC_SUBST([HYBRID_MALLOC])
AC_SUBST([GMALLOC_OBJ])
AC_SUBST([VMLIMIT_OBJ])
-if test "$doug_lea_malloc" = "yes" && test "$hybrid_malloc" != yes; then
+if test "$doug_lea_malloc" = "yes"; then
if test "$GNU_MALLOC" = yes ; then
GNU_MALLOC_reason="
(Using Doug Lea's new malloc from the GNU C Library.)"
status += pthread_create (&th, 0, 0, 0);
status += pthread_sigmask (SIG_BLOCK, &new_mask, &old_mask);
status += pthread_kill (th, 0);
- #if ! (defined SYSTEM_MALLOC || defined HYBRID_MALLOC \
- || defined DOUG_LEA_MALLOC)
+ #if ! (defined SYSTEM_MALLOC || defined DOUG_LEA_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);
libgnu_a_OBJECTS = fingerprint.o $(gl_LIBOBJS) \
$(patsubst %.c,%.o,$(filter %.c,$(libgnu_a_SOURCES)))
for_emacs_OBJECTS = $(filter-out $(not_emacs_OBJECTS),$(libgnu_a_OBJECTS))
-libegnu_a_OBJECTS = $(patsubst %.o,e-%.o,$(for_emacs_OBJECTS))
-$(libegnu_a_OBJECTS) $(libgnu_a_OBJECTS): $(BUILT_SOURCES)
+$(libgnu_a_OBJECTS): $(BUILT_SOURCES)
.SUFFIXES: .c
.c.o:
e-%.o: %.c
$(AM_V_CC)$(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) -Demacs -o $@ $<
-all: libgnu.a $(if $(HYBRID_MALLOC),libegnu.a)
+all: libgnu.a
libgnu.a: $(libgnu_a_OBJECTS)
$(AM_V_AR)rm -f $@
$(AM_V_at)$(AR) $(ARFLAGS) $@ $(libgnu_a_OBJECTS)
$(AM_V_at)$(RANLIB) $@
-libegnu.a: $(libegnu_a_OBJECTS)
- $(AM_V_AR)rm -f $@
- $(AM_V_at)$(AR) $(ARFLAGS) $@ $(libegnu_a_OBJECTS)
- $(AM_V_at)$(RANLIB) $@
-
ETAGS = ../lib-src/etags$(EXEEXT)
$(ETAGS):
$(MAKE) -C $(dir $@) $(notdir $@)
/^XRANDR_CFLAGS *=/s/@XRANDR_CFLAGS@//
/^XINERAMA_LIBS *=/s/@XINERAMA_LIBS@//
/^XINERAMA_CFLAGS *=/s/@XINERAMA_CFLAGS@//
-/^HYBRID_MALLOC *=/s/@HYBRID_MALLOC@//
/^GMALLOC_OBJ *=/s/@GMALLOC_OBJ@/gmalloc.o/
/^VMLIMIT_OBJ *=/s/@VMLIMIT_OBJ@/vm-limit.o/
/^FIRSTFILE_OBJ *=/s/@FIRSTFILE_OBJ@//
/^C_SWITCH_X_SITE *=/s/@C_SWITCH_X_SITE@//
/^PROFILING_CFLAGS *=/s/@PROFILING_CFLAGS@//
/^GNULIB_WARN_CFLAGS *=/s/@GNULIB_WARN_CFLAGS@//
-/^HYBRID_MALLOC *=/s/@HYBRID_MALLOC@//
/^WARN_CFLAGS *=/s/@WARN_CFLAGS@//
/^WERROR_CFLAGS *=/s/@WERROR_CFLAGS@//
/^ANDROID_BUILD_CFLAGS *=/s/@ANDROID_BUILD_CFLAGS@//
## widget.o if USE_X_TOOLKIT, otherwise empty.
WIDGET_OBJ=@WIDGET_OBJ@
-HYBRID_MALLOC = @HYBRID_MALLOC@
-
## cygw32.o if CYGWIN, otherwise empty.
CYGWIN_OBJ=@CYGWIN_OBJ@
profiler.o decompress.o \
thread.o systhread.o sqlite.o treesit.o \
itree.o json.o \
- $(if $(HYBRID_MALLOC),sheap.o) \
$(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \
$(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ) \
$(HAIKU_OBJ) $(PGTK_OBJ) $(ANDROID_OBJ)
$(ALLOBJS): globals.h
-LIBEGNU_ARCHIVE = $(lib)/lib$(if $(HYBRID_MALLOC),e)gnu.a
+LIBEGNU_ARCHIVE = $(lib)/libgnu.a
$(LIBEGNU_ARCHIVE): $(config_h)
$(MAKE) -C $(dir $@) all
marked objects. */
#if (defined SYSTEM_MALLOC || defined DOUG_LEA_MALLOC \
- || defined HYBRID_MALLOC || GC_CHECK_MARKED_OBJECTS)
+ || GC_CHECK_MARKED_OBJECTS)
#undef GC_MALLOC_CHECK
#endif
static Lisp_Object make_pure_vector (ptrdiff_t);
static void mark_buffer (struct buffer *);
-#if !defined REL_ALLOC || defined SYSTEM_MALLOC || defined HYBRID_MALLOC
+#if !defined REL_ALLOC || defined SYSTEM_MALLOC
static void refill_memory_reserve (void);
#endif
static void compact_small_strings (void);
Malloc
************************************************************************/
-#if defined SIGDANGER || (!defined SYSTEM_MALLOC && !defined HYBRID_MALLOC)
+#if defined SIGDANGER || (!defined SYSTEM_MALLOC)
/* Function malloc calls this if it finds we are near exhausting storage. */
# define BLOCK_ALIGN (1 << 15)
static_assert (POWER_OF_2 (BLOCK_ALIGN));
-/* Use aligned_alloc if it or a simple substitute is available.
- Aligned allocation is incompatible with unexmacosx.c, so don't use
- it on Darwin if HAVE_UNEXEC. */
-
-#if ! (defined DARWIN_OS && defined HAVE_UNEXEC)
-# if (defined HAVE_ALIGNED_ALLOC \
- || (defined HYBRID_MALLOC \
- ? defined HAVE_POSIX_MEMALIGN \
- : !defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC))
-# define USE_ALIGNED_ALLOC 1
-# elif !defined HYBRID_MALLOC && defined HAVE_POSIX_MEMALIGN
-# define USE_ALIGNED_ALLOC 1
-# define aligned_alloc my_aligned_alloc /* Avoid collision with lisp.h. */
+/* Use aligned_alloc if it or a simple substitute is available. */
+
+#if (defined HAVE_ALIGNED_ALLOC \
+ || (!defined SYSTEM_MALLOC && !defined DOUG_LEA_MALLOC))
+# define USE_ALIGNED_ALLOC 1
+#elif defined HAVE_POSIX_MEMALIGN
+# define USE_ALIGNED_ALLOC 1
+# define aligned_alloc my_aligned_alloc /* Avoid collision with lisp.h. */
static void *
aligned_alloc (size_t alignment, size_t size)
{
void *p;
return posix_memalign (&p, alignment, size) == 0 ? p : 0;
}
-# endif
#endif
/* Padding to leave at the end of a malloc'd block. This is to give
void
refill_memory_reserve (void)
{
-#if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
+#if !defined SYSTEM_MALLOC
if (spare_memory[0] == 0)
spare_memory[0] = malloc (SPARE_MEMORY);
if (spare_memory[1] == 0)
# define ADDRESS_SANITIZER false
#endif
-/* If HYBRID_MALLOC is defined (e.g., on Cygwin), emacs will use
- gmalloc before dumping and the system malloc after dumping.
- hybrid_malloc and friends, defined in gmalloc.c, are wrappers that
- accomplish this. */
-#ifdef HYBRID_MALLOC
-#ifdef emacs
-#undef malloc
-#define malloc hybrid_malloc
-#undef realloc
-#define realloc hybrid_realloc
-#undef aligned_alloc
-#define aligned_alloc hybrid_aligned_alloc
-#undef calloc
-#define calloc hybrid_calloc
-#undef free
-#define free hybrid_free
-
-extern void *hybrid_malloc (size_t);
-extern void *hybrid_calloc (size_t, size_t);
-extern void hybrid_free (void *);
-extern void *hybrid_aligned_alloc (size_t, size_t);
-extern void *hybrid_realloc (void *, size_t);
-#endif /* emacs */
-#endif /* HYBRID_MALLOC */
-
/* We have to go this route, rather than the old hpux9 approach of
renaming the functions via macros. The system's stdlib.h has fully
prototyped declarations, which yields a conflicting definition of
#include "composite.h"
#include "dispextern.h"
#include "regex-emacs.h"
-#include "sheap.h"
#include "syntax.h"
#include "sysselect.h"
#include "systime.h"
emacs_backtrace (-1);
-#if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
+#if !defined SYSTEM_MALLOC
/* Arrange to get warning messages as memory fills up. */
memory_warnings (0, malloc_warning);
Also call realloc and free for consistency. */
free (realloc (malloc (4), 4));
-#endif /* not SYSTEM_MALLOC and not HYBRID_MALLOC */
+#endif /* not SYSTEM_MALLOC */
#ifdef MSDOS
set_binary_mode (STDIN_FILENO, O_BINARY);
}
#if defined HAVE_PTHREAD && !defined SYSTEM_MALLOC \
- && !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC
+ && !defined DOUG_LEA_MALLOC
/* Do not make gmalloc thread-safe when creating bootstrap-emacs, as
that causes an infinite recursive loop with FreeBSD. See
Bug#14569. The part of this bug involving Cygwin is no longer
#include <config.h>
-#if defined HAVE_PTHREAD && !defined HYBRID_MALLOC
+#if defined HAVE_PTHREAD
#define USE_PTHREAD
#endif
extern void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void);
#endif /* !defined HAVE_MALLOC_H || glibc >= 2.24 */
-/* If HYBRID_MALLOC is defined, then temacs will use malloc,
- realloc... as defined in this file (and renamed gmalloc,
- grealloc... via the macros that follow). The dumped emacs,
- however, will use the system malloc, realloc.... In other source
- files, malloc, realloc... are renamed hybrid_malloc,
- hybrid_realloc... via macros in lisp.h. hybrid_malloc and
- friends are wrapper functions defined later in this file. */
#undef malloc
#undef realloc
#undef calloc
#define free gfree
#define malloc_info gmalloc_info
-#ifdef HYBRID_MALLOC
-# include "sheap.h"
-#endif
-
#ifdef __cplusplus
extern "C"
{
#endif
-#ifdef HYBRID_MALLOC
-#define extern static
-#endif
-
/* Allocate SIZE bytes of memory. */
extern void *malloc (size_t size) ATTRIBUTE_MALLOC_SIZE ((1));
/* Re-allocate the previously allocated block
void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);
void *(*__morecore) (ptrdiff_t);
-#ifndef HYBRID_MALLOC
-
/* Pointer to the base of the first block. */
char *_heapbase;
/* Are you experienced? */
int __malloc_initialized;
-#endif /* HYBRID_MALLOC */
-
/* Number of extra blocks to get each time we ask for more core.
This reduces the frequency of calling `(*__morecore)'. */
-#if defined DOUG_LEA_MALLOC || defined HYBRID_MALLOC || defined SYSTEM_MALLOC
+#if defined DOUG_LEA_MALLOC || defined SYSTEM_MALLOC
static
#endif
size_t __malloc_extra_blocks;
return (hook ? hook : _malloc_internal) (size);
}
\f
-#if !(defined (_LIBC) || defined (HYBRID_MALLOC))
+#if !(defined (_LIBC))
/* On some ANSI C systems, some libc functions call _malloc, _free
and _realloc. Make them use the GNU functions. */
/* Debugging hook for free. */
static void (*__MALLOC_HOOK_VOLATILE gfree_hook) (void *);
-#ifndef HYBRID_MALLOC
-
/* List of blocks allocated by aligned_alloc. */
struct alignlist *_aligned_blocks = NULL;
-#endif
/* Return memory to the heap.
Like `_free_internal' but don't lock mutex. */
_free_internal (ptr);
}
-#ifndef HYBRID_MALLOC
/* Define the `cfree' alias for `free'. */
#ifdef weak_alias
weak_alias (free, cfree)
free (ptr);
}
#endif
-#endif
/* Change the size of a block allocated by `malloc'.
Copyright (C) 1990-1993, 1995-1996, 1999, 2002-2007, 2013-2025 Free
Software Foundation, Inc.
static void *
gdefault_morecore (ptrdiff_t increment)
{
-#ifdef HYBRID_MALLOC
- if (!definitely_will_not_unexec_p ())
- {
- return bss_sbrk (increment);
- }
-#endif
#ifdef HAVE_SBRK
void *result = (void *) __sbrk (increment);
if (result != (void *) -1)
}
/* Note that memalign and posix_memalign are not used in Emacs. */
-#ifndef HYBRID_MALLOC
/* An obsolete alias for aligned_alloc, for any old libraries that use
this alias. */
return aligned_alloc (alignment, size);
}
-/* If HYBRID_MALLOC is defined, we may want to use the system
- posix_memalign below. */
int
posix_memalign (void **memptr, size_t alignment, size_t size)
{
return 0;
}
-#endif
/* Allocate memory on a page boundary.
Copyright (C) 1990-1993, 1995-1996, 1999, 2002-2007, 2013-2025 Free
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
-#ifndef HYBRID_MALLOC
-
-# ifndef HAVE_MALLOC_H
+#ifndef HAVE_MALLOC_H
/* Allocate SIZE bytes on a page boundary. */
extern void *valloc (size_t);
-# endif
+#endif
-# if defined _SC_PAGESIZE || !defined HAVE_GETPAGESIZE
-# include "getpagesize.h"
-# elif !defined getpagesize
+#if defined _SC_PAGESIZE || !defined HAVE_GETPAGESIZE
+# include "getpagesize.h"
+#elif !defined getpagesize
extern int getpagesize (void);
-# endif
+#endif
static size_t pagesize;
return aligned_alloc (pagesize, size);
}
-#endif /* HYBRID_MALLOC */
#undef malloc
#undef realloc
#undef aligned_alloc
#undef free
-#ifdef HYBRID_MALLOC
-
-/* Assuming PTR was allocated via the hybrid malloc, return true if
- PTR was allocated via gmalloc, not the system malloc. Also, return
- true if _heaplimit is zero; this can happen temporarily when
- gmalloc calls itself for internal use, and in that case PTR is
- already known to be allocated via gmalloc. */
-
-static bool
-allocated_via_gmalloc (void *ptr)
-{
- if (!__malloc_initialized)
- return false;
- size_t block = BLOCK (ptr);
- size_t blockmax = _heaplimit - 1;
- return block <= blockmax && _heapinfo[block].busy.type != 0;
-}
-
-/* See the comments near the beginning of this file for explanations
- of the following functions. */
-
-void *
-hybrid_malloc (size_t size)
-{
- if (definitely_will_not_unexec_p ())
- return malloc (size);
- return gmalloc (size);
-}
-
-void *
-hybrid_calloc (size_t nmemb, size_t size)
-{
- if (definitely_will_not_unexec_p ())
- return calloc (nmemb, size);
- return gcalloc (nmemb, size);
-}
-
-static void
-hybrid_free_1 (void *ptr)
-{
- if (allocated_via_gmalloc (ptr))
- gfree (ptr);
- else
- free (ptr);
-}
-
-void
-hybrid_free (void *ptr)
-{
- /* Stolen from Gnulib, to make sure we preserve errno. */
-#if defined __GNUC__ && !defined __clang__
- int err[2];
- err[0] = errno;
- err[1] = errno;
- errno = 0;
- hybrid_free_1 (ptr);
- errno = err[errno == 0];
-#else
- int err = errno;
- hybrid_free_1 (ptr);
- errno = err;
-#endif
-}
-
-#if defined HAVE_ALIGNED_ALLOC || defined HAVE_POSIX_MEMALIGN
-void *
-hybrid_aligned_alloc (size_t alignment, size_t size)
-{
- if (!definitely_will_not_unexec_p ())
- return galigned_alloc (alignment, size);
- /* The following is copied from alloc.c */
-#ifdef HAVE_ALIGNED_ALLOC
- return aligned_alloc (alignment, size);
-#else /* HAVE_POSIX_MEMALIGN */
- void *p;
- return posix_memalign (&p, alignment, size) == 0 ? p : 0;
-#endif
-}
-#endif
-
-void *
-hybrid_realloc (void *ptr, size_t size)
-{
- void *result;
- int type;
- size_t block, oldsize;
-
- if (!ptr)
- return hybrid_malloc (size);
- if (!allocated_via_gmalloc (ptr))
- return realloc (ptr, size);
- if (!definitely_will_not_unexec_p ())
- return grealloc (ptr, size);
-
- /* The dumped emacs is trying to realloc storage allocated before
- dumping via gmalloc. Allocate new space and copy the data. Do
- not bother with gfree (ptr), as that would just waste time. */
- block = BLOCK (ptr);
- type = _heapinfo[block].busy.type;
- oldsize =
- type < 0 ? _heapinfo[block].busy.info.size * BLOCKSIZE
- : (size_t) 1 << type;
- result = malloc (size);
- if (result)
- return memcpy (result, ptr, min (oldsize, size));
- return result;
-}
-
-#else /* ! HYBRID_MALLOC */
-
void *
malloc (size_t size)
{
return grealloc (ptr, size);
}
-#endif /* HYBRID_MALLOC */
-
#ifdef GC_MCHECK
/* Standard debugging hooks for `malloc'.
#include "lisp.h"
-#if ((!defined SYSTEM_MALLOC && !defined HYBRID_MALLOC) \
+#if (!defined SYSTEM_MALLOC \
|| defined WINDOWSNT || defined CYGWIN || defined DARWIN_OS)
char my_edata[] = "End of Emacs initialized data";
#endif
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 && !defined HYBRID_MALLOC
+#if defined REL_ALLOC && !defined SYSTEM_MALLOC
extern void refill_memory_reserve (void);
#endif
extern void mark_c_stack (char const *, char const *);
void hash_table_free_bytes (void *p, ptrdiff_t nbytes);
/* Defined in gmalloc.c. */
-#if !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC && !defined SYSTEM_MALLOC
+#if !defined DOUG_LEA_MALLOC && !defined SYSTEM_MALLOC
extern size_t __malloc_extra_blocks;
#endif
#if !HAVE_DECL_ALIGNED_ALLOC
r_alloc_initialized = 1;
page_size = PAGE;
-#if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
+#if !defined SYSTEM_MALLOC
real_morecore = __morecore;
__morecore = r_alloc_sbrk;
mallopt (M_TOP_PAD, 64 * 4096);
unblock_input ();
#else
-#if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
+#if !defined 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
#endif
#endif
-#if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
+#if !defined SYSTEM_MALLOC
first_heap->end = (void *) PAGE_ROUNDUP (first_heap->start);
/* The extra call to real_morecore guarantees that the end of the
#endif
# if HAVE_GET_CURRENT_DIR_NAME && !BROKEN_GET_CURRENT_DIR_NAME
-# ifdef HYBRID_MALLOC
- bool use_libc = will_dump_with_unexec_p ();
-# else
bool use_libc = true;
-# endif
if (use_libc)
{
/* For an unreachable directory, this returns a string that starts
}
case 'e':
-#if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
+#if !defined SYSTEM_MALLOC
{
if (NILP (Vmemory_full))
return "";