]> code.delx.au - pulseaudio/commitdiff
macro: introduce PA_INT_TYPE_MIN, PA_INT_TYPE_MAX, PA_INT_TYPE_SIGNED macros
authorLennart Poettering <lennart@poettering.net>
Fri, 18 Sep 2009 02:05:54 +0000 (04:05 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 18 Sep 2009 02:14:37 +0000 (04:14 +0200)
src/pulsecore/macro.h

index bffcc2642383bfcd3b4933aec0ba837d9be45842..9a5a2670dc57980b0540ad7aa4c1d437ee6ef143 100644 (file)
@@ -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 <pulsecore/log.h>