From ac936448f50480631f35a6ed1f4dadcc14c85483 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 21 Dec 2017 14:19:45 +0100 Subject: [PATCH] Only define min() and max() macros if not already defined Signed-off-by: Joachim Nilsson --- src/strlite.h | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/strlite.h b/src/strlite.h index 397c689..035a06d 100644 --- a/src/strlite.h +++ b/src/strlite.h @@ -29,6 +29,23 @@ #include "strndupa.h" #include "strnlen.h" +#ifndef min +#define min(a,b) \ + ({ \ + __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; \ + }) +#endif +#ifndef max +#define max(a,b) \ + ({ \ + __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; \ + }) +#endif + #ifndef strlcpy size_t strlcpy (char *dst, const char *src, size_t siz); #endif @@ -82,19 +99,4 @@ static inline int string_case_compare(const char *a, const char *b) return strlen (a) == strlen (b) && !strcasecmp (a, b); } -#define min(a,b) \ - ({ \ - __typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ - _a < _b ? _a : _b; \ - }) - -#define max(a,b) \ - ({ \ - __typeof__ (a) _a = (a); \ - __typeof__ (b) _b = (b); \ - _a > _b ? _a : _b; \ - }) - - #endif /* LITE_STRING_H_ */