merge glitch-free branch back into trunk

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2445 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2008-05-15 23:34:41 +00:00
parent 91f092eadc
commit 045c1d602d
189 changed files with 12559 additions and 4959 deletions

View file

@ -33,12 +33,22 @@
#include <stdlib.h>
#include <pulsecore/log.h>
#include <pulsecore/gccmacro.h>
#include <pulse/gccmacro.h>
#ifndef PACKAGE
#error "Please include config.h before including this file!"
#endif
#ifndef PA_LIKELY
#ifdef __GNUC__
#define PA_LIKELY(x) (__builtin_expect(!!(x),1))
#define PA_UNLIKELY(x) (__builtin_expect((x),0))
#else
#define PA_LIKELY(x) (x)
#define PA_UNLIKELY(x) (x)
#endif
#endif
#if defined(PAGE_SIZE)
#define PA_PAGE_SIZE ((size_t) PAGE_SIZE)
#elif defined(PAGESIZE)
@ -67,19 +77,53 @@ static inline size_t pa_page_align(size_t l) {
#define PA_ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
/* The users of PA_MIN and PA_MAX 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 as arguments to MIN
* and MAX. */
#ifdef __GNUC__
#define PA_MAX(a,b) \
__extension__ ({ typeof(a) _a = (a); \
typeof(b) _b = (b); \
_a > _b ? _a : _b; \
})
#else
#define PA_MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#ifdef __GNUC__
#define PA_MIN(a,b) \
__extension__ ({ typeof(a) _a = (a); \
typeof(b) _b = (b); \
_a < _b ? _a : _b; \
})
#else
#define PA_MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef CLAMP
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
#ifdef __GNUC__
#define PA_CLAMP(x, low, high) \
__extension__ ({ typeof(x) _x = (x); \
typeof(low) _low = (low); \
typeof(high) _high = (high); \
((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \
})
#else
#define PA_CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
#endif
#ifdef __GNUC__
#define PA_CLAMP_UNLIKELY(x, low, high) \
__extension__ ({ typeof(x) _x = (x); \
typeof(low) _low = (low); \
typeof(high) _high = (high); \
(PA_UNLIKELY(_x > _high) ? _high : (PA_UNLIKELY(_x < _low) ? _low : _x)); \
})
#else
#define PA_CLAMP_UNLIKELY(x, low, high) (PA_UNLIKELY((x) > (high)) ? (high) : (PA_UNLIKELY((x) < (low)) ? (low) : (x)))
#endif
/* We don't define a PA_CLAMP_LIKELY here, because it doesn't really
* make sense: we cannot know if it is more likely that the values is
* lower or greater than the boundaries.*/
@ -166,8 +210,17 @@ typedef int pa_bool_t;
#define PA_PATH_SEP_CHAR '/'
#endif
static inline const char *pa_strnull(const char *x) {
return x ? x : "(null)";
}
#ifdef __GNUC__
#define PA_WARN_REFERENCE(sym, msg) \
__asm__(".section .gnu.warning." #sym); \
__asm__(".asciz \"" msg "\""); \
__asm__(".previous")
#else
#define PA_WARN_REFERENCE(sym, msg)
#endif
#endif