[PATCH i-g-t 2/4] aux: Don't evaluate several times the arguments of min() and max()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Damien Lespiau <damien.lespiau@xxxxxxxxx>
---
 lib/igt_aux.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 9ea50de..2979314 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);	\
-- 
2.1.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux