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>
This commit is contained in:
Marc Hartmayer
2019-12-09 17:58:29 +01:00
committed by Jan Höppner
parent 2e28291c75
commit c55ceabc67
3 changed files with 18 additions and 17 deletions
+1 -16
View File
@@ -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, 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;
+17
View File
@@ -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;
-1
View File
@@ -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