Only define min() and max() macros if not already defined

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-12-21 14:19:45 +01:00
1 parent 3a26ab28b2
commit ac936448f5
1 file changed
+17 -15
+17 -15
View File
@@ -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_ */