thread_event.c 826 B

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