#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
-#include <pulse/gccmacro.h>
+#include <stdbool.h>
#ifndef PACKAGE
#error "Please include config.h before including this file!"
#define PA_ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
+#if defined(__GNUC__)
+ #define PA_DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
+#else
+ #define PA_DECLARE_ALIGNED(n,t,v) t v
+#endif
+
+#ifdef __GNUC__
+#define typeof __typeof__
+#endif
+
/* The users of PA_MIN and PA_MAX, PA_CLAMP, PA_ROUND_UP should be
* aware that these macros on non-GCC executed code with side effects
* twice. It is thus considered misuse to use code with side effects
#define PA_CLIP_SUB(a, b) ((a) > (b) ? (a) - (b) : 0)
#endif
-/* This type is not intended to be used in exported APIs! Use classic "int" there! */
-#ifdef HAVE_STD_BOOL
-typedef _Bool pa_bool_t;
-#else
-typedef int pa_bool_t;
-#endif
-
-#ifndef FALSE
-#define FALSE ((pa_bool_t) 0)
-#endif
-
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
#ifdef __GNUC__
#define PA_PRETTY_FUNCTION __PRETTY_FUNCTION__
#else
pa_log_debug("Assertion '%s' failed at %s:%u, function %s.\n", #expr , __FILE__, __LINE__, PA_PRETTY_FUNCTION); \
return; \
} \
- } while(FALSE)
+ } while(false)
#define pa_return_val_if_fail(expr, val) \
do { \
pa_log_debug("Assertion '%s' failed at %s:%u, function %s.\n", #expr , __FILE__, __LINE__, PA_PRETTY_FUNCTION); \
return (val); \
} \
- } while(FALSE)
+ } while(false)
#define pa_return_null_if_fail(expr) pa_return_val_if_fail(expr, NULL)
pa_log_error("Assertion '%s' failed at %s:%u, function %s(). Aborting.", #expr , __FILE__, __LINE__, PA_PRETTY_FUNCTION); \
abort(); \
} \
- } while (FALSE)
+ } while (false)
/* Does exactly nothing */
-#define pa_nop() do {} while (FALSE)
+#define pa_nop() do {} while (false)
/* pa_assert() is an assert that may be optimized away by defining
* NDEBUG. pa_assert_fp() is an assert that may be optimized away by
do { \
pa_log_error("Code should not be reached at %s:%u, function %s(). Aborting.", __FILE__, __LINE__, PA_PRETTY_FUNCTION); \
abort(); \
- } while (FALSE)
+ } while (false)
#endif
/* A compile time assertion */
case !!(expr): \
; \
} \
- } while (FALSE)
+ } while (false)
#define PA_PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
#define PA_UINT_TO_PTR(u) ((void*) ((uintptr_t) (u)))
#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>