zbd: Fix zone report handling
[fio.git] / minmax.h
index 97957c8874e2e68b6e84a318d70c7c62670501bf..ec0848c0d67c7f84c549868e60f5063150a0cdeb 100644 (file)
--- a/minmax.h
+++ b/minmax.h
@@ -3,18 +3,23 @@
 
 #ifndef min
 #define min(x,y) ({ \
-       typeof(x) _x = (x);     \
-       typeof(y) _y = (y);     \
+       __typeof__(x) _x = (x); \
+       __typeof__(y) _y = (y); \
        (void) (&_x == &_y);            \
        _x < _y ? _x : _y; })
 #endif
 
 #ifndef max
 #define max(x,y) ({ \
-       typeof(x) _x = (x);     \
-       typeof(y) _y = (y);     \
+       __typeof__(x) _x = (x); \
+       __typeof__(y) _y = (y); \
        (void) (&_x == &_y);            \
        _x > _y ? _x : _y; })
 #endif
 
+#define min_not_zero(x, y) ({          \
+       __typeof__(x) __x = (x);                \
+       __typeof__(y) __y = (y);                \
+       __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
+
 #endif