diff mbox

[i-g-t,3/7] lib: add common min and max macros

Message ID 1413478193-7970-4-git-send-email-thomas.wood@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Wood Oct. 16, 2014, 4:49 p.m. UTC
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 lib/igt_aux.h                | 4 ++++
 tests/eviction_common.c      | 2 --
 tests/gem_userptr_blits.c    | 2 --
 tests/kms_flip.c             | 8 +++-----
 tools/intel_display_poller.c | 4 +---
 5 files changed, 8 insertions(+), 12 deletions(-)
diff mbox

Patch

diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index d74bb8c..415614b 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -83,4 +83,8 @@  bool intel_check_memory(uint32_t count, uint32_t size, unsigned mode);
 #define CHECK_RAM 0x1
 #define CHECK_SWAP 0x2
 
+
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#define max(a, b) ((a) < (b) ? (a) : (b))
+
 #endif /* IGT_AUX_H */
diff --git a/tests/eviction_common.c b/tests/eviction_common.c
index 6de68a2..03d8e8c 100644
--- a/tests/eviction_common.c
+++ b/tests/eviction_common.c
@@ -170,8 +170,6 @@  static int swapping_evictions(int fd, struct igt_eviction_test_ops *ops,
 	return 0;
 }
 
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
 static int forking_evictions(int fd, struct igt_eviction_test_ops *ops,
 				int surface_size, int working_surfaces,
 				int trash_surfaces, unsigned flags)
diff --git a/tests/gem_userptr_blits.c b/tests/gem_userptr_blits.c
index 7b3b26f..376f59d 100644
--- a/tests/gem_userptr_blits.c
+++ b/tests/gem_userptr_blits.c
@@ -981,8 +981,6 @@  static int can_swap(void)
 	return 1;
 }
 
-#define min(a, b) ((a) < (b) ? (a) : (b))
-
 static void test_forking_evictions(int fd, int size, int count,
 			     unsigned flags)
 {
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 901f013..f6c25a2 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -84,8 +84,6 @@ 
 #define DRM_CAP_TIMESTAMP_MONOTONIC 6
 #endif
 
-#define max(a, b) ((a) > (b) ? (a) : (b))
-
 drmModeRes *resources;
 int drm_fd;
 static drm_intel_bufmgr *bufmgr;
@@ -925,7 +923,7 @@  static unsigned int run_test_step(struct test_output *o)
 	if (o->flags & TEST_PAN) {
 		int count = do_flip ?
 			o->flip_state.count : o->vblank_state.count;
-		int x_ofs = count * 10 > o->fb_width - o->kmode[0].hdisplay ? o->fb_width - o->kmode[0].hdisplay : count * 10;
+		int x_ofs = min(count * 10, o->fb_width - o->kmode[0].hdisplay);
 
 		/* Make sure DSPSURF changes value */
 		if (o->flags & TEST_HANG)
@@ -1396,7 +1394,7 @@  static int run_test(int duration, int flags)
 
 	igt_require(modes);
 	duration = duration * 1000 / modes;
-	duration = duration < 500 ? 500 : duration;
+	duration = max(500, duration);
 
 	/* Find any connected displays */
 	for (i = 0; i < resources->count_connectors; i++) {
@@ -1460,7 +1458,7 @@  static int run_pair(int duration, int flags)
 	 * configuration at all. So skip in that case. */
 	igt_require(modes);
 	duration = duration * 1000 / modes;
-	duration = duration < 500 ? 500 : duration;
+	duration = max(duration, 500);
 
 	/* Find a pair of connected displays */
 	for (i = 0; i < resources->count_connectors; i++) {
diff --git a/tools/intel_display_poller.c b/tools/intel_display_poller.c
index ebc594a..2eab6c4 100644
--- a/tools/intel_display_poller.c
+++ b/tools/intel_display_poller.c
@@ -36,9 +36,7 @@ 
 #include "intel_io.h"
 #include "igt_debugfs.h"
 #include "drmtest.h"
-
-#define min(a,b) ((a) < (b) ? (a) : (b))
-#define max(a,b) ((a) > (b) ? (a) : (b))
+#include "igt_aux.h"
 
 enum test {
 	TEST_INVALID,