defs: add SPA_LIKELY to MIN/MAX/CLAMP macros

This commit is contained in:
Wim Taymans 2019-01-07 13:39:57 +01:00
parent 5ef6a5cc5a
commit dbbcd3fdc4

View file

@ -90,20 +90,20 @@ struct spa_fraction {
({ \ ({ \
__typeof__(a) _a = (a); \ __typeof__(a) _a = (a); \
__typeof__(b) _b = (b); \ __typeof__(b) _b = (b); \
_a < _b ? _a : _b; \ SPA_LIKELY(_a < _b) ? _a : _b; \
}) })
#define SPA_MAX(a,b) \ #define SPA_MAX(a,b) \
({ \ ({ \
__typeof__(a) _a = (a); \ __typeof__(a) _a = (a); \
__typeof__(b) _b = (b); \ __typeof__(b) _b = (b); \
_a > _b ? _a : _b; \ SPA_LIKELY(_a > _b) ? _a : _b; \
}) })
#define SPA_CLAMP(v,low,high) \ #define SPA_CLAMP(v,low,high) \
({ \ ({ \
__typeof__(v) _v = (v); \ __typeof__(v) _v = (v); \
__typeof__(low) _low = (low); \ __typeof__(low) _low = (low); \
__typeof__(high) _high = (high); \ __typeof__(high) _high = (high); \
_v > _high ? _high : ( _v < _low ? _low : _v); \ SPA_MIN(SPA_MAX(_v, _low), _high); \
}) })
#define SPA_MEMBER(b,o,t) ((t*)((uint8_t*)(b) + (int)(o))) #define SPA_MEMBER(b,o,t) ((t*)((uint8_t*)(b) + (int)(o)))