aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/utils.h')
-rw-r--r--src/libstrongswan/utils.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libstrongswan/utils.h b/src/libstrongswan/utils.h
index 6b0990f5e..35008f455 100644
--- a/src/libstrongswan/utils.h
+++ b/src/libstrongswan/utils.h
@@ -72,12 +72,19 @@
/**
* Macro gives back larger of two values.
*/
-#define max(x,y) ((x) > (y) ? (x):(y))
+#define max(x,y) ({ \
+ typeof(x) _x = (x); \
+ typeof(y) _y = (y); \
+ _x > _y ? _x : _y; })
+
/**
* Macro gives back smaller of two values.
*/
-#define min(x,y) ((x) < (y) ? (x):(y))
+#define min(x,y) ({ \
+ typeof(x) _x = (x); \
+ typeof(y) _y = (y); \
+ _x < _y ? _x : _y; })
/**
* Call destructor of an object, if object != NULL