output_buffer: only realloc once, and memset just what we need
[fio.git] / minmax.h
index e5c2f584714fe877d7b119d16683f0a3cdd7146f..97957c8874e2e68b6e84a318d70c7c62670501bf 100644 (file)
--- a/minmax.h
+++ b/minmax.h
@@ -2,10 +2,19 @@
 #define FIO_MIN_MAX_H
 
 #ifndef min
-#define min(a, b)      ((a) < (b) ? (a) : (b))
+#define min(x,y) ({ \
+       typeof(x) _x = (x);     \
+       typeof(y) _y = (y);     \
+       (void) (&_x == &_y);            \
+       _x < _y ? _x : _y; })
 #endif
+
 #ifndef max
-#define max(a, b)      ((a) > (b) ? (a) : (b))
+#define max(x,y) ({ \
+       typeof(x) _x = (x);     \
+       typeof(y) _y = (y);     \
+       (void) (&_x == &_y);            \
+       _x > _y ? _x : _y; })
 #endif
 
 #endif