2 * D E B U G R O U T I N E S
4 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
11 #define TIMEOUT_DEBUG 1
12 #define DEBUG_LEVEL timeout_debug
14 static int timeout_debug
;
16 #define SAYit_(lvl, fmt, ...) do { \
17 if (DEBUG_LEVEL >= (lvl)) \
18 fprintf(stderr, fmt "%s", __FILE__, __LINE__, __func__, __VA_ARGS__); \
21 #define SAYit(lvl, ...) SAYit_((lvl), "%s:%d:%s: " __VA_ARGS__, "\n")
23 #define PANIC(...) do { \
24 SAYit(0, __VA_ARGS__); \
25 _Exit(EXIT_FAILURE); \
29 #define TIMEOUT_DEBUG 0
32 #define SAYit(...) (void)0
35 #define SAY(...) SAYit(1, __VA_ARGS__)
36 #define HAI SAY("HAI")
39 static inline char *fmt_(char *buf
, uint64_t ts
, int wheel_bit
, int wheel_num
) {
43 for (wheel
= wheel_num
- 2; wheel
>= 0; wheel
--) {
44 n
= ((1 << wheel_bit
) - 1) & (ts
>> (wheel
* WHEEL_BIT
));
46 for (i
= wheel_bit
- 1; i
>= 0; i
--) {
47 *p
++ = '0' + !!(n
& (1 << i
));
59 #define fmt(ts) fmt_(((char[((1 << WHEEL_BIT) * WHEEL_NUM) + WHEEL_NUM + 1]){ 0 }), (ts), WHEEL_BIT, WHEEL_NUM)
62 static inline char *bin64_(char *buf
, uint64_t n
, int wheel_bit
) {
66 for (i
= 0; i
< (1 << wheel_bit
); i
++) {
67 *p
++ = "01"[0x1 & (n
>> (((1 << wheel_bit
) - 1) - i
))];
75 #define bin64(ts) bin64_(((char[((1 << WHEEL_BIT) * WHEEL_NUM) + 1]){ 0 }), (ts), WHEEL_BIT)