File: assert.h

package info (click to toggle)
liburcu 0.15.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,356 kB
  • sloc: ansic: 23,361; xml: 23,227; sh: 6,480; makefile: 1,045; cpp: 15
file content (42 lines) | stat: -rw-r--r-- 1,110 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-FileCopyrightText: 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
//
// SPDX-License-Identifier: MIT

#ifndef _URCU_ASSERT_H
#define _URCU_ASSERT_H

/*
 * Userspace RCU assertion facilities.
 */

#include <urcu/config.h>

/*
 * Force usage of an expression to prevent unused expression compiler warning.
 */
#define _urcu_use_expression(_expr) ((void) sizeof((void) (_expr), 0))

#ifdef NDEBUG
/*
 * Vanilla assert() replacement. When NDEBUG is defined, the expression is
 * consumed to prevent unused variable compile warnings.
 */
# define urcu_posix_assert(_cond) _urcu_use_expression(_cond)
#else
# include <assert.h>
# define urcu_posix_assert(_cond) assert(_cond)
#endif

#if defined(DEBUG_RCU) || defined(CONFIG_RCU_DEBUG)

/*
 * Enables debugging/expensive assertions to be used in fast paths and only
 * enabled on demand. When disabled, the expression is consumed to prevent
 * unused variable compile warnings.
 */
# define urcu_assert_debug(_cond) urcu_posix_assert(_cond)
#else
# define urcu_assert_debug(_cond) _urcu_use_expression(_cond)
#endif

#endif /* _URCU_ASSERT_H */