… | |
… | |
86 | void cleanup (const char *cause, bool make_core = false); |
86 | void cleanup (const char *cause, bool make_core = false); |
87 | void fork_abort (const char *msg); |
87 | void fork_abort (const char *msg); |
88 | |
88 | |
89 | // rationale for using (U) not (T) is to reduce signed/unsigned issues, |
89 | // rationale for using (U) not (T) is to reduce signed/unsigned issues, |
90 | // as a is often a constant while b is the variable. it is still a bug, though. |
90 | // as a is often a constant while b is the variable. it is still a bug, though. |
91 | template<typename T, typename U> static inline T min (T a, U b) { return (U)a < b ? (U)a : b; } |
91 | template<typename T, typename U> static inline T min (T a, U b) { return a < (T)b ? a : (T)b; } |
92 | template<typename T, typename U> static inline T max (T a, U b) { return (U)a > b ? (U)a : b; } |
92 | template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } |
93 | template<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; } |
93 | template<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; } |
94 | |
94 | |
95 | template<typename T, typename U> static inline void min_it (T &v, U m) { v = min (v, (T)m); } |
95 | template<typename T, typename U> static inline void min_it (T &v, U m) { v = min (v, (T)m); } |
96 | template<typename T, typename U> static inline void max_it (T &v, U m) { v = max (v, (T)m); } |
96 | template<typename T, typename U> static inline void max_it (T &v, U m) { v = max (v, (T)m); } |
97 | template<typename T, typename U, typename V> static inline void clamp_it (T &v, U a, V b) { v = clamp (v, (T)a, (T)b); } |
97 | template<typename T, typename U, typename V> static inline void clamp_it (T &v, U a, V b) { v = clamp (v, (T)a, (T)b); } |