From 28f39cca1ccd44c4d51c884aca2ac85e617985f9 Mon Sep 17 00:00:00 2001 From: Kevin Li Date: Thu, 6 Jun 2024 09:23:29 +0800 Subject: [PATCH] add constructor for ApplicationContext::OffsetDeleter for internal use --- .bazelrc | 3 --- .github/workflows/ci.yml | 20 ++++++++++---------- src/babylon/application_context.h | 5 +++++ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.bazelrc b/.bazelrc index 3a2791f..0cf58fe 100644 --- a/.bazelrc +++ b/.bazelrc @@ -12,6 +12,3 @@ test --test_env=ASAN_OPTIONS=detect_odr_violation=1 test:arenastring --//proto:arenastring test:mutable-donated-string --config=arenastring --copt=-DGOOGLE_PROTOBUF_MUTABLE_DONATED_STRING=1 - -build:ci --disk_cache=bazel-disk -build:ci --repository_cache=bazel-repo diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43aa279..ced1ab3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: path: bazel-disk key: bazel-disk-gcc12-basic-asan-${{github.sha}} restore-keys: bazel-disk-gcc12-basic-asan- - - run: bazel test --config=ci --action_env=CC=gcc-12 --features=asan test/... + - run: bazel test --disk_cache=bazel-disk --action_env=CC=gcc-12 --features=asan test/... gcc12-basic-tsan: runs-on: ubuntu-latest @@ -27,7 +27,7 @@ jobs: path: bazel-disk key: bazel-disk-gcc12-basic-tsan-${{github.sha}} restore-keys: bazel-disk-gcc12-basic-tsan- - - run: bazel test --config=ci --action_env=CC=gcc-12 --features=tsan test/... + - run: bazel test --disk_cache=bazel-disk --action_env=CC=gcc-12 --features=tsan test/... gcc12-arenastring-asan: runs-on: ubuntu-latest @@ -39,7 +39,7 @@ jobs: key: bazel-disk-gcc12-arenastring-${{github.sha}} restore-keys: bazel-disk-gcc12-arenastring- - run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '25.3.arenastring'/" MODULE.bazel - - run: bazel test --config=ci --action_env=CC=gcc-12 --config=arenastring --features=asan test/... + - run: bazel test --disk_cache=bazel-disk --action_env=CC=gcc-12 --config=arenastring --features=asan test/... gcc12-mutable-donated-string-asan: runs-on: ubuntu-latest @@ -51,7 +51,7 @@ jobs: key: bazel-disk-gcc12-mutable-donated-string-${{github.sha}} restore-keys: bazel-disk-gcc12-mutable-donated-string- - run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '25.3.arenastring'/" MODULE.bazel - - run: bazel test --config=ci --action_env=CC=gcc-12 --config=mutable-donated-string --features=asan test/... + - run: bazel test --disk_cache=bazel-disk --action_env=CC=gcc-12 --config=mutable-donated-string --features=asan test/... gcc12-cxx14-asan: runs-on: ubuntu-latest @@ -73,7 +73,7 @@ jobs: path: bazel-disk key: bazel-disk-clang14-basic-asan-${{github.sha}} restore-keys: bazel-disk-clang14-basic-asan- - - run: bazel test --config=ci --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --features=asan test/... + - run: bazel test --disk_cache=bazel-disk --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --features=asan test/... clang14-basic-tsan: runs-on: ubuntu-latest @@ -84,7 +84,7 @@ jobs: path: bazel-disk key: bazel-disk-clang14-basic-tsan-${{github.sha}} restore-keys: bazel-disk-clang14-basic-tsan- - - run: bazel test --config=ci --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --features=tsan test/... + - run: bazel test --disk_cache=bazel-disk --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --features=tsan test/... clang14-arenastring-asan: runs-on: ubuntu-latest @@ -96,7 +96,7 @@ jobs: key: bazel-disk-clang14-arenastring-${{github.sha}} restore-keys: bazel-disk-clang14-arenastring- - run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '25.3.arenastring'/" MODULE.bazel - - run: bazel test --config=ci --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --config=arenastring --features=asan test/... + - run: bazel test --disk_cache=bazel-disk --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --config=arenastring --features=asan test/... clang14-mutable-donated-string-asan: runs-on: ubuntu-latest @@ -108,7 +108,7 @@ jobs: key: bazel-disk-clang14-mutable-donated-string-${{github.sha}} restore-keys: bazel-disk-clang14-mutable-donated-string- - run: sed -i "/single_version_override.*protobuf/s/version = '[^']*'/version = '25.3.arenastring'/" MODULE.bazel - - run: bazel test --config=ci --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --config=mutable-donated-string --features=asan test/... + - run: bazel test --disk_cache=bazel-disk --action_env=CC=clang-14 --cxxopt=-stdlib=libc++ --linkopt=-stdlib=libc++ --config=mutable-donated-string --features=asan test/... clang14-cxx14-asan: runs-on: ubuntu-latest @@ -133,7 +133,7 @@ jobs: - run: sudo apt install g++-12-aarch64-linux-gnu - run: sudo apt install qemu-user - run: sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 /lib/ - - run: bazel test --config=ci --platforms='@cross_config_toolchain//:cross' --action_env=CROSS_CC=/usr/bin/aarch64-linux-gnu-gcc-12 --features=-default_link_flags --features=asan --linkopt=-fuse-ld=gold --test_env=LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib --test_env=ASAN_OPTIONS=detect_odr_violation=1:detect_leaks=0 test/... + - run: bazel test --disk_cache=bazel-disk --platforms='@cross_config_toolchain//:cross' --action_env=CROSS_CC=/usr/bin/aarch64-linux-gnu-gcc-12 --features=-default_link_flags --features=asan --linkopt=-fuse-ld=gold --test_env=LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib --test_env=ASAN_OPTIONS=detect_odr_violation=1:detect_leaks=0 test/... coverage: runs-on: ubuntu-latest @@ -144,7 +144,7 @@ jobs: path: bazel-disk key: bazel-disk-coverage-${{github.sha}} restore-keys: bazel-disk-coverage- - - run: bazel coverage --config=ci --combined_report=lcov --instrumentation_filter='src/babylon,-src/babylon/reusable/patch' test/... + - run: bazel coverage --disk_cache=bazel-disk --combined_report=lcov --instrumentation_filter='src/babylon,-src/babylon/reusable/patch' test/... - run: ln -s _coverage_report.dat bazel-out/_coverage/_coverage_report.lcov - uses: coverallsapp/github-action@v2 with: diff --git a/src/babylon/application_context.h b/src/babylon/application_context.h index dbafc43..950e08c 100644 --- a/src/babylon/application_context.h +++ b/src/babylon/application_context.h @@ -120,6 +120,7 @@ class ApplicationContext::OffsetDeleter { // 在偏移offset后调用deleter来执行销毁 // 使用在按基类销毁场景 + inline OffsetDeleter(void (*deleter)(void*)) noexcept; inline OffsetDeleter(void (*deleter)(void*), ptrdiff_t offset) noexcept; void operator()(void* ptr) noexcept; @@ -374,6 +375,10 @@ class ApplicationContext::ComponentAccessor { //////////////////////////////////////////////////////////////////////////////// // ApplicationContext::OffsetDeleter begin +inline ApplicationContext::OffsetDeleter::OffsetDeleter( + void (*deleter)(void*)) noexcept + : OffsetDeleter {deleter, 0} {} + inline ApplicationContext::OffsetDeleter::OffsetDeleter( void (*deleter)(void*), ptrdiff_t offset) noexcept : deleter {deleter}, offset {offset} {}