]>
Commit | Line | Data |
---|---|---|
0ce617c8 JF |
1 | #define __STDC_LIMIT_MACROS |
2 | #include <stdint.h> | |
3 | ||
7e9a36b6 JF |
4 | #include <objc/objc.h> |
5 | ||
dfaac1da JF |
6 | #include <sys/time.h> |
7 | #include <time.h> | |
8 | ||
7a5040cc JF |
9 | #define _forever \ |
10 | for (;;) | |
11 | ||
0ce617c8 JF |
12 | extern struct timeval _ltv; |
13 | extern bool _itv; | |
14 | ||
dfaac1da | 15 | #define _trace() do { \ |
0ce617c8 JF |
16 | struct timeval _ctv; \ |
17 | gettimeofday(&_ctv, NULL); \ | |
18 | if (!_itv) { \ | |
19 | _itv = true; \ | |
20 | _ltv = _ctv; \ | |
21 | } \ | |
22 | fprintf(stderr, "%lu.%.6u[%f]:_trace()@%s:%u[%s]\n", \ | |
23 | _ctv.tv_sec, _ctv.tv_usec, \ | |
24 | (_ctv.tv_sec - _ltv.tv_sec) + (_ctv.tv_usec - _ltv.tv_usec) / 1000000.0, \ | |
25 | __FILE__, __LINE__, __FUNCTION__\ | |
26 | ); \ | |
27 | _ltv = _ctv; \ | |
dfaac1da | 28 | } while (false) |
7e9a36b6 JF |
29 | |
30 | #define _assert(test) do \ | |
31 | if (!(test)) { \ | |
32 | fprintf(stderr, "_assert(%d:%s)@%s:%u[%s]\n", errno, #test, __FILE__, __LINE__, __FUNCTION__); \ | |
33 | exit(-1); \ | |
34 | } \ | |
35 | while (false) | |
36 | ||
37 | #define _not(type) ((type) ~ (type) 0) | |
38 | ||
39 | #define _transient | |
ae5602da JF |
40 | |
41 | #define _label__(x) _label ## x | |
42 | #define _label_(y) _label__(y) | |
43 | #define _label _label_(__LINE__) | |
a30c20bd JF |
44 | |
45 | #define _packed \ | |
600d005d JF |
46 | __attribute__((__packed__)) |
47 | #define _finline \ | |
48 | inline __attribute__((__always_inline__)) | |
670a0494 JF |
49 | |
50 | #define _assume(e) \ | |
51 | _assert(e) | |
52 | ||
53 | #define _nodefault \ | |
54 | default: \ | |
55 | _assume(false); \ | |
56 | throw; | |
cf48f656 JF |
57 | |
58 | #define _likely(expr) \ | |
59 | __builtin_expect(expr, 1) | |
60 | ||
61 | #define _unlikely(expr) \ | |
62 | __builtin_expect(expr, 0) |