xref: /openbmc/libmctp/range.h (revision 99d8f126)
1 #ifndef _RANGE_H
2 #define _RANGE_H
3 
4 #ifndef typeof
5 #define typeof __typeof__
6 #endif
7 
8 #ifndef MIN
9 #define MIN(a, b)                                                              \
10 	({                                                                     \
11 		typeof(a) _a = a;                                              \
12 		typeof(b) _b = b;                                              \
13 		_a < _b ? _a : _b;                                             \
14 	})
15 #endif
16 
17 #ifndef MAX
18 #define MAX(a, b)                                                              \
19 	({                                                                     \
20 		typeof(a) _a = a;                                              \
21 		typeof(b) _b = b;                                              \
22 		_a > _b ? _a : _b;                                             \
23 	})
24 #endif
25 
26 #endif
27