… | |
… | |
17 | static bool network () { return e == 0x11223344; }; |
17 | static bool network () { return e == 0x11223344; }; |
18 | static bool little_endian () { return e == 0x44332211; }; |
18 | static bool little_endian () { return e == 0x44332211; }; |
19 | static bool vax () { return e == 0x44332211; }; |
19 | static bool vax () { return e == 0x44332211; }; |
20 | } byteorder; |
20 | } byteorder; |
21 | |
21 | |
|
|
22 | // various utility functions |
22 | template<typename T, typename U> static inline T min (T a, U b) { return a < (T)b ? a : (T)b; } |
23 | template<typename T, typename U> static inline T min (T a, U b) { return a < (T)b ? a : (T)b; } |
23 | template<typename T, typename U> static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } |
24 | template<typename T, typename U> static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } |
24 | template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } |
25 | template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } |
25 | template<typename T, typename U> static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } |
26 | template<typename T, typename U> static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } |
26 | |
27 | |
… | |
… | |
35 | |
36 | |
36 | // in range excluding end |
37 | // in range excluding end |
37 | #define IN_RANGE_EXC(val,beg,end) \ |
38 | #define IN_RANGE_EXC(val,beg,end) \ |
38 | ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg)) |
39 | ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg)) |
39 | |
40 | |
|
|
41 | // makes dynamically allocated objects zero-initialised |
40 | struct zero_initialized { |
42 | struct zero_initialized { |
41 | void *operator new (size_t s); |
43 | void *operator new (size_t s); |
42 | void operator delete (void *p, size_t s); |
44 | void operator delete (void *p, size_t s); |
43 | }; |
45 | }; |
44 | |
46 | |