--- rxvt-unicode/src/rxvtutil.h 2007/12/02 12:31:44 1.32 +++ rxvt-unicode/src/rxvtutil.h 2012/01/19 17:10:51 1.48 @@ -1,27 +1,9 @@ #ifndef RXVT_UTIL_H #define RXVT_UTIL_H -#include -#include - -using namespace std; - -#define PP_CONCAT_(a, b) a ## b -#define PP_CONCAT(a, b) PP_CONCAT_(a, b) -#define PP_STRINGIFY_(a) #a -#define PP_STRINGIFY(a) PP_STRINGIFY_(a) - -#define HAVE_GCC_BUILTINS (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ == 4)) - -#if __GNUC__ >= 4 -# define rxvt_attribute(x) __attribute__(x) -#else -# define rxvt_attribute(x) -#endif - -#define NORETURN rxvt_attribute ((noreturn)) -#define UNUSED rxvt_attribute ((unused)) -#define CONST rxvt_attribute ((const)) +#include +#include +#include "ecb.h" // increases code size unless -fno-enforce-eh-specs #if __GNUC__ @@ -32,17 +14,6 @@ # define THROW(x) throw x #endif -extern class byteorder { - static unsigned int e; // at least 32 bits -public: - byteorder (); - - static bool big_endian () { return e == 0x11223344; }; - static bool network () { return e == 0x11223344; }; - static bool little_endian () { return e == 0x44332211; }; - static bool vax () { return e == 0x44332211; }; -} byteorder; - // various utility functions template static inline T min (T a, U b) { return a < (T)b ? a : (T)b; } template static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } @@ -83,16 +54,6 @@ return (T *)rxvt_temp_buf (len * sizeof (T)); } -// some bit functions, xft fuck me plenty -#if HAVE_GCC_BUILTINS -static inline int ctz (unsigned int x) { return __builtin_ctz (x); } -static inline int popcount (unsigned int x) { 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)) @@ -101,8 +62,12 @@ #define IN_RANGE_EXC(val,beg,end) \ ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg)) +// for m >= -n, ensure remainder lies between 0..n-1 +#define MOD(m,n) (((m) + (n)) % (n)) + // makes dynamically allocated objects zero-initialised -struct zero_initialized { +struct zero_initialized +{ void *operator new (size_t s); void operator delete (void *p, size_t s); }; @@ -113,7 +78,8 @@ * Copyright (C) 1997-98 Kay Roemer & Arno Puder */ template -struct simplevec { +struct simplevec +{ typedef T* iterator; typedef const T* const_iterator; typedef unsigned long size_type; @@ -364,7 +330,8 @@ template struct vector : simplevec -{ }; +{ +}; struct stringvec : simplevec { @@ -377,7 +344,8 @@ #if 0 template -struct rxvt_vec : simplevec { +struct rxvt_vec : simplevec +{ typedef T *iterator; void push_back (T d) { simplevec::push_back ((void *)d); } @@ -389,9 +357,11 @@ T &operator [] (int i) { return * (T *) (& ((* (simplevec *)this)[i])); } const T &operator [] (int i) const { return * (const T *) (& ((* (const simplevec *)this)[i])); } }; +#endif template -struct auto_ptr { +struct auto_ptr +{ T *p; auto_ptr () : p (0) { } @@ -449,7 +419,6 @@ }; typedef auto_ptr auto_str; -#endif #endif