Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | #define JEMALLOC_MANGLE |
michael@0 | 2 | #include "jemalloc_test.h" |
michael@0 | 3 | |
michael@0 | 4 | void * |
michael@0 | 5 | je_thread_start(void *arg) |
michael@0 | 6 | { |
michael@0 | 7 | int err; |
michael@0 | 8 | size_t sz; |
michael@0 | 9 | bool e0, e1; |
michael@0 | 10 | |
michael@0 | 11 | sz = sizeof(bool); |
michael@0 | 12 | if ((err = mallctl("thread.tcache.enabled", &e0, &sz, NULL, 0))) { |
michael@0 | 13 | if (err == ENOENT) { |
michael@0 | 14 | #ifdef JEMALLOC_TCACHE |
michael@0 | 15 | assert(false); |
michael@0 | 16 | #endif |
michael@0 | 17 | } |
michael@0 | 18 | goto label_return; |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | if (e0) { |
michael@0 | 22 | e1 = false; |
michael@0 | 23 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) |
michael@0 | 24 | == 0); |
michael@0 | 25 | assert(e0); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | e1 = true; |
michael@0 | 29 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); |
michael@0 | 30 | assert(e0 == false); |
michael@0 | 31 | |
michael@0 | 32 | e1 = true; |
michael@0 | 33 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); |
michael@0 | 34 | assert(e0); |
michael@0 | 35 | |
michael@0 | 36 | e1 = false; |
michael@0 | 37 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); |
michael@0 | 38 | assert(e0); |
michael@0 | 39 | |
michael@0 | 40 | e1 = false; |
michael@0 | 41 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); |
michael@0 | 42 | assert(e0 == false); |
michael@0 | 43 | |
michael@0 | 44 | free(malloc(1)); |
michael@0 | 45 | e1 = true; |
michael@0 | 46 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); |
michael@0 | 47 | assert(e0 == false); |
michael@0 | 48 | |
michael@0 | 49 | free(malloc(1)); |
michael@0 | 50 | e1 = true; |
michael@0 | 51 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); |
michael@0 | 52 | assert(e0); |
michael@0 | 53 | |
michael@0 | 54 | free(malloc(1)); |
michael@0 | 55 | e1 = false; |
michael@0 | 56 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); |
michael@0 | 57 | assert(e0); |
michael@0 | 58 | |
michael@0 | 59 | free(malloc(1)); |
michael@0 | 60 | e1 = false; |
michael@0 | 61 | assert(mallctl("thread.tcache.enabled", &e0, &sz, &e1, sz) == 0); |
michael@0 | 62 | assert(e0 == false); |
michael@0 | 63 | |
michael@0 | 64 | free(malloc(1)); |
michael@0 | 65 | label_return: |
michael@0 | 66 | return (NULL); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | int |
michael@0 | 70 | main(void) |
michael@0 | 71 | { |
michael@0 | 72 | int ret = 0; |
michael@0 | 73 | je_thread_t thread; |
michael@0 | 74 | |
michael@0 | 75 | malloc_printf("Test begin\n"); |
michael@0 | 76 | |
michael@0 | 77 | je_thread_start(NULL); |
michael@0 | 78 | |
michael@0 | 79 | je_thread_create(&thread, je_thread_start, NULL); |
michael@0 | 80 | je_thread_join(thread, (void *)&ret); |
michael@0 | 81 | |
michael@0 | 82 | je_thread_start(NULL); |
michael@0 | 83 | |
michael@0 | 84 | je_thread_create(&thread, je_thread_start, NULL); |
michael@0 | 85 | je_thread_join(thread, (void *)&ret); |
michael@0 | 86 | |
michael@0 | 87 | je_thread_start(NULL); |
michael@0 | 88 | |
michael@0 | 89 | malloc_printf("Test end\n"); |
michael@0 | 90 | return (ret); |
michael@0 | 91 | } |