35 #define containerof(ptr, type, member) \
36 ((type *) (((char *) ptr) - offsetof(type, member)))
44 #define lengthof(x) ((sizeof(x) / sizeof(*(x))))
49 printf("Checking %s ... ", #s); \
55 #define verify(x) assert(x)
96 #define RATELIMIT_TO(n, window, fn) \
98 static ratelimit_state_t rs_; \
99 if (ratelimit_check(&rs_, n, window)) \
106 #define RATELIMIT(fn) RATELIMIT_TO(3, 10, fn)
void * xmalloc(size_t sz)
bool ratelimit_check(ratelimit_state_t *rs, uint32_t n, uint32_t window)
Check that the rate limiter has not triggered.
int32_t cyclecmp32(uint32_t a, uint32_t b)
Compares values that may be subject to overflow.
Control structure used for rate limiting.
void rf_internal_out_of_memory(void)