1a0698ed9Schristos #include "test/jemalloc_test.h" 2a0698ed9Schristos 3a0698ed9Schristos void * 4a0698ed9Schristos thd_start(void *arg) { 5a0698ed9Schristos bool e0, e1; 6a0698ed9Schristos size_t sz = sizeof(bool); 7*7bdf38e5Schristos expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, NULL, 8a0698ed9Schristos 0), 0, "Unexpected mallctl failure"); 9a0698ed9Schristos 10a0698ed9Schristos if (e0) { 11a0698ed9Schristos e1 = false; 12*7bdf38e5Schristos expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, 13a0698ed9Schristos (void *)&e1, sz), 0, "Unexpected mallctl() error"); 14*7bdf38e5Schristos expect_true(e0, "tcache should be enabled"); 15a0698ed9Schristos } 16a0698ed9Schristos 17a0698ed9Schristos e1 = true; 18*7bdf38e5Schristos expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, 19a0698ed9Schristos (void *)&e1, sz), 0, "Unexpected mallctl() error"); 20*7bdf38e5Schristos expect_false(e0, "tcache should be disabled"); 21a0698ed9Schristos 22a0698ed9Schristos e1 = true; 23*7bdf38e5Schristos expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, 24a0698ed9Schristos (void *)&e1, sz), 0, "Unexpected mallctl() error"); 25*7bdf38e5Schristos expect_true(e0, "tcache should be enabled"); 26a0698ed9Schristos 27a0698ed9Schristos e1 = false; 28*7bdf38e5Schristos expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, 29a0698ed9Schristos (void *)&e1, sz), 0, "Unexpected mallctl() error"); 30*7bdf38e5Schristos expect_true(e0, "tcache should be enabled"); 31a0698ed9Schristos 32a0698ed9Schristos e1 = false; 33*7bdf38e5Schristos expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, 34a0698ed9Schristos (void *)&e1, sz), 0, "Unexpected mallctl() error"); 35*7bdf38e5Schristos expect_false(e0, "tcache should be disabled"); 36a0698ed9Schristos 37a0698ed9Schristos free(malloc(1)); 38a0698ed9Schristos e1 = true; 39*7bdf38e5Schristos expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, 40a0698ed9Schristos (void *)&e1, sz), 0, "Unexpected mallctl() error"); 41*7bdf38e5Schristos expect_false(e0, "tcache should be disabled"); 42a0698ed9Schristos 43a0698ed9Schristos free(malloc(1)); 44a0698ed9Schristos e1 = true; 45*7bdf38e5Schristos expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, 46a0698ed9Schristos (void *)&e1, sz), 0, "Unexpected mallctl() error"); 47*7bdf38e5Schristos expect_true(e0, "tcache should be enabled"); 48a0698ed9Schristos 49a0698ed9Schristos free(malloc(1)); 50a0698ed9Schristos e1 = false; 51*7bdf38e5Schristos expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, 52a0698ed9Schristos (void *)&e1, sz), 0, "Unexpected mallctl() error"); 53*7bdf38e5Schristos expect_true(e0, "tcache should be enabled"); 54a0698ed9Schristos 55a0698ed9Schristos free(malloc(1)); 56a0698ed9Schristos e1 = false; 57*7bdf38e5Schristos expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, 58a0698ed9Schristos (void *)&e1, sz), 0, "Unexpected mallctl() error"); 59*7bdf38e5Schristos expect_false(e0, "tcache should be disabled"); 60a0698ed9Schristos 61a0698ed9Schristos free(malloc(1)); 62a0698ed9Schristos return NULL; 63a0698ed9Schristos } 64a0698ed9Schristos 65a0698ed9Schristos TEST_BEGIN(test_main_thread) { 66a0698ed9Schristos thd_start(NULL); 67a0698ed9Schristos } 68a0698ed9Schristos TEST_END 69a0698ed9Schristos 70a0698ed9Schristos TEST_BEGIN(test_subthread) { 71a0698ed9Schristos thd_t thd; 72a0698ed9Schristos 73a0698ed9Schristos thd_create(&thd, thd_start, NULL); 74a0698ed9Schristos thd_join(thd, NULL); 75a0698ed9Schristos } 76a0698ed9Schristos TEST_END 77a0698ed9Schristos 78a0698ed9Schristos int 79a0698ed9Schristos main(void) { 80a0698ed9Schristos /* Run tests multiple times to check for bad interactions. */ 81a0698ed9Schristos return test( 82a0698ed9Schristos test_main_thread, 83a0698ed9Schristos test_subthread, 84a0698ed9Schristos test_main_thread, 85a0698ed9Schristos test_subthread, 86a0698ed9Schristos test_main_thread); 87a0698ed9Schristos } 88