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)
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


No differences found
This page took 0.025015 seconds and 4 git commands to generate.