]>
git.saurik.com Git - redis.git/blob - deps/jemalloc/test/allocated.c
1 #define JEMALLOC_MANGLE
2 #include "jemalloc_test.h"
5 je_thread_start(void *arg
)
9 uint64_t a0
, a1
, d0
, d1
;
10 uint64_t *ap0
, *ap1
, *dp0
, *dp1
;
14 if ((err
= mallctl("thread.allocated", &a0
, &sz
, NULL
, 0))) {
21 malloc_printf("%s(): Error in mallctl(): %s\n", __func__
,
26 if ((err
= mallctl("thread.allocatedp", &ap0
, &sz
, NULL
, 0))) {
33 malloc_printf("%s(): Error in mallctl(): %s\n", __func__
,
40 if ((err
= mallctl("thread.deallocated", &d0
, &sz
, NULL
, 0))) {
47 malloc_printf("%s(): Error in mallctl(): %s\n", __func__
,
52 if ((err
= mallctl("thread.deallocatedp", &dp0
, &sz
, NULL
, 0))) {
59 malloc_printf("%s(): Error in mallctl(): %s\n", __func__
,
67 malloc_printf("%s(): Error in malloc()\n", __func__
);
72 mallctl("thread.allocated", &a1
, &sz
, NULL
, 0);
74 mallctl("thread.allocatedp", &ap1
, &sz
, NULL
, 0);
78 usize
= malloc_usable_size(p
);
79 assert(a0
+ usize
<= a1
);
84 mallctl("thread.deallocated", &d1
, &sz
, NULL
, 0);
86 mallctl("thread.deallocatedp", &dp1
, &sz
, NULL
, 0);
90 assert(d0
+ usize
<= d1
);
102 malloc_printf("Test begin\n");
104 je_thread_start(NULL
);
106 je_thread_create(&thread
, je_thread_start
, NULL
);
107 je_thread_join(thread
, (void *)&ret
);
109 je_thread_start(NULL
);
111 je_thread_create(&thread
, je_thread_start
, NULL
);
112 je_thread_join(thread
, (void *)&ret
);
114 je_thread_start(NULL
);
116 malloc_printf("Test end\n");