summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2012-03-02 01:19:20 (GMT)
committerJason Evans <je@fb.com>2012-03-02 01:19:20 (GMT)
commit0a5489e37da88a1a50fbf8552e0d3a7f8fd93ffc (patch)
treebc3ee548220bc90b98892c59dd5a5dbe546f465e /src
parent166a745b395198c2b0d661caa717e6a9400291c6 (diff)
downloadjemalloc-0a5489e37da88a1a50fbf8552e0d3a7f8fd93ffc.zip
jemalloc-0a5489e37da88a1a50fbf8552e0d3a7f8fd93ffc.tar.gz
jemalloc-0a5489e37da88a1a50fbf8552e0d3a7f8fd93ffc.tar.bz2
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.
Diffstat (limited to 'src')
-rw-r--r--src/jemalloc.c65
-rw-r--r--src/stats.c35
-rw-r--r--src/zone.c26
3 files changed, 59 insertions, 67 deletions
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 @@ size_t lg_pagesize;
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 @@ wrtmessage(void *cbopaque, const char *s)
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 @@ stats_print_atexit(void)
}
}
}
- JEMALLOC_P(malloc_stats_print)(NULL, NULL, NULL);
+ je_malloc_stats_print(NULL, NULL, NULL);
}
thread_allocated_t *
@@ -422,12 +422,12 @@ malloc_conf_init(void)
/* 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_darwin_init(void)
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 @@ RETURN:
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_P(posix_memalign)(void **memptr, size_t alignment, size_t size)
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 @@ RETURN:
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 @@ RETURN:
JEMALLOC_ATTR(visibility("default"))
void
-JEMALLOC_P(free)(void *ptr)
+je_free(void *ptr)
{
if (ptr != NULL) {
@@ -1234,17 +1234,13 @@ JEMALLOC_P(free)(void *ptr)
/******************************************************************************/
/*
* 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_P(memalign)(size_t alignment, size_t size)
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 @@ JEMALLOC_P(valloc)(size_t size)
}
#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 @@ JEMALLOC_P(valloc)(size_t size)
* 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 @@ void *(* const __memalign_hook)(size_t alignment, size_t size) =
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_P(malloc_usable_size)(const void *ptr)
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_P(malloc_stats_print)(void (*write_cb)(void *, const char *),
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_P(mallctl)(const char *name, void *oldp, size_t *oldlenp, void *newp,
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_P(mallctlnametomib)(const char *name, size_t *mibp, size_t *miblenp)
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 @@ iallocm(size_t usize, size_t alignment, bool zero)
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 @@ OOM:
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 @@ OOM:
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_P(sallocm)(const void *ptr, size_t *rsize, int flags)
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_P(dallocm)(void *ptr, int flags)
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 @@ malloc_vcprintf(void (*write_cb)(void *, const char *), void *cbopaque,
* 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 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
* */
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 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
* 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 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
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 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
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 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
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 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
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 @@ static void *
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 @@ zone_valloc(malloc_zone_t *zone, size_t size)
{
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 @@ static void
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 @@ zone_memalign(malloc_zone_t *zone, size_t alignment, size_t size)
{
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 @@ zone_free_definite_size(malloc_zone_t *zone, void *ptr, size_t size)
{
assert(ivsalloc(ptr) == size);
- JEMALLOC_P(free)(ptr);
+ je_free(ptr);
}
#endif
@@ -208,7 +208,7 @@ ozone_free(malloc_zone_t *zone, void *ptr)
{
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 @@ ozone_realloc(malloc_zone_t *zone, void *ptr, size_t size)
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 @@ ozone_free_definite_size(malloc_zone_t *zone, void *ptr, size_t size)
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);