From 8d2d37446d99c88e5cf0c298435450986a27bd01 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 6 May 2022 09:57:51 +0200 Subject: [PATCH] Squashed 'src/c-rbtree/' changes from 8aa7bd1828ee..9b9713aeb9ec 9b9713aeb9ec build: update docs 7d38954dfd69 c-rbtree: document c_rbtree_entry() better 401241d4db02 build: always build test-parallel 337eb6c06d48 build: declare meson dependency 5741c13745cc ci: switch to new c-util CI workflow 39f870caf0aa build: drop redundant _GNU_SOURCE cd315e186cf0 build: define 'ptrace' option a1fb0a3296ae build: drop old submodules 739c1e982d74 build: re-order build definitions alphabetically e98d4ed5a863 build: rework dependency handling f9dd3852b8de build: use both_libraries() git-subtree-dir: src/c-rbtree git-subtree-split: 9b9713aeb9eca98566a85c8c90a02942ea430819 --- .github/workflows/ci.yml | 30 ++++++++++-------------------- .gitmodules | 3 --- AUTHORS | 2 +- NEWS.md | 15 +++++++++++++++ README.md | 2 +- meson.build | 15 +++++++++------ meson_options.txt | 1 + src/c-rbtree.h | 5 +++++ src/meson.build | 33 ++++++++++++++------------------- src/test-parallel.c | 3 --- subprojects/c-stdaux | 1 - subprojects/libcstdaux-1.wrap | 3 +++ 12 files changed, 59 insertions(+), 54 deletions(-) create mode 100644 meson_options.txt delete mode 160000 subprojects/c-stdaux create mode 100644 subprojects/libcstdaux-1.wrap diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c270c52ca7..6350d3c746 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,25 +9,15 @@ on: jobs: ci: name: CI with Default Configuration - runs-on: ubuntu-latest - - steps: - - name: Fetch Sources - uses: actions/checkout@v2 - - name: Run through C-Util CI - uses: c-util/automation/src/ci-c-util@v1 - with: - m32: 1 - valgrind: 1 - + uses: bus1/cabuild/.github/workflows/ci-c-util.yml@v1 + with: + cabuild_ref: "v1" + m32: true + matrixmode: true + valgrind: true ci-ptrace: name: Reduced CI with PTrace - runs-on: ubuntu-latest - env: - CRBTREE_TEST_PTRACE: '1' - - steps: - - name: Fetch Sources - uses: actions/checkout@v2 - - name: Run through C-Util CI - uses: c-util/automation/src/ci-c-util@v1 + uses: bus1/cabuild/.github/workflows/ci-c-util.yml@v1 + with: + cabuild_ref: "v1" + mesonargs: '-Dptrace=true' diff --git a/.gitmodules b/.gitmodules index a86b29fd1c..e69de29bb2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "subprojects/c-stdaux"] - path = subprojects/c-stdaux - url = https://github.com/c-util/c-stdaux.git diff --git a/AUTHORS b/AUTHORS index ed4e72e915..cd557de26c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -30,7 +30,7 @@ AUTHORS-LGPL: along with this program; If not, see . COPYRIGHT: (ordered alphabetically) - Copyright (C) 2015-2019 Red Hat, Inc. + Copyright (C) 2015-2022 Red Hat, Inc. AUTHORS: (ordered alphabetically) David Rheinsberg diff --git a/NEWS.md b/NEWS.md index d76a412908..3fe061d977 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,20 @@ # c-rbtree - Intrusive Red-Black Tree Collection +## CHANGES WITH 4: + + * Add 'ptrace' build option to enable running tests using 'ptrace' + to verify extended execution properties. This option should not + be used in setups where 'ptrace' cannot be employed (like running + under gdb or valgrind). This option only affects the test-suite. + + * meson-0.60.0 is now the minimum required meson version. + + * TBD + + Contributions from: David Rheinsberg + + - TBD, YYYY-MM-DD + ## CHANGES WITH 3: * Add more helpers. Add both a collection of iteratiors and helpers diff --git a/README.md b/README.md index c725bbb8f4..e3183ac8aa 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ The requirements for this project are: At build-time, the following software is required: - * `meson >= 0.41` + * `meson >= 0.60` * `pkg-config >= 0.29` ### Build diff --git a/meson.build b/meson.build index c131946762..f3ae209dbb 100644 --- a/meson.build +++ b/meson.build @@ -1,19 +1,22 @@ project( 'c-rbtree', 'c', - version: '3', - license: 'Apache', default_options: [ 'c_std=c11' ], + license: 'Apache', + meson_version: '>=0.60.0', + version: '3.0.0', ) +major = meson.project_version().split('.')[0] project_description = 'Intrusive Red-Black Tree Collection' -add_project_arguments('-D_GNU_SOURCE', language: 'c') mod_pkgconfig = import('pkgconfig') +use_ptrace = get_option('ptrace') -sub_cstdaux = subproject('c-stdaux') - -dep_cstdaux = sub_cstdaux.get_variable('libcstdaux_dep') +dep_cstdaux = dependency('libcstdaux-1') +add_project_arguments(dep_cstdaux.get_variable('cflags').split(' '), language: 'c') subdir('src') + +meson.override_dependency('libcrbtree-'+major, libcrbtree_dep, static: true) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000000..ec35818053 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('ptrace', type: 'boolean', value: false, description: 'Allow ptrace in test suite') diff --git a/src/c-rbtree.h b/src/c-rbtree.h index d4d0fe45c0..5c6fd0a559 100644 --- a/src/c-rbtree.h +++ b/src/c-rbtree.h @@ -144,6 +144,11 @@ static inline void c_rbnode_init(CRBNode *n) { * * Return: Pointer to parent container, or NULL. */ +/* + * Note: This was carefully designed to avoid multiple evaluation of `_what`, + * but avoid context-expression-extensions. That is why it uses the + * possibly odd style of `(x ?: offsetof(...)) - offsetof(...))`. + */ #define c_rbnode_entry(_what, _t, _m) \ ((_t *)(void *)(((unsigned long)(void *)(_what) ?: \ offsetof(_t, _m)) - offsetof(_t, _m))) diff --git a/src/meson.build b/src/meson.build index d0b4d63ce9..c5cce8102c 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,8 +8,8 @@ libcrbtree_deps = [ dep_cstdaux, ] -libcrbtree_private = static_library( - 'crbtree-private', +libcrbtree_both = both_libraries( + 'crbtree-'+major, [ 'c-rbtree.c', ], @@ -18,26 +18,19 @@ libcrbtree_private = static_library( '-fno-common', ], dependencies: libcrbtree_deps, - pic: true, -) - -libcrbtree_shared = shared_library( - 'crbtree', - objects: libcrbtree_private.extract_all_objects(), - dependencies: libcrbtree_deps, install: not meson.is_subproject(), - soversion: 0, - link_depends: libcrbtree_symfile, link_args: [ '-Wl,--no-undefined', '-Wl,--version-script=@0@'.format(libcrbtree_symfile), ], + link_depends: libcrbtree_symfile, + soversion: 0, ) libcrbtree_dep = declare_dependency( - include_directories: include_directories('.'), - link_with: libcrbtree_private, dependencies: libcrbtree_deps, + include_directories: include_directories('.'), + link_with: libcrbtree_both.get_static_lib(), version: meson.project_version(), ) @@ -45,11 +38,11 @@ if not meson.is_subproject() install_headers('c-rbtree.h') mod_pkgconfig.generate( - libraries: libcrbtree_shared, - version: meson.project_version(), - name: 'libcrbtree', - filebase: 'libcrbtree', description: project_description, + filebase: 'libcrbtree-'+major, + libraries: libcrbtree_both.get_shared_lib(), + name: 'libcrbtree', + version: meson.project_version(), ) endif @@ -57,7 +50,7 @@ endif # target: test-* # -test_api = executable('test-api', ['test-api.c'], link_with: libcrbtree_shared) +test_api = executable('test-api', ['test-api.c'], link_with: libcrbtree_both.get_shared_lib()) test('API Symbol Visibility', test_api) test_basic = executable('test-basic', ['test-basic.c'], dependencies: libcrbtree_dep) @@ -70,7 +63,9 @@ test_misc = executable('test-misc', ['test-misc.c'], dependencies: libcrbtree_de test('Miscellaneous', test_misc) test_parallel = executable('test-parallel', ['test-parallel.c'], dependencies: libcrbtree_dep) -test('Lockless Parallel Readers', test_parallel) +if use_ptrace + test('Lockless Parallel Readers', test_parallel) +endif test_posix = executable('test-posix', ['test-posix.c'], dependencies: libcrbtree_dep) test('Posix tsearch(3p) Comparison', test_posix) diff --git a/src/test-parallel.c b/src/test-parallel.c index 1388722bf3..4baf8e702d 100644 --- a/src/test-parallel.c +++ b/src/test-parallel.c @@ -364,9 +364,6 @@ int main(int argc, char **argv) { unsigned int i; int r; - if (!getenv("CRBTREE_TEST_PTRACE")) - return 77; - /* we want stable tests, so use fixed seed */ srand(0xdeadbeef); diff --git a/subprojects/c-stdaux b/subprojects/c-stdaux deleted file mode 160000 index c5f166d02f..0000000000 --- a/subprojects/c-stdaux +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c5f166d02ff68af5cdcbad1bdcea2cb134e34ce4 diff --git a/subprojects/libcstdaux-1.wrap b/subprojects/libcstdaux-1.wrap new file mode 100644 index 0000000000..036020aafe --- /dev/null +++ b/subprojects/libcstdaux-1.wrap @@ -0,0 +1,3 @@ +[wrap-git] +url = https://github.com/c-util/c-stdaux.git +revision = v1