Refactor permuted backtrace test allocation.

Refactor permuted backtrace test allocation that was originally used
only by the prof_accum test, so that it can be used by other heap
profiling test binaries.
This commit is contained in:
Jason Evans
2014-10-01 17:51:52 -07:00
parent f8034540a1
commit cc9e626ea9
10 changed files with 60 additions and 56 deletions

View File

@@ -1,4 +1,9 @@
#include "prof_accum.h"
#include "test/jemalloc_test.h"
#define NTHREADS 4
#define NALLOCS_PER_THREAD 50
#define DUMP_INTERVAL 1
#define BT_COUNT_CHECK_INTERVAL 5
#ifdef JEMALLOC_PROF
const char *malloc_conf =
@@ -20,7 +25,7 @@ static void *
alloc_from_permuted_backtrace(unsigned thd_ind, unsigned iteration)
{
return (alloc_0(thd_ind*NALLOCS_PER_THREAD + iteration));
return (btalloc(1, thd_ind*NALLOCS_PER_THREAD + iteration));
}
static void *

View File

@@ -1,35 +0,0 @@
#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); \
}

View File

@@ -1,3 +0,0 @@
#include "prof_accum.h"
alloc_n_gen(0)

View File

@@ -1,3 +0,0 @@
#include "prof_accum.h"
alloc_n_gen(1)