diff --git a/py/misc.h b/py/misc.h index 278d59d4faa9f..7f42a781ec079 100644 --- a/py/misc.h +++ b/py/misc.h @@ -13,10 +13,17 @@ typedef unsigned int uint; /** generic ops *************************************************/ #ifndef MIN -#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#define MIN(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; }) #endif + #ifndef MAX -#define MAX(x, y) ((x) > (y) ? (x) : (y)) +#define MAX(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) #endif /** memomry allocation ******************************************/