From bf1856d2cc8bbfa4c38a30460a4ed7866611dd21 Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Fri, 9 Sep 2022 10:30:17 -0700 Subject: [PATCH] A modest split of `:gpr` for mpscq support (#30798) * A modest split of `:gpr` for mpscq support A full split of the `gpr` target into 25 separate targets is building, but there are some hurdles to get over with respect to ODR violations and public API support for the gpr library. This PR splits off a small chunk of that work. * Automated change: Fix sanity tests Co-authored-by: drfloob --- BUILD | 93 ++++++++++++++++++++++++++++++--- CMakeLists.txt | 12 +++-- Makefile | 5 +- build_autogenerated.yaml | 40 +++++++++++--- grpc.gyp | 3 +- src/core/lib/gpr/log_internal.h | 55 +++++++++++++++++++ test/core/end2end/BUILD | 1 + test/core/util/BUILD | 2 + 8 files changed, 192 insertions(+), 19 deletions(-) create mode 100644 src/core/lib/gpr/log_internal.h diff --git a/BUILD b/BUILD index ed3371fb9ed..dd41cbf62c2 100644 --- a/BUILD +++ b/BUILD @@ -154,7 +154,6 @@ version = "1.50.0-dev" # @unused GPR_PUBLIC_HDRS = [ "include/grpc/support/alloc.h", - "include/grpc/support/atm.h", "include/grpc/support/atm_gcc_atomic.h", "include/grpc/support/atm_gcc_sync.h", "include/grpc/support/atm_windows.h", @@ -948,11 +947,74 @@ grpc_cc_library( deps = ["gpr_platform"], ) +grpc_cc_library( + name = "gpr_atm", + srcs = [ + "src/core/lib/gpr/atm.cc", + ], + language = "c++", + public_hdrs = [ + "include/grpc/support/atm.h", + ], + deps = [ + "gpr_codegen", + "gpr_platform", + "useful", + ], +) + +grpc_cc_library( + name = "gpr_manual_constructor", + srcs = [], + hdrs = [ + "src/core/lib/gprpp/manual_constructor.h", + ], + language = "c++", + deps = [ + "construct_destruct", + "gpr_public_hdrs", + ], +) + +grpc_cc_library( + name = "gpr_murmur_hash", + srcs = [ + "src/core/lib/gpr/murmur_hash.cc", + ], + hdrs = [ + "src/core/lib/gpr/murmur_hash.h", + ], + external_deps = ["absl/base:core_headers"], + language = "c++", + deps = ["gpr_platform"], +) + +grpc_cc_library( + name = "gpr_spinlock", + srcs = [], + hdrs = [ + "src/core/lib/gpr/spinlock.h", + ], + language = "c++", + deps = [ + "gpr_atm", + "gpr_public_hdrs", + ], +) + +grpc_cc_library( + name = "gpr_log_internal", + hdrs = [ + "src/core/lib/gpr/log_internal.h", + ], + language = "c++", + deps = ["gpr_platform"], +) + grpc_cc_library( name = "gpr", srcs = [ "src/core/lib/gpr/alloc.cc", - "src/core/lib/gpr/atm.cc", "src/core/lib/gpr/cpu_iphone.cc", "src/core/lib/gpr/cpu_linux.cc", "src/core/lib/gpr/cpu_posix.cc", @@ -965,7 +1027,6 @@ grpc_cc_library( "src/core/lib/gpr/log_linux.cc", "src/core/lib/gpr/log_posix.cc", "src/core/lib/gpr/log_windows.cc", - "src/core/lib/gpr/murmur_hash.cc", "src/core/lib/gpr/string.cc", "src/core/lib/gpr/string_posix.cc", "src/core/lib/gpr/string_util_windows.cc", @@ -995,8 +1056,6 @@ grpc_cc_library( hdrs = [ "src/core/lib/gpr/alloc.h", "src/core/lib/gpr/env.h", - "src/core/lib/gpr/murmur_hash.h", - "src/core/lib/gpr/spinlock.h", "src/core/lib/gpr/string.h", "src/core/lib/gpr/time_precise.h", "src/core/lib/gpr/tmpfile.h", @@ -1006,7 +1065,6 @@ grpc_cc_library( "src/core/lib/gprpp/global_config_env.h", "src/core/lib/gprpp/global_config_generic.h", "src/core/lib/gprpp/host_port.h", - "src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/memory.h", "src/core/lib/gprpp/mpscq.h", "src/core/lib/gprpp/stat.h", @@ -1036,6 +1094,7 @@ grpc_cc_library( deps = [ "construct_destruct", "examine_stack", + "gpr_atm", "gpr_tls", "grpc_codegen", "no_destruct", @@ -1056,6 +1115,7 @@ grpc_cc_library( deps = [ "arena", "gpr", + "gpr_manual_constructor", ], ) @@ -2073,6 +2133,7 @@ grpc_cc_library( external_deps = ["absl/strings"], deps = [ "gpr", + "gpr_murmur_hash", "grpc_codegen", "slice_refcount", ], @@ -2105,6 +2166,7 @@ grpc_cc_library( tags = ["nofixdeps"], deps = [ "gpr", + "gpr_spinlock", "grpc_codegen", "grpc_trace", "slice", @@ -2123,6 +2185,7 @@ grpc_cc_library( "debug_location", "error", "gpr", + "gpr_manual_constructor", ], ) @@ -2162,7 +2225,9 @@ grpc_cc_library( "debug_location", "error", "gpr", + "gpr_atm", "gpr_codegen", + "gpr_spinlock", "gpr_tls", "grpc_codegen", "grpc_trace", @@ -2229,7 +2294,9 @@ grpc_cc_library( "event_engine_base_hdrs", "exec_ctx", "gpr", + "gpr_manual_constructor", "gpr_platform", + "gpr_spinlock", "gpr_tls", "grpc_trace", "iomgr_port", @@ -2490,6 +2557,7 @@ grpc_cc_library( external_deps = ["absl/status"], deps = [ "gpr", + "gpr_atm", "posix_event_engine_closure", "posix_event_engine_event_poller", "status_helper", @@ -3230,6 +3298,10 @@ grpc_cc_library( "exec_ctx", "experiments", "gpr", + "gpr_atm", + "gpr_manual_constructor", + "gpr_murmur_hash", + "gpr_spinlock", "gpr_tls", "grpc_public_hdrs", "grpc_sockaddr", @@ -3706,6 +3778,7 @@ grpc_cc_library( "default_event_engine", "dual_ref_counted", "gpr", + "gpr_atm", "gpr_codegen", "grpc_backend_metric_data", "grpc_base", @@ -4177,6 +4250,7 @@ grpc_cc_library( "debug_location", "default_event_engine", "gpr", + "gpr_atm", "gpr_codegen", "grpc_base", "grpc_client_channel", @@ -4881,6 +4955,7 @@ grpc_cc_library( "debug_location", "dual_ref_counted", "gpr", + "gpr_manual_constructor", "grpc_base", "grpc_codegen", "iomgr_fwd", @@ -6081,6 +6156,7 @@ grpc_cc_library( "arena_promise", "gpr", "gpr_codegen", + "gpr_manual_constructor", "grpc_base", "grpc_credentials_util", "grpc_security_base", @@ -6283,6 +6359,7 @@ grpc_cc_library( "event_engine_memory_allocator", "exec_ctx", "gpr", + "gpr_atm", "gpr_codegen", "grpc_base", "grpc_codegen", @@ -6755,6 +6832,7 @@ grpc_cc_library( "debug_location", "experiments", "gpr", + "gpr_atm", "grpc_base", "grpc_codegen", "grpc_public_hdrs", @@ -7036,6 +7114,7 @@ grpc_cc_library( "error", "gpr", "gpr_codegen", + "gpr_manual_constructor", "grpc", "grpc++_codegen_base", "grpc++_codegen_base_src", @@ -7091,6 +7170,7 @@ grpc_cc_library( "config", "gpr", "gpr_codegen", + "gpr_manual_constructor", "grpc++_codegen_base", "grpc++_codegen_base_src", "grpc_base", @@ -7471,6 +7551,7 @@ grpc_cc_library( language = "c++", deps = [ "gpr", + "gpr_atm", "grpc_base", "//src/proto/grpc/core:stats_proto", ], diff --git a/CMakeLists.txt b/CMakeLists.txt index 91384ae5426..3641b186866 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1535,7 +1535,6 @@ add_library(gpr src/core/lib/gpr/log_linux.cc src/core/lib/gpr/log_posix.cc src/core/lib/gpr/log_windows.cc - src/core/lib/gpr/murmur_hash.cc src/core/lib/gpr/string.cc src/core/lib/gpr/string_posix.cc src/core/lib/gpr/string_util_windows.cc @@ -2128,6 +2127,7 @@ add_library(grpc src/core/lib/event_engine/windows/windows_engine.cc src/core/lib/experiments/config.cc src/core/lib/experiments/experiments.cc + src/core/lib/gpr/murmur_hash.cc src/core/lib/gprpp/status_helper.cc src/core/lib/gprpp/time.cc src/core/lib/gprpp/time_averaged_stats.cc @@ -2468,7 +2468,6 @@ foreach(_hdr include/grpc/slice_buffer.h include/grpc/status.h include/grpc/support/alloc.h - include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h @@ -2766,6 +2765,7 @@ add_library(grpc_unsecure src/core/lib/event_engine/windows/windows_engine.cc src/core/lib/experiments/config.cc src/core/lib/experiments/experiments.cc + src/core/lib/gpr/murmur_hash.cc src/core/lib/gprpp/status_helper.cc src/core/lib/gprpp/time.cc src/core/lib/gprpp/time_averaged_stats.cc @@ -3040,7 +3040,6 @@ foreach(_hdr include/grpc/slice_buffer.h include/grpc/status.h include/grpc/support/alloc.h - include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h include/grpc/support/atm_gcc_sync.h include/grpc/support/atm_windows.h @@ -7552,6 +7551,7 @@ add_executable(chunked_vector_test src/core/lib/event_engine/memory_allocator.cc src/core/lib/experiments/config.cc src/core/lib/experiments/experiments.cc + src/core/lib/gpr/murmur_hash.cc src/core/lib/gprpp/status_helper.cc src/core/lib/gprpp/time.cc src/core/lib/iomgr/combiner.cc @@ -9640,6 +9640,7 @@ add_executable(exec_ctx_wakeup_scheduler_test src/core/ext/upb-generated/google/protobuf/any.upb.c src/core/ext/upb-generated/google/rpc/status.upb.c src/core/lib/debug/trace.cc + src/core/lib/gpr/murmur_hash.cc src/core/lib/gprpp/status_helper.cc src/core/lib/gprpp/time.cc src/core/lib/iomgr/combiner.cc @@ -10065,6 +10066,7 @@ add_executable(flow_control_test src/core/lib/event_engine/memory_allocator.cc src/core/lib/experiments/config.cc src/core/lib/experiments/experiments.cc + src/core/lib/gpr/murmur_hash.cc src/core/lib/gprpp/status_helper.cc src/core/lib/gprpp/time.cc src/core/lib/iomgr/combiner.cc @@ -10131,6 +10133,7 @@ add_executable(for_each_test src/core/lib/event_engine/memory_allocator.cc src/core/lib/experiments/config.cc src/core/lib/experiments/experiments.cc + src/core/lib/gpr/murmur_hash.cc src/core/lib/gprpp/status_helper.cc src/core/lib/gprpp/time.cc src/core/lib/iomgr/combiner.cc @@ -14301,6 +14304,7 @@ add_executable(periodic_update_test src/core/ext/upb-generated/google/protobuf/any.upb.c src/core/ext/upb-generated/google/rpc/status.upb.c src/core/lib/debug/trace.cc + src/core/lib/gpr/murmur_hash.cc src/core/lib/gprpp/status_helper.cc src/core/lib/gprpp/time.cc src/core/lib/iomgr/combiner.cc @@ -14405,6 +14409,7 @@ add_executable(pipe_test src/core/lib/event_engine/memory_allocator.cc src/core/lib/experiments/config.cc src/core/lib/experiments/experiments.cc + src/core/lib/gpr/murmur_hash.cc src/core/lib/gprpp/status_helper.cc src/core/lib/gprpp/time.cc src/core/lib/iomgr/combiner.cc @@ -16715,6 +16720,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(slice_string_helpers_test + src/core/lib/gpr/murmur_hash.cc src/core/lib/slice/slice.cc src/core/lib/slice/slice_refcount.cc src/core/lib/slice/slice_string_helpers.cc diff --git a/Makefile b/Makefile index 383aba8d980..ee509911dcc 100644 --- a/Makefile +++ b/Makefile @@ -855,7 +855,6 @@ LIBGPR_SRC = \ src/core/lib/gpr/log_linux.cc \ src/core/lib/gpr/log_posix.cc \ src/core/lib/gpr/log_windows.cc \ - src/core/lib/gpr/murmur_hash.cc \ src/core/lib/gpr/string.cc \ src/core/lib/gpr/string_posix.cc \ src/core/lib/gpr/string_util_windows.cc \ @@ -1417,6 +1416,7 @@ LIBGRPC_SRC = \ src/core/lib/event_engine/windows/windows_engine.cc \ src/core/lib/experiments/config.cc \ src/core/lib/experiments/experiments.cc \ + src/core/lib/gpr/murmur_hash.cc \ src/core/lib/gprpp/status_helper.cc \ src/core/lib/gprpp/time.cc \ src/core/lib/gprpp/time_averaged_stats.cc \ @@ -1699,7 +1699,6 @@ PUBLIC_HEADERS_C += \ include/grpc/slice_buffer.h \ include/grpc/status.h \ include/grpc/support/alloc.h \ - include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ @@ -1919,6 +1918,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/event_engine/windows/windows_engine.cc \ src/core/lib/experiments/config.cc \ src/core/lib/experiments/experiments.cc \ + src/core/lib/gpr/murmur_hash.cc \ src/core/lib/gprpp/status_helper.cc \ src/core/lib/gprpp/time.cc \ src/core/lib/gprpp/time_averaged_stats.cc \ @@ -2136,7 +2136,6 @@ PUBLIC_HEADERS_C += \ include/grpc/slice_buffer.h \ include/grpc/status.h \ include/grpc/support/alloc.h \ - include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ include/grpc/support/atm_gcc_sync.h \ include/grpc/support/atm_windows.h \ diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 302b4c1fde4..29a4728a122 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -208,8 +208,6 @@ libs: headers: - src/core/lib/gpr/alloc.h - src/core/lib/gpr/env.h - - src/core/lib/gpr/murmur_hash.h - - src/core/lib/gpr/spinlock.h - src/core/lib/gpr/string.h - src/core/lib/gpr/time_precise.h - src/core/lib/gpr/tls.h @@ -223,7 +221,6 @@ libs: - src/core/lib/gprpp/global_config_env.h - src/core/lib/gprpp/global_config_generic.h - src/core/lib/gprpp/host_port.h - - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/memory.h - src/core/lib/gprpp/mpscq.h - src/core/lib/gprpp/no_destruct.h @@ -247,7 +244,6 @@ libs: - src/core/lib/gpr/log_linux.cc - src/core/lib/gpr/log_posix.cc - src/core/lib/gpr/log_windows.cc - - src/core/lib/gpr/murmur_hash.cc - src/core/lib/gpr/string.cc - src/core/lib/gpr/string_posix.cc - src/core/lib/gpr/string_util_windows.cc @@ -337,7 +333,6 @@ libs: - include/grpc/slice_buffer.h - include/grpc/status.h - include/grpc/support/alloc.h - - include/grpc/support/atm.h - include/grpc/support/atm_gcc_atomic.h - include/grpc/support/atm_gcc_sync.h - include/grpc/support/atm_windows.h @@ -798,12 +793,15 @@ libs: - src/core/lib/event_engine/windows/windows_engine.h - src/core/lib/experiments/config.h - src/core/lib/experiments/experiments.h + - src/core/lib/gpr/murmur_hash.h + - src/core/lib/gpr/spinlock.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/chunked_vector.h - src/core/lib/gprpp/cpp_impl_of.h - src/core/lib/gprpp/debug_location.h - src/core/lib/gprpp/dual_ref_counted.h + - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/match.h - src/core/lib/gprpp/orphanable.h - src/core/lib/gprpp/overload.h @@ -1502,6 +1500,7 @@ libs: - src/core/lib/event_engine/windows/windows_engine.cc - src/core/lib/experiments/config.cc - src/core/lib/experiments/experiments.cc + - src/core/lib/gpr/murmur_hash.cc - src/core/lib/gprpp/status_helper.cc - src/core/lib/gprpp/time.cc - src/core/lib/gprpp/time_averaged_stats.cc @@ -1862,7 +1861,6 @@ libs: - include/grpc/slice_buffer.h - include/grpc/status.h - include/grpc/support/alloc.h - - include/grpc/support/atm.h - include/grpc/support/atm_gcc_atomic.h - include/grpc/support/atm_gcc_sync.h - include/grpc/support/atm_windows.h @@ -2020,12 +2018,15 @@ libs: - src/core/lib/event_engine/windows/windows_engine.h - src/core/lib/experiments/config.h - src/core/lib/experiments/experiments.h + - src/core/lib/gpr/murmur_hash.h + - src/core/lib/gpr/spinlock.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/chunked_vector.h - src/core/lib/gprpp/cpp_impl_of.h - src/core/lib/gprpp/debug_location.h - src/core/lib/gprpp/dual_ref_counted.h + - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/match.h - src/core/lib/gprpp/orphanable.h - src/core/lib/gprpp/overload.h @@ -2363,6 +2364,7 @@ libs: - src/core/lib/event_engine/windows/windows_engine.cc - src/core/lib/experiments/config.cc - src/core/lib/experiments/experiments.cc + - src/core/lib/gpr/murmur_hash.cc - src/core/lib/gprpp/status_helper.cc - src/core/lib/gprpp/time.cc - src/core/lib/gprpp/time_averaged_stats.cc @@ -4845,11 +4847,14 @@ targets: - src/core/lib/debug/trace.h - src/core/lib/experiments/config.h - src/core/lib/experiments/experiments.h + - src/core/lib/gpr/murmur_hash.h + - src/core/lib/gpr/spinlock.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/chunked_vector.h - src/core/lib/gprpp/cpp_impl_of.h - src/core/lib/gprpp/debug_location.h + - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/orphanable.h - src/core/lib/gprpp/ref_counted.h - src/core/lib/gprpp/ref_counted_ptr.h @@ -4892,6 +4897,7 @@ targets: - src/core/lib/event_engine/memory_allocator.cc - src/core/lib/experiments/config.cc - src/core/lib/experiments/experiments.cc + - src/core/lib/gpr/murmur_hash.cc - src/core/lib/gprpp/status_helper.cc - src/core/lib/gprpp/time.cc - src/core/lib/iomgr/combiner.cc @@ -5833,9 +5839,12 @@ targets: - src/core/ext/upb-generated/google/protobuf/any.upb.h - src/core/ext/upb-generated/google/rpc/status.upb.h - src/core/lib/debug/trace.h + - src/core/lib/gpr/murmur_hash.h + - src/core/lib/gpr/spinlock.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/debug_location.h + - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/orphanable.h - src/core/lib/gprpp/ref_counted.h - src/core/lib/gprpp/ref_counted_ptr.h @@ -5864,6 +5873,7 @@ targets: - src/core/ext/upb-generated/google/protobuf/any.upb.c - src/core/ext/upb-generated/google/rpc/status.upb.c - src/core/lib/debug/trace.cc + - src/core/lib/gpr/murmur_hash.cc - src/core/lib/gprpp/status_helper.cc - src/core/lib/gprpp/time.cc - src/core/lib/iomgr/combiner.cc @@ -6103,10 +6113,13 @@ targets: - src/core/lib/debug/trace.h - src/core/lib/experiments/config.h - src/core/lib/experiments/experiments.h + - src/core/lib/gpr/murmur_hash.h + - src/core/lib/gpr/spinlock.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/cpp_impl_of.h - src/core/lib/gprpp/debug_location.h + - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/orphanable.h - src/core/lib/gprpp/ref_counted.h - src/core/lib/gprpp/ref_counted_ptr.h @@ -6153,6 +6166,7 @@ targets: - src/core/lib/event_engine/memory_allocator.cc - src/core/lib/experiments/config.cc - src/core/lib/experiments/experiments.cc + - src/core/lib/gpr/murmur_hash.cc - src/core/lib/gprpp/status_helper.cc - src/core/lib/gprpp/time.cc - src/core/lib/iomgr/combiner.cc @@ -6192,10 +6206,13 @@ targets: - src/core/lib/debug/trace.h - src/core/lib/experiments/config.h - src/core/lib/experiments/experiments.h + - src/core/lib/gpr/murmur_hash.h + - src/core/lib/gpr/spinlock.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/cpp_impl_of.h - src/core/lib/gprpp/debug_location.h + - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/orphanable.h - src/core/lib/gprpp/ref_counted.h - src/core/lib/gprpp/ref_counted_ptr.h @@ -6246,6 +6263,7 @@ targets: - src/core/lib/event_engine/memory_allocator.cc - src/core/lib/experiments/config.cc - src/core/lib/experiments/experiments.cc + - src/core/lib/gpr/murmur_hash.cc - src/core/lib/gprpp/status_helper.cc - src/core/lib/gprpp/time.cc - src/core/lib/iomgr/combiner.cc @@ -8091,8 +8109,11 @@ targets: - src/core/ext/upb-generated/google/protobuf/any.upb.h - src/core/ext/upb-generated/google/rpc/status.upb.h - src/core/lib/debug/trace.h + - src/core/lib/gpr/murmur_hash.h + - src/core/lib/gpr/spinlock.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/debug_location.h + - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/status_helper.h - src/core/lib/gprpp/time.h - src/core/lib/iomgr/closure.h @@ -8112,6 +8133,7 @@ targets: - src/core/ext/upb-generated/google/protobuf/any.upb.c - src/core/ext/upb-generated/google/rpc/status.upb.c - src/core/lib/debug/trace.cc + - src/core/lib/gpr/murmur_hash.cc - src/core/lib/gprpp/status_helper.cc - src/core/lib/gprpp/time.cc - src/core/lib/iomgr/combiner.cc @@ -8176,10 +8198,13 @@ targets: - src/core/lib/debug/trace.h - src/core/lib/experiments/config.h - src/core/lib/experiments/experiments.h + - src/core/lib/gpr/murmur_hash.h + - src/core/lib/gpr/spinlock.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/cpp_impl_of.h - src/core/lib/gprpp/debug_location.h + - src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/orphanable.h - src/core/lib/gprpp/ref_counted.h - src/core/lib/gprpp/ref_counted_ptr.h @@ -8228,6 +8253,7 @@ targets: - src/core/lib/event_engine/memory_allocator.cc - src/core/lib/experiments/config.cc - src/core/lib/experiments/experiments.cc + - src/core/lib/gpr/murmur_hash.cc - src/core/lib/gprpp/status_helper.cc - src/core/lib/gprpp/time.cc - src/core/lib/iomgr/combiner.cc @@ -9247,12 +9273,14 @@ targets: build: test language: c++ headers: + - src/core/lib/gpr/murmur_hash.h - src/core/lib/slice/slice.h - src/core/lib/slice/slice_internal.h - src/core/lib/slice/slice_refcount.h - src/core/lib/slice/slice_refcount_base.h - src/core/lib/slice/slice_string_helpers.h src: + - src/core/lib/gpr/murmur_hash.cc - src/core/lib/slice/slice.cc - src/core/lib/slice/slice_refcount.cc - src/core/lib/slice/slice_string_helpers.cc diff --git a/grpc.gyp b/grpc.gyp index b7da2f41ddc..5012b08ce92 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -322,7 +322,6 @@ 'src/core/lib/gpr/log_linux.cc', 'src/core/lib/gpr/log_posix.cc', 'src/core/lib/gpr/log_windows.cc', - 'src/core/lib/gpr/murmur_hash.cc', 'src/core/lib/gpr/string.cc', 'src/core/lib/gpr/string_posix.cc', 'src/core/lib/gpr/string_util_windows.cc', @@ -822,6 +821,7 @@ 'src/core/lib/event_engine/windows/windows_engine.cc', 'src/core/lib/experiments/config.cc', 'src/core/lib/experiments/experiments.cc', + 'src/core/lib/gpr/murmur_hash.cc', 'src/core/lib/gprpp/status_helper.cc', 'src/core/lib/gprpp/time.cc', 'src/core/lib/gprpp/time_averaged_stats.cc', @@ -1269,6 +1269,7 @@ 'src/core/lib/event_engine/windows/windows_engine.cc', 'src/core/lib/experiments/config.cc', 'src/core/lib/experiments/experiments.cc', + 'src/core/lib/gpr/murmur_hash.cc', 'src/core/lib/gprpp/status_helper.cc', 'src/core/lib/gprpp/time.cc', 'src/core/lib/gprpp/time_averaged_stats.cc', diff --git a/src/core/lib/gpr/log_internal.h b/src/core/lib/gpr/log_internal.h new file mode 100644 index 00000000000..deec1518644 --- /dev/null +++ b/src/core/lib/gpr/log_internal.h @@ -0,0 +1,55 @@ +// Copyright 2022 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef GRPC_CORE_LIB_GPR_LOG_INTERNAL_H +#define GRPC_CORE_LIB_GPR_LOG_INTERNAL_H + +#include + +#include +#include + +#include + +/** abort() the process if x is zero, with rudimentary logging to prevent + circular dependencies with gpr_log. + + Intended for internal invariants. If the error can be recovered from, + without the possibility of corruption, or might best be reflected via + an exception in a higher-level language, consider returning error code. */ +#define GPR_ASSERT_INTERNAL(x) \ + do { \ + if (GPR_UNLIKELY(!(x))) { \ + fprintf(stderr, "assertion failed: %s", #x); \ + abort(); \ + } \ + } while (0) + +#ifndef NDEBUG +#define GPR_DEBUG_ASSERT_INTERNAL(x) GPR_ASSERT_INTERNAL(x) +#else +#define GPR_DEBUG_ASSERT_INTERNAL(x) +#endif + +#define GPR_LOG_ERROR_INTERNAL(format, ...) \ + do { \ + char f[] = __FILE__; \ + char* display_file = f; \ + char* slash_pos = strrchr(f, '/'); \ + if (slash_pos != nullptr) display_file = slash_pos + 1; \ + char prefix[60]; \ + sprintf(prefix, "INTERNAL %37s:%d]", display_file, __LINE__); \ + fprintf(stderr, "%-60s " format "\n", prefix, __VA_ARGS__); \ + } while (0) + +#endif // GRPC_CORE_LIB_GPR_LOG_INTERNAL_H diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD index 237a5d7d8e1..74b1465ccde 100644 --- a/test/core/end2end/BUILD +++ b/test/core/end2end/BUILD @@ -114,6 +114,7 @@ grpc_cc_test( deps = [ "cq_verifier", "//:gpr", + "//:gpr_atm", "//:grpc", "//:grpc_codegen", "//:grpc_public_hdrs", diff --git a/test/core/util/BUILD b/test/core/util/BUILD index b3617694dfa..6b3d3be65f6 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -127,6 +127,7 @@ grpc_cc_library( "//:channel_args_preconditioning", "//:config", "//:gpr", + "//:gpr_atm", "//:grpc", "//:grpc_public_hdrs", "//:grpc_security_base", @@ -165,6 +166,7 @@ grpc_cc_library( "//:channel_args_preconditioning", "//:config", "//:gpr", + "//:gpr_atm", "//:grpc_security_base", "//:grpc_sockaddr", "//:grpc_unsecure",