Subject: bug#22086: 25.1.50; [PATCH] Integrate the musl hybrid mallo

From: Paul Eggert <[email-masked]>
Date: Sun, 31 Jan 2016 09:54:26 -0800

Wolfgang Jenkner wrote:

> Thanks, I think patch 5 of my OP (for turning off direct use of mmap for
> buffer allocations on FreeBSD) should also be applied.

Sorry, I missed that one. I don't recall why it's needed but I'll take your word 
for it. Done.

> /usr/opt/src/emacs-paul-test/src/gmalloc.c:440: undefined reference to `__after_morecore_hook'
> ...
> /usr/opt/src/emacs-paul-test/src/gmalloc.c:553: undefined reference to `__malloc_initialize_hook'

I installed the attached patch to try to fix these; please give it a try.

>From 1005257b104d2dac80479eac2c98246ad29147ec Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sun, 31 Jan 2016 09:50:07 -0800
Subject: [PATCH] Port new hybrid malloc to FreeBSD

Problem reported by Wolfgang Jenkner in: http://bugs.gnu.org/22086#118
* src/gmalloc.c (__malloc_initialize_hook, __after_morecore_hook)
(__morecore) [HYBRID_MALLOC]: Define in this case too.
---
 src/gmalloc.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/gmalloc.c b/src/gmalloc.c
index 282216a..0b76aee 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -321,6 +321,13 @@ License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 /* Debugging hook for 'malloc'.  */
 static void *(*__MALLOC_HOOK_VOLATILE gmalloc_hook) (size_t);
 
+/* Replacements for traditional glibc malloc hooks, for platforms that
+   do not already have these hooks.  Platforms with these hooks all
+   used relaxed ref/def, so it is OK to define them here too.  */
+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.  */
@@ -347,10 +354,6 @@ size_t _bytes_free;
 /* Are you experienced?  */
 int __malloc_initialized;
 
-void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void);
-void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);
-void *(*__morecore) (ptrdiff_t);
-
 #else
 
 static struct list _fraghead[BLOCKLOG];
-- 
2.5.0