summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2012-04-22 08:49:13 +0000
committerjasone <jasone@FreeBSD.org>2012-04-22 08:49:13 +0000
commitb378da045b65724c107c298a068d631553a3beea (patch)
treebb74ef462b9c9eeb4d5138d777ba402363012806 /lib/libc
parent0f83f74ce126b08c5fe9eeb2e3ffe9025ef37802 (diff)
downloadFreeBSD-src-b378da045b65724c107c298a068d631553a3beea.zip
FreeBSD-src-b378da045b65724c107c298a068d631553a3beea.tar.gz
Import jemalloc a8f8d7540d66ddee7337db80c92890916e1063ca (dev branch,
prior to 3.0.0 release). This fixes several bugs related to memory initialization. Mangle __jemalloc_a0{malloc,calloc,free}() just like all the other library-internal symbols in jemalloc, and adjust the tls allocation code in libc to use the mangled names.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/tls.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c
index 84b7ba5..466f957 100644
--- a/lib/libc/gen/tls.c
+++ b/lib/libc/gen/tls.c
@@ -40,9 +40,9 @@
#include "libc_private.h"
/* Provided by jemalloc to avoid bootstrapping issues. */
-void *a0malloc(size_t size);
-void *a0calloc(size_t num, size_t size);
-void a0free(void *ptr);
+void *__jemalloc_a0malloc(size_t size);
+void *__jemalloc_a0calloc(size_t num, size_t size);
+void __jemalloc_a0free(void *ptr);
__weak_reference(__libc_allocate_tls, _rtld_allocate_tls);
__weak_reference(__libc_free_tls, _rtld_free_tls);
@@ -125,8 +125,8 @@ __libc_free_tls(void *tcb, size_t tcbsize, size_t tcbalign __unused)
tls = (Elf_Addr **)((Elf_Addr)tcb + tcbsize - TLS_TCB_SIZE);
dtv = tls[0];
- a0free(dtv);
- a0free(tcb);
+ __jemalloc_a0free(dtv);
+ __jemalloc_a0free(tcb);
}
/*
@@ -142,18 +142,18 @@ __libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign __unused)
if (oldtcb != NULL && tcbsize == TLS_TCB_SIZE)
return (oldtcb);
- tcb = a0calloc(1, tls_static_space + tcbsize - TLS_TCB_SIZE);
+ tcb = __jemalloc_a0calloc(1, tls_static_space + tcbsize - TLS_TCB_SIZE);
tls = (Elf_Addr **)(tcb + tcbsize - TLS_TCB_SIZE);
if (oldtcb != NULL) {
memcpy(tls, oldtcb, tls_static_space);
- a0free(oldtcb);
+ __jemalloc_a0free(oldtcb);
/* Adjust the DTV. */
dtv = tls[0];
dtv[2] = (Elf_Addr)tls + TLS_TCB_SIZE;
} else {
- dtv = a0malloc(3 * sizeof(Elf_Addr));
+ dtv = __jemalloc_a0malloc(3 * sizeof(Elf_Addr));
tls[0] = dtv;
dtv[0] = 1;
dtv[1] = 1;
@@ -194,8 +194,8 @@ __libc_free_tls(void *tcb, size_t tcbsize __unused, size_t tcbalign)
dtv = ((Elf_Addr**)tcb)[1];
tlsend = (Elf_Addr) tcb;
tlsstart = tlsend - size;
- a0free((void*) tlsstart);
- a0free(dtv);
+ __jemalloc_a0free((void*) tlsstart);
+ __jemalloc_a0free(dtv);
}
/*
@@ -213,8 +213,8 @@ __libc_allocate_tls(void *oldtls, size_t tcbsize, size_t tcbalign)
if (tcbsize < 2 * sizeof(Elf_Addr))
tcbsize = 2 * sizeof(Elf_Addr);
- tls = a0calloc(1, size + tcbsize);
- dtv = a0malloc(3 * sizeof(Elf_Addr));
+ tls = __jemalloc_a0calloc(1, size + tcbsize);
+ dtv = __jemalloc_a0malloc(3 * sizeof(Elf_Addr));
segbase = (Elf_Addr)(tls + size);
((Elf_Addr*)segbase)[0] = segbase;
OpenPOWER on IntegriCloud