… | |
… | |
11 | #define PP_STRINGIFY_(a) #a |
11 | #define PP_STRINGIFY_(a) #a |
12 | #define PP_STRINGIFY(a) PP_STRINGIFY_(a) |
12 | #define PP_STRINGIFY(a) PP_STRINGIFY_(a) |
13 | |
13 | |
14 | #define HAVE_GCC_BUILTINS (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ == 4)) |
14 | #define HAVE_GCC_BUILTINS (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ == 4)) |
15 | |
15 | |
16 | #ifndef __attribute__ |
|
|
17 | # if __GNUC__ |
16 | #if __GNUC__ >= 3 |
18 | # if (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (__GNUC__ < 2) |
17 | # define rxvt_attribute(x) __attribute__(x) |
19 | # define __attribute__(x) |
18 | #else |
20 | # endif |
|
|
21 | # endif |
|
|
22 | # define __attribute__(x) |
19 | # define rxvt_attribute(x) |
23 | #endif |
20 | #endif |
24 | |
21 | |
25 | #define NORETURN __attribute__ ((noreturn)) |
22 | #define NORETURN rxvt_attribute ((noreturn)) |
26 | #define UNUSED __attribute__ ((unused)) |
23 | #define UNUSED rxvt_attribute ((unused)) |
27 | #define CONST __attribute__ ((const)) |
24 | #define CONST rxvt_attribute ((const)) |
28 | |
25 | |
29 | // increases code size unless -fno-enforce-eh-specs |
26 | // increases code size unless -fno-enforce-eh-specs |
30 | #if __GNUC__ |
27 | #if __GNUC__ |
31 | # define NOTHROW |
28 | # define NOTHROW |
32 | # define THROW(x) |
29 | # define THROW(x) |
… | |
… | |
67 | return (long(a) * long(100 - p) + long(b) * long(p) + 50) / 100; |
64 | return (long(a) * long(100 - p) + long(b) * long(p) + 50) / 100; |
68 | } |
65 | } |
69 | |
66 | |
70 | // some bit functions, xft fuck me plenty |
67 | // some bit functions, xft fuck me plenty |
71 | #if HAVE_GCC_BUILTINS |
68 | #if HAVE_GCC_BUILTINS |
72 | static inline int ctz (unsigned int x) CONST { return __builtin_ctz (x); } |
69 | static inline int ctz (unsigned int x) { return __builtin_ctz (x); } |
73 | static inline int popcount (unsigned int x) CONST { return __builtin_popcount (x); } |
70 | static inline int popcount (unsigned int x) { return __builtin_popcount (x); } |
74 | #else |
71 | #else |
75 | // count trailing zero bits and count # of one bits |
72 | // count trailing zero bits and count # of one bits |
76 | int ctz (unsigned int x) CONST; |
73 | int ctz (unsigned int x) CONST; |
77 | int popcount (unsigned int x) CONST; |
74 | int popcount (unsigned int x) CONST; |
78 | #endif |
75 | #endif |