]>
git.saurik.com Git - redis.git/blob - deps/jemalloc/test/thread_arena.c
2ffdb5e800470630f786f9b267374103f5c51bc3
1 #define JEMALLOC_MANGLE
2 #include "jemalloc_test.h"
7 je_thread_start(void *arg
)
9 unsigned main_arena_ind
= *(unsigned *)arg
;
17 malloc_printf("%s(): Error in malloc()\n", __func__
);
21 size
= sizeof(arena_ind
);
22 if ((err
= mallctl("thread.arena", &arena_ind
, &size
, &main_arena_ind
,
23 sizeof(main_arena_ind
)))) {
24 malloc_printf("%s(): Error in mallctl(): %s\n", __func__
,
29 size
= sizeof(arena_ind
);
30 if ((err
= mallctl("thread.arena", &arena_ind
, &size
, NULL
,
32 malloc_printf("%s(): Error in mallctl(): %s\n", __func__
,
36 assert(arena_ind
== main_arena_ind
);
49 je_thread_t threads
[NTHREADS
];
52 malloc_printf("Test begin\n");
56 malloc_printf("%s(): Error in malloc()\n", __func__
);
61 size
= sizeof(arena_ind
);
62 if ((err
= mallctl("thread.arena", &arena_ind
, &size
, NULL
, 0))) {
63 malloc_printf("%s(): Error in mallctl(): %s\n", __func__
,
69 for (i
= 0; i
< NTHREADS
; i
++) {
70 je_thread_create(&threads
[i
], je_thread_start
,
74 for (i
= 0; i
< NTHREADS
; i
++)
75 je_thread_join(threads
[i
], (void *)&ret
);
78 malloc_printf("Test end\n");