]> git.proxmox.com Git - rustc.git/blame - src/jemalloc/test/include/test/btalloc.h
New upstream version 1.22.1+dfsg1
[rustc.git] / src / jemalloc / test / include / test / btalloc.h
CommitLineData
1a4d82fc
JJ
1/* btalloc() provides a mechanism for allocating via permuted backtraces. */
2void *btalloc(size_t size, unsigned bits);
3
4#define btalloc_n_proto(n) \
5void *btalloc_##n(size_t size, unsigned bits);
6btalloc_n_proto(0)
7btalloc_n_proto(1)
8
9#define btalloc_n_gen(n) \
10void * \
11btalloc_##n(size_t size, unsigned bits) \
12{ \
13 void *p; \
14 \
15 if (bits == 0) \
16 p = mallocx(size, 0); \
17 else { \
18 switch (bits & 0x1U) { \
19 case 0: \
20 p = (btalloc_0(size, bits >> 1)); \
21 break; \
22 case 1: \
23 p = (btalloc_1(size, bits >> 1)); \
24 break; \
25 default: not_reached(); \
26 } \
27 } \
28 /* Intentionally sabotage tail call optimization. */ \
29 assert_ptr_not_null(p, "Unexpected mallocx() failure"); \
30 return (p); \
31}