diff options
Diffstat (limited to 'src/kernel/util.h')
-rw-r--r-- | src/kernel/util.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/kernel/util.h b/src/kernel/util.h index b50810d..839aa49 100644 --- a/src/kernel/util.h +++ b/src/kernel/util.h @@ -8,3 +8,13 @@ void *memcpy(void *dest, const void *src, size_t n); void *memset(void *s, int c, size_t n); int memcmp(const void *s1, const void *s2, size_t n); + +// see https://gcc.gnu.org/onlinedocs/gcc/Typeof.html +#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; }) |