Add --with-mangling.

Add the --with-mangling configure option, which can be used to specify
name mangling on a per public symbol basis that takes precedence over
--with-jemalloc-prefix.

Expose the memalign() and valloc() overrides even if
--with-jemalloc-prefix is specified.  This change does no real harm, and
simplifies the code.
diff --git a/INSTALL b/INSTALL
index 4d3e1af..6e32d71 100644
--- a/INSTALL
+++ b/INSTALL
@@ -26,6 +26,19 @@
     Embed one or more library paths, so that libjemalloc can find the libraries
     it is linked to.  This works only on ELF-based systems.
 
+--with-mangling=<map>
+    Mangle public symbols specified in <map> which is a comma-separated list of
+    name:mangled pairs.
+
+    For example, to use ld's --wrap option as an alternative method for
+    overriding libc's malloc implementation, specify something like:
+
+      --with-mangling=malloc:__wrap_malloc,free:__wrap_free[...]
+
+    Note that mangling happens prior to application of the prefix specified by
+    --with-jemalloc-prefix, and mangled symbols are then ignored when applying
+    the prefix.
+
 --with-jemalloc-prefix=<prefix>
     Prefix all public APIs with <prefix>.  For example, if <prefix> is
     "prefix_", API changes like the following occur:
diff --git a/configure.ac b/configure.ac
index b503f64..81ab233 100644
--- a/configure.ac
+++ b/configure.ac
@@ -303,6 +303,16 @@
 AC_PATH_PROG([LD], [ld], , [$PATH])
 AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH])
 
+dnl Perform no name mangling by default.
+AC_ARG_WITH([mangling],
+  [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
+  [mangling_map="$with_mangling"], [mangling_map=""])
+for nm in `echo ${mangling_map} |tr ',' ' '` ; do
+  n="je_`echo ${nm} |tr ':' ' ' |awk '{print $1}'`"
+  m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'`
+  AC_DEFINE_UNQUOTED([${n}], [${m}])
+done
+
 dnl Do not prefix public APIs by default.
 AC_ARG_WITH([jemalloc_prefix],
   [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
@@ -317,8 +327,15 @@
   JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
   AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
   AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
-  AC_DEFINE_UNQUOTED([JEMALLOC_P(string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix)], [${JEMALLOC_PREFIX}##string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix])
 fi
+dnl Generate macros to rename public symbols.  All public symbols are prefixed
+dnl with je_ in the source code, so these macro definitions are needed even if
+dnl --with-jemalloc-prefix wasn't specified.
+for stem in malloc_conf malloc_message malloc calloc posix_memalign realloc free malloc_usable_size malloc_stats_print mallctl mallctlnametomib mallctlbymib memalign valloc allocm dallocm nallocm rallocm sallocm; do
+  n="je_${stem}"
+  m="${JEMALLOC_PREFIX}${stem}"
+  AC_DEFINE_UNQUOTED([${n}], [${m}])
+done
 
 dnl Do not mangle library-private APIs by default.
 AC_ARG_WITH([private_namespace],
diff --git a/include/jemalloc/internal/ctl.h b/include/jemalloc/internal/ctl.h
index 28be2ae..8f72f7f 100644
--- a/include/jemalloc/internal/ctl.h
+++ b/include/jemalloc/internal/ctl.h
@@ -74,7 +74,7 @@
 bool	ctl_boot(void);
 
 #define	xmallctl(name, oldp, oldlenp, newp, newlen) do {		\
-	if (JEMALLOC_P(mallctl)(name, oldp, oldlenp, newp, newlen)	\
+	if (je_mallctl(name, oldp, oldlenp, newp, newlen)		\
 	    != 0) {							\
 		malloc_write("<jemalloc>: Failure in xmallctl(\"");	\
 		malloc_write(name);					\
@@ -84,7 +84,7 @@
 } while (0)
 
 #define	xmallctlnametomib(name, mibp, miblenp) do {			\
-	if (JEMALLOC_P(mallctlnametomib)(name, mibp, miblenp) != 0) {	\
+	if (je_mallctlnametomib(name, mibp, miblenp) != 0) {		\
 		malloc_write(						\
 		    "<jemalloc>: Failure in xmallctlnametomib(\"");	\
 		malloc_write(name);					\
@@ -94,7 +94,7 @@
 } while (0)
 
 #define	xmallctlbymib(mib, miblen, oldp, oldlenp, newp, newlen) do {	\
-	if (JEMALLOC_P(mallctlbymib)(mib, miblen, oldp, oldlenp, newp,	\
+	if (je_mallctlbymib(mib, miblen, oldp, oldlenp, newp,		\
 	    newlen) != 0) {						\
 		malloc_write(						\
 		    "<jemalloc>: Failure in xmallctlbymib()\n");	\
diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in
index aa07346..f13b406 100644
--- a/include/jemalloc/internal/jemalloc_internal.h.in
+++ b/include/jemalloc/internal/jemalloc_internal.h.in
@@ -30,7 +30,7 @@
 #include <pthread.h>
 #include <math.h>
 
-#define	JEMALLOC_MANGLE
+#define	JEMALLOC_NO_DEMANGLE
 #include "../jemalloc@install_suffix@.h"
 
 #include "jemalloc/internal/private_namespace.h"
@@ -149,7 +149,7 @@
 #include "jemalloc/internal/qr.h"
 #include "jemalloc/internal/ql.h"
 
-extern void	(*JEMALLOC_P(malloc_message))(void *wcbopaque, const char *s);
+extern void	(*je_malloc_message)(void *wcbopaque, const char *s);
 
 /*
  * Define a custom assert() in order to reduce the chances of deadlock during
@@ -618,13 +618,13 @@
 
 /*
  * Wrapper around malloc_message() that avoids the need for
- * JEMALLOC_P(malloc_message)(...) throughout the code.
+ * je_malloc_message(...) throughout the code.
  */
 JEMALLOC_INLINE void
 malloc_write(const char *s)
 {
 
-	JEMALLOC_P(malloc_message)(NULL, s);
+	je_malloc_message(NULL, s);
 }
 
 /*
diff --git a/include/jemalloc/jemalloc.h.in b/include/jemalloc/jemalloc.h.in
index 428c0d3..b930117 100644
--- a/include/jemalloc/jemalloc.h.in
+++ b/include/jemalloc/jemalloc.h.in
@@ -15,9 +15,6 @@
 #define	JEMALLOC_VERSION_GID "@jemalloc_version_gid@"
 
 #include "jemalloc_defs@install_suffix@.h"
-#ifndef JEMALLOC_P
-#  define JEMALLOC_P(s) s
-#endif
 
 #define	ALLOCM_LG_ALIGN(la)	(la)
 #if LG_SIZEOF_PTR == 2
@@ -32,34 +29,99 @@
 #define	ALLOCM_ERR_OOM		1
 #define	ALLOCM_ERR_NOT_MOVED	2
 
-extern const char	*JEMALLOC_P(malloc_conf);
-extern void		(*JEMALLOC_P(malloc_message))(void *, const char *);
+/*
+ * The je_ prefix on the following public symbol declarations is an artifact of
+ * namespace management, and should be omitted in application code unless
+ * JEMALLOC_NO_DEMANGLE is defined (see below).
+ */
+extern const char	*je_malloc_conf;
+extern void		(*je_malloc_message)(void *, const char *);
 
-void	*JEMALLOC_P(malloc)(size_t size) JEMALLOC_ATTR(malloc);
-void	*JEMALLOC_P(calloc)(size_t num, size_t size) JEMALLOC_ATTR(malloc);
-int	JEMALLOC_P(posix_memalign)(void **memptr, size_t alignment, size_t size)
+void	*je_malloc(size_t size) JEMALLOC_ATTR(malloc);
+void	*je_calloc(size_t num, size_t size) JEMALLOC_ATTR(malloc);
+int	je_posix_memalign(void **memptr, size_t alignment, size_t size)
     JEMALLOC_ATTR(nonnull(1));
-void	*JEMALLOC_P(realloc)(void *ptr, size_t size);
-void	JEMALLOC_P(free)(void *ptr);
+void	*je_realloc(void *ptr, size_t size);
+void	je_free(void *ptr);
 
-size_t	JEMALLOC_P(malloc_usable_size)(const void *ptr);
-void	JEMALLOC_P(malloc_stats_print)(void (*write_cb)(void *, const char *),
-    void *cbopaque, const char *opts);
-int	JEMALLOC_P(mallctl)(const char *name, void *oldp, size_t *oldlenp,
-    void *newp, size_t newlen);
-int	JEMALLOC_P(mallctlnametomib)(const char *name, size_t *mibp,
-    size_t *miblenp);
-int	JEMALLOC_P(mallctlbymib)(const size_t *mib, size_t miblen, void *oldp,
+size_t	je_malloc_usable_size(const void *ptr);
+void	je_malloc_stats_print(void (*write_cb)(void *, const char *),
+    void *je_cbopaque, const char *opts);
+int	je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp,
+    size_t newlen);
+int	je_mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp);
+int	je_mallctlbymib(const size_t *mib, size_t miblen, void *oldp,
     size_t *oldlenp, void *newp, size_t newlen);
 
-int	JEMALLOC_P(allocm)(void **ptr, size_t *rsize, size_t size, int flags)
+int	je_allocm(void **ptr, size_t *rsize, size_t size, int flags)
     JEMALLOC_ATTR(nonnull(1));
-int	JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size,
-    size_t extra, int flags) JEMALLOC_ATTR(nonnull(1));
-int	JEMALLOC_P(sallocm)(const void *ptr, size_t *rsize, int flags)
+int	je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra,
+    int flags) JEMALLOC_ATTR(nonnull(1));
+int	je_sallocm(const void *ptr, size_t *rsize, int flags)
     JEMALLOC_ATTR(nonnull(1));
-int	JEMALLOC_P(dallocm)(void *ptr, int flags) JEMALLOC_ATTR(nonnull(1));
-int	JEMALLOC_P(nallocm)(size_t *rsize, size_t size, int flags);
+int	je_dallocm(void *ptr, int flags) JEMALLOC_ATTR(nonnull(1));
+int	je_nallocm(size_t *rsize, size_t size, int flags);
+
+/*
+ * By default application code must explicitly refer to mangled symbol names,
+ * so that it is possible to use jemalloc in conjunction with another allocator
+ * in the same application.  Define JEMALLOC_MANGLE in order to cause automatic
+ * name mangling that matches the API prefixing that happened as a result of
+ * --with-mangling and/or --with-jemalloc-prefix configuration settings.
+ */
+#ifdef JEMALLOC_MANGLE
+#ifndef JEMALLOC_NO_DEMANGLE
+#define	JEMALLOC_NO_DEMANGLE
+#endif
+#define	malloc_conf je_malloc_conf
+#define	malloc_message je_malloc_message
+#define	malloc je_malloc
+#define	calloc je_calloc
+#define	posix_memalign je_posix_memalign
+#define	realloc je_realloc
+#define	free je_free
+#define	malloc_usable_size je_malloc_usable_size
+#define	malloc_stats_print je_malloc_stats_print
+#define	mallctl je_mallctl
+#define	mallctlnametomib je_mallctlnametomib
+#define	mallctlbymib je_mallctlbymib
+#define	memalign je_memalign
+#define	valloc je_valloc
+#define	allocm je_allocm
+#define	dallocm je_dallocm
+#define	nallocm je_nallocm
+#define	rallocm je_rallocm
+#define	sallocm je_sallocm
+#endif
+
+/*
+ * The je_* macros can be used as stable alternative names for the public
+ * jemalloc API if JEMALLOC_NO_DEMANGLE is defined.  This is primarily meant
+ * for use in jemalloc itself, but it can be used by application code to
+ * provide isolation from the name mangling specified via --with-mangling
+ * and/or --with-jemalloc-prefix.
+ */
+#ifndef JEMALLOC_NO_DEMANGLE
+#undef je_malloc_conf
+#undef je_malloc_message
+#undef je_malloc
+#undef je_calloc
+#undef je_posix_memalign
+#undef je_realloc
+#undef je_free
+#undef je_malloc_usable_size
+#undef je_malloc_stats_print
+#undef je_mallctl
+#undef je_mallctlnametomib
+#undef je_mallctlbymib
+#undef je_memalign
+#undef je_valloc
+#undef je_allocm
+#undef je_dallocm
+#undef je_nallocm
+#undef je_rallocm
+#undef je_sallocm
+#endif
 
 #ifdef __cplusplus
 };
diff --git a/include/jemalloc/jemalloc_defs.h.in b/include/jemalloc/jemalloc_defs.h.in
index 1360364..3d1a8d3 100644
--- a/include/jemalloc/jemalloc_defs.h.in
+++ b/include/jemalloc/jemalloc_defs.h.in
@@ -1,22 +1,35 @@
-#ifndef JEMALLOC_DEFS_H_
-#define	JEMALLOC_DEFS_H_
-
 /*
- * If JEMALLOC_PREFIX is defined, it will cause all public APIs to be prefixed.
- * This makes it possible, with some care, to use multiple allocators
- * simultaneously.
- *
- * In many cases it is more convenient to manually prefix allocator function
- * calls than to let macros do it automatically, particularly when using
- * multiple allocators simultaneously.  Define JEMALLOC_MANGLE before
- * #include'ing jemalloc.h in order to cause name mangling that corresponds to
- * the API prefixing.
+ * If JEMALLOC_PREFIX is defined via --with-jemalloc-prefix, it will cause all
+ * public APIs to be prefixed.  This makes it possible, with some care, to use
+ * multiple allocators simultaneously.
  */
 #undef JEMALLOC_PREFIX
 #undef JEMALLOC_CPREFIX
-#if (defined(JEMALLOC_PREFIX) && defined(JEMALLOC_MANGLE))
-#undef JEMALLOC_P
-#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.
+ */
+#undef je_malloc_conf
+#undef je_malloc_message
+#undef je_malloc
+#undef je_calloc
+#undef je_posix_memalign
+#undef je_realloc
+#undef je_free
+#undef je_malloc_usable_size
+#undef je_malloc_stats_print
+#undef je_mallctl
+#undef je_mallctlnametomib
+#undef je_mallctlbymib
+#undef je_memalign
+#undef je_valloc
+#undef je_allocm
+#undef je_dallocm
+#undef je_nallocm
+#undef je_rallocm
+#undef je_sallocm
 
 /*
  * JEMALLOC_PRIVATE_NAMESPACE is used as a prefix for all library-private APIs.
@@ -150,5 +163,3 @@
 
 /* sizeof(long) == 2^LG_SIZEOF_LONG. */
 #undef LG_SIZEOF_LONG
-
-#endif /* JEMALLOC_DEFS_H_ */
diff --git a/src/jemalloc.c b/src/jemalloc.c
index 34fd1aa..6e34706 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -36,7 +36,7 @@
 unsigned	ncpus;
 
 /* Runtime configuration options. */
-const char	*JEMALLOC_P(malloc_conf) JEMALLOC_ATTR(visibility("default"));
+const char	*je_malloc_conf JEMALLOC_ATTR(visibility("default"));
 #ifdef JEMALLOC_DEBUG
 bool	opt_abort = true;
 #  ifdef JEMALLOC_FILL
@@ -81,7 +81,7 @@
 	UNUSED int result = write(STDERR_FILENO, s, strlen(s));
 }
 
-void	(*JEMALLOC_P(malloc_message))(void *, const char *s)
+void	(*je_malloc_message)(void *, const char *s)
     JEMALLOC_ATTR(visibility("default")) = wrtmessage;
 
 /******************************************************************************/
@@ -230,7 +230,7 @@
 			}
 		}
 	}
-	JEMALLOC_P(malloc_stats_print)(NULL, NULL, NULL);
+	je_malloc_stats_print(NULL, NULL, NULL);
 }
 
 thread_allocated_t *
@@ -422,12 +422,12 @@
 		/* Get runtime configuration. */
 		switch (i) {
 		case 0:
-			if (JEMALLOC_P(malloc_conf) != NULL) {
+			if (je_malloc_conf != NULL) {
 				/*
 				 * Use options that were compiled into the
 				 * program.
 				 */
-				opts = JEMALLOC_P(malloc_conf);
+				opts = je_malloc_conf;
 			} else {
 				/* No configuration specified. */
 				buf[0] = '\0';
@@ -836,7 +836,7 @@
 JEMALLOC_ATTR(malloc)
 JEMALLOC_ATTR(visibility("default"))
 void *
-JEMALLOC_P(malloc)(size_t size)
+je_malloc(size_t size)
 {
 	void *ret;
 	size_t usize;
@@ -990,7 +990,7 @@
 JEMALLOC_ATTR(nonnull(1))
 JEMALLOC_ATTR(visibility("default"))
 int
-JEMALLOC_P(posix_memalign)(void **memptr, size_t alignment, size_t size)
+je_posix_memalign(void **memptr, size_t alignment, size_t size)
 {
 
 	return imemalign(memptr, alignment, size, true);
@@ -999,7 +999,7 @@
 JEMALLOC_ATTR(malloc)
 JEMALLOC_ATTR(visibility("default"))
 void *
-JEMALLOC_P(calloc)(size_t num, size_t size)
+je_calloc(size_t num, size_t size)
 {
 	void *ret;
 	size_t num_size;
@@ -1077,7 +1077,7 @@
 
 JEMALLOC_ATTR(visibility("default"))
 void *
-JEMALLOC_P(realloc)(void *ptr, size_t size)
+je_realloc(void *ptr, size_t size)
 {
 	void *ret;
 	size_t usize;
@@ -1207,7 +1207,7 @@
 
 JEMALLOC_ATTR(visibility("default"))
 void
-JEMALLOC_P(free)(void *ptr)
+je_free(void *ptr)
 {
 
 	if (ptr != NULL) {
@@ -1234,17 +1234,13 @@
 /******************************************************************************/
 /*
  * Begin non-standard override functions.
- *
- * These overrides are omitted if the JEMALLOC_PREFIX is defined, since the
- * entire point is to avoid accidental mixed allocator usage.
  */
-#ifndef JEMALLOC_PREFIX
 
 #ifdef JEMALLOC_OVERRIDE_MEMALIGN
 JEMALLOC_ATTR(malloc)
 JEMALLOC_ATTR(visibility("default"))
 void *
-JEMALLOC_P(memalign)(size_t alignment, size_t size)
+je_memalign(size_t alignment, size_t size)
 {
 	void *ret
 #ifdef JEMALLOC_CC_SILENCE
@@ -1260,7 +1256,7 @@
 JEMALLOC_ATTR(malloc)
 JEMALLOC_ATTR(visibility("default"))
 void *
-JEMALLOC_P(valloc)(size_t size)
+je_valloc(size_t size)
 {
 	void *ret
 #ifdef JEMALLOC_CC_SILENCE
@@ -1272,7 +1268,7 @@
 }
 #endif
 
-#if defined(__GLIBC__) && !defined(__UCLIBC__)
+#if (!defined(JEMALLOC_PREFIX) && defined(__GLIBC__) && !defined(__UCLIBC__))
 /*
  * glibc provides the RTLD_DEEPBIND flag for dlopen which can make it possible
  * to inconsistently reference libc's malloc(3)-compatible functions
@@ -1283,20 +1279,18 @@
  * ignored.
  */
 JEMALLOC_ATTR(visibility("default"))
-void (* const __free_hook)(void *ptr) = JEMALLOC_P(free);
+void (* const __free_hook)(void *ptr) = je_free;
 
 JEMALLOC_ATTR(visibility("default"))
-void *(* const __malloc_hook)(size_t size) = JEMALLOC_P(malloc);
+void *(* const __malloc_hook)(size_t size) = je_malloc;
 
 JEMALLOC_ATTR(visibility("default"))
-void *(* const __realloc_hook)(void *ptr, size_t size) = JEMALLOC_P(realloc);
+void *(* const __realloc_hook)(void *ptr, size_t size) = je_realloc;
 
 JEMALLOC_ATTR(visibility("default"))
-void *(* const __memalign_hook)(size_t alignment, size_t size) =
-    JEMALLOC_P(memalign);
+void *(* const __memalign_hook)(size_t alignment, size_t size) = je_memalign;
 #endif
 
-#endif /* JEMALLOC_PREFIX */
 /*
  * End non-standard override functions.
  */
@@ -1307,7 +1301,7 @@
 
 JEMALLOC_ATTR(visibility("default"))
 size_t
-JEMALLOC_P(malloc_usable_size)(const void *ptr)
+je_malloc_usable_size(const void *ptr)
 {
 	size_t ret;
 
@@ -1325,8 +1319,8 @@
 
 JEMALLOC_ATTR(visibility("default"))
 void
-JEMALLOC_P(malloc_stats_print)(void (*write_cb)(void *, const char *),
-    void *cbopaque, const char *opts)
+je_malloc_stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
+    const char *opts)
 {
 
 	stats_print(write_cb, cbopaque, opts);
@@ -1334,7 +1328,7 @@
 
 JEMALLOC_ATTR(visibility("default"))
 int
-JEMALLOC_P(mallctl)(const char *name, void *oldp, size_t *oldlenp, void *newp,
+je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp,
     size_t newlen)
 {
 
@@ -1346,7 +1340,7 @@
 
 JEMALLOC_ATTR(visibility("default"))
 int
-JEMALLOC_P(mallctlnametomib)(const char *name, size_t *mibp, size_t *miblenp)
+je_mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp)
 {
 
 	if (malloc_init())
@@ -1357,8 +1351,8 @@
 
 JEMALLOC_ATTR(visibility("default"))
 int
-JEMALLOC_P(mallctlbymib)(const size_t *mib, size_t miblen, void *oldp,
-    size_t *oldlenp, void *newp, size_t newlen)
+je_mallctlbymib(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
+  void *newp, size_t newlen)
 {
 
 	if (malloc_init())
@@ -1385,7 +1379,7 @@
 JEMALLOC_ATTR(nonnull(1))
 JEMALLOC_ATTR(visibility("default"))
 int
-JEMALLOC_P(allocm)(void **ptr, size_t *rsize, size_t size, int flags)
+je_allocm(void **ptr, size_t *rsize, size_t size, int flags)
 {
 	void *p;
 	size_t usize;
@@ -1451,8 +1445,7 @@
 JEMALLOC_ATTR(nonnull(1))
 JEMALLOC_ATTR(visibility("default"))
 int
-JEMALLOC_P(rallocm)(void **ptr, size_t *rsize, size_t size, size_t extra,
-    int flags)
+je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra, int flags)
 {
 	void *p, *q;
 	size_t usize;
@@ -1544,7 +1537,7 @@
 JEMALLOC_ATTR(nonnull(1))
 JEMALLOC_ATTR(visibility("default"))
 int
-JEMALLOC_P(sallocm)(const void *ptr, size_t *rsize, int flags)
+je_sallocm(const void *ptr, size_t *rsize, int flags)
 {
 	size_t sz;
 
@@ -1565,7 +1558,7 @@
 JEMALLOC_ATTR(nonnull(1))
 JEMALLOC_ATTR(visibility("default"))
 int
-JEMALLOC_P(dallocm)(void *ptr, int flags)
+je_dallocm(void *ptr, int flags)
 {
 	size_t usize;
 
@@ -1588,7 +1581,7 @@
 
 JEMALLOC_ATTR(visibility("default"))
 int
-JEMALLOC_P(nallocm)(size_t *rsize, size_t size, int flags)
+je_nallocm(size_t *rsize, size_t size, int flags)
 {
 	size_t usize;
 	size_t alignment = (ZU(1) << (flags & ALLOCM_LG_ALIGN_MASK)
diff --git a/src/stats.c b/src/stats.c
index 2f61e7b..f905d04 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -108,7 +108,7 @@
 		 * function, so use the default one.  malloc_write() is an
 		 * inline function, so use malloc_message() directly here.
 		 */
-		write_cb = JEMALLOC_P(malloc_message);
+		write_cb = je_malloc_message;
 		cbopaque = NULL;
 	}
 
@@ -376,8 +376,7 @@
 	 * */
 	epoch = 1;
 	u64sz = sizeof(uint64_t);
-	err = JEMALLOC_P(mallctl)("epoch", &epoch, &u64sz, &epoch,
-	    sizeof(uint64_t));
+	err = je_mallctl("epoch", &epoch, &u64sz, &epoch, sizeof(uint64_t));
 	if (err != 0) {
 		if (err == EAGAIN) {
 			malloc_write("<jemalloc>: Memory allocation failure in "
@@ -395,7 +394,7 @@
 		 * function, so use the default one.  malloc_write() is an
 		 * inline function, so use malloc_message() directly here.
 		 */
-		write_cb = JEMALLOC_P(malloc_message);
+		write_cb = je_malloc_message;
 		cbopaque = NULL;
 	}
 
@@ -448,22 +447,22 @@
 		write_cb(cbopaque, "\n");
 
 #define OPT_WRITE_BOOL(n)						\
-		if ((err = JEMALLOC_P(mallctl)("opt."#n, &bv, &bsz,	\
-		    NULL, 0)) == 0) {					\
+		if ((err = je_mallctl("opt."#n, &bv, &bsz, NULL, 0))	\
+		    == 0) {						\
 			write_cb(cbopaque, "  opt."#n": ");		\
 			write_cb(cbopaque, bv ? "true" : "false");	\
 			write_cb(cbopaque, "\n");			\
 		}
 #define OPT_WRITE_SIZE_T(n)						\
-		if ((err = JEMALLOC_P(mallctl)("opt."#n, &sv, &ssz,	\
-		    NULL, 0)) == 0) {					\
+		if ((err = je_mallctl("opt."#n, &sv, &ssz, NULL, 0))	\
+		    == 0) {						\
 			write_cb(cbopaque, "  opt."#n": ");		\
 			write_cb(cbopaque, u2s(sv, 10, s));		\
 			write_cb(cbopaque, "\n");			\
 		}
 #define OPT_WRITE_SSIZE_T(n)						\
-		if ((err = JEMALLOC_P(mallctl)("opt."#n, &ssv, &sssz,	\
-		    NULL, 0)) == 0) {					\
+		if ((err = je_mallctl("opt."#n, &ssv, &sssz, NULL, 0))	\
+		    == 0) {						\
 			if (ssv >= 0) {					\
 				write_cb(cbopaque, "  opt."#n": ");	\
 				write_cb(cbopaque, u2s(ssv, 10, s));	\
@@ -474,8 +473,8 @@
 			write_cb(cbopaque, "\n");			\
 		}
 #define OPT_WRITE_CHAR_P(n)						\
-		if ((err = JEMALLOC_P(mallctl)("opt."#n, &cpv, &cpsz,	\
-		    NULL, 0)) == 0) {					\
+		if ((err = je_mallctl("opt."#n, &cpv, &cpsz, NULL, 0))	\
+		    == 0) {						\
 			write_cb(cbopaque, "  opt."#n": \"");		\
 			write_cb(cbopaque, cpv);			\
 			write_cb(cbopaque, "\"\n");			\
@@ -535,15 +534,15 @@
 			write_cb(cbopaque,
 			    "Min active:dirty page ratio per arena: N/A\n");
 		}
-		if ((err = JEMALLOC_P(mallctl)("arenas.tcache_max", &sv,
-		    &ssz, NULL, 0)) == 0) {
+		if ((err = je_mallctl("arenas.tcache_max", &sv, &ssz, NULL, 0))
+		    == 0) {
 			write_cb(cbopaque,
 			    "Maximum thread-cached size class: ");
 			write_cb(cbopaque, u2s(sv, 10, s));
 			write_cb(cbopaque, "\n");
 		}
-		if ((err = JEMALLOC_P(mallctl)("opt.lg_tcache_gc_sweep", &ssv,
-		    &ssz, NULL, 0)) == 0) {
+		if ((err = je_mallctl("opt.lg_tcache_gc_sweep", &ssv, &ssz,
+		    NULL, 0)) == 0) {
 			size_t tcache_gc_sweep = (1U << ssv);
 			bool tcache_enabled;
 			CTL_GET("opt.tcache", &tcache_enabled, bool);
@@ -552,8 +551,8 @@
 			    u2s(tcache_gc_sweep, 10, s) : "N/A");
 			write_cb(cbopaque, "\n");
 		}
-		if ((err = JEMALLOC_P(mallctl)("opt.prof", &bv, &bsz, NULL, 0))
-		   == 0 && bv) {
+		if ((err = je_mallctl("opt.prof", &bv, &bsz, NULL, 0)) == 0 &&
+		    bv) {
 			CTL_GET("opt.lg_prof_sample", &sv, size_t);
 			write_cb(cbopaque, "Average profile sample interval: ");
 			write_cb(cbopaque, u2s((((uint64_t)1U) << sv), 10, s));
diff --git a/src/zone.c b/src/zone.c
index 07f8861..5beed5f 100644
--- a/src/zone.c
+++ b/src/zone.c
@@ -67,14 +67,14 @@
 zone_malloc(malloc_zone_t *zone, size_t size)
 {
 
-	return (JEMALLOC_P(malloc)(size));
+	return (je_malloc(size));
 }
 
 static void *
 zone_calloc(malloc_zone_t *zone, size_t num, size_t size)
 {
 
-	return (JEMALLOC_P(calloc)(num, size));
+	return (je_calloc(num, size));
 }
 
 static void *
@@ -82,7 +82,7 @@
 {
 	void *ret = NULL; /* Assignment avoids useless compiler warning. */
 
-	JEMALLOC_P(posix_memalign)(&ret, PAGE_SIZE, size);
+	je_posix_memalign(&ret, PAGE_SIZE, size);
 
 	return (ret);
 }
@@ -91,14 +91,14 @@
 zone_free(malloc_zone_t *zone, void *ptr)
 {
 
-	JEMALLOC_P(free)(ptr);
+	je_free(ptr);
 }
 
 static void *
 zone_realloc(malloc_zone_t *zone, void *ptr, size_t size)
 {
 
-	return (JEMALLOC_P(realloc)(ptr, size));
+	return (je_realloc(ptr, size));
 }
 
 #if (JEMALLOC_ZONE_VERSION >= 6)
@@ -107,7 +107,7 @@
 {
 	void *ret = NULL; /* Assignment avoids useless compiler warning. */
 
-	JEMALLOC_P(posix_memalign)(&ret, alignment, size);
+	je_posix_memalign(&ret, alignment, size);
 
 	return (ret);
 }
@@ -117,7 +117,7 @@
 {
 
 	assert(ivsalloc(ptr) == size);
-	JEMALLOC_P(free)(ptr);
+	je_free(ptr);
 }
 #endif
 
@@ -208,7 +208,7 @@
 {
 
 	if (ivsalloc(ptr) != 0)
-		JEMALLOC_P(free)(ptr);
+		je_free(ptr);
 	else {
 		size_t size = szone.size(zone, ptr);
 		if (size != 0)
@@ -222,17 +222,17 @@
 	size_t oldsize;
 
 	if (ptr == NULL)
-		return (JEMALLOC_P(malloc)(size));
+		return (je_malloc(size));
 
 	oldsize = ivsalloc(ptr);
 	if (oldsize != 0)
-		return (JEMALLOC_P(realloc)(ptr, size));
+		return (je_realloc(ptr, size));
 	else {
 		oldsize = szone.size(zone, ptr);
 		if (oldsize == 0)
-			return (JEMALLOC_P(malloc)(size));
+			return (je_malloc(size));
 		else {
-			void *ret = JEMALLOC_P(malloc)(size);
+			void *ret = je_malloc(size);
 			if (ret != NULL) {
 				memcpy(ret, ptr, (oldsize < size) ? oldsize :
 				    size);
@@ -268,7 +268,7 @@
 
 	if (ivsalloc(ptr) != 0) {
 		assert(ivsalloc(ptr) == size);
-		JEMALLOC_P(free)(ptr);
+		je_free(ptr);
 	} else {
 		assert(size == szone.size(zone, ptr));
 		szone.free_definite_size(zone, ptr, size);
diff --git a/test/allocated.c b/test/allocated.c
index b1e40e4..701c175 100644
--- a/test/allocated.c
+++ b/test/allocated.c
@@ -20,8 +20,7 @@
 	size_t sz, usize;
 
 	sz = sizeof(a0);
-	if ((err = JEMALLOC_P(mallctl)("thread.allocated", &a0, &sz, NULL,
-	    0))) {
+	if ((err = mallctl("thread.allocated", &a0, &sz, NULL, 0))) {
 		if (err == ENOENT) {
 #ifdef JEMALLOC_STATS
 			assert(false);
@@ -33,8 +32,7 @@
 		exit(1);
 	}
 	sz = sizeof(ap0);
-	if ((err = JEMALLOC_P(mallctl)("thread.allocatedp", &ap0, &sz, NULL,
-	    0))) {
+	if ((err = mallctl("thread.allocatedp", &ap0, &sz, NULL, 0))) {
 		if (err == ENOENT) {
 #ifdef JEMALLOC_STATS
 			assert(false);
@@ -48,8 +46,7 @@
 	assert(*ap0 == a0);
 
 	sz = sizeof(d0);
-	if ((err = JEMALLOC_P(mallctl)("thread.deallocated", &d0, &sz, NULL,
-	    0))) {
+	if ((err = mallctl("thread.deallocated", &d0, &sz, NULL, 0))) {
 		if (err == ENOENT) {
 #ifdef JEMALLOC_STATS
 			assert(false);
@@ -61,8 +58,7 @@
 		exit(1);
 	}
 	sz = sizeof(dp0);
-	if ((err = JEMALLOC_P(mallctl)("thread.deallocatedp", &dp0, &sz, NULL,
-	    0))) {
+	if ((err = mallctl("thread.deallocatedp", &dp0, &sz, NULL, 0))) {
 		if (err == ENOENT) {
 #ifdef JEMALLOC_STATS
 			assert(false);
@@ -75,28 +71,28 @@
 	}
 	assert(*dp0 == d0);
 
-	p = JEMALLOC_P(malloc)(1);
+	p = malloc(1);
 	if (p == NULL) {
 		fprintf(stderr, "%s(): Error in malloc()\n", __func__);
 		exit(1);
 	}
 
 	sz = sizeof(a1);
-	JEMALLOC_P(mallctl)("thread.allocated", &a1, &sz, NULL, 0);
+	mallctl("thread.allocated", &a1, &sz, NULL, 0);
 	sz = sizeof(ap1);
-	JEMALLOC_P(mallctl)("thread.allocatedp", &ap1, &sz, NULL, 0);
+	mallctl("thread.allocatedp", &ap1, &sz, NULL, 0);
 	assert(*ap1 == a1);
 	assert(ap0 == ap1);
 
-	usize = JEMALLOC_P(malloc_usable_size)(p);
+	usize = malloc_usable_size(p);
 	assert(a0 + usize <= a1);
 
-	JEMALLOC_P(free)(p);
+	free(p);
 
 	sz = sizeof(d1);
-	JEMALLOC_P(mallctl)("thread.deallocated", &d1, &sz, NULL, 0);
+	mallctl("thread.deallocated", &d1, &sz, NULL, 0);
 	sz = sizeof(dp1);
-	JEMALLOC_P(mallctl)("thread.deallocatedp", &dp1, &sz, NULL, 0);
+	mallctl("thread.deallocatedp", &dp1, &sz, NULL, 0);
 	assert(*dp1 == d1);
 	assert(dp0 == dp1);
 
diff --git a/test/allocm.c b/test/allocm.c
index 762e350..151f574 100644
--- a/test/allocm.c
+++ b/test/allocm.c
@@ -23,13 +23,13 @@
 
 	sz = 42;
 	nsz = 0;
-	r = JEMALLOC_P(nallocm)(&nsz, sz, 0);
+	r = nallocm(&nsz, sz, 0);
 	if (r != ALLOCM_SUCCESS) {
 		fprintf(stderr, "Unexpected nallocm() error\n");
 		abort();
 	}
 	rsz = 0;
-	r = JEMALLOC_P(allocm)(&p, &rsz, sz, 0);
+	r = allocm(&p, &rsz, sz, 0);
 	if (r != ALLOCM_SUCCESS) {
 		fprintf(stderr, "Unexpected allocm() error\n");
 		abort();
@@ -38,32 +38,32 @@
 		fprintf(stderr, "Real size smaller than expected\n");
 	if (nsz != rsz)
 		fprintf(stderr, "nallocm()/allocm() rsize mismatch\n");
-	if (JEMALLOC_P(dallocm)(p, 0) != ALLOCM_SUCCESS)
+	if (dallocm(p, 0) != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected dallocm() error\n");
 
-	r = JEMALLOC_P(allocm)(&p, NULL, sz, 0);
+	r = allocm(&p, NULL, sz, 0);
 	if (r != ALLOCM_SUCCESS) {
 		fprintf(stderr, "Unexpected allocm() error\n");
 		abort();
 	}
-	if (JEMALLOC_P(dallocm)(p, 0) != ALLOCM_SUCCESS)
+	if (dallocm(p, 0) != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected dallocm() error\n");
 
 	nsz = 0;
-	r = JEMALLOC_P(nallocm)(&nsz, sz, ALLOCM_ZERO);
+	r = nallocm(&nsz, sz, ALLOCM_ZERO);
 	if (r != ALLOCM_SUCCESS) {
 		fprintf(stderr, "Unexpected nallocm() error\n");
 		abort();
 	}
 	rsz = 0;
-	r = JEMALLOC_P(allocm)(&p, &rsz, sz, ALLOCM_ZERO);
+	r = allocm(&p, &rsz, sz, ALLOCM_ZERO);
 	if (r != ALLOCM_SUCCESS) {
 		fprintf(stderr, "Unexpected allocm() error\n");
 		abort();
 	}
 	if (nsz != rsz)
 		fprintf(stderr, "nallocm()/allocm() rsize mismatch\n");
-	if (JEMALLOC_P(dallocm)(p, 0) != ALLOCM_SUCCESS)
+	if (dallocm(p, 0) != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected dallocm() error\n");
 
 #if LG_SIZEOF_PTR == 3
@@ -74,14 +74,14 @@
 	sz        = 0x80000000LU;
 #endif
 	nsz = 0;
-	r = JEMALLOC_P(nallocm)(&nsz, sz, ALLOCM_ALIGN(alignment));
+	r = nallocm(&nsz, sz, ALLOCM_ALIGN(alignment));
 	if (r == ALLOCM_SUCCESS) {
 		fprintf(stderr,
 		    "Expected error for nallocm(&nsz, %zu, 0x%x)\n",
 		    sz, ALLOCM_ALIGN(alignment));
 	}
 	rsz = 0;
-	r = JEMALLOC_P(allocm)(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
+	r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
 	if (r == ALLOCM_SUCCESS) {
 		fprintf(stderr,
 		    "Expected error for allocm(&p, %zu, 0x%x)\n",
@@ -98,11 +98,11 @@
 	sz        = 0x84000001LU;
 #endif
 	nsz = 0;
-	r = JEMALLOC_P(nallocm)(&nsz, sz, ALLOCM_ALIGN(alignment));
+	r = nallocm(&nsz, sz, ALLOCM_ALIGN(alignment));
 	if (r != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected nallocm() error\n");
 	rsz = 0;
-	r = JEMALLOC_P(allocm)(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
+	r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
 	if (r == ALLOCM_SUCCESS) {
 		fprintf(stderr,
 		    "Expected error for allocm(&p, %zu, 0x%x)\n",
@@ -116,14 +116,14 @@
 	sz   = 0xfffffff0LU;
 #endif
 	nsz = 0;
-	r = JEMALLOC_P(nallocm)(&nsz, sz, ALLOCM_ALIGN(alignment));
+	r = nallocm(&nsz, sz, ALLOCM_ALIGN(alignment));
 	if (r == ALLOCM_SUCCESS) {
 		fprintf(stderr,
 		    "Expected error for nallocm(&nsz, %zu, 0x%x)\n",
 		    sz, ALLOCM_ALIGN(alignment));
 	}
 	rsz = 0;
-	r = JEMALLOC_P(allocm)(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
+	r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
 	if (r == ALLOCM_SUCCESS) {
 		fprintf(stderr,
 		    "Expected error for allocm(&p, %zu, 0x%x)\n",
@@ -145,7 +145,7 @@
 		    sz += (alignment >> (LG_SIZEOF_PTR-1)) - 1) {
 			for (i = 0; i < NITER; i++) {
 				nsz = 0;
-				r = JEMALLOC_P(nallocm)(&nsz, sz,
+				r = nallocm(&nsz, sz,
 				    ALLOCM_ALIGN(alignment) | ALLOCM_ZERO);
 				if (r != ALLOCM_SUCCESS) {
 					fprintf(stderr,
@@ -155,7 +155,7 @@
 					exit(1);
 				}
 				rsz = 0;
-				r = JEMALLOC_P(allocm)(&ps[i], &rsz, sz,
+				r = allocm(&ps[i], &rsz, sz,
 				    ALLOCM_ALIGN(alignment) | ALLOCM_ZERO);
 				if (r != ALLOCM_SUCCESS) {
 					fprintf(stderr,
@@ -179,14 +179,14 @@
 					    "%p inadequately aligned for"
 					    " alignment: %zu\n", p, alignment);
 				}
-				JEMALLOC_P(sallocm)(ps[i], &rsz, 0);
+				sallocm(ps[i], &rsz, 0);
 				total += rsz;
 				if (total >= (MAXALIGN << 1))
 					break;
 			}
 			for (i = 0; i < NITER; i++) {
 				if (ps[i] != NULL) {
-					JEMALLOC_P(dallocm)(ps[i], 0);
+					dallocm(ps[i], 0);
 					ps[i] = NULL;
 				}
 			}
diff --git a/test/mremap.c b/test/mremap.c
index 146c66f..8d35a64 100644
--- a/test/mremap.c
+++ b/test/mremap.c
@@ -17,8 +17,7 @@
 	fprintf(stderr, "Test begin\n");
 
 	sz = sizeof(lg_chunk);
-	if ((err = JEMALLOC_P(mallctl)("opt.lg_chunk", &lg_chunk, &sz, NULL,
-	    0))) {
+	if ((err = mallctl("opt.lg_chunk", &lg_chunk, &sz, NULL, 0))) {
 		assert(err != ENOENT);
 		fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
 		    strerror(err));
diff --git a/test/posix_memalign.c b/test/posix_memalign.c
index 3e306c0..789131c 100644
--- a/test/posix_memalign.c
+++ b/test/posix_memalign.c
@@ -24,7 +24,7 @@
 
 	/* Test error conditions. */
 	for (alignment = 0; alignment < sizeof(void *); alignment++) {
-		err = JEMALLOC_P(posix_memalign)(&p, alignment, 1);
+		err = posix_memalign(&p, alignment, 1);
 		if (err != EINVAL) {
 			fprintf(stderr,
 			    "Expected error for invalid alignment %zu\n",
@@ -34,7 +34,7 @@
 
 	for (alignment = sizeof(size_t); alignment < MAXALIGN;
 	    alignment <<= 1) {
-		err = JEMALLOC_P(posix_memalign)(&p, alignment + 1, 1);
+		err = posix_memalign(&p, alignment + 1, 1);
 		if (err == 0) {
 			fprintf(stderr,
 			    "Expected error for invalid alignment %zu\n",
@@ -49,7 +49,7 @@
 	alignment = 0x80000000LU;
 	size      = 0x80000000LU;
 #endif
-	err = JEMALLOC_P(posix_memalign)(&p, alignment, size);
+	err = posix_memalign(&p, alignment, size);
 	if (err == 0) {
 		fprintf(stderr,
 		    "Expected error for posix_memalign(&p, %zu, %zu)\n",
@@ -63,7 +63,7 @@
 	alignment = 0x40000000LU;
 	size      = 0x84000001LU;
 #endif
-	err = JEMALLOC_P(posix_memalign)(&p, alignment, size);
+	err = posix_memalign(&p, alignment, size);
 	if (err == 0) {
 		fprintf(stderr,
 		    "Expected error for posix_memalign(&p, %zu, %zu)\n",
@@ -76,7 +76,7 @@
 #else
 	size = 0xfffffff0LU;
 #endif
-	err = JEMALLOC_P(posix_memalign)(&p, alignment, size);
+	err = posix_memalign(&p, alignment, size);
 	if (err == 0) {
 		fprintf(stderr,
 		    "Expected error for posix_memalign(&p, %zu, %zu)\n",
@@ -95,7 +95,7 @@
 		    size < 3 * alignment && size < (1U << 31);
 		    size += (alignment >> (LG_SIZEOF_PTR-1)) - 1) {
 			for (i = 0; i < NITER; i++) {
-				err = JEMALLOC_P(posix_memalign)(&ps[i],
+				err = posix_memalign(&ps[i],
 				    alignment, size);
 				if (err) {
 					fprintf(stderr,
@@ -103,13 +103,13 @@
 					    size, size, strerror(err));
 					exit(1);
 				}
-				total += JEMALLOC_P(malloc_usable_size)(ps[i]);
+				total += malloc_usable_size(ps[i]);
 				if (total >= (MAXALIGN << 1))
 					break;
 			}
 			for (i = 0; i < NITER; i++) {
 				if (ps[i] != NULL) {
-					JEMALLOC_P(free)(ps[i]);
+					free(ps[i]);
 					ps[i] = NULL;
 				}
 			}
diff --git a/test/rallocm.c b/test/rallocm.c
index ccf326b..9c0df40 100644
--- a/test/rallocm.c
+++ b/test/rallocm.c
@@ -24,14 +24,14 @@
 		pagesize = (size_t)result;
 	}
 
-	r = JEMALLOC_P(allocm)(&p, &sz, 42, 0);
+	r = allocm(&p, &sz, 42, 0);
 	if (r != ALLOCM_SUCCESS) {
 		fprintf(stderr, "Unexpected allocm() error\n");
 		abort();
 	}
 
 	q = p;
-	r = JEMALLOC_P(rallocm)(&q, &tsz, sz, 0, ALLOCM_NO_MOVE);
+	r = rallocm(&q, &tsz, sz, 0, ALLOCM_NO_MOVE);
 	if (r != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected rallocm() error\n");
 	if (q != p)
@@ -42,7 +42,7 @@
 	}
 
 	q = p;
-	r = JEMALLOC_P(rallocm)(&q, &tsz, sz, 5, ALLOCM_NO_MOVE);
+	r = rallocm(&q, &tsz, sz, 5, ALLOCM_NO_MOVE);
 	if (r != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected rallocm() error\n");
 	if (q != p)
@@ -53,7 +53,7 @@
 	}
 
 	q = p;
-	r = JEMALLOC_P(rallocm)(&q, &tsz, sz + 5, 0, ALLOCM_NO_MOVE);
+	r = rallocm(&q, &tsz, sz + 5, 0, ALLOCM_NO_MOVE);
 	if (r != ALLOCM_ERR_NOT_MOVED)
 		fprintf(stderr, "Unexpected rallocm() result\n");
 	if (q != p)
@@ -64,7 +64,7 @@
 	}
 
 	q = p;
-	r = JEMALLOC_P(rallocm)(&q, &tsz, sz + 5, 0, 0);
+	r = rallocm(&q, &tsz, sz + 5, 0, 0);
 	if (r != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected rallocm() error\n");
 	if (q == p)
@@ -76,7 +76,7 @@
 	p = q;
 	sz = tsz;
 
-	r = JEMALLOC_P(rallocm)(&q, &tsz, pagesize*2, 0, 0);
+	r = rallocm(&q, &tsz, pagesize*2, 0, 0);
 	if (r != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected rallocm() error\n");
 	if (q == p)
@@ -88,7 +88,7 @@
 	p = q;
 	sz = tsz;
 
-	r = JEMALLOC_P(rallocm)(&q, &tsz, pagesize*4, 0, 0);
+	r = rallocm(&q, &tsz, pagesize*4, 0, 0);
 	if (r != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected rallocm() error\n");
 	if (tsz == sz) {
@@ -98,7 +98,7 @@
 	p = q;
 	sz = tsz;
 
-	r = JEMALLOC_P(rallocm)(&q, &tsz, pagesize*2, 0, ALLOCM_NO_MOVE);
+	r = rallocm(&q, &tsz, pagesize*2, 0, ALLOCM_NO_MOVE);
 	if (r != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected rallocm() error\n");
 	if (q != p)
@@ -109,7 +109,7 @@
 	}
 	sz = tsz;
 
-	r = JEMALLOC_P(rallocm)(&q, &tsz, pagesize*4, 0, ALLOCM_NO_MOVE);
+	r = rallocm(&q, &tsz, pagesize*4, 0, ALLOCM_NO_MOVE);
 	if (r != ALLOCM_SUCCESS)
 		fprintf(stderr, "Unexpected rallocm() error\n");
 	if (q != p)
@@ -120,7 +120,7 @@
 	}
 	sz = tsz;
 
-	JEMALLOC_P(dallocm)(p, 0);
+	dallocm(p, 0);
 
 	fprintf(stderr, "Test end\n");
 	return (0);
diff --git a/test/thread_arena.c b/test/thread_arena.c
index ef8d681..2922d1b 100644
--- a/test/thread_arena.c
+++ b/test/thread_arena.c
@@ -18,22 +18,22 @@
 	size_t size;
 	int err;
 
-	p = JEMALLOC_P(malloc)(1);
+	p = malloc(1);
 	if (p == NULL) {
 		fprintf(stderr, "%s(): Error in malloc()\n", __func__);
 		return (void *)1;
 	}
 
 	size = sizeof(arena_ind);
-	if ((err = JEMALLOC_P(mallctl)("thread.arena", &arena_ind, &size,
-	    &main_arena_ind, sizeof(main_arena_ind)))) {
+	if ((err = mallctl("thread.arena", &arena_ind, &size, &main_arena_ind,
+	    sizeof(main_arena_ind)))) {
 		fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
 		    strerror(err));
 		return (void *)1;
 	}
 
 	size = sizeof(arena_ind);
-	if ((err = JEMALLOC_P(mallctl)("thread.arena", &arena_ind, &size, NULL,
+	if ((err = mallctl("thread.arena", &arena_ind, &size, NULL,
 	    0))) {
 		fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
 		    strerror(err));
@@ -57,7 +57,7 @@
 
 	fprintf(stderr, "Test begin\n");
 
-	p = JEMALLOC_P(malloc)(1);
+	p = malloc(1);
 	if (p == NULL) {
 		fprintf(stderr, "%s(): Error in malloc()\n", __func__);
 		ret = 1;
@@ -65,8 +65,7 @@
 	}
 
 	size = sizeof(arena_ind);
-	if ((err = JEMALLOC_P(mallctl)("thread.arena", &arena_ind, &size, NULL,
-	    0))) {
+	if ((err = mallctl("thread.arena", &arena_ind, &size, NULL, 0))) {
 		fprintf(stderr, "%s(): Error in mallctl(): %s\n", __func__,
 		    strerror(err));
 		ret = 1;