Skip to content

Commit

Permalink
Move platform-specific sockaddr logic out of port_platform for EventE…
Browse files Browse the repository at this point in the history
…ngine (grpc#25886)
  • Loading branch information
drfloob authored Apr 6, 2021
1 parent 9a2c2c0 commit 03adef1
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 20 deletions.
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 2 additions & 0 deletions build_autogenerated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions grpc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
1 change: 1 addition & 0 deletions include/grpc/event_engine/event_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
39 changes: 39 additions & 0 deletions include/grpc/event_engine/port.h
Original file line number Diff line number Diff line change
@@ -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 <grpc/support/port_platform.h>

// Platform-specific sockaddr includes
#ifdef GRPC_UV
#include <uv.h>
#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 <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#elif defined(GPR_WINDOWS)
#include <winsock2.h>
#include <ws2tcpip.h>
// must be included after the above
#include <mswsock.h>
#else
#error UNKNOWN PLATFORM
#endif

#endif // GRPC_EVENT_ENGINE_PORT_H
20 changes: 0 additions & 20 deletions include/grpc/impl/codegen/port_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,24 +659,4 @@ typedef unsigned __int64 uint64_t;
#define __STDC_FORMAT_MACROS
#endif

// Platform-specific sockaddr includes
#ifdef GRPC_UV
#include <uv.h>
#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 <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#elif defined(GPR_WINDOWS)
#include <winsock2.h>
#include <ws2tcpip.h>
// must be included after the above
#include <mswsock.h>
#else
#error UNKNOWN PLATFORM
#endif

#endif /* GRPC_IMPL_CODEGEN_PORT_PLATFORM_H */
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<file baseinstalldir="/" name="include/grpc/compression.h" role="src" />
<file baseinstalldir="/" name="include/grpc/event_engine/channel_args.h" role="src" />
<file baseinstalldir="/" name="include/grpc/event_engine/event_engine.h" role="src" />
<file baseinstalldir="/" name="include/grpc/event_engine/port.h" role="src" />
<file baseinstalldir="/" name="include/grpc/event_engine/slice_allocator.h" role="src" />
<file baseinstalldir="/" name="include/grpc/fork.h" role="src" />
<file baseinstalldir="/" name="include/grpc/grpc.h" role="src" />
Expand Down
1 change: 1 addition & 0 deletions src/core/lib/event_engine/sockaddr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <string.h>

#include "grpc/event_engine/event_engine.h"
#include "grpc/event_engine/port.h"
#include "grpc/support/log.h"

namespace grpc_event_engine {
Expand Down
1 change: 1 addition & 0 deletions tools/doxygen/Doxyfile.c++
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions tools/doxygen/Doxyfile.c++.internal
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions tools/doxygen/Doxyfile.core
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions tools/doxygen/Doxyfile.core.internal
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 03adef1

Please sign in to comment.