Commit | Line | Data |
---|---|---|
5ffb051d JA |
1 | #ifndef FIO_MIN_MAX_H |
2 | #define FIO_MIN_MAX_H | |
3 | ||
4 | #ifndef min | |
f747ad2c | 5 | #define min(x,y) ({ \ |
3376ecf4 KC |
6 | __typeof__(x) _x = (x); \ |
7 | __typeof__(y) _y = (y); \ | |
f747ad2c JA |
8 | (void) (&_x == &_y); \ |
9 | _x < _y ? _x : _y; }) | |
5ffb051d | 10 | #endif |
f747ad2c | 11 | |
5ffb051d | 12 | #ifndef max |
f747ad2c | 13 | #define max(x,y) ({ \ |
3376ecf4 KC |
14 | __typeof__(x) _x = (x); \ |
15 | __typeof__(y) _y = (y); \ | |
f747ad2c JA |
16 | (void) (&_x == &_y); \ |
17 | _x > _y ? _x : _y; }) | |
5ffb051d JA |
18 | #endif |
19 | ||
4b157ac6 | 20 | #define min_not_zero(x, y) ({ \ |
3376ecf4 KC |
21 | __typeof__(x) __x = (x); \ |
22 | __typeof__(y) __y = (y); \ | |
4b157ac6 JA |
23 | __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); }) |
24 | ||
5ffb051d | 25 | #endif |