From: Lennart Poettering Date: Fri, 18 Sep 2009 02:05:54 +0000 (+0200) Subject: macro: introduce PA_INT_TYPE_MIN, PA_INT_TYPE_MAX, PA_INT_TYPE_SIGNED macros X-Git-Tag: 1.0_branch~1220 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=56f217f3f8b43a02a72bf28e049f9a20738843c8;p=profile%2Fivi%2Fpulseaudio.git macro: introduce PA_INT_TYPE_MIN, PA_INT_TYPE_MAX, PA_INT_TYPE_SIGNED macros --- diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h index bffcc26..9a5a267 100644 --- a/src/pulsecore/macro.h +++ b/src/pulsecore/macro.h @@ -304,6 +304,18 @@ typedef int pa_bool_t; #define pa_memzero(x,l) (memset((x), 0, (l))) #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 */ #include