Changeset - r5603:362be85e7eb3
[Not reviewed]
master
0 1 0
celestar - 17 years ago 2007-01-11 12:38:04
celestar@openttd.org
(svn r8057) -Codechange: Declare the "new" max template as static line.
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/macros.h
Show inline comments
 
@@ -11,25 +11,29 @@
 
#define SB(x, s, n, d) ((x) = ((x) & ~(((1U << (n)) - 1) << (s))) | ((d) << (s)))
 
/// Add i to the n bits starting at bit s in x
 
#define AB(x, s, n, i) ((x) = ((x) & ~(((1U << (n)) - 1) << (s))) | (((x) + ((i) << (s))) & (((1U << (n)) - 1) << (s))))
 

	
 
#ifdef min
 
#undef min
 
#endif
 

	
 
#ifdef max
 
#undef max
 
#endif
 

	
 
template <typename T> T max(T a, T b) { return a >= b ? a : b; }
 
template <typename T>
 
static inline T max(T a, T b)
 
{
 
	return a >= b ? a : b;
 
}
 

	
 
static inline int min(int a, int b) { if (a <= b) return a; return b; }
 

	
 
static inline uint minu(uint a, uint b) { if (a <= b) return a; return b; }
 

	
 

	
 
static inline int clamp(int a, int min, int max)
 
{
 
	if (a <= min) return min;
 
	if (a >= max) return max;
 
	return a;
 
}
0 comments (0 inline, 0 general)