[PATCH weston v2 3/4] Moved the MIN() macro to the helper include.

Jon A. Cruz jonc at osg.samsung.com
Mon Jun 15 15:37:09 PDT 2015


Removed multiple definitions of the MIN() macro from existing
locations and unified with a single definition. Updated sources
to use the shared version.

Signed-off-by: Jon A. Cruz <jonc at osg.samsung.com>
---
 clients/nested.c      |  2 --
 clients/weston-info.c |  2 --
 clients/window.c      |  2 --
 desktop-shell/shell.c |  1 +
 shared/helpers.h      | 11 +++++++++++
 src/compositor.h      |  4 ----
 6 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/clients/nested.c b/clients/nested.c
index f758fdc..e78f08c 100644
--- a/clients/nested.c
+++ b/clients/nested.c
@@ -49,8 +49,6 @@
 #include "shared/helpers.h"
 #include "window.h"
 
-#define MIN(x,y) (((x) < (y)) ? (x) : (y))
-
 #ifndef EGL_WL_create_wayland_buffer_from_image
 #define EGL_WL_create_wayland_buffer_from_image 1
 
diff --git a/clients/weston-info.c b/clients/weston-info.c
index 58e8e83..89ef8f1 100644
--- a/clients/weston-info.c
+++ b/clients/weston-info.c
@@ -36,8 +36,6 @@
 #include "shared/os-compatibility.h"
 #include "presentation_timing-client-protocol.h"
 
-#define MIN(x,y) (((x) < (y)) ? (x) : (y))
-
 typedef void (*print_info_t)(void *info);
 typedef void (*destroy_info_t)(void *info);
 
diff --git a/clients/window.c b/clients/window.c
index c5e6f5a..ff4be8c 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -5150,8 +5150,6 @@ fini_xkb(struct input *input)
 	xkb_keymap_unref(input->xkb.keymap);
 }
 
-#define MIN(a,b) ((a) < (b) ? a : b)
-
 static void
 display_add_input(struct display *d, uint32_t id)
 {
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 3793614..a60a3aa 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -39,6 +39,7 @@
 #include "desktop-shell-server-protocol.h"
 #include "workspaces-server-protocol.h"
 #include "shared/config-parser.h"
+#include "shared/helpers.h"
 #include "xdg-shell-server-protocol.h"
 
 #define DEFAULT_NUM_WORKSPACES 1
diff --git a/shared/helpers.h b/shared/helpers.h
index 7502ff3..83f79b1 100644
--- a/shared/helpers.h
+++ b/shared/helpers.h
@@ -41,6 +41,17 @@ extern "C" {
 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
 #endif
 
+/**
+ * Returns the smaller of two values.
+ *
+ * @param x the first item to compare.
+ * @param y the second item to compare.
+ * @return the value that evaluates to lesser than the other.
+ */
+#ifndef MIN
+#define MIN(x,y) (((x) < (y)) ? (x) : (y))
+#endif
+
 #ifdef  __cplusplus
 }
 #endif
diff --git a/src/compositor.h b/src/compositor.h
index 685767e..b7b2d22 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -45,10 +45,6 @@ extern "C" {
 #include "zalloc.h"
 #include "timeline-object.h"
 
-#ifndef MIN
-#define MIN(x,y) (((x) < (y)) ? (x) : (y))
-#endif
-
 #define container_of(ptr, type, member) ({				\
 	const __typeof__( ((type *)0)->member ) *__mptr = (ptr);	\
 	(type *)( (char *)__mptr - offsetof(type,member) );})
-- 
2.1.0



More information about the wayland-devel mailing list