summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2015-06-30 00:15:15 +0100
committerDamien Lespiau <damien.lespiau@intel.com>2015-07-02 11:20:42 +0100
commit390653acfb47664ffebe07a6928fa6b0fc18f4e8 (patch)
tree80cbbb79433db7c08f2d37144b05ce508881b7f7 /lib
parent643aab2249992f4c4ad75e98ef3d43f3c6700895 (diff)
aux: Don't evaluate several times the arguments of min() and max()
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/igt_aux.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 9ea50de2..2979314a 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -91,8 +91,16 @@ void intel_require_memory(uint32_t count, uint32_t size, unsigned mode);
#define CHECK_SWAP 0x2
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#define max(a, b) ((a) > (b) ? (a) : (b))
+#define min(a, b) ({ \
+ typeof(a) _a = (a); \
+ typeof(b) _b = (b); \
+ _a < _b ? _a : _b; \
+})
+#define max(a, b) ({ \
+ typeof(a) _a = (a); \
+ typeof(b) _b = (b); \
+ _a > _b ? _a : _b; \
+})
#define igt_swap(a, b) do { \
typeof(a) _tmp = (a); \