ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/util.h
(Generate patch)

Comparing deliantra/server/include/util.h (file contents):
Revision 1.34 by root, Fri Jan 19 15:15:50 2007 UTC vs.
Revision 1.35 by root, Fri Jan 19 22:47:57 2007 UTC

35#define IN_RANGE_EXC(val,beg,end) \ 35#define IN_RANGE_EXC(val,beg,end) \
36 ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg)) 36 ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg))
37 37
38void fork_abort (const char *msg); 38void fork_abort (const char *msg);
39 39
40// rationale for using (U) not (T) is to reduce signed/unsigned issues,
41// as a is often a constant while b is the variable. it is still a bug, though.
40template<typename T, typename U> static inline T min (T a, U b) { return a < (T)b ? a : (T)b; } 42template<typename T, typename U> static inline T min (T a, U b) { return (U)a < b ? (U)a : b; }
41template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } 43template<typename T, typename U> static inline T max (T a, U b) { return (U)a > b ? (U)a : b; }
42template<typename T, typename U, typename V> static inline T clamp (T v, U a, V b) { return v < (T)a ? a : v >(T)b ? b : v; } 44template<typename T, typename U, typename V> static inline T clamp (T v, U a, V b) { return v < (T)a ? (T)a : v >(T)b ? (T)b : v; }
43 45
44template<typename T, typename U> static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; } 46template<typename T, typename U> static inline void swap (T& a, U& b) { T t=a; a=(T)b; b=(U)t; }
45 47
46// this is much faster than crossfires original algorithm 48// this is much faster than crossfires original algorithm
47// on modern cpus 49// on modern cpus

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines