… | |
… | |
20 | # define rxvt_attribute(x) |
20 | # define rxvt_attribute(x) |
21 | # define expect(expr,value) (expr) |
21 | # define expect(expr,value) (expr) |
22 | #endif |
22 | #endif |
23 | |
23 | |
24 | // put into ifs if you are very sure that the expression |
24 | // put into ifs if you are very sure that the expression |
25 | // is mostly true or mosty false. note that these return |
25 | // is mostly true or mostly false. note that these return |
26 | // booleans, not the expression. |
26 | // booleans, not the expression. |
27 | #define expect_false(expr) expect ((expr) != 0, 0) |
27 | #define expect_false(expr) expect ((expr) != 0, 0) |
28 | #define expect_true(expr) expect ((expr) != 0, 1) |
28 | #define expect_true(expr) expect ((expr) != 0, 1) |
29 | |
29 | |
30 | #define NORETURN rxvt_attribute ((noreturn)) |
30 | #define NORETURN rxvt_attribute ((noreturn)) |
… | |
… | |
91 | return (T *)rxvt_temp_buf (len * sizeof (T)); |
91 | return (T *)rxvt_temp_buf (len * sizeof (T)); |
92 | } |
92 | } |
93 | |
93 | |
94 | // some bit functions, xft fuck me plenty |
94 | // some bit functions, xft fuck me plenty |
95 | #if HAVE_GCC_BUILTINS |
95 | #if HAVE_GCC_BUILTINS |
|
|
96 | /* netbsd stupidly defines popcount itself and puts it into string.h */ |
96 | static inline int ctz (unsigned int x) { return __builtin_ctz (x); } |
97 | static inline int rxvt_ctz (unsigned int x) { return __builtin_ctz (x); } |
97 | static inline int popcount (unsigned int x) { return __builtin_popcount (x); } |
98 | static inline int rxvt_popcount (unsigned int x) { return __builtin_popcount (x); } |
98 | #else |
99 | #else |
99 | // count trailing zero bits and count # of one bits |
100 | // count trailing zero bits and count # of one bits |
100 | int ctz (unsigned int x) CONST; |
101 | int rxvt_ctz (unsigned int x) CONST; |
101 | int popcount (unsigned int x) CONST; |
102 | int rxvt_popcount (unsigned int x) CONST; |
102 | #endif |
103 | #endif |
103 | |
104 | |
104 | // in range including end |
105 | // in range including end |
105 | #define IN_RANGE_INC(val,beg,end) \ |
106 | #define IN_RANGE_INC(val,beg,end) \ |
106 | ((unsigned int)(val) - (unsigned int)(beg) <= (unsigned int)(end) - (unsigned int)(beg)) |
107 | ((unsigned int)(val) - (unsigned int)(beg) <= (unsigned int)(end) - (unsigned int)(beg)) |