]>
git.saurik.com Git - redis.git/blob - deps/jemalloc/test/thread_arena.c
7 #define JEMALLOC_MANGLE
8 #include "jemalloc_test.h"
13 thread_start(void *arg
)
15 unsigned main_arena_ind
= *(unsigned *)arg
;
21 p
= JEMALLOC_P(malloc
)(1);
23 fprintf(stderr
, "%s(): Error in malloc()\n", __func__
);
27 size
= sizeof(arena_ind
);
28 if ((err
= JEMALLOC_P(mallctl
)("thread.arena", &arena_ind
, &size
,
29 &main_arena_ind
, sizeof(main_arena_ind
)))) {
30 fprintf(stderr
, "%s(): Error in mallctl(): %s\n", __func__
,
35 size
= sizeof(arena_ind
);
36 if ((err
= JEMALLOC_P(mallctl
)("thread.arena", &arena_ind
, &size
, NULL
,
38 fprintf(stderr
, "%s(): Error in mallctl(): %s\n", __func__
,
42 assert(arena_ind
== main_arena_ind
);
55 pthread_t threads
[NTHREADS
];
58 fprintf(stderr
, "Test begin\n");
60 p
= JEMALLOC_P(malloc
)(1);
62 fprintf(stderr
, "%s(): Error in malloc()\n", __func__
);
67 size
= sizeof(arena_ind
);
68 if ((err
= JEMALLOC_P(mallctl
)("thread.arena", &arena_ind
, &size
, NULL
,
70 fprintf(stderr
, "%s(): Error in mallctl(): %s\n", __func__
,
76 for (i
= 0; i
< NTHREADS
; i
++) {
77 if (pthread_create(&threads
[i
], NULL
, thread_start
,
78 (void *)&arena_ind
) != 0) {
79 fprintf(stderr
, "%s(): Error in pthread_create()\n",
86 for (i
= 0; i
< NTHREADS
; i
++)
87 pthread_join(threads
[i
], (void *)&ret
);
90 fprintf(stderr
, "Test end\n");