Skip to content

Commit

Permalink
add constructor for ApplicationContext::OffsetDeleter for internal use
Browse files Browse the repository at this point in the history
  • Loading branch information
oathdruid committed Jun 6, 2024
1 parent 21b834d commit 28f39cc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions src/babylon/application_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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} {}
Expand Down

0 comments on commit 28f39cc

Please sign in to comment.