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.36 by ayin, Fri Dec 14 11:11:31 2007 UTC vs.
Revision 1.38 by root, Wed Nov 5 14:43:54 2008 UTC

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#if __GNUC__ >= 4 16#if __GNUC__ >= 4
17# define rxvt_attribute(x) __attribute__(x) 17# define rxvt_attribute(x) __attribute__(x)
18# define expect(expr,value) __builtin_expect ((expr),(value))
18#else 19#else
19# define rxvt_attribute(x) 20# define rxvt_attribute(x)
21# define expect(expr,value) (expr)
20#endif 22#endif
23
24// put into ifs if you are very sure that the expression
25// is mostly true or mosty false. note that these return
26// booleans, not the expression.
27#define expect_false(expr) expect ((expr) != 0, 0)
28#define expect_true(expr) expect ((expr) != 0, 1)
21 29
22#define NORETURN rxvt_attribute ((noreturn)) 30#define NORETURN rxvt_attribute ((noreturn))
23#define UNUSED rxvt_attribute ((unused)) 31#define UNUSED rxvt_attribute ((unused))
24#define CONST rxvt_attribute ((const)) 32#define CONST rxvt_attribute ((const))
25 33
103 111
104// for m >= -n, ensure remainder lies between 0..n-1 112// for m >= -n, ensure remainder lies between 0..n-1
105#define MOD(m,n) (((m) + (n)) % (n)) 113#define MOD(m,n) (((m) + (n)) % (n))
106 114
107// makes dynamically allocated objects zero-initialised 115// makes dynamically allocated objects zero-initialised
108struct zero_initialized { 116struct zero_initialized
117{
109 void *operator new (size_t s); 118 void *operator new (size_t s);
110 void operator delete (void *p, size_t s); 119 void operator delete (void *p, size_t s);
111}; 120};
112 121
113/* simplevec taken (and heavily modified), from: 122/* simplevec taken (and heavily modified), from:
114 * 123 *
115 * MICO --- a free CORBA implementation 124 * MICO --- a free CORBA implementation
116 * Copyright (C) 1997-98 Kay Roemer & Arno Puder 125 * Copyright (C) 1997-98 Kay Roemer & Arno Puder
117 */ 126 */
118template<class T> 127template<class T>
119struct simplevec { 128struct simplevec
129{
120 typedef T* iterator; 130 typedef T* iterator;
121 typedef const T* const_iterator; 131 typedef const T* const_iterator;
122 typedef unsigned long size_type; 132 typedef unsigned long size_type;
123 133
124private: 134private:
379 } 389 }
380}; 390};
381 391
382#if 0 392#if 0
383template<typename T> 393template<typename T>
384struct rxvt_vec : simplevec<void *> { 394struct rxvt_vec : simplevec<void *>
395{
385 typedef T *iterator; 396 typedef T *iterator;
386 397
387 void push_back (T d) { simplevec<void *>::push_back ((void *)d); } 398 void push_back (T d) { simplevec<void *>::push_back ((void *)d); }
388 T pop_back () { return (T*)simplevec<void *>::pop_back (); } 399 T pop_back () { return (T*)simplevec<void *>::pop_back (); }
389 void erase (int i) { erase (begin () + i); } 400 void erase (int i) { erase (begin () + i); }
394 const T &operator [] (int i) const { return * (const T *) (& ((* (const simplevec<void *> *)this)[i])); } 405 const T &operator [] (int i) const { return * (const T *) (& ((* (const simplevec<void *> *)this)[i])); }
395}; 406};
396#endif 407#endif
397 408
398template<typename T> 409template<typename T>
399struct auto_ptr { 410struct auto_ptr
411{
400 T *p; 412 T *p;
401 413
402 auto_ptr () : p (0) { } 414 auto_ptr () : p (0) { }
403 auto_ptr (T *a) : p (a) { } 415 auto_ptr (T *a) : p (a) { }
404 416

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines