1 #include "test/jemalloc_test.h" 2 3 TEST_BEGIN(test_next_event_fast) { 4 tsd_t *tsd = tsd_fetch(); 5 te_ctx_t ctx; 6 te_ctx_get(tsd, &ctx, true); 7 8 te_ctx_last_event_set(&ctx, 0); 9 te_ctx_current_bytes_set(&ctx, TE_NEXT_EVENT_FAST_MAX - 8U); 10 te_ctx_next_event_set(tsd, &ctx, TE_NEXT_EVENT_FAST_MAX); 11 #define E(event, condition, is_alloc) \ 12 if (is_alloc && condition) { \ 13 event##_event_wait_set(tsd, TE_NEXT_EVENT_FAST_MAX); \ 14 } 15 ITERATE_OVER_ALL_EVENTS 16 #undef E 17 18 /* Test next_event_fast rolling back to 0. */ 19 void *p = malloc(16U); 20 assert_ptr_not_null(p, "malloc() failed"); 21 free(p); 22 23 /* Test next_event_fast resuming to be equal to next_event. */ 24 void *q = malloc(SC_LOOKUP_MAXCLASS); 25 assert_ptr_not_null(q, "malloc() failed"); 26 free(q); 27 } 28 TEST_END 29 30 int 31 main(void) { 32 return test( 33 test_next_event_fast); 34 } 35