From d2cfef1bb74e905f85dab23f3b1dfcf474eb6568 Mon Sep 17 00:00:00 2001 From: Nelson Ferreira Date: Sun, 6 Dec 2015 16:46:36 -0500 Subject: [PATCH] Turn off warning about deprecated usage of __free_hook. Since this is to try and avoid crashes on shutdown, it will either be available and work, or linking will fail, which will be detected by configure, and thus we will not use it. * configure.ac: Add HAVE_FREE_HOOK when __free_hook is available. Also fix detection of __after_morecore_hook. * src/emacs.c (voodoo_free_hook): Ignore the warning about deprecated variable. * src/emacs.c (Fkill_emacs): Ditto. Signed-off-by: Nelson Ferreira --- configure.ac | 22 +++++++++++++++++++++- src/emacs.c | 16 ++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 51f6041..de6d160 100644 --- a/configure.ac +++ b/configure.ac @@ -1740,10 +1740,30 @@ fi after_morecore_hook_exists=yes AC_CHECK_FUNC(malloc_set_state, ,doug_lea_malloc=no) AC_MSG_CHECKING(whether __after_morecore_hook exists) -AC_LINK_IFELSE([AC_LANG_SOURCE([[extern void (* __after_morecore_hook)();],[__after_morecore_hook = 0]])], +AC_LINK_IFELSE([AC_LANG_SOURCE([ + [extern void (* __after_morecore_hook)();] + [main() {__after_morecore_hook = 0;}] + ])], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) after_morecore_hook_exists=no]) +if test "$after_morecore_hook_exists" = "yes" ; then + AC_DEFINE([HAVE_MORECORE_HOOK], [1], [Define if __after_morecore_hook is available]) +fi +AC_SUBST(HAVE_MORECORE_HOOK) +free_hook_exists=yes +AC_MSG_CHECKING(whether __free_hook exists) +AC_LINK_IFELSE([AC_LANG_SOURCE([ + [extern void (* __free_hook)();] + [main() {__free_hook = 0;}] + ])], + [AC_MSG_RESULT(yes)], + [AC_MSG_RESULT(no) + free_hook_exists=no]) +if test "$free_hook_exists" = "yes" ; then + AC_DEFINE([HAVE_FREE_HOOK], [1], [Define if __free_hook is available]) +fi +AC_SUBST(HAVE_FREE_HOOK) if test "$system_malloc" = "yes" ; then GNU_MALLOC=no GNU_MALLOC_reason=" diff --git a/src/emacs.c b/src/emacs.c index 04f9664..49fa20d 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2778,8 +2778,15 @@ main(int argc, char **argv, char **envp) /* various system shared libraries have been built and linked with */ /* GCC >= 2.8. -slb */ #if defined(GNU_MALLOC) +#if defined(HAVE_MORECORE_HOOK) static void voodoo_free_hook(void *mem) { + /* If it no longer works, we'll know about it. For now there is really no + good alternatic. Shut the warning off + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + /* Disable all calls to free() when SXEmacs is exiting and it doesn't */ /* matter. */ __free_hook = @@ -2788,7 +2795,9 @@ static void voodoo_free_hook(void *mem) (__typeof__(__free_hook)) #endif voodoo_free_hook; +#pragma GCC diagnostic pop } +#endif #endif /* GNU_MALLOC */ DEFUN("kill-emacs", Fkill_emacs, 0, 1, "P", /* @@ -2843,12 +2852,17 @@ all of which are called before SXEmacs is actually killed. shut_down_emacs(0, STRINGP(arg) ? arg : Qnil, 0); #if defined(GNU_MALLOC) +#if defined(HAVE_MORECORE_HOOK) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" __free_hook = #if defined __GNUC__ || defined __INTEL_COMPILER /* prototype of __free_hook varies with glibc version */ (__typeof__(__free_hook)) #endif voodoo_free_hook; +#pragma GCC diagnostic pop +#endif #endif exit(INTP(arg) ? XINT(arg) : 0); @@ -3214,6 +3228,8 @@ static int assertions_dont_abort = 0; #define enter_debugger() +void debug_backtrace(); + void assert_failed(const char *file, int line, const char *expr) { -- 2.25.1