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.34 by root, Sun Dec 2 22:37:14 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
99 107
100// in range excluding end 108// in range excluding end
101#define IN_RANGE_EXC(val,beg,end) \ 109#define IN_RANGE_EXC(val,beg,end) \
102 ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg)) 110 ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg))
103 111
112// for m >= -n, ensure remainder lies between 0..n-1
113#define MOD(m,n) (((m) + (n)) % (n))
114
104// makes dynamically allocated objects zero-initialised 115// makes dynamically allocated objects zero-initialised
105struct zero_initialized { 116struct zero_initialized
117{
106 void *operator new (size_t s); 118 void *operator new (size_t s);
107 void operator delete (void *p, size_t s); 119 void operator delete (void *p, size_t s);
108}; 120};
109 121
110/* simplevec taken (and heavily modified), from: 122/* simplevec taken (and heavily modified), from:
111 * 123 *
112 * MICO --- a free CORBA implementation 124 * MICO --- a free CORBA implementation
113 * Copyright (C) 1997-98 Kay Roemer & Arno Puder 125 * Copyright (C) 1997-98 Kay Roemer & Arno Puder
114 */ 126 */
115template<class T> 127template<class T>
116struct simplevec { 128struct simplevec
129{
117 typedef T* iterator; 130 typedef T* iterator;
118 typedef const T* const_iterator; 131 typedef const T* const_iterator;
119 typedef unsigned long size_type; 132 typedef unsigned long size_type;
120 133
121private: 134private:
362} 375}
363 376
364 377
365template<typename T> 378template<typename T>
366struct vector : simplevec<T> 379struct vector : simplevec<T>
367{ }; 380{
381};
368 382
369struct stringvec : simplevec<char *> 383struct stringvec : simplevec<char *>
370{ 384{
371 ~stringvec () 385 ~stringvec ()
372 { 386 {
375 } 389 }
376}; 390};
377 391
378#if 0 392#if 0
379template<typename T> 393template<typename T>
380struct rxvt_vec : simplevec<void *> { 394struct rxvt_vec : simplevec<void *>
395{
381 typedef T *iterator; 396 typedef T *iterator;
382 397
383 void push_back (T d) { simplevec<void *>::push_back ((void *)d); } 398 void push_back (T d) { simplevec<void *>::push_back ((void *)d); }
384 T pop_back () { return (T*)simplevec<void *>::pop_back (); } 399 T pop_back () { return (T*)simplevec<void *>::pop_back (); }
385 void erase (int i) { erase (begin () + i); } 400 void erase (int i) { erase (begin () + i); }
390 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])); }
391}; 406};
392#endif 407#endif
393 408
394template<typename T> 409template<typename T>
395struct auto_ptr { 410struct auto_ptr
411{
396 T *p; 412 T *p;
397 413
398 auto_ptr () : p (0) { } 414 auto_ptr () : p (0) { }
399 auto_ptr (T *a) : p (a) { } 415 auto_ptr (T *a) : p (a) { }
400 416

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines