… | |
… | |
9 | #define PP_CONCAT_(a, b) a ## b |
9 | #define PP_CONCAT_(a, b) a ## b |
10 | #define PP_CONCAT(a, b) PP_CONCAT_(a, b) |
10 | #define PP_CONCAT(a, b) PP_CONCAT_(a, b) |
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 | // actually, some gcc-3.x versions work, too |
14 | #define HAVE_GCC_BUILTINS (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ == 4)) |
15 | #define HAVE_GCC_BUILTINS (__GNUC__ >= 4) |
|
|
16 | |
15 | |
17 | #ifndef __attribute__ |
|
|
18 | # if __GNUC__ |
16 | #if __GNUC__ >= 3 |
19 | # if (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (__GNUC__ < 2) |
17 | # define rxvt_attribute(x) __attribute__(x) |
20 | # define __attribute__(x) |
18 | #else |
21 | # endif |
|
|
22 | # endif |
|
|
23 | # define __attribute__(x) |
19 | # define rxvt_attribute(x) |
24 | #endif |
20 | #endif |
25 | |
21 | |
26 | #define NORETURN __attribute__ ((noreturn)) |
22 | #define NORETURN rxvt_attribute ((noreturn)) |
27 | #define UNUSED __attribute__ ((unused)) |
23 | #define UNUSED rxvt_attribute ((unused)) |
28 | #define CONST __attribute__ ((const)) |
24 | #define CONST rxvt_attribute ((const)) |
29 | |
25 | |
30 | // increases code size unless -fno-enforce-eh-specs |
26 | // increases code size unless -fno-enforce-eh-specs |
31 | #if __GNUC__ |
27 | #if __GNUC__ |
32 | # define NOTHROW |
28 | # define NOTHROW |
33 | # define THROW(x) |
29 | # define THROW(x) |
… | |
… | |
68 | 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; |
69 | } |
65 | } |
70 | |
66 | |
71 | // some bit functions, xft fuck me plenty |
67 | // some bit functions, xft fuck me plenty |
72 | #if HAVE_GCC_BUILTINS |
68 | #if HAVE_GCC_BUILTINS |
73 | static inline int ctz (unsigned int x) CONST { return __builtin_ctz (x); } |
69 | static inline int ctz (unsigned int x) { return __builtin_ctz (x); } |
74 | static inline int popcount (unsigned int x) CONST { return __builtin_popcount (x); } |
70 | static inline int popcount (unsigned int x) { return __builtin_popcount (x); } |
75 | #else |
71 | #else |
76 | // count trailing zero bits and count # of one bits |
72 | // count trailing zero bits and count # of one bits |
77 | int ctz (unsigned int x) CONST; |
73 | int ctz (unsigned int x) CONST; |
78 | int popcount (unsigned int x) CONST; |
74 | int popcount (unsigned int x) CONST; |
79 | #endif |
75 | #endif |
… | |
… | |
91 | void *operator new (size_t s); |
87 | void *operator new (size_t s); |
92 | void operator delete (void *p, size_t s); |
88 | void operator delete (void *p, size_t s); |
93 | }; |
89 | }; |
94 | |
90 | |
95 | /* simplevec taken (and heavily modified), from: |
91 | /* simplevec taken (and heavily modified), from: |
96 | * |
92 | * |
97 | * MICO --- a free CORBA implementation |
93 | * MICO --- a free CORBA implementation |
98 | * Copyright (C) 1997-98 Kay Roemer & Arno Puder |
94 | * Copyright (C) 1997-98 Kay Roemer & Arno Puder |
99 | */ |
95 | */ |
100 | template<class T> |
96 | template<class T> |
101 | struct simplevec { |
97 | struct simplevec { |