1 | #ifndef RXVT_UTIL_H |
1 | #ifndef RXVT_UTIL_H |
2 | #define RXVT_UTIL_H |
2 | #define RXVT_UTIL_H |
3 | |
3 | |
4 | #include <stdlib.h> |
4 | #include <stdlib.h> |
5 | #include <string.h> |
5 | #include <string.h> |
|
|
6 | |
|
|
7 | #define ECB_NO_THREADS 1 |
6 | #include "ecb.h" |
8 | #include "ecb.h" |
|
|
9 | |
7 | #include "estl.h" |
10 | #include "estl.h" |
8 | |
11 | |
9 | #include "emman.h" |
12 | #include "emman.h" |
10 | |
|
|
11 | // increases code size unless -fno-enforce-eh-specs |
|
|
12 | #if __GNUC__ |
|
|
13 | # define NOTHROW |
|
|
14 | # define THROW(x) |
|
|
15 | #else |
|
|
16 | # define NOTHROW throw() |
|
|
17 | # define THROW(x) throw x |
|
|
18 | #endif |
|
|
19 | |
13 | |
20 | // various utility functions |
14 | // various utility functions |
21 | template<typename T, typename U> static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } |
15 | template<typename T, typename U> static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } |
22 | template<typename T, typename U> static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } |
16 | template<typename T, typename U> static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } |
23 | |
17 | |
24 | template<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; } |
18 | template<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; } |
25 | template<typename T, typename U, typename V> static inline void clamp_it (T &v, U a, V b) { v = v < (T)a ? a : v >(T)b ? b : v; } |
19 | template<typename T, typename U, typename V> static inline void clamp_it (T &v, U a, V b) { v = v < (T)a ? a : v >(T)b ? b : v; } |
26 | |
|
|
27 | template<typename T> static inline T squared_diff (T a, T b) { return (a - b) * (a - b); } |
|
|
28 | |
20 | |
29 | // linear interpolation |
21 | // linear interpolation |
30 | template<typename T, typename U, typename P> |
22 | template<typename T, typename U, typename P> |
31 | static inline T |
23 | static inline T |
32 | lerp (T a, U b, P p) |
24 | lerp (T a, U b, P p) |