mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
add pa_assert_cc() for compile time assertions
This commit is contained in:
parent
a467bec423
commit
52dcb950ef
2 changed files with 15 additions and 1 deletions
|
|
@ -39,7 +39,7 @@ int pa_detect_fork(void) {
|
||||||
* however have to deal with this cleanly, so we try to detect the
|
* however have to deal with this cleanly, so we try to detect the
|
||||||
* forks making sure all our calls fail cleanly after the fork. */
|
* forks making sure all our calls fail cleanly after the fork. */
|
||||||
|
|
||||||
pa_assert(sizeof(pa_atomic_t) >= sizeof(pid_t));
|
pa_assert_cc(sizeof(pa_atomic_t) >= sizeof(pid_t));
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
pid_t stored_pid = (pid_t) pa_atomic_load(&pid);
|
pid_t stored_pid = (pid_t) pa_atomic_load(&pid);
|
||||||
|
|
|
||||||
|
|
@ -193,11 +193,25 @@ typedef int pa_bool_t;
|
||||||
#define pa_assert_fp(expr) pa_assert_se(expr)
|
#define pa_assert_fp(expr) pa_assert_se(expr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#define pa_assert_not_reached() pa_nop()
|
||||||
|
#else
|
||||||
#define pa_assert_not_reached() \
|
#define pa_assert_not_reached() \
|
||||||
do { \
|
do { \
|
||||||
pa_log_error("Code should not be reached at %s:%u, function %s(). Aborting.", __FILE__, __LINE__, PA_PRETTY_FUNCTION); \
|
pa_log_error("Code should not be reached at %s:%u, function %s(). Aborting.", __FILE__, __LINE__, PA_PRETTY_FUNCTION); \
|
||||||
abort(); \
|
abort(); \
|
||||||
} while (FALSE)
|
} while (FALSE)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* A compile time assertion */
|
||||||
|
#define pa_assert_cc(expr) \
|
||||||
|
do { \
|
||||||
|
switch (0) { \
|
||||||
|
case 0: \
|
||||||
|
case !!(expr): \
|
||||||
|
; \
|
||||||
|
} \
|
||||||
|
} while (FALSE)
|
||||||
|
|
||||||
#define PA_PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
|
#define PA_PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
|
||||||
#define PA_UINT_TO_PTR(u) ((void*) ((uintptr_t) (u)))
|
#define PA_UINT_TO_PTR(u) ((void*) ((uintptr_t) (u)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue