ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtutil.h
(Generate patch)

Comparing rxvt-unicode/src/rxvtutil.h (file contents):
Revision 1.37 by root, Mon Jul 21 16:51:31 2008 UTC vs.
Revision 1.39 by root, Fri Sep 4 15:40:13 2009 UTC

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 */
96static inline int ctz (unsigned int x) { return __builtin_ctz (x); } 97static inline int rxvt_ctz (unsigned int x) { return __builtin_ctz (x); }
97static inline int popcount (unsigned int x) { return __builtin_popcount (x); } 98static 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
100int ctz (unsigned int x) CONST; 101int rxvt_ctz (unsigned int x) CONST;
101int popcount (unsigned int x) CONST; 102int 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))
111 112
112// for m >= -n, ensure remainder lies between 0..n-1 113// for m >= -n, ensure remainder lies between 0..n-1
113#define MOD(m,n) (((m) + (n)) % (n)) 114#define MOD(m,n) (((m) + (n)) % (n))
114 115
115// makes dynamically allocated objects zero-initialised 116// makes dynamically allocated objects zero-initialised
116struct zero_initialized { 117struct zero_initialized
118{
117 void *operator new (size_t s); 119 void *operator new (size_t s);
118 void operator delete (void *p, size_t s); 120 void operator delete (void *p, size_t s);
119}; 121};
120 122
121/* simplevec taken (and heavily modified), from: 123/* simplevec taken (and heavily modified), from:
122 * 124 *
123 * MICO --- a free CORBA implementation 125 * MICO --- a free CORBA implementation
124 * Copyright (C) 1997-98 Kay Roemer & Arno Puder 126 * Copyright (C) 1997-98 Kay Roemer & Arno Puder
125 */ 127 */
126template<class T> 128template<class T>
127struct simplevec { 129struct simplevec
130{
128 typedef T* iterator; 131 typedef T* iterator;
129 typedef const T* const_iterator; 132 typedef const T* const_iterator;
130 typedef unsigned long size_type; 133 typedef unsigned long size_type;
131 134
132private: 135private:
387 } 390 }
388}; 391};
389 392
390#if 0 393#if 0
391template<typename T> 394template<typename T>
392struct rxvt_vec : simplevec<void *> { 395struct rxvt_vec : simplevec<void *>
396{
393 typedef T *iterator; 397 typedef T *iterator;
394 398
395 void push_back (T d) { simplevec<void *>::push_back ((void *)d); } 399 void push_back (T d) { simplevec<void *>::push_back ((void *)d); }
396 T pop_back () { return (T*)simplevec<void *>::pop_back (); } 400 T pop_back () { return (T*)simplevec<void *>::pop_back (); }
397 void erase (int i) { erase (begin () + i); } 401 void erase (int i) { erase (begin () + i); }
402 const T &operator [] (int i) const { return * (const T *) (& ((* (const simplevec<void *> *)this)[i])); } 406 const T &operator [] (int i) const { return * (const T *) (& ((* (const simplevec<void *> *)this)[i])); }
403}; 407};
404#endif 408#endif
405 409
406template<typename T> 410template<typename T>
407struct auto_ptr { 411struct auto_ptr
412{
408 T *p; 413 T *p;
409 414
410 auto_ptr () : p (0) { } 415 auto_ptr () : p (0) { }
411 auto_ptr (T *a) : p (a) { } 416 auto_ptr (T *a) : p (a) { }
412 417

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines