… | |
… | |
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)) |