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.
This commit is contained in:
@@ -20,8 +20,7 @@ thread_start(void *arg)
|
||||
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 @@ thread_start(void *arg)
|
||||
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 @@ thread_start(void *arg)
|
||||
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 @@ thread_start(void *arg)
|
||||
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 @@ thread_start(void *arg)
|
||||
}
|
||||
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);
|
||||
|
||||
|
@@ -23,13 +23,13 @@ main(void)
|
||||
|
||||
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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
"%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;
|
||||
}
|
||||
}
|
||||
|
@@ -17,8 +17,7 @@ main(void)
|
||||
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));
|
||||
|
@@ -24,7 +24,7 @@ main(void)
|
||||
|
||||
/* 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 @@ main(void)
|
||||
|
||||
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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
#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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -24,14 +24,14 @@ main(void)
|
||||
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 @@ main(void)
|
||||
}
|
||||
|
||||
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 @@ main(void)
|
||||
}
|
||||
|
||||
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 @@ main(void)
|
||||
}
|
||||
|
||||
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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
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 @@ main(void)
|
||||
}
|
||||
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 @@ main(void)
|
||||
}
|
||||
sz = tsz;
|
||||
|
||||
JEMALLOC_P(dallocm)(p, 0);
|
||||
dallocm(p, 0);
|
||||
|
||||
fprintf(stderr, "Test end\n");
|
||||
return (0);
|
||||
|
@@ -18,22 +18,22 @@ thread_start(void *arg)
|
||||
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 @@ main(void)
|
||||
|
||||
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 @@ main(void)
|
||||
}
|
||||
|
||||
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;
|
||||
|
Reference in New Issue
Block a user