summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-09-18 04:05:54 +0200
committerColin Guthrie <cguthrie@mandriva.org>2009-09-18 09:09:19 +0100
commitfd1f9f85713a58e34c63c6218b7a81e6c3fe6f9f (patch)
treecad45c1d33a767313e6fb844922b9a009c5eafa4 /src/pulsecore
parent180ef1eebdfbdf0220af1fb5e4bf43e348207cde (diff)
macro: introduce PA_INT_TYPE_MIN, PA_INT_TYPE_MAX, PA_INT_TYPE_SIGNED macros
Diffstat (limited to 'src/pulsecore')
-rw-r--r--src/pulsecore/macro.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index bffcc264..9a5a2670 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 <pulsecore/log.h>