spa: add SPA_ABS helper macro

This commit is contained in:
Wim Taymans 2021-09-21 12:16:11 +02:00
parent 23edb9ab2a
commit 1c3802bd82

View file

@ -120,6 +120,11 @@ struct spa_fraction {
#define SPA_FOR_EACH_ELEMENT(arr, ptr) \
for (ptr = arr; (void*)ptr < SPA_PTROFF(arr, sizeof(arr), void); ptr++)
#define SPA_ABS(a) \
({ \
__typeof__(a) _a = (a); \
SPA_LIKELY(_a >= 0) ? _a : -_a; \
})
#define SPA_MIN(a,b) \
({ \
__typeof__(a) _min_a = (a); \