diff --git a/BUILD b/BUILD index 5dcf3b282f6..9dc049fd288 100644 --- a/BUILD +++ b/BUILD @@ -98,6 +98,7 @@ GPR_PUBLIC_HDRS = [ "include/grpc/support/port_platform.h", "include/grpc/support/string_util.h", "include/grpc/support/sync.h", + "include/grpc/support/sync_abseil.h", "include/grpc/support/sync_custom.h", "include/grpc/support/sync_generic.h", "include/grpc/support/sync_posix.h", @@ -509,6 +510,7 @@ grpc_cc_library( "src/core/lib/gpr/string_util_windows.cc", "src/core/lib/gpr/string_windows.cc", "src/core/lib/gpr/sync.cc", + "src/core/lib/gpr/sync_abseil.cc", "src/core/lib/gpr/sync_posix.cc", "src/core/lib/gpr/sync_windows.cc", "src/core/lib/gpr/time.cc", @@ -587,6 +589,7 @@ grpc_cc_library( "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/sync.h", + "include/grpc/impl/codegen/sync_abseil.h", "include/grpc/impl/codegen/sync_custom.h", "include/grpc/impl/codegen/sync_generic.h", "include/grpc/impl/codegen/sync_posix.h", diff --git a/BUILD.gn b/BUILD.gn index d0a9b061737..8dc1e1f1590 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -66,6 +66,7 @@ config("grpc_config") { "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/sync.h", + "include/grpc/impl/codegen/sync_abseil.h", "include/grpc/impl/codegen/sync_custom.h", "include/grpc/impl/codegen/sync_generic.h", "include/grpc/impl/codegen/sync_posix.h", @@ -81,6 +82,7 @@ config("grpc_config") { "include/grpc/support/port_platform.h", "include/grpc/support/string_util.h", "include/grpc/support/sync.h", + "include/grpc/support/sync_abseil.h", "include/grpc/support/sync_custom.h", "include/grpc/support/sync_generic.h", "include/grpc/support/sync_posix.h", @@ -114,6 +116,7 @@ config("grpc_config") { "src/core/lib/gpr/string_windows.cc", "src/core/lib/gpr/string_windows.h", "src/core/lib/gpr/sync.cc", + "src/core/lib/gpr/sync_abseil.cc", "src/core/lib/gpr/sync_posix.cc", "src/core/lib/gpr/sync_windows.cc", "src/core/lib/gpr/time.cc", @@ -199,6 +202,7 @@ config("grpc_config") { "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/status.h", "include/grpc/impl/codegen/sync.h", + "include/grpc/impl/codegen/sync_abseil.h", "include/grpc/impl/codegen/sync_custom.h", "include/grpc/impl/codegen/sync_generic.h", "include/grpc/impl/codegen/sync_posix.h", @@ -1051,6 +1055,7 @@ config("grpc_config") { "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/status.h", "include/grpc/impl/codegen/sync.h", + "include/grpc/impl/codegen/sync_abseil.h", "include/grpc/impl/codegen/sync_custom.h", "include/grpc/impl/codegen/sync_generic.h", "include/grpc/impl/codegen/sync_posix.h", @@ -1070,6 +1075,7 @@ config("grpc_config") { "include/grpc/support/port_platform.h", "include/grpc/support/string_util.h", "include/grpc/support/sync.h", + "include/grpc/support/sync_abseil.h", "include/grpc/support/sync_custom.h", "include/grpc/support/sync_generic.h", "include/grpc/support/sync_posix.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e93bf193f8..f9a15dd8289 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1286,6 +1286,7 @@ foreach(_hdr include/grpc/support/port_platform.h include/grpc/support/string_util.h include/grpc/support/sync.h + include/grpc/support/sync_abseil.h include/grpc/support/sync_custom.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h @@ -1302,6 +1303,7 @@ foreach(_hdr include/grpc/impl/codegen/log.h include/grpc/impl/codegen/port_platform.h include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_abseil.h include/grpc/impl/codegen/sync_custom.h include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_posix.h @@ -1384,6 +1386,7 @@ add_library(gpr src/core/lib/gpr/string_util_windows.cc src/core/lib/gpr/string_windows.cc src/core/lib/gpr/sync.cc + src/core/lib/gpr/sync_abseil.cc src/core/lib/gpr/sync_posix.cc src/core/lib/gpr/sync_windows.cc src/core/lib/gpr/time.cc @@ -1458,6 +1461,7 @@ foreach(_hdr include/grpc/support/port_platform.h include/grpc/support/string_util.h include/grpc/support/sync.h + include/grpc/support/sync_abseil.h include/grpc/support/sync_custom.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h @@ -1474,6 +1478,7 @@ foreach(_hdr include/grpc/impl/codegen/log.h include/grpc/impl/codegen/port_platform.h include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_abseil.h include/grpc/impl/codegen/sync_custom.h include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_posix.h @@ -1942,6 +1947,7 @@ foreach(_hdr include/grpc/impl/codegen/log.h include/grpc/impl/codegen/port_platform.h include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_abseil.h include/grpc/impl/codegen/sync_custom.h include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_posix.h @@ -2352,6 +2358,7 @@ foreach(_hdr include/grpc/impl/codegen/log.h include/grpc/impl/codegen/port_platform.h include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_abseil.h include/grpc/impl/codegen/sync_custom.h include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_posix.h @@ -2686,6 +2693,7 @@ foreach(_hdr include/grpc/support/port_platform.h include/grpc/support/string_util.h include/grpc/support/sync.h + include/grpc/support/sync_abseil.h include/grpc/support/sync_custom.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h @@ -2702,6 +2710,7 @@ foreach(_hdr include/grpc/impl/codegen/log.h include/grpc/impl/codegen/port_platform.h include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_abseil.h include/grpc/impl/codegen/sync_custom.h include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_posix.h @@ -3028,6 +3037,7 @@ foreach(_hdr include/grpc/support/port_platform.h include/grpc/support/string_util.h include/grpc/support/sync.h + include/grpc/support/sync_abseil.h include/grpc/support/sync_custom.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h @@ -3044,6 +3054,7 @@ foreach(_hdr include/grpc/impl/codegen/log.h include/grpc/impl/codegen/port_platform.h include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_abseil.h include/grpc/impl/codegen/sync_custom.h include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_posix.h @@ -3436,6 +3447,7 @@ foreach(_hdr include/grpc/impl/codegen/log.h include/grpc/impl/codegen/port_platform.h include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_abseil.h include/grpc/impl/codegen/sync_custom.h include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_posix.h @@ -3886,6 +3898,7 @@ foreach(_hdr include/grpc/support/port_platform.h include/grpc/support/string_util.h include/grpc/support/sync.h + include/grpc/support/sync_abseil.h include/grpc/support/sync_custom.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h @@ -3902,6 +3915,7 @@ foreach(_hdr include/grpc/impl/codegen/log.h include/grpc/impl/codegen/port_platform.h include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_abseil.h include/grpc/impl/codegen/sync_custom.h include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_posix.h @@ -4585,6 +4599,7 @@ foreach(_hdr include/grpc/impl/codegen/log.h include/grpc/impl/codegen/port_platform.h include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_abseil.h include/grpc/impl/codegen/sync_custom.h include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_posix.h @@ -4782,6 +4797,7 @@ foreach(_hdr include/grpc/impl/codegen/log.h include/grpc/impl/codegen/port_platform.h include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_abseil.h include/grpc/impl/codegen/sync_custom.h include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_posix.h @@ -5018,6 +5034,7 @@ foreach(_hdr include/grpc/support/port_platform.h include/grpc/support/string_util.h include/grpc/support/sync.h + include/grpc/support/sync_abseil.h include/grpc/support/sync_custom.h include/grpc/support/sync_generic.h include/grpc/support/sync_posix.h @@ -5034,6 +5051,7 @@ foreach(_hdr include/grpc/impl/codegen/log.h include/grpc/impl/codegen/port_platform.h include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_abseil.h include/grpc/impl/codegen/sync_custom.h include/grpc/impl/codegen/sync_generic.h include/grpc/impl/codegen/sync_posix.h diff --git a/Makefile b/Makefile index c50372f1552..30384b57a98 100644 --- a/Makefile +++ b/Makefile @@ -3759,6 +3759,7 @@ PUBLIC_HEADERS_C += \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ include/grpc/support/sync.h \ + include/grpc/support/sync_abseil.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ include/grpc/support/sync_posix.h \ @@ -3775,6 +3776,7 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -3882,6 +3884,7 @@ LIBGPR_SRC = \ src/core/lib/gpr/string_util_windows.cc \ src/core/lib/gpr/string_windows.cc \ src/core/lib/gpr/sync.cc \ + src/core/lib/gpr/sync_abseil.cc \ src/core/lib/gpr/sync_posix.cc \ src/core/lib/gpr/sync_windows.cc \ src/core/lib/gpr/time.cc \ @@ -3915,6 +3918,7 @@ PUBLIC_HEADERS_C += \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ include/grpc/support/sync.h \ + include/grpc/support/sync_abseil.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ include/grpc/support/sync_posix.h \ @@ -3931,6 +3935,7 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -4376,6 +4381,7 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -4778,6 +4784,7 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -5108,6 +5115,7 @@ PUBLIC_HEADERS_C += \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ include/grpc/support/sync.h \ + include/grpc/support/sync_abseil.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ include/grpc/support/sync_posix.h \ @@ -5124,6 +5132,7 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -5436,6 +5445,7 @@ PUBLIC_HEADERS_C += \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ include/grpc/support/sync.h \ + include/grpc/support/sync_abseil.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ include/grpc/support/sync_posix.h \ @@ -5452,6 +5462,7 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -5813,6 +5824,7 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -6230,6 +6242,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ include/grpc/support/sync.h \ + include/grpc/support/sync_abseil.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ include/grpc/support/sync_posix.h \ @@ -6246,6 +6259,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -6919,6 +6933,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -7099,6 +7114,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -7337,6 +7353,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ include/grpc/support/sync.h \ + include/grpc/support/sync_abseil.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ include/grpc/support/sync_posix.h \ @@ -7353,6 +7370,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ diff --git a/build.yaml b/build.yaml index 948f87a5c59..4a6de9e6ada 100644 --- a/build.yaml +++ b/build.yaml @@ -248,6 +248,7 @@ filegroups: - src/core/lib/gpr/string_util_windows.cc - src/core/lib/gpr/string_windows.cc - src/core/lib/gpr/sync.cc + - src/core/lib/gpr/sync_abseil.cc - src/core/lib/gpr/sync_posix.cc - src/core/lib/gpr/sync_windows.cc - src/core/lib/gpr/time.cc @@ -287,6 +288,7 @@ filegroups: - include/grpc/support/port_platform.h - include/grpc/support/string_util.h - include/grpc/support/sync.h + - include/grpc/support/sync_abseil.h - include/grpc/support/sync_custom.h - include/grpc/support/sync_generic.h - include/grpc/support/sync_posix.h @@ -337,6 +339,7 @@ filegroups: - include/grpc/impl/codegen/log.h - include/grpc/impl/codegen/port_platform.h - include/grpc/impl/codegen/sync.h + - include/grpc/impl/codegen/sync_abseil.h - include/grpc/impl/codegen/sync_custom.h - include/grpc/impl/codegen/sync_generic.h - include/grpc/impl/codegen/sync_posix.h diff --git a/config.m4 b/config.m4 index 4e4f6e8d675..8278e2500fa 100644 --- a/config.m4 +++ b/config.m4 @@ -230,6 +230,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/string_util_windows.cc \ src/core/lib/gpr/string_windows.cc \ src/core/lib/gpr/sync.cc \ + src/core/lib/gpr/sync_abseil.cc \ src/core/lib/gpr/sync_posix.cc \ src/core/lib/gpr/sync_windows.cc \ src/core/lib/gpr/time.cc \ diff --git a/config.w32 b/config.w32 index f2b8433232c..bbd6318b8ee 100644 --- a/config.w32 +++ b/config.w32 @@ -199,6 +199,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\string_util_windows.cc " + "src\\core\\lib\\gpr\\string_windows.cc " + "src\\core\\lib\\gpr\\sync.cc " + + "src\\core\\lib\\gpr\\sync_abseil.cc " + "src\\core\\lib\\gpr\\sync_posix.cc " + "src\\core\\lib\\gpr\\sync_windows.cc " + "src\\core\\lib\\gpr\\time.cc " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 2bab109f71d..6fdda1cb52e 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -139,6 +139,7 @@ Pod::Spec.new do |s| 'include/grpc/impl/codegen/slice.h', 'include/grpc/impl/codegen/status.h', 'include/grpc/impl/codegen/sync.h', + 'include/grpc/impl/codegen/sync_abseil.h', 'include/grpc/impl/codegen/sync_custom.h', 'include/grpc/impl/codegen/sync_generic.h', 'include/grpc/impl/codegen/sync_posix.h', @@ -158,6 +159,7 @@ Pod::Spec.new do |s| 'include/grpc/support/port_platform.h', 'include/grpc/support/string_util.h', 'include/grpc/support/sync.h', + 'include/grpc/support/sync_abseil.h', 'include/grpc/support/sync_custom.h', 'include/grpc/support/sync_generic.h', 'include/grpc/support/sync_posix.h', @@ -531,6 +533,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/string_windows.cc', 'src/core/lib/gpr/string_windows.h', 'src/core/lib/gpr/sync.cc', + 'src/core/lib/gpr/sync_abseil.cc', 'src/core/lib/gpr/sync_posix.cc', 'src/core/lib/gpr/sync_windows.cc', 'src/core/lib/gpr/time.cc', diff --git a/grpc.gemspec b/grpc.gemspec index 49b9a684f8e..3cd9dcb4b58 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -73,6 +73,7 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/codegen/slice.h ) s.files += %w( include/grpc/impl/codegen/status.h ) s.files += %w( include/grpc/impl/codegen/sync.h ) + s.files += %w( include/grpc/impl/codegen/sync_abseil.h ) s.files += %w( include/grpc/impl/codegen/sync_custom.h ) s.files += %w( include/grpc/impl/codegen/sync_generic.h ) s.files += %w( include/grpc/impl/codegen/sync_posix.h ) @@ -92,6 +93,7 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/support/port_platform.h ) s.files += %w( include/grpc/support/string_util.h ) s.files += %w( include/grpc/support/sync.h ) + s.files += %w( include/grpc/support/sync_abseil.h ) s.files += %w( include/grpc/support/sync_custom.h ) s.files += %w( include/grpc/support/sync_generic.h ) s.files += %w( include/grpc/support/sync_posix.h ) @@ -453,6 +455,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/string_windows.cc ) s.files += %w( src/core/lib/gpr/string_windows.h ) s.files += %w( src/core/lib/gpr/sync.cc ) + s.files += %w( src/core/lib/gpr/sync_abseil.cc ) s.files += %w( src/core/lib/gpr/sync_posix.cc ) s.files += %w( src/core/lib/gpr/sync_windows.cc ) s.files += %w( src/core/lib/gpr/time.cc ) diff --git a/grpc.gyp b/grpc.gyp index 7067a8f7c7b..3f3fd1fd814 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -466,6 +466,7 @@ 'src/core/lib/gpr/string_util_windows.cc', 'src/core/lib/gpr/string_windows.cc', 'src/core/lib/gpr/sync.cc', + 'src/core/lib/gpr/sync_abseil.cc', 'src/core/lib/gpr/sync_posix.cc', 'src/core/lib/gpr/sync_windows.cc', 'src/core/lib/gpr/time.cc', diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index 98b516b625d..cb3fb79f5ed 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -34,6 +34,13 @@ #define GRPC_USE_ABSL 1 #endif +/* + * Defines GPR_ABSEIL_SYNC to use synchronization features from Abseil + */ +#ifndef GPR_ABSEIL_SYNC +/* #define GPR_ABSEIL_SYNC 1 */ +#endif + /* Get windows.h included everywhere (we need it) */ #if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32) #ifndef WIN32_LEAN_AND_MEAN diff --git a/include/grpc/impl/codegen/sync.h b/include/grpc/impl/codegen/sync.h index 3df68c644f7..49e3194748f 100644 --- a/include/grpc/impl/codegen/sync.h +++ b/include/grpc/impl/codegen/sync.h @@ -46,12 +46,14 @@ extern "C" { #include -#if defined(GPR_POSIX_SYNC) +#if defined(GPR_CUSTOM_SYNC) +#include +#elif defined(GPR_ABSEIL_SYNC) +#include +#elif defined(GPR_POSIX_SYNC) #include #elif defined(GPR_WINDOWS) #include -#elif defined(GPR_CUSTOM_SYNC) -#include #else #error Unable to determine platform for sync #endif diff --git a/include/grpc/impl/codegen/sync_abseil.h b/include/grpc/impl/codegen/sync_abseil.h new file mode 100644 index 00000000000..38dfab32737 --- /dev/null +++ b/include/grpc/impl/codegen/sync_abseil.h @@ -0,0 +1,36 @@ +/* + * + * Copyright 2020 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_IMPL_CODEGEN_SYNC_ABSEIL_H +#define GRPC_IMPL_CODEGEN_SYNC_ABSEIL_H + +#include + +#include + +#ifdef GPR_ABSEIL_SYNC + +typedef intptr_t gpr_mu; +typedef intptr_t gpr_cv; +typedef int32_t gpr_once; + +#define GPR_ONCE_INIT 0 + +#endif + +#endif /* GRPC_IMPL_CODEGEN_SYNC_ABSEIL_H */ diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index 9612a05bf5b..5e3b97e1b86 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -10,6 +10,7 @@ framework module grpc { header "support/port_platform.h" header "support/string_util.h" header "support/sync.h" + header "support/sync_abseil.h" header "support/sync_generic.h" header "support/thd_id.h" header "support/time.h" @@ -20,6 +21,7 @@ framework module grpc { header "impl/codegen/log.h" header "impl/codegen/port_platform.h" header "impl/codegen/sync.h" + header "impl/codegen/sync_abseil.h" header "impl/codegen/sync_generic.h" header "impl/codegen/byte_buffer.h" header "impl/codegen/byte_buffer_reader.h" @@ -36,6 +38,7 @@ framework module grpc { header "impl/codegen/log.h" header "impl/codegen/port_platform.h" header "impl/codegen/sync.h" + header "impl/codegen/sync_abseil.h" header "impl/codegen/sync_generic.h" header "grpc_security.h" header "byte_buffer.h" diff --git a/include/grpc/support/sync_abseil.h b/include/grpc/support/sync_abseil.h new file mode 100644 index 00000000000..3ee73489786 --- /dev/null +++ b/include/grpc/support/sync_abseil.h @@ -0,0 +1,26 @@ +/* + * + * Copyright 2020 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_SUPPORT_SYNC_ABSEIL_H +#define GRPC_SUPPORT_SYNC_ABSEIL_H + +#include + +#include + +#endif /* GRPC_SUPPORT_SYNC_ABSEIL_H */ diff --git a/package.xml b/package.xml index 07e5a75383f..cd9e718c6a2 100644 --- a/package.xml +++ b/package.xml @@ -56,6 +56,7 @@ + @@ -75,6 +76,7 @@ + @@ -436,6 +438,7 @@ + diff --git a/src/core/lib/gpr/sync_abseil.cc b/src/core/lib/gpr/sync_abseil.cc new file mode 100644 index 00000000000..2a1ca05d9a0 --- /dev/null +++ b/src/core/lib/gpr/sync_abseil.cc @@ -0,0 +1,114 @@ +/* + * + * Copyright 2020 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. + * + */ + +#include + +#if defined(GPR_ABSEIL_SYNC) && !defined(GPR_CUSTOM_SYNC) + +#include + +#include +#include +#include +#include +#include +#include "src/core/lib/profiling/timers.h" + +#include "absl/base/call_once.h" +#include "absl/synchronization/mutex.h" +#include "absl/time/clock.h" +#include "absl/time/time.h" + +#ifdef GPR_LOW_LEVEL_COUNTERS +gpr_atm gpr_mu_locks = 0; +gpr_atm gpr_counter_atm_cas = 0; +gpr_atm gpr_counter_atm_add = 0; +#endif + +void gpr_mu_init(gpr_mu* mu) { + static_assert(sizeof(gpr_mu) == sizeof(absl::Mutex), + "gpr_mu and Mutex must be the same size"); + new (mu) absl::Mutex; +} + +void gpr_mu_destroy(gpr_mu* mu) { + reinterpret_cast(mu)->~Mutex(); +} + +void gpr_mu_lock(gpr_mu* mu) ABSL_NO_THREAD_SAFETY_ANALYSIS { + GPR_TIMER_SCOPE("gpr_mu_lock", 0); + reinterpret_cast(mu)->Lock(); +} + +void gpr_mu_unlock(gpr_mu* mu) ABSL_NO_THREAD_SAFETY_ANALYSIS { + GPR_TIMER_SCOPE("gpr_mu_unlock", 0); + reinterpret_cast(mu)->Unlock(); +} + +int gpr_mu_trylock(gpr_mu* mu) { + GPR_TIMER_SCOPE("gpr_mu_trylock", 0); + int ret = reinterpret_cast(mu)->TryLock() == true; + return ret; +} + +/*----------------------------------------*/ + +void gpr_cv_init(gpr_cv* cv) { + static_assert(sizeof(gpr_cv) == sizeof(absl::CondVar), + "gpr_cv and CondVar must be the same size"); + new (cv) absl::CondVar; +} + +void gpr_cv_destroy(gpr_cv* cv) { + reinterpret_cast(cv)->~CondVar(); +} + +int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) { + GPR_TIMER_SCOPE("gpr_cv_wait", 0); + if (gpr_time_cmp(abs_deadline, gpr_inf_future(abs_deadline.clock_type)) == + 0) { + reinterpret_cast(cv)->Wait( + reinterpret_cast(mu)); + return 0; + } + abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME); + timespec ts = {static_cast(abs_deadline.tv_sec), + static_cast(abs_deadline.tv_nsec)}; + int ret = reinterpret_cast(cv)->WaitWithDeadline( + reinterpret_cast(mu), + absl::TimeFromTimespec(ts)) == true; + return ret; +} + +void gpr_cv_signal(gpr_cv* cv) { + GPR_TIMER_MARK("gpr_cv_signal", 0); + reinterpret_cast(cv)->Signal(); +} + +void gpr_cv_broadcast(gpr_cv* cv) { + GPR_TIMER_MARK("gpr_cv_broadcast", 0); + reinterpret_cast(cv)->SignalAll(); +} + +/*----------------------------------------*/ + +void gpr_once_init(gpr_once* once, void (*init_function)(void)) { + absl::call_once(*reinterpret_cast(once), init_function); +} + +#endif /* defined(GPR_ABSEIL_SYNC) && !defined(GPR_CUSTOM_SYNC) */ diff --git a/src/core/lib/gpr/sync_posix.cc b/src/core/lib/gpr/sync_posix.cc index fe2d5a9ca38..120bfda25c2 100644 --- a/src/core/lib/gpr/sync_posix.cc +++ b/src/core/lib/gpr/sync_posix.cc @@ -18,15 +18,17 @@ #include -#include - -#ifdef GPR_POSIX_SYNC +#if defined(GPR_POSIX_SYNC) && !defined(GPR_ABSEIL_SYNC) && \ + !defined(GPR_CUSTOM_SYNC) -#include +#include #include #include #include + +#include #include + #include "src/core/lib/profiling/timers.h" #ifdef GPR_LOW_LEVEL_COUNTERS @@ -170,4 +172,5 @@ void gpr_once_init(gpr_once* once, void (*init_function)(void)) { GPR_ASSERT(pthread_once(once, init_function) == 0); } -#endif /* GRP_POSIX_SYNC */ +#endif /* defined(GPR_POSIX_SYNC) && !defined(GPR_ABSEIL_SYNC) && \ + !defined(GPR_CUSTOM_SYNC) */ diff --git a/src/core/lib/gpr/sync_windows.cc b/src/core/lib/gpr/sync_windows.cc index 7cd41633d53..64eec7c2e11 100644 --- a/src/core/lib/gpr/sync_windows.cc +++ b/src/core/lib/gpr/sync_windows.cc @@ -20,7 +20,8 @@ #include -#ifdef GPR_WINDOWS +#if defined(GPR_WINDOWS) && !defined(GPR_ABSEIL_SYNC) && \ + !defined(GPR_CUSTOM_SYNC) #include #include @@ -115,4 +116,5 @@ void gpr_once_init(gpr_once* once, void (*init_function)(void)) { InitOnceExecuteOnce(once, run_once_func, &arg, &dummy); } -#endif /* GPR_WINDOWS */ +#endif /* defined(GPR_WINDOWS) && !defined(GPR_ABSEIL_SYNC) && \ + !defined(GPR_CUSTOM_SYNC) */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 580cc6761e3..f0c99ecc590 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -208,6 +208,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/string_util_windows.cc', 'src/core/lib/gpr/string_windows.cc', 'src/core/lib/gpr/sync.cc', + 'src/core/lib/gpr/sync_abseil.cc', 'src/core/lib/gpr/sync_posix.cc', 'src/core/lib/gpr/sync_windows.cc', 'src/core/lib/gpr/time.cc', diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index 3c20e55620e..b6ba715e247 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 2c857a10650..d3d4b096043 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -900,6 +900,7 @@ include/grpc/impl/codegen/propagation_bits.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/status.h \ include/grpc/impl/codegen/sync.h \ +include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -919,6 +920,7 @@ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ include/grpc/support/sync.h \ +include/grpc/support/sync_abseil.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ include/grpc/support/sync_posix.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 4408ada7f66..b72624b8cc2 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -901,6 +901,7 @@ include/grpc/impl/codegen/propagation_bits.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/status.h \ include/grpc/impl/codegen/sync.h \ +include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ include/grpc/impl/codegen/sync_posix.h \ @@ -920,6 +921,7 @@ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ include/grpc/support/sync.h \ +include/grpc/support/sync_abseil.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ include/grpc/support/sync_posix.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index df67542e6f2..54bac85317f 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -842,6 +842,8 @@ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/status.h \ include/grpc/impl/codegen/sync.h \ include/grpc/impl/codegen/sync.h \ +include/grpc/impl/codegen/sync_abseil.h \ +include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ @@ -865,6 +867,7 @@ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ include/grpc/support/sync.h \ +include/grpc/support/sync_abseil.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ include/grpc/support/sync_posix.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 87ba22e7336..1fe83249e55 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -842,6 +842,8 @@ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/status.h \ include/grpc/impl/codegen/sync.h \ include/grpc/impl/codegen/sync.h \ +include/grpc/impl/codegen/sync_abseil.h \ +include/grpc/impl/codegen/sync_abseil.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_custom.h \ include/grpc/impl/codegen/sync_generic.h \ @@ -865,6 +867,7 @@ include/grpc/support/log_windows.h \ include/grpc/support/port_platform.h \ include/grpc/support/string_util.h \ include/grpc/support/sync.h \ +include/grpc/support/sync_abseil.h \ include/grpc/support/sync_custom.h \ include/grpc/support/sync_generic.h \ include/grpc/support/sync_posix.h \ @@ -1242,6 +1245,7 @@ src/core/lib/gpr/string_util_windows.cc \ src/core/lib/gpr/string_windows.cc \ src/core/lib/gpr/string_windows.h \ src/core/lib/gpr/sync.cc \ +src/core/lib/gpr/sync_abseil.cc \ src/core/lib/gpr/sync_posix.cc \ src/core/lib/gpr/sync_windows.cc \ src/core/lib/gpr/time.cc \