From 34779914400988922d36815b7085893fbcc89a2e Mon Sep 17 00:00:00 2001
From: Jason Evans <je@fb.com>
Date: Fri, 13 Dec 2013 15:07:43 -0800
Subject: Fix name mangling issues.

Move je_* definitions from jemalloc_macros.h.in to jemalloc_defs.h.in,
because only the latter is an autoconf header (#undef substitution
occurs).

Fix unit tests to use automatic mangling, so that e.g. mallocx is
macro-substituted to becom jet_mallocx.
---
 include/jemalloc/jemalloc_defs.h.in   | 34 ++++++++++++++++++++++++++++++++++
 include/jemalloc/jemalloc_macros.h.in | 34 ----------------------------------
 test/include/test/jemalloc_test.h.in  |  1 +
 test/unit/mq.c                        |  4 ++--
 4 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/include/jemalloc/jemalloc_defs.h.in b/include/jemalloc/jemalloc_defs.h.in
index eb38d71..71e23af 100644
--- a/include/jemalloc/jemalloc_defs.h.in
+++ b/include/jemalloc/jemalloc_defs.h.in
@@ -22,3 +22,37 @@
 
 /* sizeof(void *) == 2^LG_SIZEOF_PTR. */
 #undef LG_SIZEOF_PTR
+
+/*
+ * Name mangling for public symbols is controlled by --with-mangling and
+ * --with-jemalloc-prefix.  With default settings the je_ prefix is stripped by
+ * these macro definitions.
+ */
+#ifndef JEMALLOC_NO_RENAME
+#  undef je_malloc_conf
+#  undef je_malloc_message
+#  undef je_malloc
+#  undef je_calloc
+#  undef je_posix_memalign
+#  undef je_aligned_alloc
+#  undef je_realloc
+#  undef je_free
+#  undef je_mallocx
+#  undef je_rallocx
+#  undef je_xallocx
+#  undef je_sallocx
+#  undef je_dallocx
+#  undef je_nallocx
+#  undef je_mallctl
+#  undef je_mallctlnametomib
+#  undef je_mallctlbymib
+#  undef je_malloc_stats_print
+#  undef je_malloc_usable_size
+#  undef je_memalign
+#  undef je_valloc
+#  undef je_allocm
+#  undef je_rallocm
+#  undef je_sallocm
+#  undef je_dallocm
+#  undef je_nallocm
+#endif
diff --git a/include/jemalloc/jemalloc_macros.h.in b/include/jemalloc/jemalloc_macros.h.in
index 9773bcb..13dbdd9 100644
--- a/include/jemalloc/jemalloc_macros.h.in
+++ b/include/jemalloc/jemalloc_macros.h.in
@@ -36,40 +36,6 @@
 #  define ALLOCM_ERR_NOT_MOVED	2
 #endif
 
-/*
- * Name mangling for public symbols is controlled by --with-mangling and
- * --with-jemalloc-prefix.  With default settings the je_ prefix is stripped by
- * these macro definitions.
- */
-#ifndef JEMALLOC_NO_RENAME
-#  undef je_malloc_conf
-#  undef je_malloc_message
-#  undef je_malloc
-#  undef je_calloc
-#  undef je_posix_memalign
-#  undef je_aligned_alloc
-#  undef je_realloc
-#  undef je_free
-#  undef je_mallocx
-#  undef je_rallocx
-#  undef je_xallocx
-#  undef je_sallocx
-#  undef je_dallocx
-#  undef je_nallocx
-#  undef je_mallctl
-#  undef je_mallctlnametomib
-#  undef je_mallctlbymib
-#  undef je_malloc_stats_print
-#  undef je_malloc_usable_size
-#  undef je_memalign
-#  undef je_valloc
-#  undef je_allocm
-#  undef je_rallocm
-#  undef je_sallocm
-#  undef je_dallocm
-#  undef je_nallocm
-#endif
-
 #ifdef JEMALLOC_HAVE_ATTR
 #  define JEMALLOC_ATTR(s) __attribute__((s))
 #  define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default"))
diff --git a/test/include/test/jemalloc_test.h.in b/test/include/test/jemalloc_test.h.in
index 9f7dfa4..38db000 100644
--- a/test/include/test/jemalloc_test.h.in
+++ b/test/include/test/jemalloc_test.h.in
@@ -64,6 +64,7 @@
  */
 #ifdef JEMALLOC_UNIT_TEST
 #  define JEMALLOC_JET
+#  define JEMALLOC_MANGLE
 #  include "jemalloc/internal/jemalloc_internal.h"
 
 /******************************************************************************/
diff --git a/test/unit/mq.c b/test/unit/mq.c
index e6cba10..f57e96a 100644
--- a/test/unit/mq.c
+++ b/test/unit/mq.c
@@ -39,7 +39,7 @@ thd_receiver_start(void *arg)
 	for (i = 0; i < (NSENDERS * NMSGS); i++) {
 		mq_msg_t *msg = mq_get(mq);
 		assert_ptr_not_null(msg, "mq_get() should never return NULL");
-		jet_dallocx(msg, 0);
+		dallocx(msg, 0);
 	}
 	return (NULL);
 }
@@ -53,7 +53,7 @@ thd_sender_start(void *arg)
 	for (i = 0; i < NMSGS; i++) {
 		mq_msg_t *msg;
 		void *p;
-		p = jet_mallocx(sizeof(mq_msg_t), 0);
+		p = mallocx(sizeof(mq_msg_t), 0);
 		assert_ptr_not_null(p, "Unexpected allocm() failure");
 		msg = (mq_msg_t *)p;
 		mq_put(mq, msg);
-- 
cgit v0.12