1#include "test/jemalloc_test.h"
2
3#define	NTHREADS		4
4#define	NALLOCS_PER_THREAD	50
5#define	DUMP_INTERVAL		1
6#define	BT_COUNT_CHECK_INTERVAL	5
7
8#define	alloc_n_proto(n)						\
9void	*alloc_##n(unsigned bits);
10alloc_n_proto(0)
11alloc_n_proto(1)
12
13#define	alloc_n_gen(n)							\
14void *									\
15alloc_##n(unsigned bits)						\
16{									\
17	void *p;							\
18									\
19	if (bits == 0)							\
20		p = mallocx(1, 0);					\
21	else {								\
22		switch (bits & 0x1U) {					\
23		case 0:							\
24			p = (alloc_0(bits >> 1));			\
25			break;						\
26		case 1:							\
27			p = (alloc_1(bits >> 1));			\
28			break;						\
29		default: not_reached();					\
30		}							\
31	}								\
32	/* Intentionally sabotage tail call optimization. */		\
33	assert_ptr_not_null(p, "Unexpected mallocx() failure");		\
34	return (p);							\
35}
36