[common] only define min/max if they have not already been defined

This commit is contained in:
Geoffrey McRae 2022-01-05 19:45:09 +11:00
parent 952ebea2c5
commit 912ca62a7b

View File

@ -21,10 +21,15 @@
#ifndef _H_LG_COMMON_UTIL_
#define _H_LG_COMMON_UTIL_
#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
#define UPCAST(type, x) \
(type *)((uintptr_t)(x) - offsetof(type, base))