fix: add missing SPDX licensing tags Change-Id: If7016a3c83211e88c102f8b395dc290859af4789 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tests: Add test for byte/short atomics on addresses which are not word-aligned Add a unit test to catch architectures which do not allow byte and short atomic operations on addresses which are not word aligned. If an architecture supports byte and short atomic operations, it should be valid to issue those operations on variables which are not word-aligned, otherwise the architecture should not define UATOMIC_HAS_ATOMIC_BYTE nor UATOMIC_HAS_ATOMIC_SHORT. This should help identify architectures which mistakenly define UATOMIC_HAS_ATOMIC_BYTE and UATOMIC_HAS_ATOMIC_SHORT. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I13d2f3be41749b018b39499106938b3746c419c1
tests/unit: Remove urcu-signal unit tests In preparation for deprecation of the urcu-signal flavor, remove the urcu-signal unit tests. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: Ic74dd38d111e320cfd2860c2fc0fdb7ffde114dd
tests: Add tests for checking race conditions These tests do nothing useful except of stress testing a single-consumer, multiple-producers program on various data structures. These tests are only meaningful when compiling liburcu with TSAN. Change-Id: If22b27ed0fb95bf890947fc4e75f923edb5ada8f Signed-off-by: Olivier Dion <odion@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/unit/test_build: Quiet unused return value Change-Id: Ie5a18e0ccc4b1b5ee85c5bd140561cc2ff9e2fbc Co-authored-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Olivier Dion <odion@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests: use SPDX identifiers The SPDX identifiers [1] are a legally binding shorthand, which can be used instead of the full boiler plate text. This is another step towards implementing the full REUSE spec [2] to help with copyright and licensing audits and compliance. This will reduce a lot a manual work required for the licensing audit required in Debian on each update. For files that lacked copyright and licensing information, I used the following guidelines. Use the author from the git history and the test scripts license as stated in LICENSE, 'GPL-2.0-only'. [1] https://spdx.org/ids-how [2] https://reuse.software/tutorial/ Change-Id: I23c23edeffe6f3448ad673034480de46c98b746b Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Build system: use SPDX identifiers The SPDX identifiers [1] are a legally binding shorthand, which can be used instead of the full boiler plate text. This is the first step towards implementing the full REUSE spec [2] to help with copyright and licensing audits and compliance. This will reduce a lot a manual work required for the licensing audit required in Debian on each update. For files that lacked copyright and licensing information, I used the following guidelines. If a clear author could be determined from the git history use it, otherwise use 'EfficiOS Inc.'. For build system files, use 'MIT', for documentation 'CC-BY-4.0' and for data files 'CC-1.0'. [1] https://spdx.org/ids-how [2] https://reuse.software/tutorial/ Change-Id: Ie507130c00b95606dc439616fda4fd9b1d35353d Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Adjust shell scripts to allow Bash in other locations Linux-based OS for the most part provide Bash and being located in /bin, but on other OS's the shell would be in another location. Utilize env(1) and allow it to be located elsewhere. Signed-off-by: Brad Smith <brad@comstyle.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I9d4d4a3feaf993754c64b740ea91e42b336ba2b4
Fix: change method used by _rcu_dereference to strip type constness Commit 1e41ec3b07e4 ("Make temporary variable in _rcu_dereference non-const") used the trick to add 0 to the pointer passed as a parameter to the macro to get rid of its constness, should it be const (with the end goal of avoiding compiler warnings). This is problematic (as shown in [1]) if it is a pointer to an opaque type though, as the compiler cannot perform pointer arithmetic on such a pointer (even though it wouldn't really need to here, as we add 0). Change it to use another trick to strip away the constness, that shouldn't hit this problem. It was found in the same stackoverflow post as the original trick [2]. It consists of using a statement expression like so: __typeof__(({ const int foo; foo; })) The statement expression yields a value of type `int`. Statement expressions are extensions to the C language, but we already use them here. The test_build* binaries now need to be linked against the urcu library, otherwise they would be missing the rcu_dereference_sym symbol. [1] https://lists.lttng.org/pipermail/lttng-dev/2022-August/030247.html [2] https://stackoverflow.com/a/54016713 Change-Id: Ic73590ef4beaa1832161aa05a6df37e467f85116 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
fix: ifdef linux specific cpu count compat Expand the '#ifdef __linux__' block in src/compat-cpu.h to all static inline functions related to sysfs since they are only useful on Linux and fail to build on some non-Linux platforms. This issue was reported on QNX. The corresponding unit tests have to be skipped on non-Linux platforms. Thanks to Elad Lahav <e2lahav@gmail.com> for reporting this issue. Change-Id: I17c88a9a2fb5b9be6cf5325234a18ff40788cd09 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Add unit tests for possible_cpus_array_len Change-Id: Ida3affbc7021c96bbc8941a96455ef93030c5c96 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Improved test framework This is based on the babeltrace / librseq test framework with the objective of standardising across projects. Regroup all the configure detected values relevant to the test suite in a single generated file. This file will be automatically sourced by the test suite in most scenarios but can also be sourced in the shell of a user. * All user overridable variables start with 'URCU_TESTS_'. * The priority for variables is : Environment -> env.sh -> utils.sh (defaults). * A user can source 'env.sh', override some of the values and manually run test scripts. * The test suite can run without an 'env.sh' file present. Change-Id: Id94f7085ed1ea0e30207856cf1594ca30585536c Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
fix: use urcu-tls compat with c++ compiler * Initialize all fields of 'struct urcu_tls' to avoid : sorry, unimplemented: non-trivial designated initializers not supported * Cast void* to proper type pointers to avoid : error: invalid conversion from ‘void*’ to ... Change-Id: I654f924324cda2eaea723f4a0759d706b2a2bf40 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Add C++ build tests Some urcu header files cause build failures when included in C++ programs. Add a test file that includes all exported headers (except those that are marked as deprecated) and build that test file as a C and C++ program, with and without _LGPL_SOURCE defined (to test both the static and non-static implementations). This helps ensure that the code in these headers works as both languages. This alone does not ensure full coverage, there may be code in unused macros that would need fixing. But by including the "static" headers, this already finds a few issues. The test doesn't run anything, its purpose is only to verify that things build. This catches the following build failures: - clang++ doesn't know the __transparent_union__ attribute, place some pragmas to ignore this warning around where __transparent_union__ is used. - CDS_WFS_WOULDBLOCK and CDS_WFS_END are cast to a void*. This doesn't work in C++ when assigning to a field them to typed pointer. Fix them by casting to the appropriate type. - The transparent union trick doesn't work in C++: CXX test_build_cxx.o In file included from /home/simark/src/urcu/include/urcu/wfstack.h:116, from /home/simark/src/urcu/include/urcu/cds.h:35, from /home/simark/src/urcu/tests/unit/test_build_cxx.cpp:34: /home/simark/src/urcu/include/urcu/static/wfstack.h: In function ‘cds_wfs_node* _cds_wfs_pop_with_state_blocking(cds_wfs_stack*, int*)’: /home/simark/src/urcu/include/urcu/static/wfstack.h:350:54: error: could not convert ‘s’ from ‘cds_wfs_stack*’ to ‘cds_wfs_stack_ptr_t’ 350 | retnode = ___cds_wfs_pop_with_state_blocking(s, state); | ^ | | | cds_wfs_stack* A C++ user can fall back to instantiating a cds_wfs_stack_ptr_t explicitly, assigning the right field, and passing the cds_wfs_stack_ptr_t to the function. Fix a few instances in the static headers. A follow up commit will introduce C++ API wrappers based on function overloading to provide a C++ API similar to the C API. Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Change-Id: I30adc8df69414a0a019c5ec081f64cfac64843f5
Build and run regression and unit tests as C++ programs Build and run all tests under tests/regression and tests/unit as C++ programs in addition to C. This helps get confidence that urcu, when used from a C++ program, behaves well. Change-Id: Iacaa42dddbcbf59eff8e327edfd0352cce0b74b7 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
cleanup: explicitly mark unused parameters (-Wunused-parameter) Add the 'unused' attribute to function parameters that are unused to allow turning on -Wunused-parameter and distinguish unused parameters that are actual errors. Change-Id: Ie585e37f9d38718543a31aee2e7ab3428cdfd0a5 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>