From 03adef1d3cb6a796f9a910794dfbcea48f510ba8 Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Mon, 5 Apr 2021 21:03:04 -0700 Subject: [PATCH] Move platform-specific sockaddr logic out of port_platform for EventEngine (#25886) --- BUILD | 1 + BUILD.gn | 1 + CMakeLists.txt | 2 ++ Makefile | 2 ++ build_autogenerated.yaml | 2 ++ grpc.gemspec | 1 + include/grpc/event_engine/event_engine.h | 1 + include/grpc/event_engine/port.h | 39 +++++++++++++++++++++++ include/grpc/impl/codegen/port_platform.h | 20 ------------ package.xml | 1 + src/core/lib/event_engine/sockaddr.cc | 1 + tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 1 + tools/doxygen/Doxyfile.core | 1 + tools/doxygen/Doxyfile.core.internal | 1 + 15 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 include/grpc/event_engine/port.h diff --git a/BUILD b/BUILD index f218294e0a7..39296e23b45 100644 --- a/BUILD +++ b/BUILD @@ -131,6 +131,7 @@ GRPC_PUBLIC_HDRS = [ GRPC_PUBLIC_EVENT_ENGINE_HDRS = [ "include/grpc/event_engine/channel_args.h", "include/grpc/event_engine/event_engine.h", + "include/grpc/event_engine/port.h", "include/grpc/event_engine/slice_allocator.h", ] diff --git a/BUILD.gn b/BUILD.gn index e0db24d3b94..c52d61e9d80 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -201,6 +201,7 @@ config("grpc_config") { "include/grpc/compression.h", "include/grpc/event_engine/channel_args.h", "include/grpc/event_engine/event_engine.h", + "include/grpc/event_engine/port.h", "include/grpc/event_engine/slice_allocator.h", "include/grpc/fork.h", "include/grpc/grpc.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 83940c2c9cb..7b7087c1f1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2086,6 +2086,7 @@ foreach(_hdr include/grpc/compression.h include/grpc/event_engine/channel_args.h include/grpc/event_engine/event_engine.h + include/grpc/event_engine/port.h include/grpc/event_engine/slice_allocator.h include/grpc/fork.h include/grpc/grpc.h @@ -2638,6 +2639,7 @@ foreach(_hdr include/grpc/compression.h include/grpc/event_engine/channel_args.h include/grpc/event_engine/event_engine.h + include/grpc/event_engine/port.h include/grpc/event_engine/slice_allocator.h include/grpc/fork.h include/grpc/grpc.h diff --git a/Makefile b/Makefile index a6d1fd90b87..ba4cd11ad96 100644 --- a/Makefile +++ b/Makefile @@ -1599,6 +1599,7 @@ PUBLIC_HEADERS_C += \ include/grpc/compression.h \ include/grpc/event_engine/channel_args.h \ include/grpc/event_engine/event_engine.h \ + include/grpc/event_engine/port.h \ include/grpc/event_engine/slice_allocator.h \ include/grpc/fork.h \ include/grpc/grpc.h \ @@ -2001,6 +2002,7 @@ PUBLIC_HEADERS_C += \ include/grpc/compression.h \ include/grpc/event_engine/channel_args.h \ include/grpc/event_engine/event_engine.h \ + include/grpc/event_engine/port.h \ include/grpc/event_engine/slice_allocator.h \ include/grpc/fork.h \ include/grpc/grpc.h \ diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 542da7e2a1b..70934a131dd 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -370,6 +370,7 @@ libs: - include/grpc/compression.h - include/grpc/event_engine/channel_args.h - include/grpc/event_engine/event_engine.h + - include/grpc/event_engine/port.h - include/grpc/event_engine/slice_allocator.h - include/grpc/fork.h - include/grpc/grpc.h @@ -1582,6 +1583,7 @@ libs: - include/grpc/compression.h - include/grpc/event_engine/channel_args.h - include/grpc/event_engine/event_engine.h + - include/grpc/event_engine/port.h - include/grpc/event_engine/slice_allocator.h - include/grpc/fork.h - include/grpc/grpc.h diff --git a/grpc.gemspec b/grpc.gemspec index 745e2ae38f7..e982144feac 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -55,6 +55,7 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/compression.h ) s.files += %w( include/grpc/event_engine/channel_args.h ) s.files += %w( include/grpc/event_engine/event_engine.h ) + s.files += %w( include/grpc/event_engine/port.h ) s.files += %w( include/grpc/event_engine/slice_allocator.h ) s.files += %w( include/grpc/fork.h ) s.files += %w( include/grpc/grpc.h ) diff --git a/include/grpc/event_engine/event_engine.h b/include/grpc/event_engine/event_engine.h index 6053382a00b..9044e1b5ba1 100644 --- a/include/grpc/event_engine/event_engine.h +++ b/include/grpc/event_engine/event_engine.h @@ -24,6 +24,7 @@ #include "absl/time/time.h" #include "grpc/event_engine/channel_args.h" +#include "grpc/event_engine/port.h" #include "grpc/event_engine/slice_allocator.h" // TODO(hork): explicitly define lifetimes and ownership of all objects. diff --git a/include/grpc/event_engine/port.h b/include/grpc/event_engine/port.h new file mode 100644 index 00000000000..c24b8f90245 --- /dev/null +++ b/include/grpc/event_engine/port.h @@ -0,0 +1,39 @@ +// Copyright 2021 The 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_EVENT_ENGINE_PORT_H +#define GRPC_EVENT_ENGINE_PORT_H + +#include + +// Platform-specific sockaddr includes +#ifdef GRPC_UV +#include +#elif defined(GPR_ANDROID) || defined(GPR_LINUX) || defined(GPR_APPLE) || \ + defined(GPR_FREEBSD) || defined(GPR_OPENBSD) || defined(GPR_SOLARIS) || \ + defined(GPR_AIX) || defined(GPR_NACL) || defined(GPR_FUCHSIA) || \ + defined(GRPC_POSIX_SOCKET) +#define GRPC_EVENT_ENGINE_POSIX +#include +#include +#include +#elif defined(GPR_WINDOWS) +#include +#include +// must be included after the above +#include +#else +#error UNKNOWN PLATFORM +#endif + +#endif // GRPC_EVENT_ENGINE_PORT_H diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index 52865a5f8de..cd0310d88ca 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -659,24 +659,4 @@ typedef unsigned __int64 uint64_t; #define __STDC_FORMAT_MACROS #endif -// Platform-specific sockaddr includes -#ifdef GRPC_UV -#include -#elif defined(GPR_ANDROID) || defined(GPR_LINUX) || defined(GPR_APPLE) || \ - defined(GPR_FREEBSD) || defined(GPR_OPENBSD) || defined(GPR_SOLARIS) || \ - defined(GPR_AIX) || defined(GPR_NACL) || defined(GPR_FUCHSIA) || \ - defined(GRPC_POSIX_SOCKET) -#define GRPC_EVENT_ENGINE_POSIX -#include -#include -#include -#elif defined(GPR_WINDOWS) -#include -#include -// must be included after the above -#include -#else -#error UNKNOWN PLATFORM -#endif - #endif /* GRPC_IMPL_CODEGEN_PORT_PLATFORM_H */ diff --git a/package.xml b/package.xml index 3c3a89f9600..a1f6a18ceef 100644 --- a/package.xml +++ b/package.xml @@ -35,6 +35,7 @@ + diff --git a/src/core/lib/event_engine/sockaddr.cc b/src/core/lib/event_engine/sockaddr.cc index deb448f70d9..811d351936a 100644 --- a/src/core/lib/event_engine/sockaddr.cc +++ b/src/core/lib/event_engine/sockaddr.cc @@ -16,6 +16,7 @@ #include #include "grpc/event_engine/event_engine.h" +#include "grpc/event_engine/port.h" #include "grpc/support/log.h" namespace grpc_event_engine { diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 394747cd921..4bd36408504 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -883,6 +883,7 @@ include/grpc/census.h \ include/grpc/compression.h \ include/grpc/event_engine/channel_args.h \ include/grpc/event_engine/event_engine.h \ +include/grpc/event_engine/port.h \ include/grpc/event_engine/slice_allocator.h \ include/grpc/fork.h \ include/grpc/grpc.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 6d57609ac1b..005784f95bf 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -883,6 +883,7 @@ include/grpc/census.h \ include/grpc/compression.h \ include/grpc/event_engine/channel_args.h \ include/grpc/event_engine/event_engine.h \ +include/grpc/event_engine/port.h \ include/grpc/event_engine/slice_allocator.h \ include/grpc/fork.h \ include/grpc/grpc.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index 37d17dcaeea..1db9688b601 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -813,6 +813,7 @@ include/grpc/census.h \ include/grpc/compression.h \ include/grpc/event_engine/channel_args.h \ include/grpc/event_engine/event_engine.h \ +include/grpc/event_engine/port.h \ include/grpc/event_engine/slice_allocator.h \ include/grpc/fork.h \ include/grpc/grpc.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index eeb235daa62..bef690ca2a0 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -813,6 +813,7 @@ include/grpc/census.h \ include/grpc/compression.h \ include/grpc/event_engine/channel_args.h \ include/grpc/event_engine/event_engine.h \ +include/grpc/event_engine/port.h \ include/grpc/event_engine/slice_allocator.h \ include/grpc/fork.h \ include/grpc/grpc.h \