File s390-tools-sles15sp2-32-Consolidate-MIN-and-MAX-macros.patch of Package s390-tools.19608

Subject: [PATCH] [FEAT VS1804] Consolidate MIN and MAX macros
From: Marc Hartmayer <mhartmay@linux.ibm.com>

Summary:     genprotimg: Introduce new tool for the creation of PV images
Description: genprotimg takes a kernel, host-key documents, optionally an
             initrd, optionally a file with the kernel command line, and it
             generates a single, loadable image file. The image consists of a
             concatenation of a plain text boot loader, the encrypted
             components for kernel, initrd, and cmdline, and the
             integrity-protected PV header, containing metadata necessary for
             running the guest in PV mode. It's possible to use this image file
             as a kernel for zIPL or for a direct kernel boot using QEMU.
Upstream-ID: c55ceabc6726a7806922d288149003661f673a2f
Problem-ID:  VS1804

Upstream-Description:

             Consolidate MIN and MAX macros

             Consolidate MIN and MAX macros and make sure it can be used in
             combination with glib.

             Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
             Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
             Acked-by: Jan Höppner <hoeppner@linux.ibm.com>
             Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
             Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>


Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
---
 include/lib/util_base.h |   17 +----------------
 include/lib/zt_common.h |   17 +++++++++++++++++
 zipl/boot/s390.h        |    1 -
 3 files changed, 18 insertions(+), 17 deletions(-)

--- a/include/lib/util_base.h
+++ b/include/lib/util_base.h
@@ -14,6 +14,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#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
 
 #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;
--- 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;
--- 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
openSUSE Build Service is sponsored by