summaryrefslogtreecommitdiff
path: root/deps/jemalloc/test/unit/prof_accum.h
blob: 109d86b598dd35772d8049916fa391f50234a730 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "test/jemalloc_test.h"

#define	NTHREADS		4
#define	NALLOCS_PER_THREAD	50
#define	DUMP_INTERVAL		1
#define	BT_COUNT_CHECK_INTERVAL	5

#define	alloc_n_proto(n)						\
void	*alloc_##n(unsigned bits);
alloc_n_proto(0)
alloc_n_proto(1)

#define	alloc_n_gen(n)							\
void *									\
alloc_##n(unsigned bits)						\
{									\
	void *p;							\
									\
	if (bits == 0)							\
		p = mallocx(1, 0);					\
	else {								\
		switch (bits & 0x1U) {					\
		case 0:							\
			p = (alloc_0(bits >> 1));			\
			break;						\
		case 1:							\
			p = (alloc_1(bits >> 1));			\
			break;						\
		default: not_reached();					\
		}							\
	}								\
	/* Intentionally sabotage tail call optimization. */		\
	assert_ptr_not_null(p, "Unexpected mallocx() failure");		\
	return (p);							\
}