macro: introduce PA_INT_TYPE_MIN, PA_INT_TYPE_MAX, PA_INT_TYPE_SIGNED macros

This commit is contained in:
Lennart Poettering 2009-09-18 04:05:54 +02:00
parent fb4a2a1bbb
commit 56f217f3f8

View file

@ -304,6 +304,18 @@ typedef int pa_bool_t;
#define pa_memzero(x,l) (memset((x), 0, (l))) #define pa_memzero(x,l) (memset((x), 0, (l)))
#define pa_zero(x) (pa_memzero(&(x), sizeof(x))) #define pa_zero(x) (pa_memzero(&(x), sizeof(x)))
#define PA_INT_TYPE_SIGNED(type) (!!((type) 0 > (type) -1))
#define PA_INT_TYPE_MAX(type) \
((type) (PA_INT_TYPE_SIGNED(type) \
? ~(~(type) 0 << (8*sizeof(type)-1)) \
: (type) -1))
#define PA_INT_TYPE_MIN(type) \
((type) (PA_INT_TYPE_SIGNED(type) \
? (~(type) 0 << (8*sizeof(type)-1)) \
: (type) 0))
/* We include this at the very last place */ /* We include this at the very last place */
#include <pulsecore/log.h> #include <pulsecore/log.h>