diff options
author | David CARLIER <devnexen@gmail.com> | 2021-02-17 20:40:11 +0000 |
---|---|---|
committer | Qi Wang <interwq@gmail.com> | 2021-10-01 14:32:40 -0700 |
commit | cf9724531af2864b243668d82aa63114e9737bfd (patch) | |
tree | b4b3bcbda4a7e784cbe270d2a280008fa35e9ca2 /test | |
parent | ab0f1604b4fc563158f142d41f6a3550463d7729 (diff) | |
download | jemalloc-cf9724531af2864b243668d82aa63114e9737bfd.tar.gz |
Darwin malloc_size override support proposal.
Darwin has similar api than Linux/FreeBSD's malloc_usable_size.
Diffstat (limited to 'test')
-rw-r--r-- | test/include/test/jemalloc_test.h.in | 5 | ||||
-rw-r--r-- | test/integration/aligned_alloc.c | 4 | ||||
-rw-r--r-- | test/integration/allocated.c | 2 | ||||
-rw-r--r-- | test/integration/malloc.c | 2 | ||||
-rw-r--r-- | test/integration/posix_memalign.c | 2 | ||||
-rw-r--r-- | test/integration/rallocx.c | 4 | ||||
-rw-r--r-- | test/stress/microbench.c | 2 | ||||
-rw-r--r-- | test/unit/junk.c | 2 | ||||
-rw-r--r-- | test/unit/prof_stats.c | 2 |
9 files changed, 15 insertions, 10 deletions
diff --git a/test/include/test/jemalloc_test.h.in b/test/include/test/jemalloc_test.h.in index 0e332165..3f8c0da7 100644 --- a/test/include/test/jemalloc_test.h.in +++ b/test/include/test/jemalloc_test.h.in @@ -132,6 +132,11 @@ static const bool config_debug = #define MEXP 19937 #include "test/SFMT.h" +#ifndef JEMALLOC_HAVE_MALLOC_SIZE +#define TEST_MALLOC_SIZE malloc_usable_size +#else +#define TEST_MALLOC_SIZE malloc_size +#endif /******************************************************************************/ /* * Define always-enabled assertion macros, so that test assertions execute even diff --git a/test/integration/aligned_alloc.c b/test/integration/aligned_alloc.c index 3f619e7e..b37d5ba0 100644 --- a/test/integration/aligned_alloc.c +++ b/test/integration/aligned_alloc.c @@ -120,7 +120,7 @@ TEST_BEGIN(test_alignment_and_size) { "size=%zu (%#zx): %s", alignment, size, size, buf); } - total += malloc_usable_size(ps[i]); + total += TEST_MALLOC_SIZE(ps[i]); if (total >= (MAXALIGN << 1)) { break; } @@ -141,7 +141,7 @@ TEST_END TEST_BEGIN(test_zero_alloc) { void *res = aligned_alloc(8, 0); assert(res); - size_t usable = malloc_usable_size(res); + size_t usable = TEST_MALLOC_SIZE(res); assert(usable > 0); free(res); } diff --git a/test/integration/allocated.c b/test/integration/allocated.c index 8f2f21d5..0c64272c 100644 --- a/test/integration/allocated.c +++ b/test/integration/allocated.c @@ -70,7 +70,7 @@ thd_start(void *arg) { expect_ptr_eq(ap0, ap1, "Pointer returned by \"thread.allocatedp\" should not change"); - usize = malloc_usable_size(p); + usize = TEST_MALLOC_SIZE(p); expect_u64_le(a0 + usize, a1, "Allocated memory counter should increase by at least the amount " "explicitly allocated"); diff --git a/test/integration/malloc.c b/test/integration/malloc.c index 8b33bc8f..ef449163 100644 --- a/test/integration/malloc.c +++ b/test/integration/malloc.c @@ -3,7 +3,7 @@ TEST_BEGIN(test_zero_alloc) { void *res = malloc(0); assert(res); - size_t usable = malloc_usable_size(res); + size_t usable = TEST_MALLOC_SIZE(res); assert(usable > 0); free(res); } diff --git a/test/integration/posix_memalign.c b/test/integration/posix_memalign.c index 6f8a1b03..2da0549b 100644 --- a/test/integration/posix_memalign.c +++ b/test/integration/posix_memalign.c @@ -101,7 +101,7 @@ TEST_BEGIN(test_alignment_and_size) { "size=%zu (%#zx): %s", alignment, size, size, buf); } - total += malloc_usable_size(ps[i]); + total += TEST_MALLOC_SIZE(ps[i]); if (total >= (MAXALIGN << 1)) { break; } diff --git a/test/integration/rallocx.c b/test/integration/rallocx.c index 57c7967f..d4a48fce 100644 --- a/test/integration/rallocx.c +++ b/test/integration/rallocx.c @@ -185,7 +185,7 @@ TEST_BEGIN(test_align_enum) { assert_ptr_not_null(p, "Unexpected mallocx() error"); assert_zu_eq(nallocx(1, flags), - malloc_usable_size(p), + TEST_MALLOC_SIZE(p), "Wrong mallocx() usable size"); int flags_next = MALLOCX_LG_ALIGN(lg_align_next); @@ -193,7 +193,7 @@ TEST_BEGIN(test_align_enum) { assert_ptr_not_null(p, "Unexpected rallocx() error"); expect_zu_eq(nallocx(size, flags_next), - malloc_usable_size(p), + TEST_MALLOC_SIZE(p), "Wrong rallocx() usable size"); free(p); } diff --git a/test/stress/microbench.c b/test/stress/microbench.c index 226677f7..062e32fd 100644 --- a/test/stress/microbench.c +++ b/test/stress/microbench.c @@ -69,7 +69,7 @@ malloc_mus_free(void) { test_fail("Unexpected malloc() failure"); return; } - malloc_usable_size(p); + TEST_MALLOC_SIZE(p); free(p); } diff --git a/test/unit/junk.c b/test/unit/junk.c index 314da3ce..543092f1 100644 --- a/test/unit/junk.c +++ b/test/unit/junk.c @@ -30,7 +30,7 @@ do_allocs(size_t size, bool zero, size_t lg_align) { if (opt_junk_alloc && !zero) { \ expect_ptr_eq(ptr, last_junked_ptr, ""); \ expect_zu_eq(last_junked_usize, \ - malloc_usable_size(ptr), ""); \ + TEST_MALLOC_SIZE(ptr), ""); \ } \ } while (0) if (!zero && lg_align == 0) { diff --git a/test/unit/prof_stats.c b/test/unit/prof_stats.c index a9145871..c88c4ae0 100644 --- a/test/unit/prof_stats.c +++ b/test/unit/prof_stats.c @@ -43,7 +43,7 @@ test_combinations(szind_t ind, size_t sizes_array[N_PTRS], int flags = flags_array[i]; void *p = mallocx(sz, flags); assert_ptr_not_null(p, "malloc() failed"); - assert(malloc_usable_size(p) == sz_index2size(ind)); + assert(TEST_MALLOC_SIZE(p) == sz_index2size(ind)); ptrs[i] = p; live_req_sum += sz; live_count++; |