From c55ceabc6726a7806922d288149003661f673a2f Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Mon, 9 Dec 2019 17:58:29 +0100 Subject: [PATCH] Consolidate MIN and MAX macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consolidate MIN and MAX macros and make sure it can be used in combination with glib. Reviewed-by: Philipp Rudo Reviewed-by: Stefan Haberland Acked-by: Jan Höppner Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- include/lib/util_base.h | 17 +---------------- include/lib/zt_common.h | 17 +++++++++++++++++ zipl/boot/s390.h | 1 - 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/lib/util_base.h b/include/lib/util_base.h index 6f0f78b2..60c9561b 100644 --- a/include/lib/util_base.h +++ b/include/lib/util_base.h @@ -14,6 +14,7 @@ #include #include +#include "zt_common.h" void util_hexdump(FILE *fh, const char *tag, const void *data, int cnt); void util_hexdump_grp(FILE *fh, const char *tag, const void *data, int group, @@ -22,22 +23,6 @@ void util_print_indented(const char *str, int indent); #define UTIL_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) -#define MIN(x, y) \ -({ \ - __typeof__(x) _x = (x); \ - __typeof__(y) _y = (y); \ - \ - _x < _y ? _x : _y; \ -}) - -#define MAX(x, y) \ -({ \ - __typeof__(x) _x = (x); \ - __typeof__(y) _y = (y); \ - \ - _x > _y ? _x : _y; \ -}) - static inline void util_ptr_vec_free(void **ptr_vec, int count) { int i; diff --git a/include/lib/zt_common.h b/include/lib/zt_common.h index 00c5f9a4..5269e0ed 100644 --- a/include/lib/zt_common.h +++ b/include/lib/zt_common.h @@ -67,6 +67,23 @@ #define barrier() __asm__ __volatile__("": : :"memory") +#undef MIN +#define MIN(x, y) \ + ({ \ + __typeof__(x) _x = (x); \ + __typeof__(y) _y = (y); \ + \ + _x < _y ? _x : _y; \ + }) + +#undef MAX +#define MAX(x, y) \ + ({ \ + __typeof__(x) _x = (x); \ + __typeof__(y) _y = (y); \ + \ + _x > _y ? _x : _y; \ + }) typedef unsigned long long u64; typedef signed long long s64; diff --git a/zipl/boot/s390.h b/zipl/boot/s390.h index 219be2fa..ec7c321c 100644 --- a/zipl/boot/s390.h +++ b/zipl/boot/s390.h @@ -15,7 +15,6 @@ #include "libc.h" #include "boot/sigp.h" -#define MIN(x, y) ((x) < (y) ? (x) : (y)) /* * Helper macro for exception table entries