Add --with-jemalloc-prefix, which supports API mangling.
Rename jemalloc_options-->malloc_options and jemalloc_message-->malloc_message.
This commit is contained in:
parent
bca042dfeb
commit
90895cf859
@ -26,6 +26,11 @@ any of the following arguments (not a definitive list) to 'configure':
|
||||
Embed one or more library paths, so that Crux's internal shared library can
|
||||
find the libraries it is linked to. This works only on ELF-based systems.
|
||||
|
||||
--with-jemalloc-prefix=<prefix>
|
||||
Prefix all public APIs with <prefix>, so that, for example, malloc()
|
||||
becomes <prefix>malloc(). This makes it possible to use jemalloc at the
|
||||
same time as the system allocator.
|
||||
|
||||
--enable-debug
|
||||
Enable assertions and validation code. This incurs a substantial
|
||||
performance hit, but is very useful during application development.
|
||||
|
@ -205,7 +205,7 @@ AC_SUBST([RPATH])
|
||||
|
||||
dnl Support optional additions to rpath.
|
||||
AC_ARG_WITH([rpath],
|
||||
[AS_HELP_STRING([--with-rpath=<rpath>], [colon-separated rpath (ELF systems only)])],
|
||||
[AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
|
||||
if test "x$with_rpath" = "xno" ; then
|
||||
RPATH_EXTRA=
|
||||
else
|
||||
@ -234,6 +234,30 @@ AC_PATH_PROG([AR], [ar], , [$PATH])
|
||||
AC_PATH_PROG([LD], [ld], , [$PATH])
|
||||
AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH])
|
||||
|
||||
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])],
|
||||
if test "x$with_jemalloc_prefix" = "xno" ; then
|
||||
JEMALLOC_PREFIX=
|
||||
else
|
||||
JEMALLOC_PREFIX="$with_jemalloc_prefix"
|
||||
fi,
|
||||
JEMALLOC_PREFIX=
|
||||
)
|
||||
if test "x$JEMALLOC_PREFIX" != "x" ; then
|
||||
AC_DEFINE([JEMALLOC_PREFIX], [ ])
|
||||
jemalloc_prefix=$JEMALLOC_PREFIX
|
||||
AC_SUBST([jemalloc_prefix])
|
||||
AC_DEFINE_UNQUOTED([malloc], [${JEMALLOC_PREFIX}malloc])
|
||||
AC_DEFINE_UNQUOTED([calloc], [${JEMALLOC_PREFIX}calloc])
|
||||
AC_DEFINE_UNQUOTED([posix_memalign], [${JEMALLOC_PREFIX}posix_memalign])
|
||||
AC_DEFINE_UNQUOTED([realloc], [${JEMALLOC_PREFIX}realloc])
|
||||
AC_DEFINE_UNQUOTED([free], [${JEMALLOC_PREFIX}free])
|
||||
AC_DEFINE_UNQUOTED([malloc_usable_size], [${JEMALLOC_PREFIX}malloc_usable_size])
|
||||
AC_DEFINE_UNQUOTED([malloc_options], [${JEMALLOC_PREFIX}malloc_options])
|
||||
AC_DEFINE_UNQUOTED([malloc_message], [${JEMALLOC_PREFIX}malloc_message])
|
||||
fi
|
||||
|
||||
dnl Do not compile with debugging by default.
|
||||
AC_ARG_ENABLE([debug],
|
||||
[AS_HELP_STRING([--enable-debug], [Build debugging code])],
|
||||
@ -601,6 +625,7 @@ AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_RESULT([bins : ${bins}])
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
|
||||
AC_MSG_RESULT([autogen : ${enable_autogen}])
|
||||
AC_MSG_RESULT([debug : ${enable_debug}])
|
||||
AC_MSG_RESULT([stats : ${enable_stats}])
|
||||
|
@ -35,7 +35,7 @@
|
||||
.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93
|
||||
.\" $FreeBSD: head/lib/libc/stdlib/malloc.3 182225 2008-08-27 02:00:53Z jasone $
|
||||
.\"
|
||||
.Dd June 22, 2009
|
||||
.Dd November 13, 2009
|
||||
.Dt JEMALLOC 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -45,28 +45,28 @@
|
||||
.Lb libjemalloc
|
||||
.Sh SYNOPSIS
|
||||
.In stdlib.h
|
||||
.Ft void *
|
||||
.Fn malloc "size_t size"
|
||||
.Ft void *
|
||||
.Fn calloc "size_t number" "size_t size"
|
||||
.Ft int
|
||||
.Fn posix_memalign "void **ptr" "size_t alignment" "size_t size"
|
||||
.Ft void *
|
||||
.Fn realloc "void *ptr" "size_t size"
|
||||
.Ft void
|
||||
.Fn free "void *ptr"
|
||||
.In jemalloc.h
|
||||
.Ft size_t
|
||||
.Fn malloc_usable_size "const void *ptr"
|
||||
.Ft const char *
|
||||
.Va jemalloc_options ;
|
||||
.Ft void *
|
||||
.Fn @jemalloc_prefix@malloc "size_t size"
|
||||
.Ft void *
|
||||
.Fn @jemalloc_prefix@calloc "size_t number" "size_t size"
|
||||
.Ft int
|
||||
.Fn @jemalloc_prefix@posix_memalign "void **ptr" "size_t alignment" "size_t size"
|
||||
.Ft void *
|
||||
.Fn @jemalloc_prefix@realloc "void *ptr" "size_t size"
|
||||
.Ft void
|
||||
.Fo \*(lp*jemalloc_message\*(rp
|
||||
.Fn @jemalloc_prefix@free "void *ptr"
|
||||
.Ft size_t
|
||||
.Fn @jemalloc_prefix@malloc_usable_size "const void *ptr"
|
||||
.Ft const char *
|
||||
.Va @jemalloc_prefix@malloc_options ;
|
||||
.Ft void
|
||||
.Fo \*(lp*@jemalloc_prefix@malloc_message\*(rp
|
||||
.Fa "const char *p1" "const char *p2" "const char *p3" "const char *p4"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Fn malloc
|
||||
.Fn @jemalloc_prefix@malloc
|
||||
function allocates
|
||||
.Fa size
|
||||
bytes of uninitialized memory.
|
||||
@ -75,7 +75,7 @@ The allocated space is suitably aligned
|
||||
for storage of any type of object.
|
||||
.Pp
|
||||
The
|
||||
.Fn calloc
|
||||
.Fn @jemalloc_prefix@calloc
|
||||
function allocates space for
|
||||
.Fa number
|
||||
objects,
|
||||
@ -83,14 +83,14 @@ each
|
||||
.Fa size
|
||||
bytes in length.
|
||||
The result is identical to calling
|
||||
.Fn malloc
|
||||
.Fn @jemalloc_prefix@malloc
|
||||
with an argument of
|
||||
.Dq "number * size" ,
|
||||
with the exception that the allocated memory is explicitly initialized
|
||||
to zero bytes.
|
||||
.Pp
|
||||
The
|
||||
.Fn posix_memalign
|
||||
.Fn @jemalloc_prefix@posix_memalign
|
||||
function allocates
|
||||
.Fa size
|
||||
bytes of memory such that the allocation's base address is an even multiple of
|
||||
@ -103,7 +103,7 @@ must be a power of 2 at least as large as
|
||||
.Fn sizeof "void *" .
|
||||
.Pp
|
||||
The
|
||||
.Fn realloc
|
||||
.Fn @jemalloc_prefix@realloc
|
||||
function changes the size of the previously allocated memory referenced by
|
||||
.Fa ptr
|
||||
to
|
||||
@ -117,7 +117,7 @@ Upon success, the memory referenced by
|
||||
.Fa ptr
|
||||
is freed and a pointer to the newly allocated memory is returned.
|
||||
Note that
|
||||
.Fn realloc
|
||||
.Fn @jemalloc_prefix@realloc
|
||||
may move the memory allocation, resulting in a different return value than
|
||||
.Fa ptr .
|
||||
If
|
||||
@ -125,13 +125,13 @@ If
|
||||
is
|
||||
.Dv NULL ,
|
||||
the
|
||||
.Fn realloc
|
||||
.Fn @jemalloc_prefix@realloc
|
||||
function behaves identically to
|
||||
.Fn malloc
|
||||
.Fn @jemalloc_prefix@malloc
|
||||
for the specified size.
|
||||
.Pp
|
||||
The
|
||||
.Fn free
|
||||
.Fn @jemalloc_prefix@free
|
||||
function causes the allocated memory referenced by
|
||||
.Fa ptr
|
||||
to be made available for future allocations.
|
||||
@ -142,18 +142,18 @@ is
|
||||
no action occurs.
|
||||
.Pp
|
||||
The
|
||||
.Fn malloc_usable_size
|
||||
.Fn @jemalloc_prefix@malloc_usable_size
|
||||
function returns the usable size of the allocation pointed to by
|
||||
.Fa ptr .
|
||||
The return value may be larger than the size that was requested during
|
||||
allocation.
|
||||
The
|
||||
.Fn malloc_usable_size
|
||||
.Fn @jemalloc_prefix@malloc_usable_size
|
||||
function is not a mechanism for in-place
|
||||
.Fn realloc ;
|
||||
.Fn @jemalloc_prefix@realloc ;
|
||||
rather it is provided solely as a tool for introspection purposes.
|
||||
Any discrepancy between the requested allocation size and the size reported by
|
||||
.Fn malloc_usable_size
|
||||
.Fn @jemalloc_prefix@malloc_usable_size
|
||||
should not be depended on, since such behavior is entirely
|
||||
implementation-dependent.
|
||||
.Sh TUNING
|
||||
@ -168,7 +168,7 @@ of the file referenced by the symbolic link named
|
||||
the value of the environment variable
|
||||
.Ev JEMALLOC_OPTIONS ,
|
||||
and the string pointed to by the global variable
|
||||
.Va jemalloc_options
|
||||
.Va @jemalloc_prefix@malloc_options
|
||||
will be interpreted, in that order, from left to right as flags.
|
||||
.Pp
|
||||
Each flag is a single letter, optionally prefixed by a non-negative base 10
|
||||
@ -236,14 +236,14 @@ will prevent any dirty unused pages from accumulating.
|
||||
@roff_mag@@roff_tls@option for related tuning information.
|
||||
@roff_fill@.It J
|
||||
@roff_fill@Each byte of new memory allocated by
|
||||
@roff_fill@.Fn malloc
|
||||
@roff_fill@.Fn @jemalloc_prefix@malloc
|
||||
@roff_fill@or
|
||||
@roff_fill@.Fn realloc
|
||||
@roff_fill@.Fn @jemalloc_prefix@realloc
|
||||
@roff_fill@will be initialized to 0xa5.
|
||||
@roff_fill@All memory returned by
|
||||
@roff_fill@.Fn free
|
||||
@roff_fill@.Fn @jemalloc_prefix@free
|
||||
@roff_fill@or
|
||||
@roff_fill@.Fn realloc
|
||||
@roff_fill@.Fn @jemalloc_prefix@realloc
|
||||
@roff_fill@will be initialized to 0x5a.
|
||||
@roff_fill@This is intended for debugging and will impact performance
|
||||
@roff_fill@negatively.
|
||||
@ -292,7 +292,7 @@ The default value is 128 bytes.
|
||||
@roff_mag@@roff_tls@the expense of increased memory usage.
|
||||
@roff_stats@.It U
|
||||
@roff_stats@Generate a verbose trace log via
|
||||
@roff_stats@.Fn jemalloc_message
|
||||
@roff_stats@.Fn @jemalloc_prefix@malloc_message
|
||||
@roff_stats@for all allocation operations.
|
||||
@roff_sysv@.It V
|
||||
@roff_sysv@Attempting to allocate zero bytes will return a
|
||||
@ -313,16 +313,16 @@ The default value is 128 bytes.
|
||||
@roff_xmalloc@This option should be set at compile time by including the
|
||||
@roff_xmalloc@following in the source code:
|
||||
@roff_xmalloc@.Bd -literal -offset indent
|
||||
@roff_xmalloc@jemalloc_options = "X";
|
||||
@roff_xmalloc@@jemalloc_prefix@malloc_options = "X";
|
||||
@roff_xmalloc@.Ed
|
||||
@roff_fill@.It Z
|
||||
@roff_fill@Each byte of new memory allocated by
|
||||
@roff_fill@.Fn malloc
|
||||
@roff_fill@.Fn @jemalloc_prefix@malloc
|
||||
@roff_fill@or
|
||||
@roff_fill@.Fn realloc
|
||||
@roff_fill@.Fn @jemalloc_prefix@realloc
|
||||
@roff_fill@will be initialized to 0.
|
||||
@roff_fill@Note that this initialization only happens once for each byte, so
|
||||
@roff_fill@.Fn realloc
|
||||
@roff_fill@.Fn @jemalloc_prefix@realloc
|
||||
@roff_fill@calls do not zero memory that was previously allocated.
|
||||
@roff_fill@This is intended for debugging and will impact performance
|
||||
@roff_fill@negatively.
|
||||
@ -467,7 +467,7 @@ If the
|
||||
option is set, all warnings are treated as errors.
|
||||
.Pp
|
||||
The
|
||||
.Va jemalloc_message
|
||||
.Va @jemalloc_prefix@malloc_message
|
||||
variable allows the programmer to override the function which emits
|
||||
the text strings forming the errors and warnings if for some reason
|
||||
the
|
||||
@ -480,9 +480,9 @@ All messages are prefixed by
|
||||
.Dq <jemalloc>: .
|
||||
.Sh RETURN VALUES
|
||||
The
|
||||
.Fn malloc
|
||||
.Fn @jemalloc_prefix@malloc
|
||||
and
|
||||
.Fn calloc
|
||||
.Fn @jemalloc_prefix@calloc
|
||||
functions return a pointer to the allocated memory if successful; otherwise
|
||||
a
|
||||
.Dv NULL
|
||||
@ -492,10 +492,10 @@ is set to
|
||||
.Er ENOMEM .
|
||||
.Pp
|
||||
The
|
||||
.Fn posix_memalign
|
||||
.Fn @jemalloc_prefix@posix_memalign
|
||||
function returns the value 0 if successful; otherwise it returns an error value.
|
||||
The
|
||||
.Fn posix_memalign
|
||||
.Fn @jemalloc_prefix@posix_memalign
|
||||
function will fail if:
|
||||
.Bl -tag -width Er
|
||||
.It Bq Er EINVAL
|
||||
@ -508,7 +508,7 @@ Memory allocation error.
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Fn realloc
|
||||
.Fn @jemalloc_prefix@realloc
|
||||
function returns a pointer, possibly identical to
|
||||
.Fa ptr ,
|
||||
to the allocated memory
|
||||
@ -520,16 +520,16 @@ is set to
|
||||
.Er ENOMEM
|
||||
if the error was the result of an allocation failure.
|
||||
The
|
||||
.Fn realloc
|
||||
.Fn @jemalloc_prefix@realloc
|
||||
function always leaves the original buffer intact
|
||||
when an error occurs.
|
||||
.Pp
|
||||
The
|
||||
.Fn free
|
||||
.Fn @jemalloc_prefix@free
|
||||
function returns no value.
|
||||
.Pp
|
||||
The
|
||||
.Fn malloc_usable_size
|
||||
.Fn @jemalloc_prefix@malloc_usable_size
|
||||
function returns the usable size of the allocation pointed to by
|
||||
.Fa ptr .
|
||||
.Sh ENVIRONMENT
|
||||
@ -552,7 +552,7 @@ ln -s 'A' /etc/jemalloc.conf
|
||||
To specify in the source that a program does no return value checking
|
||||
on calls to these functions:
|
||||
.Bd -literal -offset indent
|
||||
jemalloc_options = "X";
|
||||
@jemalloc_prefix@malloc_options = "X";
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr madvise 2 ,
|
||||
@ -563,15 +563,15 @@ jemalloc_options = "X";
|
||||
.Xr getpagesize 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn malloc ,
|
||||
.Fn calloc ,
|
||||
.Fn realloc
|
||||
.Fn @jemalloc_prefix@malloc ,
|
||||
.Fn @jemalloc_prefix@calloc ,
|
||||
.Fn @jemalloc_prefix@realloc
|
||||
and
|
||||
.Fn free
|
||||
.Fn @jemalloc_prefix@free
|
||||
functions conform to
|
||||
.St -isoC .
|
||||
.Pp
|
||||
The
|
||||
.Fn posix_memalign
|
||||
.Fn @jemalloc_prefix@posix_memalign
|
||||
function conforms to
|
||||
.St -p1003.1-2001 .
|
||||
|
@ -137,8 +137,6 @@
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "jemalloc_defs.h"
|
||||
|
||||
#if 0
|
||||
__FBSDID("$FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.183 2008/12/01 10:20:59 jasone Exp $");
|
||||
#endif
|
||||
@ -167,6 +165,10 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/malloc.c,v 1.183 2008/12/01 10:20:59 jas
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define JEMALLOC_MANGLE
|
||||
#include "jemalloc.h"
|
||||
|
||||
#ifdef JEMALLOC_LAZY_LOCK
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
@ -1045,7 +1047,7 @@ static chunk_stats_t stats_chunks;
|
||||
/*
|
||||
* Runtime configuration options.
|
||||
*/
|
||||
const char *jemalloc_options;
|
||||
const char *malloc_options;
|
||||
|
||||
#ifdef JEMALLOC_DEBUG
|
||||
static bool opt_abort = true;
|
||||
@ -1225,7 +1227,7 @@ wrtmessage(const char *p1, const char *p2, const char *p3, const char *p4)
|
||||
return;
|
||||
}
|
||||
|
||||
void (*jemalloc_message)(const char *p1, const char *p2, const char *p3,
|
||||
void (*malloc_message)(const char *p1, const char *p2, const char *p3,
|
||||
const char *p4) = wrtmessage;
|
||||
|
||||
/*
|
||||
@ -1259,9 +1261,9 @@ umax2s(uintmax_t x, char *s)
|
||||
# define assert(e) do { \
|
||||
if (!(e)) { \
|
||||
char line_buf[UMAX2S_BUFSIZE]; \
|
||||
jemalloc_message("<jemalloc>: ", __FILE__, ":", \
|
||||
malloc_message("<jemalloc>: ", __FILE__, ":", \
|
||||
umax2s(__LINE__, line_buf)); \
|
||||
jemalloc_message(": Failed assertion: ", "\"", #e, \
|
||||
malloc_message(": Failed assertion: ", "\"", #e, \
|
||||
"\"\n"); \
|
||||
abort(); \
|
||||
} \
|
||||
@ -1308,7 +1310,7 @@ malloc_printf(const char *format, ...)
|
||||
va_start(ap, format);
|
||||
vsnprintf(buf, sizeof(buf), format, ap);
|
||||
va_end(ap);
|
||||
jemalloc_message(buf, "", "", "");
|
||||
malloc_message(buf, "", "", "");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1328,7 +1330,7 @@ get_pthread_create_fptr(void)
|
||||
|
||||
pthread_create_fptr = dlsym(RTLD_NEXT, "pthread_create");
|
||||
if (pthread_create_fptr == NULL) {
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Error in dlsym(RTLD_NEXT, \"pthread_create\")\n", "",
|
||||
"");
|
||||
abort();
|
||||
@ -1864,7 +1866,7 @@ pages_map(void *addr, size_t size)
|
||||
char buf[STRERROR_BUF];
|
||||
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Error in munmap(): ", buf, "\n");
|
||||
if (opt_abort)
|
||||
abort();
|
||||
@ -1885,7 +1887,7 @@ pages_unmap(void *addr, size_t size)
|
||||
char buf[STRERROR_BUF];
|
||||
|
||||
strerror_r(errno, buf, sizeof(buf));
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Error in munmap(): ", buf, "\n");
|
||||
if (opt_abort)
|
||||
abort();
|
||||
@ -4335,7 +4337,7 @@ arenas_extend(unsigned ind)
|
||||
* by using arenas[0]. In practice, this is an extremely unlikely
|
||||
* failure.
|
||||
*/
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Error initializing arena\n", "", "");
|
||||
if (opt_abort)
|
||||
abort();
|
||||
@ -4647,79 +4649,79 @@ malloc_print_stats(void)
|
||||
|
||||
if (opt_print_stats) {
|
||||
char s[UMAX2S_BUFSIZE];
|
||||
jemalloc_message("___ Begin jemalloc statistics ___\n", "", "",
|
||||
malloc_message("___ Begin jemalloc statistics ___\n", "", "",
|
||||
"");
|
||||
jemalloc_message("Assertions ",
|
||||
malloc_message("Assertions ",
|
||||
#ifdef NDEBUG
|
||||
"disabled",
|
||||
#else
|
||||
"enabled",
|
||||
#endif
|
||||
"\n", "");
|
||||
jemalloc_message("Boolean JEMALLOC_OPTIONS: ",
|
||||
malloc_message("Boolean JEMALLOC_OPTIONS: ",
|
||||
opt_abort ? "A" : "a", "", "");
|
||||
#ifdef JEMALLOC_DSS
|
||||
jemalloc_message(opt_dss ? "D" : "d", "", "", "");
|
||||
malloc_message(opt_dss ? "D" : "d", "", "", "");
|
||||
#endif
|
||||
#ifdef JEMALLOC_MAG
|
||||
jemalloc_message(opt_mag ? "G" : "g", "", "", "");
|
||||
malloc_message(opt_mag ? "G" : "g", "", "", "");
|
||||
#endif
|
||||
#ifdef JEMALLOC_FILL
|
||||
jemalloc_message(opt_junk ? "J" : "j", "", "", "");
|
||||
malloc_message(opt_junk ? "J" : "j", "", "", "");
|
||||
#endif
|
||||
#ifdef JEMALLOC_DSS
|
||||
jemalloc_message(opt_mmap ? "M" : "m", "", "", "");
|
||||
malloc_message(opt_mmap ? "M" : "m", "", "", "");
|
||||
#endif
|
||||
jemalloc_message("P", "", "", "");
|
||||
malloc_message("P", "", "", "");
|
||||
#ifdef JEMALLOC_STATS
|
||||
jemalloc_message(opt_utrace ? "U" : "u", "", "", "");
|
||||
malloc_message(opt_utrace ? "U" : "u", "", "", "");
|
||||
#endif
|
||||
#ifdef JEMALLOC_SYSV
|
||||
jemalloc_message(opt_sysv ? "V" : "v", "", "", "");
|
||||
malloc_message(opt_sysv ? "V" : "v", "", "", "");
|
||||
#endif
|
||||
#ifdef JEMALLOC_XMALLOC
|
||||
jemalloc_message(opt_xmalloc ? "X" : "x", "", "", "");
|
||||
malloc_message(opt_xmalloc ? "X" : "x", "", "", "");
|
||||
#endif
|
||||
#ifdef JEMALLOC_FILL
|
||||
jemalloc_message(opt_zero ? "Z" : "z", "", "", "");
|
||||
malloc_message(opt_zero ? "Z" : "z", "", "", "");
|
||||
#endif
|
||||
jemalloc_message("\n", "", "", "");
|
||||
malloc_message("\n", "", "", "");
|
||||
|
||||
jemalloc_message("CPUs: ", umax2s(ncpus, s), "\n", "");
|
||||
jemalloc_message("Max arenas: ", umax2s(narenas, s), "\n", "");
|
||||
malloc_message("CPUs: ", umax2s(ncpus, s), "\n", "");
|
||||
malloc_message("Max arenas: ", umax2s(narenas, s), "\n", "");
|
||||
#ifdef JEMALLOC_BALANCE
|
||||
jemalloc_message("Arena balance threshold: ",
|
||||
malloc_message("Arena balance threshold: ",
|
||||
umax2s(opt_balance_threshold, s), "\n", "");
|
||||
#endif
|
||||
jemalloc_message("Pointer size: ", umax2s(sizeof(void *), s),
|
||||
malloc_message("Pointer size: ", umax2s(sizeof(void *), s),
|
||||
"\n", "");
|
||||
jemalloc_message("Quantum size: ", umax2s(QUANTUM, s), "\n",
|
||||
malloc_message("Quantum size: ", umax2s(QUANTUM, s), "\n",
|
||||
"");
|
||||
jemalloc_message("Cacheline size (assumed): ",
|
||||
malloc_message("Cacheline size (assumed): ",
|
||||
umax2s(CACHELINE, s), "\n", "");
|
||||
#ifdef JEMALLOC_TINY
|
||||
jemalloc_message("Tiny 2^n-spaced sizes: [", umax2s((1U <<
|
||||
malloc_message("Tiny 2^n-spaced sizes: [", umax2s((1U <<
|
||||
TINY_MIN_2POW), s), "..", "");
|
||||
jemalloc_message(umax2s((qspace_min >> 1), s), "]\n", "", "");
|
||||
malloc_message(umax2s((qspace_min >> 1), s), "]\n", "", "");
|
||||
#endif
|
||||
jemalloc_message("Quantum-spaced sizes: [", umax2s(qspace_min,
|
||||
malloc_message("Quantum-spaced sizes: [", umax2s(qspace_min,
|
||||
s), "..", "");
|
||||
jemalloc_message(umax2s(qspace_max, s), "]\n", "", "");
|
||||
jemalloc_message("Cacheline-spaced sizes: [",
|
||||
malloc_message(umax2s(qspace_max, s), "]\n", "", "");
|
||||
malloc_message("Cacheline-spaced sizes: [",
|
||||
umax2s(cspace_min, s), "..", "");
|
||||
jemalloc_message(umax2s(cspace_max, s), "]\n", "", "");
|
||||
jemalloc_message("Subpage-spaced sizes: [", umax2s(sspace_min,
|
||||
malloc_message(umax2s(cspace_max, s), "]\n", "", "");
|
||||
malloc_message("Subpage-spaced sizes: [", umax2s(sspace_min,
|
||||
s), "..", "");
|
||||
jemalloc_message(umax2s(sspace_max, s), "]\n", "", "");
|
||||
malloc_message(umax2s(sspace_max, s), "]\n", "", "");
|
||||
#ifdef JEMALLOC_MAG
|
||||
jemalloc_message("Rounds per magazine: ", umax2s(max_rounds,
|
||||
malloc_message("Rounds per magazine: ", umax2s(max_rounds,
|
||||
s), "\n", "");
|
||||
#endif
|
||||
jemalloc_message("Max dirty pages per arena: ",
|
||||
malloc_message("Max dirty pages per arena: ",
|
||||
umax2s(opt_dirty_max, s), "\n", "");
|
||||
|
||||
jemalloc_message("Chunk size: ", umax2s(chunksize, s), "", "");
|
||||
jemalloc_message(" (2^", umax2s(opt_chunk_2pow, s), ")\n", "");
|
||||
malloc_message("Chunk size: ", umax2s(chunksize, s), "", "");
|
||||
malloc_message(" (2^", umax2s(opt_chunk_2pow, s), ")\n", "");
|
||||
|
||||
#ifdef JEMALLOC_STATS
|
||||
{
|
||||
@ -4800,7 +4802,7 @@ malloc_print_stats(void)
|
||||
}
|
||||
}
|
||||
#endif /* #ifdef JEMALLOC_STATS */
|
||||
jemalloc_message("--- End jemalloc statistics ---\n", "", "",
|
||||
malloc_message("--- End jemalloc statistics ---\n", "", "",
|
||||
"");
|
||||
}
|
||||
}
|
||||
@ -5034,12 +5036,12 @@ malloc_init_hard(void)
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (jemalloc_options != NULL) {
|
||||
if (malloc_options != NULL) {
|
||||
/*
|
||||
* Use options that were compiled into the
|
||||
* program.
|
||||
*/
|
||||
opts = jemalloc_options;
|
||||
opts = malloc_options;
|
||||
} else {
|
||||
/* No configuration specified. */
|
||||
buf[0] = '\0';
|
||||
@ -5241,7 +5243,7 @@ MALLOC_OUT:
|
||||
|
||||
cbuf[0] = opts[j];
|
||||
cbuf[1] = '\0';
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Unsupported character "
|
||||
"in malloc options: '", cbuf,
|
||||
"'\n");
|
||||
@ -5302,7 +5304,7 @@ MALLOC_OUT:
|
||||
*/
|
||||
if (nbins > 256) {
|
||||
char line_buf[UMAX2S_BUFSIZE];
|
||||
jemalloc_message("<jemalloc>: Too many size classes (",
|
||||
malloc_message("<jemalloc>: Too many size classes (",
|
||||
umax2s(nbins, line_buf), " > 256)\n", "");
|
||||
abort();
|
||||
}
|
||||
@ -5411,7 +5413,7 @@ MALLOC_OUT:
|
||||
|
||||
#ifdef JEMALLOC_MAG
|
||||
if (pthread_key_create(&mag_rack_tsd, thread_cleanup) != 0) {
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Error in pthread_key_create()\n", "", "");
|
||||
abort();
|
||||
}
|
||||
@ -5554,7 +5556,7 @@ RETURN:
|
||||
if (ret == NULL) {
|
||||
#ifdef JEMALLOC_XMALLOC
|
||||
if (opt_xmalloc) {
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Error in malloc(): out of memory\n", "",
|
||||
"");
|
||||
abort();
|
||||
@ -5581,7 +5583,7 @@ posix_memalign(void **memptr, size_t alignment, size_t size)
|
||||
|| alignment < sizeof(void *)) {
|
||||
#ifdef JEMALLOC_XMALLOC
|
||||
if (opt_xmalloc) {
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Error in posix_memalign(): "
|
||||
"invalid alignment\n", "", "");
|
||||
abort();
|
||||
@ -5598,7 +5600,7 @@ posix_memalign(void **memptr, size_t alignment, size_t size)
|
||||
if (result == NULL) {
|
||||
#ifdef JEMALLOC_XMALLOC
|
||||
if (opt_xmalloc) {
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Error in posix_memalign(): out of memory\n",
|
||||
"", "");
|
||||
abort();
|
||||
@ -5658,7 +5660,7 @@ RETURN:
|
||||
if (ret == NULL) {
|
||||
#ifdef JEMALLOC_XMALLOC
|
||||
if (opt_xmalloc) {
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Error in calloc(): out of memory\n", "",
|
||||
"");
|
||||
abort();
|
||||
@ -5700,7 +5702,7 @@ realloc(void *ptr, size_t size)
|
||||
if (ret == NULL) {
|
||||
#ifdef JEMALLOC_XMALLOC
|
||||
if (opt_xmalloc) {
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Error in realloc(): out of "
|
||||
"memory\n", "", "");
|
||||
abort();
|
||||
@ -5717,7 +5719,7 @@ realloc(void *ptr, size_t size)
|
||||
if (ret == NULL) {
|
||||
#ifdef JEMALLOC_XMALLOC
|
||||
if (opt_xmalloc) {
|
||||
jemalloc_message("<jemalloc>",
|
||||
malloc_message("<jemalloc>",
|
||||
": Error in realloc(): out of "
|
||||
"memory\n", "", "");
|
||||
abort();
|
||||
|
@ -28,24 +28,21 @@
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef JEMALLOC_H_
|
||||
#define JEMALLOC_H_
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef JEMALLOC_H_
|
||||
#define JEMALLOC_H_
|
||||
|
||||
#include "jemalloc_defs.h"
|
||||
|
||||
size_t malloc_usable_size(const void *ptr);
|
||||
|
||||
extern const char *jemalloc_options;
|
||||
extern void (*jemalloc_message)(const char *p1, const char *p2,
|
||||
const char *p3, const char *p4);
|
||||
|
||||
#endif /* JEMALLOC_H_ */
|
||||
extern const char *malloc_options;
|
||||
extern void (*malloc_message)(const char *p1,
|
||||
const char *p2, const char *p3, const char *p4);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* JEMALLOC_H_ */
|
||||
|
@ -36,6 +36,29 @@
|
||||
*/
|
||||
#undef JEMALLOC_VERSION
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#undef JEMALLOC_PREFIX
|
||||
#if (defined(JEMALLOC_PREFIX) && defined(JEMALLOC_MANGLE))
|
||||
#undef malloc
|
||||
#undef calloc
|
||||
#undef posix_memalign
|
||||
#undef realloc
|
||||
#undef free
|
||||
#undef malloc_usable_size
|
||||
#undef malloc_options
|
||||
#undef malloc_message
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hyper-threaded CPUs may need a special instruction inside spin loops in
|
||||
* order to yield to another virtual CPU.
|
||||
|
@ -74,7 +74,7 @@
|
||||
#include <gdfontl.h>
|
||||
#include <gdfontg.h>
|
||||
|
||||
#include "jemalloc_defs.h"
|
||||
#include "jemalloc.h"
|
||||
#ifndef JEMALLOC_DEBUG
|
||||
# define NDEBUG
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user