Go to the documentation of this file.
44 #ifndef PA_UNIX_UTIL_H
45 #define PA_UNIX_UTIL_H
57 #define PA_MIN(x,y) ( (x) < (y) ? (x) : (y) )
58 #define PA_MAX(x,y) ( (x) > (y) ? (x) : (y) )
61 #if defined __GNUC__ && __GNUC__ >= 3
62 #define UNLIKELY(expr) __builtin_expect( (expr), 0 )
64 #define UNLIKELY(expr) (expr)
67 #define STRINGIZE_HELPER(expr) #expr
68 #define STRINGIZE(expr) STRINGIZE_HELPER(expr)
70 #define PA_UNLESS(expr, code) \
72 if( UNLIKELY( (expr) == 0 ) ) \
74 PaUtil_DebugPrint(( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZE( __LINE__ ) "\n" )); \
83 #define PA_ENSURE(expr) \
85 if( UNLIKELY( (paUtilErr_ = (expr)) < paNoError ) ) \
87 PaUtil_DebugPrint(( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZE( __LINE__ ) "\n" )); \
88 result = paUtilErr_; \
93 #define PA_ASSERT_CALL(expr, success) \
94 paUtilErr_ = (expr); \
95 assert( success == paUtilErr_ );
97 #define PA_ENSURE_SYSTEM(expr, success) \
99 if( UNLIKELY( (paUtilErr_ = (expr)) != success ) ) \
102 if( pthread_equal(pthread_self(), paUnixMainThread) ) \
104 PaUtil_SetLastHostErrorInfo( paALSA, paUtilErr_, strerror( paUtilErr_ ) ); \
106 PaUtil_DebugPrint( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZE( __LINE__ ) "\n" ); \
107 result = paUnanticipatedHostError; \
171 #define PaUnixThreading_EXIT(result) \
173 PaError* pres = NULL; \
174 if( paNoError != (result) ) \
176 pres = malloc( sizeof (PaError) ); \
179 pthread_exit( pres ); \