Fix: Add missing cmm_smp_mb() in deprecated urcu-signal
[urcu.git] / include / urcu / assert.h
CommitLineData
d3d3857f
MJ
1// SPDX-FileCopyrightText: 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
2//
3// SPDX-License-Identifier: MIT
4
01477510
FD
5#ifndef _URCU_ASSERT_H
6#define _URCU_ASSERT_H
7
8/*
01477510 9 * Userspace RCU assertion facilities.
01477510
FD
10 */
11
12#include <urcu/config.h>
13
14/*
15 * Force usage of an expression to prevent unused expression compiler warning.
16 */
17#define _urcu_use_expression(_expr) ((void) sizeof((void) (_expr), 0))
18
19#ifdef NDEBUG
20/*
21 * Vanilla assert() replacement. When NDEBUG is defined, the expression is
22 * consumed to prevent unused variable compile warnings.
23 */
24# define urcu_posix_assert(_cond) _urcu_use_expression(_cond)
25#else
26# include <assert.h>
27# define urcu_posix_assert(_cond) assert(_cond)
28#endif
29
30#if defined(DEBUG_RCU) || defined(CONFIG_RCU_DEBUG)
31
32/*
33 * Enables debugging/expensive assertions to be used in fast paths and only
34 * enabled on demand. When disabled, the expression is consumed to prevent
35 * unused variable compile warnings.
36 */
37# define urcu_assert_debug(_cond) urcu_posix_assert(_cond)
38#else
39# define urcu_assert_debug(_cond) _urcu_use_expression(_cond)
40#endif
41
42#endif /* _URCU_ASSERT_H */
This page took 0.027707 seconds and 4 git commands to generate.