]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
tools: Move the typesafe min/max helpers into xen-tools/libs.h
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 19 Jul 2018 15:42:07 +0000 (16:42 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 5 Nov 2018 17:07:11 +0000 (17:07 +0000)
... rather than implementing them separately for libxc and libxl.  They will
shortly be wanted in libx86 as well.

Fix up the style/consistency in the declaration, but no functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/include/xen-tools/libs.h
tools/libxc/xc_private.h
tools/libxl/libxl_internal.h

index 927e05738917dfb2140b3d8be6f59e5b98576df8..cc7dfc8c64530166aba5fd9b858fe562716f4a5c 100644 (file)
 #define MIN(x, y) ((x) < (y) ? (x) : (y))
 #endif
 
+#ifndef min
+#define min(x, y)                               \
+    ({                                          \
+        const typeof(x) _x = (x);               \
+        const typeof(y) _y = (y);               \
+        (void) (&_x == &_y);                    \
+        (_x < _y) ? _x : _y;                    \
+    })
+#endif
+
+#ifndef max
+#define max(x, y)                               \
+    ({                                          \
+        const typeof(x) _x = (x);               \
+        const typeof(y) _y = (y);               \
+        (void)(&_x == &_y);                     \
+        (_x > _y) ? _x : _y;                    \
+    })
+#endif
+
+#ifndef min_t
+#define min_t(type, x, y)                       \
+    ({                                          \
+        const type _x = (x);                    \
+        const type _y = (y);                    \
+        (_x < _y) ? _x: _y;                     \
+    })
+#endif
+
+#ifndef max_t
+#define max_t(type, x, y)                       \
+    ({                                          \
+        const type _x = (x);                    \
+        const type _y = (y);                    \
+        (_x > _y) ? _x: _y;                     \
+    })
+#endif
+
 #endif /* __XEN_TOOLS_LIBS__ */
index 705eaa93850974334a02789549146d9bf8b812c9..adc3b6a5718e4cf61008c1932e128659420e3c4f 100644 (file)
@@ -405,22 +405,6 @@ int xc_ffs16(uint16_t x);
 int xc_ffs32(uint32_t x);
 int xc_ffs64(uint64_t x);
 
-#define min(X, Y) ({                             \
-            const typeof (X) _x = (X);           \
-            const typeof (Y) _y = (Y);           \
-            (void) (&_x == &_y);                 \
-            (_x < _y) ? _x : _y; })
-#define max(X, Y) ({                             \
-            const typeof (X) _x = (X);           \
-            const typeof (Y) _y = (Y);           \
-            (void) (&_x == &_y);                 \
-            (_x > _y) ? _x : _y; })
-
-#define min_t(type,x,y) \
-        ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
-#define max_t(type,x,y) \
-        ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
-
 #define DOMPRINTF(fmt, args...) xc_dom_printf(dom->xch, fmt, ## args)
 #define DOMPRINTF_CALLED(xch) xc_dom_printf((xch), "%s: called", __FUNCTION__)
 
index 153566acd06f4f10744b52a3bc86799959fdcbac..ff889385fe8e44a3945ce421363f59a9e8090c01 100644 (file)
 #define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m)))
 #define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m))
 
-#define min(X, Y) ({                             \
-            const typeof (X) _x = (X);           \
-            const typeof (Y) _y = (Y);           \
-            (void) (&_x == &_y);                 \
-            (_x < _y) ? _x : _y; })
-#define max(X, Y) ({                             \
-            const typeof (X) _x = (X);           \
-            const typeof (Y) _y = (Y);           \
-            (void) (&_x == &_y);                 \
-            (_x > _y) ? _x : _y; })
-
-#define min_t(type, x, y)                                               \
-    ({ const type _x = (x); const type _y = (y); _x < _y ? _x: _y; })
-#define max_t(type, x, y)                                               \
-    ({ const type _x = (x); const type _y = (y); _x > _y ? _x: _y; })
-
 #define LIBXL__LOGGING_ENABLED
 
 #ifdef LIBXL__LOGGING_ENABLED