Add `urcu_posix_assert()` as `assert()` replacement
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 1 Sep 2021 17:34:17 +0000 (13:34 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 3 Sep 2021 18:31:37 +0000 (14:31 -0400)
commit014775106c60f02818ca755b331f887030bd440f
tree4a8bdb306ae5f3194837abb3105a5ad2a23678c9
parent2a27e9319bacc9bc98f38afb7e4f050601ab979b
Add `urcu_posix_assert()` as `assert()` replacement

This macro acts like the regular `assert()` macro unless NDEBUG is
defined in which case it consumes the expression and becomes a no-op.

This consumption trick (see `_urcu_use_expression()` macro) prevents the
compiler from warning about unused variables even when assert() are
removed by the NDEBUG define.

This macro is also used for the existing `urcu_assert_debug()` macro.

The implementation of `_urcu_use_expression()` is inspired by the
Babeltrace 2 approach.

See `BT_USE_EXPR()` macro and documentation in Babeltrace commit [1]:
  commit 1778c2a4134647150b199b2b57130817144446b0
  Author: Philippe Proulx <eeppeliteloop@gmail.com>
  Date:   Tue Apr 21 11:15:42 2020 -0400
  lib: assign a unique ID to each pre/postcond. and report it on failure

All assertion macros are moved to the new urcu/assert.h file.

Link: https://github.com/efficios/babeltrace/commit/1778c2a4134647150b199b2b57130817144446b0
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If60ce2d3f45ea8f5ec1dbb92fb43f83fd9f8102b
57 files changed:
include/Makefile.am
include/urcu/assert.h [new file with mode: 0644]
include/urcu/debug.h
include/urcu/rculfqueue.h
include/urcu/ref.h
include/urcu/static/lfstack.h
include/urcu/static/rculfqueue.h
include/urcu/static/urcu-bp.h
include/urcu/static/urcu-common.h
include/urcu/static/urcu-mb.h
include/urcu/static/urcu-memb.h
include/urcu/static/urcu-qsbr.h
include/urcu/static/urcu-signal.h
include/urcu/static/wfcqueue.h
include/urcu/static/wfqueue.h
include/urcu/static/wfstack.h
include/urcu/wfcqueue.h
include/urcu/wfqueue.h
include/urcu/wfstack.h
src/compat_arch.c
src/compat_futex.c
src/rculfhash-internal.h
src/rculfhash-mm-chunk.c
src/rculfhash-mm-mmap.c
src/rculfhash-mm-order.c
src/rculfhash.c
src/urcu-bp.c
src/urcu-call-rcu-impl.h
src/urcu-defer-impl.h
src/urcu-qsbr.c
src/urcu-wait.h
src/urcu.c
src/workqueue.c
tests/benchmark/test_looplen.c
tests/benchmark/test_mutex.c
tests/benchmark/test_perthreadlock.c
tests/benchmark/test_perthreadlock_timing.c
tests/benchmark/test_rwlock.c
tests/benchmark/test_rwlock_timing.c
tests/benchmark/test_urcu.c
tests/benchmark/test_urcu_assign.c
tests/benchmark/test_urcu_bp.c
tests/benchmark/test_urcu_defer.c
tests/benchmark/test_urcu_gc.c
tests/benchmark/test_urcu_hash.c
tests/benchmark/test_urcu_hash.h
tests/benchmark/test_urcu_lfq.c
tests/benchmark/test_urcu_lfs.c
tests/benchmark/test_urcu_lfs_rcu.c
tests/benchmark/test_urcu_qsbr.c
tests/benchmark/test_urcu_qsbr_gc.c
tests/benchmark/test_urcu_qsbr_timing.c
tests/benchmark/test_urcu_timing.c
tests/benchmark/test_urcu_wfcq.c
tests/benchmark/test_urcu_wfq.c
tests/benchmark/test_urcu_wfs.c
tests/regression/test_urcu_fork.c
This page took 0.030553 seconds and 4 git commands to generate.