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>
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>
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>
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>
configure: standardise include path Use the same include setup as our other projects, set the default includes globally in configure.ac in AM_CPPFLAGS. This is part of an effort to standardise our autotools setup across project to simplify maintenance. Change-Id: Ia40344e22920bafca9ed34ea2867acf38a1807e3 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests: Move tap-driver.sh out of the autotools aux directory We have made local modifications to this script, move it to the test suite directory so it doesn't get overwritten by an updated version from autotools. This is part of an effort to standardise our autotools setup across project to simplify maintenance. Change-Id: I4bc0bdbff05d03d8e4c0f9dcda51cf6a6cf7fec4 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tests: Replace prove by autotools tap runner This patch removes the dependency on the prove perl script to run the TAP test suite. It replaces it with the autotools shell TAP driver that only requires a shell and awk. Custom arguments can be passed to the test runner with env variables as follow: env LOG_DRIVER_FLAGS='--comments --ignore-exit' \ TESTS='foo.test baz.test' make -e check This tap driver also creates a log file for each test that can then be used by another system to build a test report. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: Don't override user variables within the build system Instead use the appropriatly prefixed AM_* variables as to not interfere when a user variable is passed to a make command. The proper use of flag variables is documented at : https://www.gnu.org/software/automake/manual/automake.html#Flag-Variables-Ordering Fixes #1095 Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cleanup: Re-organise source dir Re-organise the sources, add a top level "src" and "include" dir and move relevant files. Disable autotools automated includes and define them manually. This fixes problems with collision of header names with system headers. Include the autoconf config.h in the default includes and remove it where it's explicitely included. Remove _GNU_SOURCE defines since it's detected at configure for platforms that requires it and added to the config.h. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cleanup: Check for pthread in Libc Some libc like Googles's Bionic for Android include pThread. Instead of checking for Android as in commit 58a052effb2305655ff1b7233c78ab24fc25257e this patch checks for pthread in libc as proposed by Thomas Petazzoni. Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Charles Briere <charlesbriere.flatzo@gmail.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>