--- rxvt-unicode/src/rxvtutil.h 2006/01/29 20:51:28 1.21 +++ rxvt-unicode/src/rxvtutil.h 2006/01/30 16:12:58 1.24 @@ -9,6 +9,31 @@ #define PP_STRINGIFY_(a) #a #define PP_STRINGIFY(a) PP_STRINGIFY_(a) +// actually, some gcc-3.x versions work, too +#define HAVE_GCC_BUILTINS (__GNUC__ >= 4) + +#ifndef __attribute__ +# if __GNUC__ +# if (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (__GNUC__ < 2) +# define __attribute__(x) +# endif +# endif +# define __attribute__(x) +#endif + +#define NORETURN __attribute__ ((noreturn)) +#define UNUSED __attribute__ ((unused)) +#define CONST __attribute__ ((const)) + +// increases code size unless -fno-enforce-eh-specs +#if __GNUC__ +# define NOTHROW +# define THROW(x) +#else +# define NOTHROW throw() +# define THROW(x) throw x +#endif + extern class byteorder { static unsigned int e; // at least 32 bits public: @@ -39,6 +64,16 @@ return (int(a) * int(p) + int(b) * int(100 - p)) / 100; } +// some bit functions, xft fuck me plenty +#if HAVE_GCC_BUILTINS +static inline int ctz (unsigned int x) CONST { return __builtin_ctz (x); } +static inline int popcount (unsigned int x) CONST { return __builtin_popcount (x); } +#else +// count trailing zero bits and count # of one bits +int ctz (unsigned int x) CONST; +int popcount (unsigned int x) CONST; +#endif + // in range including end #define IN_RANGE_INC(val,beg,end) \ ((unsigned int)(val) - (unsigned int)(beg) <= (unsigned int)(end) - (unsigned int)(beg)) @@ -410,7 +445,7 @@ void *rxvt_temp_buf (int len); template -inline T * +static inline T * rxvt_temp_buf (int len) { return (T *)rxvt_temp_buf (len * sizeof (T));