3 new commits in XEmacs:
https://bitbucket.org/xemacs/xemacs/commits/3b1ef8c61ffe/
Changeset: 3b1ef8c61ffe
User: kehoea
Date: 2017-11-23 05:08:49+00:00
Summary: Remove gmalloc.c entirely. Use mcheck.h if ERROR_CHECK_MALLOC.
ChangeLog addition:
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
* configure.ac (XE_COMPLEX_ARG):
Remove gmalloc.c, remove the configure line options
--with-dlmalloc, --with-system-malloc, --with-debug-malloc. Always
use the system malloc. Autodetect __after_morecore_hook, use it
for our memory-full warning if available, otherwise ignore it.
Use mcheck.h if ERROR_CHECK_MALLOC is defined, as we had planned
for years pending its maturity.
* configure.ac (have_libmcheck): Make this available.
* configure: Regenerate.
src/ChangeLog addition:
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
* gmalloc.c: Removed. Use the system malloc all the time instead.
* config.h.in:
Remove DOUG_LEA_MALLOC, USE_SYSTEM_MALLOC, USE_DEBUG_MALLOC from
this file.
Rename _NO_MALLOC_WARNING_ to HAVE_MALLOC_WARNING, invert its
sense.
* Makefile.in.in:
Take a different approach as to whether to include vm-limit.o or
free-hook.o.
* alloc.c:
* alloc.c (malloced_storage_size):
Now we always use the system malloc, update this to use the GNU
malloc accounting if we are on a glibc system.
* alloc.c (common_init_alloc_early):
Call mallopt() if we're on a glibc system.
* emacs.c:
* emacs.c (main_1):
* emacs.c (main):
* emacs.c (Fdump_emacs):
* emacs.c (Fkill_emacs):
Remove use of old glibc malloc hooks that are deprecated and
removed from more recent versions.
Call init_ralloc() early in every startup if we were built with
REL_ALLOC support.
Remove the use of malloc_set_state(), deprecated.
* free-hook.c:
Remove the debugging hooks for
* gc.h:
* ralloc.c:
* ralloc.c (init_ralloc):
Avoid using the deprecated glibc malloc hooks in this file.
* sysdep.c:
SYSTEM_MALLOC is effectively always defined, don't check it.
* text.h:
* text.h (STRIDE_ALIGN_BITS):
Rename ALIGN_BIGS, ALIGN_MASK, they conflict with ralloc.c.
* vm-limit.c:
Rename _NO_MALLOC_WARNING to HAVE_MALLOC_WARNING, reverse its
sense.
man/ChangeLog addition:
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
* internals/internals.texi (A Summary of the Various XEmacs Modules):
* internals/internals.texi (Low-Level Modules):
* internals/internals.texi (Modules for Allocation):
* internals/internals.texi (Low-level allocation):
Remove mention of malloc.c (long gone) and gmalloc.c (gone today).
Affected #: 17 files
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * configure.ac (XE_COMPLEX_ARG):
+ Remove gmalloc.c, remove the configure line options
+ --with-dlmalloc, --with-system-malloc, --with-debug-malloc. Always
+ use the system malloc. Autodetect __after_morecore_hook, use it
+ for our memory-full warning if available, otherwise ignore it.
+ Use mcheck.h if ERROR_CHECK_MALLOC is defined, as we had planned
+ for years pending its maturity.
+ * configure.ac (have_libmcheck): Make this available.
+ * configure: Regenerate.
+
2017-11-15 Aidan Kehoe <kehoea(a)parhasard.net>
* configure: Regenerate.
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 configure
--- a/configure
+++ b/configure
@@ -780,6 +780,7 @@
INSTALL_PROGRAM
RANLIB
AR
+libmcheck
lib_gcc
ld
start_files
@@ -824,6 +825,7 @@
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -1012,12 +1014,6 @@
with_tls
enable_rel_alloc
with_rel_alloc
-enable_dlmalloc
-with_dlmalloc
-enable_system_malloc
-with_system_malloc
-enable_debug_malloc
-with_debug_malloc
enable_pdump
with_pdump
enable_dump_in_exec
@@ -1110,6 +1106,7 @@
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1362,6 +1359,15 @@
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1499,7 +1505,7 @@
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1652,6 +1658,7 @@
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -1959,9 +1966,6 @@
-------------------------
--with-rel-alloc Enable the relocating allocator.
- --with-dlmalloc Use Doug Lea's malloc implementation.
- --with-system-malloc Use the system malloc, (default).
- --with-debug-malloc Use a debugging malloc.
--with-pdump Enable portable LISP preloader.
--with-dump-in-exec Enable dumping into executable (enabled by default
for `pdump', not enabled by default in combination
@@ -2487,6 +2491,52 @@
} # ac_fn_c_try_link
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ as_decl_name=`echo $2|sed 's/ *(.*//'`
+ as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/)
0& (/g'`
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is
declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+ (void) $as_decl_use;
+#else
+ (void) $as_decl_name;
+#endif
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
+
# ac_fn_c_check_func LINENO FUNC VAR
# ----------------------------------
# Tests whether FUNC exists, setting the cache variable VAR accordingly
@@ -2554,52 +2604,6 @@
} # ac_fn_c_check_func
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- as_decl_name=`echo $2|sed 's/ *(.*//'`
- as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/)
0& (/g'`
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is
declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
- (void) $as_decl_use;
-#else
- (void) $as_decl_name;
-#endif
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- eval "$3=yes"
-else
- eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
-
# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
# -------------------------------------------
# Tests whether TYPE exists after having included INCLUDES, setting cache
@@ -4988,58 +4992,6 @@
else
with_rel_alloc='default'
fi;
-# If --with-dlmalloc or --without-dlmalloc were given then copy the value to the
-# equivalent enable_dlmalloc variable.
-if test "${with_dlmalloc+set}" = set; then
- enable_dlmalloc="$with_dlmalloc"
-fi;
-# If -enable-dlmalloc or --disable-dlmalloc were given then copy the value to the
-# equivalent with_dlmalloc variable.
-if test "${enable_dlmalloc+set}" = set; then
- with_dlmalloc="$enable_dlmalloc"
-fi;
-# Check whether --with-dlmalloc or --without-dlmalloc was given.
-if test "${with_dlmalloc+set}" = set; then
- enableval="$with_dlmalloc"
- withval="$with_dlmalloc"
-
-else
- with_dlmalloc='default'
-fi;
-# If --with-system-malloc or --without-system-malloc were given then copy the value to
the
-# equivalent enable_system-malloc variable.
-if test "${with_system_malloc+set}" = set; then
- enable_system_malloc="$with_system_malloc"
-fi;
-# If -enable-system-malloc or --disable-system-malloc were given then copy the value to
the
-# equivalent with_system-malloc variable.
-if test "${enable_system_malloc+set}" = set; then
- with_system_malloc="$enable_system_malloc"
-fi;
-# Check whether --with-system-malloc or --without-system-malloc was given.
-if test "${with_system_malloc+set}" = set; then
- enableval="$with_system_malloc"
- withval="$with_system_malloc"
-
-else
- with_system_malloc='default'
-fi;
-# If --with-debug-malloc or --without-debug-malloc were given then copy the value to the
-# equivalent enable_debug-malloc variable.
-if test "${with_debug_malloc+set}" = set; then
- enable_debug_malloc="$with_debug_malloc"
-fi;
-# If -enable-debug-malloc or --disable-debug-malloc were given then copy the value to
the
-# equivalent with_debug-malloc variable.
-if test "${enable_debug_malloc+set}" = set; then
- with_debug_malloc="$enable_debug_malloc"
-fi;
-# Check whether --with-debug-malloc or --without-debug-malloc was given.
-if test "${with_debug_malloc+set}" = set; then
- enableval="$with_debug_malloc"
- withval="$with_debug_malloc"
-
-fi;
# If --with-pdump or --without-pdump were given then copy the value to the
# equivalent enable_pdump variable.
if test "${with_pdump+set}" = set; then
@@ -5500,10 +5452,6 @@
fi;
-if test "$with_purify" = "yes" -o "$with_quantify" =
"yes"; then
- test "$with_system_malloc" = "default" &&
with_system_malloc=yes
-fi
-
if test "$with_cde $with_tooltalk" = "yes no"; then
(echo "$progname: Usage error:"
echo " " "--with-cde requires --with-tooltalk"
@@ -9446,12 +9394,6 @@
configure___ ordinary_link=no
#endif
-#ifdef SYSTEM_MALLOC
-configure___ system_malloc=yes
-#else
-configure___ system_malloc=no
-#endif
-
#ifdef TERMINFO
configure___ have_terminfo=yes
#else
@@ -10266,19 +10208,9 @@
-if test "$with_dlmalloc" = "yes"; then
- ac_fn_c_check_func "$LINENO" "malloc_set_state"
"ac_cv_func_malloc_set_state"
-if test "x$ac_cv_func_malloc_set_state" = xyes; then :
- doug_lea_malloc=yes
-else
- doug_lea_malloc=no
-fi
-
- if test "$doug_lea_malloc" = "yes"; then
- system_malloc=no
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __after_morecore_hook
exists" >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __after_morecore_hook
exists" >&5
$as_echo_n "checking whether __after_morecore_hook exists... " >&6; }
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
extern void (* __after_morecore_hook)();
int
@@ -10292,48 +10224,83 @@
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- after_morecore_hook_exists=yes
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- after_morecore_hook_exists=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
- GNU_MALLOC=yes
- $as_echo "#define DOUG_LEA_MALLOC 1" >>confdefs.h
-
- if test "$after_morecore_hook_exists" = "no" ; then
- GNU_MALLOC_reason="
- - Using Doug Lea's new malloc from the Linux C Library."
- $as_echo "#define _NO_MALLOC_WARNING_ 1" >>confdefs.h
-
- else
- GNU_MALLOC_reason="
- - Using Doug Lea's new malloc from the GNU C Library."
- fi
- else
- system_malloc=yes
- fi
-elif test "$with_debug_malloc" = "yes" ; then
- debug_malloc=yes
- system_malloc=yes
- GNU_MALLOC=no
- GNU_MALLOC_reason="
- - User chose to use Debugging Malloc."
-elif test "$with_system_malloc" = "no" ; then
- GNU_MALLOC=yes
- GNU_MALLOC_reason="
- - System malloc explicitly overridden."
- system_malloc=no
-else
- GNU_MALLOC=no
- GNU_MALLOC_reason="
- - Defaulting to system malloc."
- system_malloc=yes
-fi
-
-
+ after_morecore_hook_exists=yes
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ after_morecore_hook_exists=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test "$after_morecore_hook_exists" = "yes" ; then
+ $as_echo "#define HAVE_MALLOC_WARNING 1" >>confdefs.h
+
+fi
+
+have_libmcheck=no
+if test "$with_error_checking_malloc" = "yes" -a
"$have_glibc" = "yes" ; then
+ for ac_header in mcheck.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "mcheck.h"
"ac_cv_header_mcheck_h" "$ac_includes_default"
+if test "x$ac_cv_header_mcheck_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MCHECK_H 1
+_ACEOF
+
+fi
+
+done
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mcheck in -lmcheck"
>&5
+$as_echo_n "checking for mcheck in -lmcheck... " >&6; }
+if ${ac_cv_lib_mcheck_mcheck+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmcheck $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char mcheck ();
+int
+main ()
+{
+return mcheck ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_mcheck_mcheck=yes
+else
+ ac_cv_lib_mcheck_mcheck=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mcheck_mcheck"
>&5
+$as_echo "$ac_cv_lib_mcheck_mcheck" >&6; }
+if test "x$ac_cv_lib_mcheck_mcheck" = xyes; then :
+ have_libmcheck=yes
+else
+ have_libmcheck=no
+fi
+
+fi
+
+if test "$have_libmcheck" = "yes"; then
+ $as_echo "#define HAVE_LIBMCHECK 1" >>confdefs.h
+
+ libmcheck=-lmcheck
+
+fi
# Extract the first word of "ar", so it can be a program name with args.
@@ -11814,7 +11781,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31)
<< 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -11860,7 +11827,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31)
<< 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -11884,7 +11851,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31)
<< 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -11929,7 +11896,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31)
<< 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -11953,7 +11920,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31)
<< 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -19199,12 +19166,12 @@
case "$opsys" in cygwin*)
test "$with_rel_alloc" = "default" && with_rel_alloc=no ;;
esac
-test "$GNU_MALLOC" != "yes" -a "$have_mmap" !=
"yes" && with_rel_alloc=no
+
+test "$have_mmap" != "yes" && with_rel_alloc=no
if test "$with_rel_alloc $have_mmap" = "default yes"; then
- if test "$doug_lea_malloc" = "yes"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for M_MMAP_THRESHOLD"
>&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for M_MMAP_THRESHOLD"
>&5
$as_echo_n "checking for M_MMAP_THRESHOLD... " >&6; }
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <malloc.h>
int
@@ -19228,9 +19195,6 @@
$as_echo "no" >&6; };
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- else
- with_rel_alloc=yes
- fi
fi
test "$with_rel_alloc" = "yes" && $as_echo "#define
REL_ALLOC 1" >>confdefs.h
@@ -22098,13 +22062,6 @@
-if test "$debug_malloc" = "yes"; then $as_echo "#define
USE_DEBUG_MALLOC 1" >>confdefs.h
-
- $as_echo "#define USE_SYSTEM_MALLOC 1"
>>confdefs.h
-
-elif test "$system_malloc" = "yes"; then $as_echo "#define
USE_SYSTEM_MALLOC 1" >>confdefs.h
-
-fi
test "$GCC" = "yes" && $as_echo
"#define USE_GCC 1" >>confdefs.h
test "$XEMACS_CC_GPP" = "yes" && $as_echo
"#define USE_GPLUSPLUS 1" >>confdefs.h
@@ -22211,7 +22168,6 @@
fi
echo " libc version: $libc_version"
echo " Relocating allocator for buffers: $with_rel_alloc"
-echo " Using gmalloc.c from XEmacs: ${GNU_MALLOC}${GNU_MALLOC_reason}"
case "$ld_switch_site" in
*nocombreloc*) echo " Linking with \`-z nocombreloc'.
- Consider configuring with --with-pdump." ;;
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -969,15 +969,6 @@
XE_MERGED_ARG([rel-alloc],
AS_HELP_STRING([--with-rel-alloc],[Enable the relocating allocator.]),
[], [with_rel_alloc='default'])
-XE_MERGED_ARG([dlmalloc],
- AS_HELP_STRING([--with-dlmalloc],[Use Doug Lea's malloc implementation.]),
- [], [with_dlmalloc='default'])
-XE_MERGED_ARG([system-malloc],
- AS_HELP_STRING([--with-system-malloc],[Use the system malloc, (default).]),
- [], [with_system_malloc='default'])
-XE_MERGED_ARG([debug-malloc],
- AS_HELP_STRING([--with-debug-malloc],[Use a debugging malloc.]),
- [], [])
XE_MERGED_ARG([pdump],
AS_HELP_STRING([--with-pdump],[Enable portable LISP preloader.]),
[], [])
@@ -1098,11 +1089,6 @@
dnl -------------------------------------------------------------------------
dnl Final command line argument checks.
-dnl --with-quantify or --with-purify imply --with-system-malloc
-if test "$with_purify" = "yes" -o "$with_quantify" =
"yes"; then
- test "$with_system_malloc" = "default" &&
with_system_malloc=yes
-fi
-
dnl CDE requires tooltalk
XE_CHECK_FEATURE_DEPENDENCY(cde, tooltalk)
@@ -1818,7 +1804,6 @@
configure___ start_files=START_FILES
CPP_boolean_to_sh(ORDINARY_LINK, ordinary_link)
-CPP_boolean_to_sh(SYSTEM_MALLOC, system_malloc)
CPP_boolean_to_sh(TERMINFO, have_terminfo)
dnl The MAIL_USE_xxx variables come from the s&m headers
CPP_boolean_to_sh(MAIL_USE_FLOCK, mail_use_flock)
@@ -2533,69 +2518,34 @@
dnl Do some misc autoconf-special tests
dnl -----------------------------------
-dnl Default to the system malloc. The right thing here is to remove
-dnl src/gmalloc.c entirely, and just autoconfiscate and use malloc_set_state
-dnl and __after_morecore_hook and if they are available, otherwise no. But
-dnl this is a reasonable first step.
-
-if test "$with_dlmalloc" = "yes"; then
- AC_CHECK_FUNC(malloc_set_state, doug_lea_malloc=yes,doug_lea_malloc=no)
- if test "$doug_lea_malloc" = "yes"; then
- system_malloc=no
- AC_MSG_CHECKING(whether __after_morecore_hook exists)
- AC_LINK_IFELSE([AC_LANG_PROGRAM([extern void (* __after_morecore_hook)();],
- [__after_morecore_hook = 0])],
- [AC_MSG_RESULT(yes)
- after_morecore_hook_exists=yes],
- [AC_MSG_RESULT(no)
- after_morecore_hook_exists=no])
- GNU_MALLOC=yes
- AC_DEFINE(DOUG_LEA_MALLOC)
- if test "$after_morecore_hook_exists" = "no" ; then
- GNU_MALLOC_reason="
- - Using Doug Lea's new malloc from the Linux C Library."
- AC_DEFINE(_NO_MALLOC_WARNING_)
- else
- GNU_MALLOC_reason="
- - Using Doug Lea's new malloc from the GNU C Library."
- fi
- else
- system_malloc=yes
- fi
-elif test "$with_debug_malloc" = "yes" ; then
- debug_malloc=yes
- system_malloc=yes
- GNU_MALLOC=no
- GNU_MALLOC_reason="
- - User chose to use Debugging Malloc."
-elif test "$with_system_malloc" = "no" ; then
- GNU_MALLOC=yes
- GNU_MALLOC_reason="
- - System malloc explicitly overridden."
- system_malloc=no
-else
- GNU_MALLOC=no
- GNU_MALLOC_reason="
- - Defaulting to system malloc."
- system_malloc=yes
-fi
-
-dnl #### mcheck is broken in all versions of Linux libc and glibc.
-dnl Try this again when 2.1 hits the streets.
-dnl Avoid using free-hook.c if support exists for malloc debugging in libc
-dnl have_libmcheck=no
-dnl if test "$with_error_checking_malloc" = "yes" -a \
-dnl "$have_glibc" = "yes" -a \
-dnl "$doug_lea_malloc" = "yes"; then
-dnl AC_CHECK_HEADERS(mcheck.h)
-dnl AC_CHECK_LIB(mcheck, mcheck, have_libmcheck=yes, have_libmcheck=no)
-dnl fi
-
-dnl if test "$have_libmcheck" = "yes"; then
-dnl AC_DEFINE(HAVE_LIBMCHECK)
-dnl libmcheck=-lmcheck
-dnl AC_SUBST(libmcheck)
-dnl fi
+dnl We used to include a copy of gmalloc.c, and would usually use that. Now
+dnl that most Linuxes have gmalloc, and now that that's more maintained than
+dnl is our copy, use the system malloc() instead, even on non-Linux
+dnl platforms.
+
+AC_MSG_CHECKING(whether __after_morecore_hook exists)
+AC_LINK_IFELSE([AC_LANG_PROGRAM([extern void (* __after_morecore_hook)();],
+[__after_morecore_hook = 0])],
+[AC_MSG_RESULT(yes)
+ after_morecore_hook_exists=yes],
+[AC_MSG_RESULT(no)
+ after_morecore_hook_exists=no])
+if test "$after_morecore_hook_exists" = "yes" ; then
+ AC_DEFINE(HAVE_MALLOC_WARNING)
+fi
+
+dnl Use the support for for malloc debugging in libc if available.
+have_libmcheck=no
+if test "$with_error_checking_malloc" = "yes" -a
"$have_glibc" = "yes" ; then
+ AC_CHECK_HEADERS(mcheck.h)
+ AC_CHECK_LIB(mcheck, mcheck, have_libmcheck=yes, have_libmcheck=no)
+fi
+
+if test "$have_libmcheck" = "yes"; then
+ AC_DEFINE(HAVE_LIBMCHECK)
+ libmcheck=-lmcheck
+ AC_SUBST(libmcheck)
+fi
dnl Some other nice autoconf tests. If you add a test here which
dnl should make an entry in src/config.h, do not forget to add an
@@ -4896,23 +4846,20 @@
case "$opsys" in cygwin*)
test "$with_rel_alloc" = "default" && with_rel_alloc=no ;;
esac
-dnl rel_alloc requires either GNU malloc or system malloc with mmap
-dnl We only turn rel_alloc on by default if mmap is available.
-test "$GNU_MALLOC" != "yes" -a "$have_mmap" !=
"yes" && with_rel_alloc=no
+
+dnl rel_alloc requires system malloc with mmap. We only turn rel_alloc on by
+dnl default if mmap is available.
+test "$have_mmap" != "yes" && with_rel_alloc=no
if test "$with_rel_alloc $have_mmap" = "default yes"; then
- if test "$doug_lea_malloc" = "yes"; then
- dnl Check if malloc() calls mmap(), making rel_alloc pointless.
- AC_MSG_CHECKING(for M_MMAP_THRESHOLD)
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <malloc.h>],[
+ dnl Check if malloc() calls mmap(), making rel_alloc pointless.
+ AC_MSG_CHECKING(for M_MMAP_THRESHOLD)
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <malloc.h>],[
#ifndef M_MMAP_THRESHOLD
#error No M_MMAP_THRESHOLD :-(
!@+$%^&*_)(_ - unlikely to compile...
#endif
])], [with_rel_alloc=no; AC_MSG_RESULT(yes);],
- [with_rel_alloc=yes; AC_MSG_RESULT(no);])
- else
- with_rel_alloc=yes
- fi
+ [with_rel_alloc=yes; AC_MSG_RESULT(no);])
fi
test "$with_rel_alloc" = "yes" && AC_DEFINE(REL_ALLOC)
@@ -5851,10 +5798,6 @@
dnl so that the user gets immediate feedback on the results of the
dnl autodetection.
-if test "$debug_malloc" = "yes"; then AC_DEFINE(USE_DEBUG_MALLOC)
- AC_DEFINE(USE_SYSTEM_MALLOC)
-elif test "$system_malloc" = "yes"; then
AC_DEFINE(USE_SYSTEM_MALLOC)
-fi
test "$GCC" = "yes" && AC_DEFINE(USE_GCC)
test "$XEMACS_CC_GPP" = "yes" &&
AC_DEFINE(USE_GPLUSPLUS)
test "$with_external_widget" = "yes" &&
AC_DEFINE(EXTERNAL_WIDGET)
@@ -5952,7 +5895,6 @@
fi
echo " libc version: $libc_version"
echo " Relocating allocator for buffers: $with_rel_alloc"
-echo " Using gmalloc.c from XEmacs: ${GNU_MALLOC}${GNU_MALLOC_reason}"
case "$ld_switch_site" in
*nocombreloc*) echo " Linking with \`-z nocombreloc'.
- Consider configuring with --with-pdump." ;;
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 man/ChangeLog
--- a/man/ChangeLog
+++ b/man/ChangeLog
@@ -1,3 +1,11 @@
+2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * internals/internals.texi (A Summary of the Various XEmacs Modules):
+ * internals/internals.texi (Low-Level Modules):
+ * internals/internals.texi (Modules for Allocation):
+ * internals/internals.texi (Low-level allocation):
+ Remove mention of malloc.c (long gone) and gmalloc.c (gone today).
+
2017-11-14 Stephen J. Turnbull <stephen(a)xemacs.org>
* lispref/faces.texi (Face Properties): Add items to itemize.
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 man/internals/internals.texi
--- a/man/internals/internals.texi
+++ b/man/internals/internals.texi
@@ -3057,7 +3057,6 @@
@item @file{glyphs-x.h} @tab @ref{Modules for other Display-Related Lisp Objects}.
@item @file{glyphs.c} @tab @ref{Modules for other Display-Related Lisp Objects}.
@item @file{glyphs.h} @tab @ref{Modules for other Display-Related Lisp Objects}.
-@item @file{gmalloc.c} @tab @ref{Low-Level Modules}.
@item @file{gpmevent.c} @tab @ref{Editor-Level Control Flow Modules}.
@item @file{gpmevent.h} @tab @ref{Editor-Level Control Flow Modules}.
@item @file{gtk-glue.c} @tab
@@ -3445,7 +3444,7 @@
very last file linked, respectively. (Actually, this is not really true.
@file{lastfile.c} should be after all Emacs modules whose initialized
data should be made constant, and before all other Emacs files and all
-libraries. In particular, the allocation modules @file{gmalloc.c},
+libraries. In particular, the allocation modules
@file{alloca.c}, etc. are normally placed past @file{lastfile.c}, and
all of the files that implement Xt widget classes @emph{must} be placed
after @file{lastfile.c} because they contain various structures that
@@ -7980,8 +7979,6 @@
@file{alloca.c}
@file{free-hook.c}
@file{getpagesize.h}
-(a)file{gmalloc.c}
-(a)file{malloc.c}
@file{mem-limits.h}
@file{ralloc.c}
@file{vm-limit.c}
@@ -7991,16 +7988,6 @@
the stack allocation function @code{alloca()} on machines that lack
this. (XEmacs makes extensive use of @code{alloca()} in its code.)
-(a)file{gmalloc.c} and @file{malloc.c} are two implementations of the standard C
-functions @code{malloc()}, @code{realloc()} and @code{free()}. They are
-often used in place of the standard system-provided @code{malloc()}
-because they usually provide a much faster implementation, at the
-expense of additional memory use. @file{gmalloc.c} is a newer implementation
-that is much more memory-efficient for large allocations than @file{malloc.c},
-and should always be preferred if it works. (At one point, @file{gmalloc.c}
-didn't work on some systems where @file{malloc.c} worked; but this should be
-fixed now.)
-
@cindex relocating allocator
@file{ralloc.c} is the @dfn{relocating allocator}. It provides
functions similar to @code{malloc()}, @code{realloc()} and @code{free()}
@@ -9644,37 +9631,11 @@
difficult in the general circumstance, perhaps requiring extra
unwind-protects and such.)
- Note that XEmacs provides two separate replacements for the standard
-@code{malloc()} library function. These are called @dfn{old GNU malloc}
-((a)file{malloc.c}) and @dfn{new GNU malloc} (@file{gmalloc.c}),
-respectively. New GNU malloc is better in pretty much every way than
-old GNU malloc, and should be used if possible. (It used to be that on
-some systems, the old one worked but the new one didn't. I think this
-was due specifically to a bug in SunOS, which the new one now works
-around; so I don't think the old one ever has to be used any more.) The
-primary difference between both of these mallocs and the standard system
-malloc is that they are much faster, at the expense of increased space.
-The basic idea is that memory is allocated in fixed chunks of powers of
-two. This allows for basically constant malloc time, since the various
-chunks can just be kept on a number of free lists. (The standard system
-malloc typically allocates arbitrary-sized chunks and has to spend some
-time, sometimes a significant amount of time, walking the heap looking
-for a free block to use and cleaning things up.) The new GNU malloc
-improves on things by allocating large objects in chunks of 4096 bytes
-rather than in ever larger powers of two, which results in ever larger
-wastage. There is a slight speed loss here, but it's of doubtful
-significance.
-
- NOTE: Apparently there is a third-generation GNU malloc that is
-significantly better than the new GNU malloc, and should probably
-be included in XEmacs.
-
There is also the relocating allocator, @file{ralloc.c}. This actually
moves blocks of memory around so that the @code{sbrk()} pointer shrunk
and virtual memory released back to the system. On some systems,
this is a big win. On all systems, it causes a noticeable (and
sometimes huge) speed penalty, so I turn it off by default.
-(a)file{ralloc.c} only works with the new GNU malloc in @file{gmalloc.c}.
There are also two versions of @file{ralloc.c}, one that uses @code{mmap()}
rather than block copies to move data around. This purports to
be faster, although that depends on the amount of data that would
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,46 @@
+2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * gmalloc.c: Removed. Use the system malloc all the time instead.
+ * config.h.in:
+ Remove DOUG_LEA_MALLOC, USE_SYSTEM_MALLOC, USE_DEBUG_MALLOC from
+ this file.
+ Rename _NO_MALLOC_WARNING_ to HAVE_MALLOC_WARNING, invert its
+ sense.
+ * Makefile.in.in:
+ Take a different approach as to whether to include vm-limit.o or
+ free-hook.o.
+ * alloc.c:
+ * alloc.c (malloced_storage_size):
+ Now we always use the system malloc, update this to use the GNU
+ malloc accounting if we are on a glibc system.
+ * alloc.c (common_init_alloc_early):
+ Call mallopt() if we're on a glibc system.
+
+ * emacs.c:
+ * emacs.c (main_1):
+ * emacs.c (main):
+ * emacs.c (Fdump_emacs):
+ * emacs.c (Fkill_emacs):
+ Remove use of old glibc malloc hooks that are deprecated and
+ removed from more recent versions.
+ Call init_ralloc() early in every startup if we were built with
+ REL_ALLOC support.
+ Remove the use of malloc_set_state(), deprecated.
+ * free-hook.c:
+ Remove the debugging hooks for
+ * gc.h:
+ * ralloc.c:
+ * ralloc.c (init_ralloc):
+ Avoid using the deprecated glibc malloc hooks in this file.
+ * sysdep.c:
+ SYSTEM_MALLOC is effectively always defined, don't check it.
+ * text.h:
+ * text.h (STRIDE_ALIGN_BITS):
+ Rename ALIGN_BIGS, ALIGN_MASK, they conflict with ralloc.c.
+ * vm-limit.c:
+ Rename _NO_MALLOC_WARNING to HAVE_MALLOC_WARNING, reverse its
+ sense.
+
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
* alloca.c (xemacs_c_alloca):
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 src/Makefile.in.in
--- a/src/Makefile.in.in
+++ b/src/Makefile.in.in
@@ -307,29 +307,14 @@
#endif
malloclib = $(libmcheck)
-#ifndef SYSTEM_MALLOC
-# ifdef ERROR_CHECK_MALLOC
-# ifdef DOUG_LEA_MALLOC
-mallocobjs = free-hook.o vm-limit.o
-# else
-mallocobjs = gmalloc.o free-hook.o vm-limit.o
-# endif
-mallocdocsrc = free-hook.c
-# else /* GNU malloc, sans error checking */
-# ifdef DOUG_LEA_MALLOC
-mallocobjs = vm-limit.o
-# else
-mallocobjs = gmalloc.o vm-limit.o
-# endif
mallocdocsrc =
-# endif /* ERROR_CHECK_MALLOC */
-#else /* SYSTEM_MALLOC */
mallocobjs =
-mallocdocsrc =
-# ifdef USE_DEBUG_MALLOC
-malloclib = -ldmalloc
-# endif /* USE_DEBUG_MALLOC */
-#endif /* SYSTEM_MALLOC */
+#ifdef HAVE_MALLOC_WARNING
+mallocobjs += vm-limit.o
+#endif /* HAVE_MALLOC_WARNING */
+#ifdef DEBUG_GCPRO
+mallocobjs += free-hook.o
+#endif
#ifdef HAVE_X_WINDOWS
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 src/alloc.c
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -66,7 +66,7 @@
#endif /* NEW_GC */
#include "console-stream.h"
-#ifdef DOUG_LEA_MALLOC
+#ifdef _GNU_SOURCE
#include <malloc.h>
#endif
#ifdef USE_VALGRIND
@@ -81,14 +81,6 @@
#endif
#endif
-/* Define this to use malloc/free with no freelist for all datatypes,
- the hope being that some debugging tools may help detect
- freed memory references */
-#ifdef USE_DEBUG_MALLOC /* Taking the above comment at face value -slb */
-#include <dmalloc.h>
-#define ALLOC_NO_POOLS
-#endif
-
#ifdef DEBUG_XEMACS
static Fixnum debug_allocation;
static Fixnum debug_allocation_backtrace_length;
@@ -228,7 +220,7 @@
}
}
-#if !defined(HAVE_MMAP) || defined(DOUG_LEA_MALLOC)
+#if !defined(HAVE_MMAP) || defined(_GNU_SOURCE)
/* 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.
@@ -241,7 +233,7 @@
if (breathing_space == 0)
breathing_space = (char *) malloc (4096 - MALLOC_OVERHEAD);
}
-#endif /* !defined(HAVE_MMAP) || defined(DOUG_LEA_MALLOC) */
+#endif /* !defined(HAVE_MMAP) || defined(_GNU_SOURCE) */
#endif /* not NEW_GC */
@@ -4059,7 +4051,11 @@
{
Bytecount orig_claimed_size = claimed_size;
-#ifndef SYSTEM_MALLOC
+#ifdef _GNU_SOURCE
+ /* The following actually reflects the old gmalloc.c that we included with
+ XEmacs. The malloc implementation included in glibc has likely diverged
+ from this, but this answer is still going to be better than the
+ default. */
if (claimed_size < (Bytecount) (2 * sizeof (void *)))
claimed_size = 2 * sizeof (void *);
# ifdef SUNOS_LOCALTIME_BUG
@@ -5964,7 +5960,7 @@
all_lcrecords = 0;
#endif /* not NEW_GC */
ignore_malloc_warnings = 1;
-#ifdef DOUG_LEA_MALLOC
+#ifdef _GNU_SOURCE
mallopt (M_TRIM_THRESHOLD, 128*1024); /* trim threshold */
mallopt (M_MMAP_THRESHOLD, 64*1024); /* mmap threshold */
#if 0 /* Moved to emacs.c */
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 src/config.h.in
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -151,20 +151,12 @@
/* Undefine on systems which don't have processes */
#undef HAVE_UNIX_PROCESSES
-/* Define if you are using the GNU C Library. -- experimental. */
-#undef DOUG_LEA_MALLOC
-
/* Define if you are using libmcheck.a from the GNU C Library. */
#undef HAVE_LIBMCHECK
-/* Define if you are using dlmalloc from the Linux C library. */
-#undef _NO_MALLOC_WARNING_
-
-/* Use the system malloc? */
-#undef USE_SYSTEM_MALLOC
-
-/* Use a debugging malloc? -- experimental */
-#undef USE_DEBUG_MALLOC
+/* Define if your malloc has an __after_morecore_hook(), as is
+ usual on Linux. */
+#undef HAVE_MALLOC_WARNING
/* Use the relocating allocator for buffer space? */
#undef REL_ALLOC
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 src/emacs.c
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -468,12 +468,6 @@
void report_sheap_usage (int die_if_pure_storage_exceeded);
#endif
-#if !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC)
-extern void *(*__malloc_hook)(size_t);
-extern void *(*__realloc_hook)(void *, size_t);
-extern void (*__free_hook)(void *);
-#endif /* not SYSTEM_MALLOC && not DOUG_LEA_MALLOC */
-
/* Command line args from shell, as list of strings */
Lisp_Object Vcommand_line_args;
@@ -482,16 +476,9 @@
on subsequent starts. */
int initialized;
-#ifdef DOUG_LEA_MALLOC
+#ifdef _GNU_SOURCE
# include <malloc.h>
-/* Preserves a pointer to the memory allocated that copies that
- static data inside glibc's malloc. */
-static void *malloc_state_ptr;
-#endif /* DOUG_LEA_MALLOC */
-
-# ifdef REL_ALLOC
-void r_alloc_reinit (void);
-# endif
+#endif /* _GNU_SOURCE */
/* Variable whose value is symbol giving operating system type. */
Lisp_Object Vsystem_type;
@@ -895,17 +882,6 @@
int skip_args = 0;
Lisp_Object load_me;
-#if (!defined (SYSTEM_MALLOC) && !defined (HAVE_LIBMCHECK) \
- && !defined (DOUG_LEA_MALLOC))
- /* Make sure that any libraries we link against haven't installed a
- hook for a gmalloc of a potentially incompatible version. */
- /* If we're using libmcheck, the hooks have already been initialized, */
- /* don't touch them. -slb */
- __malloc_hook = NULL;
- __realloc_hook = NULL;
- __free_hook = NULL;
-#endif /* not SYSTEM_MALLOC or HAVE_LIBMCHECK or DOUG_LEA_MALLOC */
-
noninteractive = 0;
display_use = NULL;
inhibit_non_essential_conversion_operations = 1;
@@ -987,12 +963,8 @@
clearerr (stdin);
-#if defined (HAVE_MMAP) && defined (REL_ALLOC)
- /* ralloc can only be used if using the GNU memory allocator. */
+#if defined (REL_ALLOC)
init_ralloc ();
-#elif defined (REL_ALLOC) && !defined (DOUG_LEA_MALLOC)
- if (initialized)
- init_ralloc ();
#endif
#ifdef HAVE_SOCKS
@@ -1000,11 +972,11 @@
SOCKSinit (argv[0]);
#endif /* HAVE_SOCKS */
-#ifndef SYSTEM_MALLOC
+#ifdef HAVE_MALLOC_WARNING
if (!initialized)
/* Arrange to get warning messages as memory fills up. */
memory_warnings (0, malloc_warning);
-#endif /* not SYSTEM_MALLOC */
+#endif /* HAVE_MALLOC_WARNING */
#ifdef SET_EMACS_PRIORITY
if (emacs_priority != 0)
@@ -1591,7 +1563,7 @@
syms_of_process_nt ();
#endif
syms_of_profile ();
-#if defined (HAVE_MMAP) && defined (REL_ALLOC) && !defined
(DOUG_LEA_MALLOC)
+#ifdef REL_ALLOC
syms_of_ralloc ();
#endif /* HAVE_MMAP && REL_ALLOC */
syms_of_rangetab ();
@@ -2205,9 +2177,9 @@
#endif
vars_of_profile ();
-#if defined (HAVE_MMAP) && defined (REL_ALLOC) && !defined
(DOUG_LEA_MALLOC)
+#ifdef REL_ALLOC
vars_of_ralloc ();
-#endif /* HAVE_MMAP && REL_ALLOC */
+#endif
vars_of_realpath ();
vars_of_redisplay ();
vars_of_regex ();
@@ -3217,7 +3189,7 @@
if (!initialized)
{
-#ifdef DOUG_LEA_MALLOC
+#ifdef _GNU_SOURCE
mallopt (M_MMAP_MAX, 0);
#endif
run_temacs_argc = 0;
@@ -3257,30 +3229,17 @@
run_time_remap (argv[0]);
#endif
-#ifdef DOUG_LEA_MALLOC
- if (initialized && (malloc_state_ptr != NULL))
+#ifdef _GNU_SOURCE
+ if (initialized)
{
- int rc = malloc_set_state (malloc_state_ptr);
- if (rc != 0)
- {
- stderr_out ("malloc_set_state failed, rc = %d\n", rc);
- ABORT ();
- }
-#if 0
- free (malloc_state_ptr);
-#endif
/* mmap works in glibc-2.1, glibc-2.0 (Non-Mule only) and Linux libc5 */
#if (defined (__GLIBC__) && __GLIBC_MINOR__ >= 1) || \
- defined (_NO_MALLOC_WARNING_) || \
- (defined (__GLIBC__) && __GLIBC_MINOR__ < 1 && !defined (MULE)) ||
\
- defined (DEBUG_DOUG_LEA_MALLOC)
+ defined (HAVE_MALLOC_WARNING) || \
+ (defined (__GLIBC__) && __GLIBC_MINOR__ < 1 && !defined (MULE))
mallopt (M_MMAP_MAX, 64);
#endif
-#ifdef REL_ALLOC
- r_alloc_reinit ();
-#endif
}
-#endif /* DOUG_LEA_MALLOC */
+#endif /* _GNU_SOURCE */
run_temacs_argc = -2;
@@ -3301,7 +3260,7 @@
/* dumping XEmacs (to a new EXE file) */
/************************************************************************/
-#if !defined (PDUMP) || !defined (SYSTEM_MALLOC)
+#if !defined (PDUMP) || defined (HAVE_MALLOC_WARNING)
extern Rawbyte my_edata[];
#endif
@@ -3361,7 +3320,7 @@
/* Tell malloc where start of impure now is */
/* Also arrange for warnings when nearly out of space. */
-#ifndef SYSTEM_MALLOC
+#ifdef HAVE_MALLOC_WARNING
memory_warnings (my_edata, malloc_warning);
#endif
@@ -3389,9 +3348,6 @@
else
symfile_ext = 0;
-# ifdef DOUG_LEA_MALLOC
- malloc_state_ptr = malloc_get_state ();
-# endif
/* here we break our rule that the filename conversion should
be performed at the actual time that the system call is made.
It's a whole lot easier to do the conversion here than to
@@ -3399,9 +3355,6 @@
conversion is applied everywhere. Don't worry about memory
leakage because this call only happens once. */
unexec (filename_ext, symfile_ext, (uintptr_t) my_edata, 0, 0);
-# ifdef DOUG_LEA_MALLOC
- free (malloc_state_ptr);
-# endif
}
#endif /* not PDUMP, not WIN32_NATIVE */
@@ -3741,25 +3694,6 @@
#endif /* TOOLTALK */
}
-/* Dumping apparently isn't supported by versions of GCC >= 2.8. */
-/* The following needs conditionalization on whether either XEmacs or */
-/* various system shared libraries have been built and linked with */
-/* GCC >= 2.8. -slb */
-#ifndef SYSTEM_MALLOC
-static void
-voodoo_free_hook (void *UNUSED (mem))
-{
- /* Disable all calls to free() when XEmacs is exiting and it doesn't */
- /* matter. */
- __free_hook =
-#if defined (TYPEOF) && !defined (UNO)
- /* prototype of __free_hook varies with glibc version */
- (TYPEOF (__free_hook))
-#endif
- voodoo_free_hook;
-}
-#endif /* SYSTEM_MALLOC */
-
DEFUN_NORETURN ("kill-emacs", Fkill_emacs, 0, 1, "P", /*
Exit the XEmacs job and kill it. Ask for confirmation, without argument.
If ARG is an integer, return ARG as the exit program code.
@@ -3816,15 +3750,6 @@
shut_down_emacs (0, STRINGP (arg) ? arg : Qnil, 0);
-#ifndef SYSTEM_MALLOC
- __free_hook =
-#if defined (TYPEOF) && !defined (UNO)
- /* prototype of __free_hook varies with glibc version */
- (TYPEOF (__free_hook))
-#endif
- voodoo_free_hook;
-#endif
-
exit (FIXNUMP (arg) ? XFIXNUM (arg) : 0);
RETURN_NOT_REACHED (Qnil);
}
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 src/free-hook.c
--- a/src/free-hook.c
+++ b/src/free-hook.c
@@ -14,404 +14,12 @@
You should have received a copy of the GNU General Public License
along with XEmacs. If not, see <
http://www.gnu.org/licenses/>. */
-/* Synched up with: Not in FSF. */
-
-/* Debugging hooks for malloc. */
-
-/* These hooks work with gmalloc to catch allocation errors.
- In particular, the following is trapped:
-
- * Freeing the same pointer twice.
- * Trying to free a pointer not returned by malloc.
- * Trying to realloc a pointer not returned by malloc.
-
- In addition, every word of every block freed is set to 0xDEADBEEF
- (-559038737). This causes many uses of freed storage to be trapped or
- recognized.
-
- When you use this, the storage used by the last FREE_QUEUE_LIMIT
- calls to free() is not recycled. When you call free for the Nth
- time, the (N - FREE_QUEUE_LIMIT)'th block is actually recycled.
-
- For these last FREE_QUEUE_LIMIT calls to free() a backtrace is
- saved showing where it was called from. The function
- find_backtrace() is provided here to be called from GDB with a
- pointer (such as would be passed to free()) as argument, e.g.
- (gdb) p/a *find_backtrace (0x234000). If SAVE_ARGS is defined,
- the first three arguments to each function are saved as well as the
- return addresses.
-
- If UNMAPPED_FREE is defined, instead of setting every word of freed
- storage to 0xDEADBEEF, every call to malloc goes on its own page(s).
- When free() is called, the block is read and write protected. This
- is very useful when debugging, since it usually generates a bus error
- when the DEADBEEF hack might only cause some garbage to be printed.
- However, this is too slow for everyday use, since it takes an enormous
- number of pages.
-
-
- Some other features that would be useful are:
-
- * Checking for storage leaks.
- This could be done by a GC-like facility that would scan the data
- segment looking for pointers to allocated storage and tell you
- about those that are no longer referenced. This could be invoked
- at any time. Another possibility is to report on what allocated
- storage is still in use when the process is exited. Typically
- there will be a large amount, so this might not be very useful.
-*/
-
-#ifdef emacs
#include <config.h>
#include "lisp.h"
-#else
-void *malloc (size_t);
-#endif
-#if !defined(HAVE_LIBMCHECK)
-#include <stdio.h>
-
-#include "hash.h"
-
-#ifdef UNMAPPED_FREE
-#include <sys/mman.h>
-#include <sys/param.h>
-#define ROUND_UP_TO_PAGE(i) (((i) + PAGEOFFSET) & PAGEMASK)
-#endif
-
-#include <sys/types.h>
-
-/* System function prototypes don't belong in C source files */
-/* extern void free (void *); */
-
-static struct hash_table *pointer_table;
-
-extern void (*__free_hook) (void *);
-extern void *(*__malloc_hook) (size_t);
-
-static void *check_malloc (size_t);
-
-typedef void (*fun_ptr) (void);
-
-/* free_queue is not too useful without backtrace logging */
-#define FREE_QUEUE_LIMIT 1
-#define TRACE_LIMIT 20
-
-typedef struct {
- fun_ptr return_pc;
-#ifdef SAVE_ARGS
- void *arg[3];
-#endif
-} fun_entry;
-
-typedef struct {
- void *address;
- unsigned long length;
-} free_queue_entry;
-
-static free_queue_entry free_queue[FREE_QUEUE_LIMIT];
-
-static int current_free;
-
-static int strict_free_check;
-
-static void
-check_free (void *ptr)
-{
- __free_hook = 0;
- __malloc_hook = 0;
- if (!pointer_table)
- pointer_table = make_hash_table (max (100, FREE_QUEUE_LIMIT * 2));
- if (ptr != 0)
- {
- long size;
-#ifdef UNMAPPED_FREE
- unsigned long rounded_up_size;
-#endif
-
- EMACS_INT present = (EMACS_INT) gethash (ptr, pointer_table,
- (const void **)
- (void *) &size);
-
- if (!present)
- {
- /* This can only happen if you try to free something that didn't
- come from malloc */
-#if !defined(__linux__)
- /* I originally wrote: "There's really no need to drop core."
- I have seen the error of my ways. -slb */
- assert (!strict_free_check);
-#endif
- printf("Freeing unmalloc'ed memory at %p\n", ptr);
- __free_hook = check_free;
- __malloc_hook = check_malloc;
- goto end;
- }
-
- if (size < 0)
- {
- /* This happens when you free twice */
-#if !defined(__linux__)
- /* See above comment. */
- assert (!strict_free_check);
-#endif
- printf("Freeing %p twice\n", ptr);
- __free_hook = check_free;
- __malloc_hook = check_malloc;
- goto end;
- }
-
- puthash (ptr, (void *)-size, pointer_table);
-#ifdef UNMAPPED_FREE
- /* Round up size to an even number of pages. */
- rounded_up_size = ROUND_UP_TO_PAGE (size);
- /* Protect the pages freed from all access */
- if (strict_free_check)
- mprotect (ptr, rounded_up_size, PROT_NONE);
-#else
- /* Set every word in the block to 0xDEADBEEF */
- if (strict_free_check)
- {
- unsigned long long_length = (size + (sizeof (long) - 1))
- / sizeof (long);
- unsigned long i;
-
- /* Not using the DEADBEEF_CONSTANT #define, since we don't know
- * that allocation sizes will be multiples of eight. */
- for (i = 0; i < long_length; i++)
- ((unsigned long *) ptr)[i] = 0xDEADBEEF;
- }
-#endif
- free_queue[current_free].address = ptr;
- free_queue[current_free].length = size;
-
- current_free++;
- if (current_free >= FREE_QUEUE_LIMIT)
- current_free = 0;
- /* Really free this if there's something there */
- {
- void *old = free_queue[current_free].address;
-
- if (old)
- {
-#ifdef UNMAPPED_FREE
- unsigned long old_len = free_queue[current_free].length;
-
- mprotect (old, old_len, PROT_READ | PROT_WRITE | PROT_EXEC);
-#endif
- free (old);
- remhash (old, pointer_table);
- }
- }
- }
- __free_hook = check_free;
- __malloc_hook = check_malloc;
-
- end:
- return;
-}
-
-static void *
-check_malloc (size_t size)
-{
- size_t rounded_up_size;
- void *result;
-
- __free_hook = 0;
- __malloc_hook = 0;
- if (size == 0)
- {
- result = 0;
- goto end;
- }
-#ifdef UNMAPPED_FREE
- /* Round up to an even number of pages. */
- rounded_up_size = ROUND_UP_TO_PAGE (size);
-#else
- rounded_up_size = size;
-#endif
- result = malloc (rounded_up_size);
- if (!pointer_table)
- pointer_table = make_hash_table (FREE_QUEUE_LIMIT * 2);
- puthash (result, (void *)size, pointer_table);
- __free_hook = check_free;
- __malloc_hook = check_malloc;
- end:
- return result;
-}
-
-extern void *(*__realloc_hook) (void *, size_t);
-
-#ifdef MIN
-#undef MIN
-#endif
-#define MIN(A, B) ((A) < (B) ? (A) : (B))
-
-/* Don't optimize realloc */
-
-static void *
-check_realloc (void * ptr, size_t size)
-{
- EMACS_INT present;
- size_t old_size;
- void *result = malloc (size);
-
- if (!ptr) return result;
- present = (EMACS_INT) gethash (ptr, pointer_table, (const void **) &old_size);
- if (!present)
- {
- /* This can only happen by reallocing a pointer that didn't
- come from malloc. */
-#if !defined(__linux__)
- /* see comment in check_free(). */
- ABORT ();
-#endif
- printf("Realloc'ing unmalloc'ed pointer at %p\n", ptr);
- }
-
- if (result == 0)
- goto end;
- memcpy (result, ptr, MIN (size, old_size));
- free (ptr);
- end:
- return result;
-}
-
-void enable_strict_free_check (void);
-void
-enable_strict_free_check (void)
-{
- strict_free_check = 1;
-}
-
-void disable_strict_free_check (void);
-void
-disable_strict_free_check (void)
-{
- strict_free_check = 0;
-}
-
-/* Note: All BLOCK_INPUT stuff removed from this file because it's
- completely gone in XEmacs */
-
-static void *
-block_input_malloc (size_t size);
-
-static void
-block_input_free (void* ptr)
-{
- __free_hook = 0;
- __malloc_hook = 0;
- free (ptr);
- __free_hook = block_input_free;
- __malloc_hook = block_input_malloc;
-}
-
-static void *
-block_input_malloc (size_t size)
-{
- void* result;
- __free_hook = 0;
- __malloc_hook = 0;
- result = malloc (size);
- __free_hook = block_input_free;
- __malloc_hook = block_input_malloc;
- return result;
-}
-
-
-static void *
-block_input_realloc (void* ptr, size_t size)
-{
- void* result;
- __free_hook = 0;
- __malloc_hook = 0;
- __realloc_hook = 0;
- result = realloc (ptr, size);
- __free_hook = block_input_free;
- __malloc_hook = block_input_malloc;
- __realloc_hook = block_input_realloc;
- return result;
-}
-
-#ifdef emacs
-
-void disable_free_hook (void);
-void
-disable_free_hook (void)
-{
- __free_hook = block_input_free;
- __malloc_hook = block_input_malloc;
- __realloc_hook = block_input_realloc;
-}
-
-void
-init_free_hook (void)
-{
- __free_hook = check_free;
- __malloc_hook = check_malloc;
- __realloc_hook = check_realloc;
- current_free = 0;
- strict_free_check = 1;
-}
-
-void really_free_one_entry (void *, int, int *);
-
-DEFUN ("really-free", Freally_free, 0, 1, "P", /*
-Actually free the storage held by the free() debug hook.
-A no-op if the free hook is disabled.
-*/
- (UNUSED (arg)))
-{
- int count[2];
- Lisp_Object lisp_count[2];
-
- if ((__free_hook != 0) && pointer_table)
- {
- count[0] = 0;
- count[1] = 0;
- __free_hook = 0;
- maphash ((maphash_function)really_free_one_entry,
- pointer_table, (void *)&count);
- memset (free_queue, 0, sizeof (free_queue_entry) * FREE_QUEUE_LIMIT);
- current_free = 0;
- __free_hook = check_free;
- lisp_count[0] = make_fixnum (count[0]);
- lisp_count[1] = make_fixnum (count[1]);
- return Fcons (lisp_count[0], lisp_count[1]);
- }
- else
- return Fcons (make_fixnum (0), make_fixnum (0));
-}
-
-void
-really_free_one_entry (void *key, int contents, int *countp)
-{
- if (contents < 0)
- {
- free (key);
-#ifdef UNMAPPED_FREE
- mprotect (key, -contents, PROT_READ | PROT_WRITE | PROT_EXEC);
-#endif
- remhash (key, pointer_table);
- countp[0]++;
- countp[1] += -contents;
- }
-}
-
-void
-syms_of_free_hook (void)
-{
- DEFSUBR (Freally_free);
-}
-
-#else
-void (*__free_hook)(void *) = check_free;
-void *(*__malloc_hook)(size_t) = check_malloc;
-void *(*__realloc_hook)(void *, size_t) = check_realloc;
-#endif
-
-#endif /* !defined(HAVE_LIBMCHECK) */
+/* This file used to include debugging hooks for malloc(), back when we
+ shipped our own copy of gmalloc.c. Now we just use the system malloc, and
+ this file has code to debug GCPROs. */
#if defined(DEBUG_INPUT_BLOCKING) || defined (DEBUG_GCPRO)
diff -r c129b2eb4cf991ce0b541b0490b86f9fbe55f56e -r
3b1ef8c61ffe707960e449c29f1b06b4e96499f3 src/gc.h
--- a/src/gc.h
+++ b/src/gc.h
@@ -84,7 +84,7 @@
/************************************************************************/
#ifndef MALLOC_OVERHEAD
-#ifndef SYSTEM_MALLOC
+#ifdef _GNU_SOURCE
#define MALLOC_OVERHEAD 0
#elif defined (rcheck)
#define MALLOC_OVERHEAD 20
This diff is so big that we needed to truncate the remainder.
https://bitbucket.org/xemacs/xemacs/commits/443cffbae274/
Changeset: 443cffbae274
User: kehoea
Date: 2017-11-23 06:21:28+00:00
Summary: _GNU_SOURCE isn't specific enough for glibc, provide HAVE_GLIBC instead
ChangeLog addition:
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
* configure.ac (XE_COMPLEX_ARG):
Make a HAVE_GLIBC #define available, turns out autoconf is too
enthusiastic about _GNU_SOURCE, #defining it even on non-glibc
systems.
* configure: Regenerate.
src/ChangeLog addition:
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
* config.h.in:
Provide HAVE_GLIBC, since _GNU_SOURCE isn't specific enough to
glibc.
* alloc.c:
* alloc.c (malloced_storage_size):
* alloc.c (common_init_alloc_early):
* emacs.c:
* emacs.c (main):
* gc.h:
* ralloc.c:
* ralloc.c (init_ralloc):
Use the new HAVE_GLIBC define in these files, instead of _GNU_SOURCE.
Affected #: 9 files
diff -r 3b1ef8c61ffe707960e449c29f1b06b4e96499f3 -r
443cffbae274ea3343c00812661255855a54296b ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * configure.ac (XE_COMPLEX_ARG):
+ Make a HAVE_GLIBC #define available, turns out autoconf is too
+ enthusiastic about _GNU_SOURCE, #defining it even on non-glibc
+ systems.
+ * configure: Regenerate.
+
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
* configure.ac (XE_COMPLEX_ARG):
diff -r 3b1ef8c61ffe707960e449c29f1b06b4e96499f3 -r
443cffbae274ea3343c00812661255855a54296b configure
--- a/configure
+++ b/configure
@@ -825,7 +825,6 @@
docdir
oldincludedir
includedir
-runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -1106,7 +1105,6 @@
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1359,15 +1357,6 @@
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
- -runstatedir | --runstatedir | --runstatedi | --runstated \
- | --runstate | --runstat | --runsta | --runst | --runs \
- | --run | --ru | --r)
- ac_prev=runstatedir ;;
- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
- | --run=* | --ru=* | --r=*)
- runstatedir=$ac_optarg ;;
-
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1505,7 +1494,7 @@
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir runstatedir
+ libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1658,7 +1647,6 @@
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -9189,8 +9177,12 @@
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_glibc" >&5
$as_echo "$have_glibc" >&6; }
-test "$have_glibc" = "yes" && $as_echo "#define
_GNU_SOURCE 1" >>confdefs.h
-
+if test "$have_glibc" = "yes"; then
+ $as_echo "#define HAVE_GLIBC 1" >>confdefs.h
+
+ $as_echo "#define _GNU_SOURCE 1" >>confdefs.h
+
+fi
case "$opsys" in
sol2)
@@ -11781,7 +11773,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31)
<< 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -11827,7 +11819,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31)
<< 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -11851,7 +11843,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31)
<< 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -11896,7 +11888,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31)
<< 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -11920,7 +11912,7 @@
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31)
<< 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
diff -r 3b1ef8c61ffe707960e449c29f1b06b4e96499f3 -r
443cffbae274ea3343c00812661255855a54296b configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1673,7 +1673,13 @@
AC_MSG_RESULT($have_glibc)
dnl I'm tired of pop being broken with GLIBC -slb
dnl Well. then why not fix fucking pop?
-test "$have_glibc" = "yes" && AC_DEFINE(_GNU_SOURCE)
+if test "$have_glibc" = "yes"; then
+ dnl Defining _GNU_SOURCE on its own isn't helpful, since autoconf is very
+ dnl enthusiastic about defining it on non-GNU systems. Make a separate
+ dnl HAVE_GLIBC available.
+ AC_DEFINE(HAVE_GLIBC)
+ AC_DEFINE(_GNU_SOURCE)
+fi
dnl We'd like to use vendor extensions, where available.
dnl We'd like to use functions from the latest Unix98 standards.
diff -r 3b1ef8c61ffe707960e449c29f1b06b4e96499f3 -r
443cffbae274ea3343c00812661255855a54296b src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,18 @@
+2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * config.h.in:
+ Provide HAVE_GLIBC, since _GNU_SOURCE isn't specific enough to
+ glibc.
+ * alloc.c:
+ * alloc.c (malloced_storage_size):
+ * alloc.c (common_init_alloc_early):
+ * emacs.c:
+ * emacs.c (main):
+ * gc.h:
+ * ralloc.c:
+ * ralloc.c (init_ralloc):
+ Use the new HAVE_GLIBC define in these files, instead of _GNU_SOURCE.
+
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
* gmalloc.c: Removed. Use the system malloc all the time instead.
diff -r 3b1ef8c61ffe707960e449c29f1b06b4e96499f3 -r
443cffbae274ea3343c00812661255855a54296b src/alloc.c
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -66,7 +66,7 @@
#endif /* NEW_GC */
#include "console-stream.h"
-#ifdef _GNU_SOURCE
+#ifdef HAVE_GLIBC
#include <malloc.h>
#endif
#ifdef USE_VALGRIND
@@ -220,7 +220,7 @@
}
}
-#if !defined(HAVE_MMAP) || defined(_GNU_SOURCE)
+#if !defined(HAVE_MMAP) || defined(HAVE_GLIBC)
/* 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.
@@ -233,7 +233,7 @@
if (breathing_space == 0)
breathing_space = (char *) malloc (4096 - MALLOC_OVERHEAD);
}
-#endif /* !defined(HAVE_MMAP) || defined(_GNU_SOURCE) */
+#endif /* !defined(HAVE_MMAP) || defined(HAVE_GLIBC) */
#endif /* not NEW_GC */
@@ -4051,7 +4051,7 @@
{
Bytecount orig_claimed_size = claimed_size;
-#ifdef _GNU_SOURCE
+#ifdef HAVE_GLIBC
/* The following actually reflects the old gmalloc.c that we included with
XEmacs. The malloc implementation included in glibc has likely diverged
from this, but this answer is still going to be better than the
@@ -5960,7 +5960,7 @@
all_lcrecords = 0;
#endif /* not NEW_GC */
ignore_malloc_warnings = 1;
-#ifdef _GNU_SOURCE
+#ifdef HAVE_GLIBC
mallopt (M_TRIM_THRESHOLD, 128*1024); /* trim threshold */
mallopt (M_MMAP_THRESHOLD, 64*1024); /* mmap threshold */
#if 0 /* Moved to emacs.c */
diff -r 3b1ef8c61ffe707960e449c29f1b06b4e96499f3 -r
443cffbae274ea3343c00812661255855a54296b src/config.h.in
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -151,6 +151,9 @@
/* Undefine on systems which don't have processes */
#undef HAVE_UNIX_PROCESSES
+/* Use this define to actually check if this is a glibc system. */
+#undef HAVE_GLIBC
+
/* Define if you are using libmcheck.a from the GNU C Library. */
#undef HAVE_LIBMCHECK
diff -r 3b1ef8c61ffe707960e449c29f1b06b4e96499f3 -r
443cffbae274ea3343c00812661255855a54296b src/emacs.c
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -476,9 +476,9 @@
on subsequent starts. */
int initialized;
-#ifdef _GNU_SOURCE
+#ifdef HAVE_GLIBC
# include <malloc.h>
-#endif /* _GNU_SOURCE */
+#endif /* HAVE_GLIBC */
/* Variable whose value is symbol giving operating system type. */
Lisp_Object Vsystem_type;
@@ -3189,7 +3189,7 @@
if (!initialized)
{
-#ifdef _GNU_SOURCE
+#ifdef HAVE_GLIBC
mallopt (M_MMAP_MAX, 0);
#endif
run_temacs_argc = 0;
@@ -3229,7 +3229,7 @@
run_time_remap (argv[0]);
#endif
-#ifdef _GNU_SOURCE
+#ifdef HAVE_GLIBC
if (initialized)
{
/* mmap works in glibc-2.1, glibc-2.0 (Non-Mule only) and Linux libc5 */
@@ -3239,7 +3239,7 @@
mallopt (M_MMAP_MAX, 64);
#endif
}
-#endif /* _GNU_SOURCE */
+#endif /* HAVE_GLIBC */
run_temacs_argc = -2;
diff -r 3b1ef8c61ffe707960e449c29f1b06b4e96499f3 -r
443cffbae274ea3343c00812661255855a54296b src/gc.h
--- a/src/gc.h
+++ b/src/gc.h
@@ -84,7 +84,7 @@
/************************************************************************/
#ifndef MALLOC_OVERHEAD
-#ifdef _GNU_SOURCE
+#ifdef HAVE_GLIBC
#define MALLOC_OVERHEAD 0
#elif defined (rcheck)
#define MALLOC_OVERHEAD 20
diff -r 3b1ef8c61ffe707960e449c29f1b06b4e96499f3 -r
443cffbae274ea3343c00812661255855a54296b src/ralloc.c
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -51,7 +51,7 @@
/* Unconditionally use unsigned char * for this. */
typedef unsigned char *POINTER;
-#ifdef _GNU_SOURCE
+#ifdef HAVE_GLIBC
#define M_TOP_PAD -2
#include <malloc.h>
#endif
@@ -1122,7 +1122,7 @@
page_size = PAGE;
extra_bytes = ROUNDUP (50000);
-#ifdef _GNU_SOURCE
+#ifdef HAVE_GLIBC
mallopt (M_TOP_PAD, 64 * 4096);
#else
#if 0 /* Hasn't been synched yet */
https://bitbucket.org/xemacs/xemacs/commits/e02d10a9c9c8/
Changeset: e02d10a9c9c8
User: kehoea
Date: 2017-11-23 06:27:49+00:00
Summary: Fix some mmap() compatibility problems on OSX.
ChangeLog addition:
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
* configure.ac (XE_COMPLEX_ARG):
[...]
Accept MAP_ANON, a BSDism, as an alias for MAP_ANONYMOUS here.
Remove a caddr_t variable, this type is long obsolete and the
variable was unused.
* configure: Regenerate.
src/ChangeLog addition:
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
[...]
* ralloc.c:
* ralloc.c (MAP_FLAGS):
* unexelf.c (unexec):
caddr_t is long deprecated, use void * instead when calling
mmap().
Accept MAP_ANON, an old BSDism, as an alias for MAP_ANONYMOUS.
Affected #: 6 files
diff -r 443cffbae274ea3343c00812661255855a54296b -r
e02d10a9c9c805b9d5253f0cef5301927fb01c0f ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,10 @@
Make a HAVE_GLIBC #define available, turns out autoconf is too
enthusiastic about _GNU_SOURCE, #defining it even on non-glibc
systems.
+
+ Accept MAP_ANON, a BSDism, as an alias for MAP_ANONYMOUS here.
+ Remove a caddr_t variable, this type is long obsolete and the
+ variable was unused.
* configure: Regenerate.
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
diff -r 443cffbae274ea3343c00812661255855a54296b -r
e02d10a9c9c805b9d5253f0cef5301927fb01c0f configure
--- a/configure
+++ b/configure
@@ -19126,7 +19126,9 @@
int main (int argc, char **argv)
{
int fd = -1;
- caddr_t p;
+#ifdef MAP_ANON
+#define MAP_ANONYMOUS MAP_ANON
+#endif
#ifndef MAP_ANONYMOUS
fd = open ("/dev/zero", O_RDWR);
if (fd < 0)
diff -r 443cffbae274ea3343c00812661255855a54296b -r
e02d10a9c9c805b9d5253f0cef5301927fb01c0f configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -4831,7 +4831,9 @@
int main (int argc, char **argv)
{
int fd = -1;
- caddr_t p;
+#ifdef MAP_ANON
+#define MAP_ANONYMOUS MAP_ANON
+#endif
#ifndef MAP_ANONYMOUS
fd = open ("/dev/zero", O_RDWR);
if (fd < 0)
diff -r 443cffbae274ea3343c00812661255855a54296b -r
e02d10a9c9c805b9d5253f0cef5301927fb01c0f src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -12,6 +12,12 @@
* ralloc.c:
* ralloc.c (init_ralloc):
Use the new HAVE_GLIBC define in these files, instead of _GNU_SOURCE.
+ * ralloc.c:
+ * ralloc.c (MAP_FLAGS):
+ * unexelf.c (unexec):
+ caddr_t is long deprecated, use void * instead when calling
+ mmap().
+ Accept MAP_ANON, an old BSDism, as an alias for MAP_ANONYMOUS.
2017-11-23 Aidan Kehoe <kehoea(a)parhasard.net>
diff -r 443cffbae274ea3343c00812661255855a54296b -r
e02d10a9c9c805b9d5253f0cef5301927fb01c0f src/ralloc.c
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -1248,6 +1248,10 @@
# define MAP_ADDRCHOICE_FLAG 0
#endif /* MAP_ADDRCHOICE_FLAG */
+#ifdef MAP_ANON
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
#ifdef MAP_ANONYMOUS
# define MAP_FLAGS (MAP_PRIVATE | MAP_ADDRCHOICE_FLAG | MAP_ANONYMOUS)
#else
@@ -1708,7 +1712,7 @@
static void
Free_Addr_Block (VM_ADDR addr, size_t sz)
{
- munmap ((caddr_t) addr, sz );
+ munmap ((void *) addr, sz );
}
#endif /* MMAP_GENERATE_ADDRESSES */
diff -r 443cffbae274ea3343c00812661255855a54296b -r
e02d10a9c9c805b9d5253f0cef5301927fb01c0f src/unexelf.c
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -569,7 +569,7 @@
int new_file, old_file, new_file_size;
/* Pointers to the base of the image of the two files. */
- caddr_t old_base, new_base;
+ void *old_base, *new_base;
/* Pointers to the file, program and section headers for the old and new
* files.
@@ -600,9 +600,10 @@
if (fstat (old_file, &stat_buf) == -1)
fatal ("Can't fstat (%s): errno %d\n", old_name, errno);
- old_base = (caddr_t) mmap (0, stat_buf.st_size, PROT_READ, MAP_SHARED, old_file, 0);
+ old_base = (void *) mmap (0, stat_buf.st_size, PROT_READ, MAP_SHARED,
+ old_file, 0);
- if (old_base == (caddr_t) -1)
+ if (old_base == (void *) -1)
fatal ("Can't mmap (%s): errno %d\n", old_name, errno);
#ifdef DEBUG
@@ -727,7 +728,7 @@
if (ftruncate (new_file, new_file_size))
fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno);
- new_base = (caddr_t) mmap (0, new_file_size, PROT_READ | PROT_WRITE,
+ new_base = (void *) mmap (0, new_file_size, PROT_READ | PROT_WRITE,
#ifdef UNEXEC_USE_MAP_PRIVATE
MAP_PRIVATE,
#else
@@ -735,7 +736,7 @@
#endif
new_file, 0);
- if (new_base == (caddr_t) -1)
+ if (new_base == (void *) -1)
fatal ("Can't mmap (%s): errno %d\n", new_name, errno);
new_file_h = (ElfW(Ehdr) *) new_base;
@@ -841,7 +842,7 @@
before the new bss section. */
for (n = 1, nn = 1; n < (int) old_file_h->e_shnum; n++, nn++)
{
- caddr_t src;
+ void * src;
/* If it is (s)bss section, insert the new data2 section before it. */
/* new_data2_index is the index of either old_sbss or old_bss, that was
chosen as a section for new_data2. */
@@ -861,7 +862,7 @@
/* Now copy over what we have in the memory now. */
memcpy (NEW_SECTION_H (nn).sh_offset + new_base,
- (caddr_t) OLD_SECTION_H (n).sh_addr,
+ (void *) OLD_SECTION_H (n).sh_addr,
new_data2_size);
nn++;
}
@@ -952,7 +953,7 @@
".sdata1")
|| !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
".data1"))
- src = (caddr_t) OLD_SECTION_H (n).sh_addr;
+ src = (void *) OLD_SECTION_H (n).sh_addr;
else
src = old_base + OLD_SECTION_H (n).sh_offset;
@@ -1134,7 +1135,7 @@
{
ElfW(Addr) offset = NEW_SECTION_H (nn).sh_addr -
NEW_SECTION_H (nn).sh_offset;
- caddr_t reloc = old_base + section.sh_offset, end;
+ void *reloc = old_base + section.sh_offset, end;
for (end = reloc + section.sh_size; reloc < end;
reloc += section.sh_entsize)
{
Repository URL:
https://bitbucket.org/xemacs/xemacs/
--
This is a commit notification from
bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.