Unexec removal: Remove HYBRID_MALLOC support
* src/gmalloc.c (gdefault_morecore): Remove HYBRID_MALLOC code. (allocated_via_gmalloc, hybrid_malloc, hybrid_calloc, hybrid_free_1) (hybrid_free, hybrid_aligned_alloc, hybrid_realloc): Remove functions. * msdos/sed1v2.inp: * msdos/sedlibmk.inp: * src/alloc.c (GC_MALLOC_CHECK, USE_ALIGNED_ALLOC) (refill_memory_reserve, aligned_alloc): * src/emacs.c (main): * src/lastfile.c (my_edata): * src/lisp.h: * src/ralloc.c: * src/sysdep.c (get_current_dir_name_or_unreachable): * src/xdisp.c (decode_mode_spec): Remove HYBRID_MALLOC conditions. * configure.ac (hybrid_malloc, HYBRID_MALLOC): Remove variables and dependent code. * src/conf_post.h (hybrid_malloc, hybrid_calloc, hybrid_free) (hybrid_aligned_alloc, hybrid_realloc): Remove conditional prototypes. * src/Makefile.in (HYBRID_MALLOC): Remove variable. (base_obj): Remove sheap.o (LIBEGNU_ARCHIVE): * lib/Makefile.in (libgnu_a_OBJECTS): Remove libegnu.a support.
This commit is contained in:
parent
15e2b14f03
commit
b2bc337a5f
14 changed files with 35 additions and 243 deletions
16
configure.ac
16
configure.ac
|
@ -3213,14 +3213,12 @@ AC_CACHE_CHECK(
|
|||
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
|
||||
|
@ -3229,14 +3227,6 @@ if test "${system_malloc}" = "yes"; then
|
|||
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
|
||||
|
@ -3255,11 +3245,10 @@ else
|
|||
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.)"
|
||||
|
@ -3321,8 +3310,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);
|
||||
#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);
|
||||
|
|
|
@ -94,9 +94,8 @@ not_emacs_OBJECTS = regex.o malloc/%.o free.o
|
|||
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:
|
||||
|
@ -104,18 +103,13 @@ $(libegnu_a_OBJECTS) $(libgnu_a_OBJECTS): $(BUILT_SOURCES)
|
|||
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 $@)
|
||||
|
|
|
@ -163,7 +163,6 @@ s/ *@WEBP_LIBS@//
|
|||
/^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@//
|
||||
|
|
|
@ -153,7 +153,6 @@ s/@PACKAGE@/emacs/
|
|||
/^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@//
|
||||
|
|
|
@ -306,8 +306,6 @@ XSHAPE_CFLAGS = @XSHAPE_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@
|
||||
|
||||
|
@ -477,7 +475,6 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
|
|||
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)
|
||||
|
@ -718,7 +715,7 @@ globals.h: gl-stamp; @true
|
|||
|
||||
$(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
|
||||
|
|
28
src/alloc.c
28
src/alloc.c
|
@ -127,7 +127,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
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
|
||||
|
||||
|
@ -460,7 +460,7 @@ static void gc_sweep (void);
|
|||
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);
|
||||
|
@ -644,7 +644,7 @@ struct Lisp_Finalizer doomed_finalizers;
|
|||
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. */
|
||||
|
||||
|
@ -1066,19 +1066,14 @@ lisp_free (void *block)
|
|||
# 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. */
|
||||
/* Use aligned_alloc if it or a simple substitute is available. */
|
||||
|
||||
#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. */
|
||||
#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)
|
||||
{
|
||||
|
@ -1095,7 +1090,6 @@ 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
|
||||
|
@ -4433,7 +4427,7 @@ memory_full (size_t nbytes)
|
|||
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)
|
||||
|
|
|
@ -93,31 +93,6 @@ typedef bool bool_bf;
|
|||
# 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
|
||||
|
|
|
@ -110,7 +110,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
#include "composite.h"
|
||||
#include "dispextern.h"
|
||||
#include "regex-emacs.h"
|
||||
#include "sheap.h"
|
||||
#include "syntax.h"
|
||||
#include "sysselect.h"
|
||||
#include "systime.h"
|
||||
|
@ -1565,7 +1564,7 @@ main (int argc, char **argv)
|
|||
|
||||
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);
|
||||
|
||||
|
@ -1573,7 +1572,7 @@ main (int argc, char **argv)
|
|||
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);
|
||||
|
@ -1879,7 +1878,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
|
|||
}
|
||||
|
||||
#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
|
||||
|
|
167
src/gmalloc.c
167
src/gmalloc.c
|
@ -21,7 +21,7 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#if defined HAVE_PTHREAD && !defined HYBRID_MALLOC
|
||||
#if defined HAVE_PTHREAD
|
||||
#define USE_PTHREAD
|
||||
#endif
|
||||
|
||||
|
@ -57,13 +57,6 @@ extern void *(*__morecore) (ptrdiff_t);
|
|||
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 conf_post.h. hybrid_malloc and
|
||||
friends are wrapper functions defined later in this file. */
|
||||
#undef malloc
|
||||
#undef realloc
|
||||
#undef calloc
|
||||
|
@ -76,19 +69,11 @@ extern void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void);
|
|||
#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
|
||||
|
@ -326,8 +311,6 @@ void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void);
|
|||
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;
|
||||
|
||||
|
@ -349,11 +332,9 @@ size_t _bytes_free;
|
|||
/* 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;
|
||||
|
@ -916,7 +897,7 @@ malloc (size_t size)
|
|||
return (hook ? hook : _malloc_internal) (size);
|
||||
}
|
||||
|
||||
#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. */
|
||||
|
@ -967,11 +948,8 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
|
|||
/* 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. */
|
||||
|
@ -1242,7 +1220,6 @@ free (void *ptr)
|
|||
_free_internal (ptr);
|
||||
}
|
||||
|
||||
#ifndef HYBRID_MALLOC
|
||||
/* Define the `cfree' alias for `free'. */
|
||||
#ifdef weak_alias
|
||||
weak_alias (free, cfree)
|
||||
|
@ -1253,7 +1230,6 @@ cfree (void *ptr)
|
|||
free (ptr);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Change the size of a block allocated by `malloc'.
|
||||
Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||
Written May 1989 by Mike Haertel.
|
||||
|
@ -1496,12 +1472,6 @@ extern void *__sbrk (ptrdiff_t increment);
|
|||
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)
|
||||
|
@ -1611,7 +1581,6 @@ aligned_alloc (size_t alignment, size_t size)
|
|||
}
|
||||
|
||||
/* 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. */
|
||||
|
||||
|
@ -1621,8 +1590,6 @@ memalign (size_t alignment, size_t size)
|
|||
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)
|
||||
{
|
||||
|
@ -1641,7 +1608,6 @@ posix_memalign (void **memptr, size_t alignment, size_t size)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Allocate memory on a page boundary.
|
||||
Copyright (C) 1991, 92, 93, 94, 96 Free Software Foundation, Inc.
|
||||
|
@ -1662,18 +1628,16 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
|
|||
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;
|
||||
|
||||
|
@ -1685,7 +1649,6 @@ valloc (size_t size)
|
|||
|
||||
return aligned_alloc (pagesize, size);
|
||||
}
|
||||
#endif /* HYBRID_MALLOC */
|
||||
|
||||
#undef malloc
|
||||
#undef realloc
|
||||
|
@ -1693,116 +1656,6 @@ valloc (size_t size)
|
|||
#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)
|
||||
{
|
||||
|
@ -1833,8 +1686,6 @@ realloc (void *ptr, size_t size)
|
|||
return grealloc (ptr, size);
|
||||
}
|
||||
|
||||
#endif /* HYBRID_MALLOC */
|
||||
|
||||
#ifdef GC_MCHECK
|
||||
|
||||
/* Standard debugging hooks for `malloc'.
|
||||
|
|
|
@ -38,7 +38,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
|||
|
||||
#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
|
||||
|
|
|
@ -4444,7 +4444,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 && !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 *);
|
||||
|
@ -4687,7 +4687,7 @@ void *hash_table_alloc_bytes (ptrdiff_t nbytes) ATTRIBUTE_MALLOC_SIZE ((1));
|
|||
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
|
||||
|
|
|
@ -1162,7 +1162,7 @@ r_alloc_init (void)
|
|||
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;
|
||||
|
||||
|
@ -1181,7 +1181,7 @@ r_alloc_init (void)
|
|||
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
|
||||
|
@ -1194,7 +1194,7 @@ r_alloc_init (void)
|
|||
#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
|
||||
|
|
|
@ -287,11 +287,7 @@ get_current_dir_name_or_unreachable (void)
|
|||
#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
|
||||
|
|
|
@ -28751,7 +28751,7 @@ decode_mode_spec (struct window *w, register int c, int field_width,
|
|||
}
|
||||
|
||||
case 'e':
|
||||
#if !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
|
||||
#if !defined SYSTEM_MALLOC
|
||||
{
|
||||
if (NILP (Vmemory_full))
|
||||
return "";
|
||||
|
|
Loading…
Add table
Reference in a new issue