2 * Copyright 2004-2005 Timo Hirvonen
9 #include "config/debug.h"
17 void debug_init(void);
18 void __debug_bug(const char *function
, const char *fmt
, ...) __FORMAT(2, 3) __NORETURN
;
19 void __debug_print(const char *function
, const char *fmt
, ...) __FORMAT(2, 3);
21 /* ------------------------------------------------------------------------ */
25 #define BUG(...) do { } while (0)
29 #define BUG(...) __debug_bug(__FUNCTION__, __VA_ARGS__)
33 /* ------------------------------------------------------------------------ */
37 #define d_print(...) do { } while (0)
39 static inline uint64_t timer_get(void)
44 static inline void timer_print(const char *what
, uint64_t usec
)
50 #define d_print(...) __debug_print(__FUNCTION__, __VA_ARGS__)
52 static inline uint64_t timer_get(void)
56 gettimeofday(&tv
, NULL
);
57 return tv
.tv_sec
* 1e6L
+ tv
.tv_usec
;
60 static inline void timer_print(const char *what
, uint64_t usec
)
62 uint64_t a
= usec
/ 1e6
;
63 uint64_t b
= usec
- a
* 1e6
;
65 __debug_print("TIMER", "%s: %11u.%06u\n", what
, (unsigned int)a
, (unsigned int)b
);
70 /* ------------------------------------------------------------------------ */
77 BUG("%s\n", __STR(a)); \