• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #include <grpc/support/port_platform.h>
20 
21 #ifndef GRPC_CORE_LIB_IOMGR_PORT_H
22 #define GRPC_CORE_LIB_IOMGR_PORT_H
23 
24 #ifdef GRPC_UV
25 #ifndef GRPC_CUSTOM_SOCKET
26 #define GRPC_CUSTOM_SOCKET
27 #endif
28 #endif
29 #if defined(GRPC_CUSTOM_SOCKET)
30 // Do Nothing
31 #elif defined(GPR_MANYLINUX1)
32 #define GRPC_HAVE_ARPA_NAMESER 1
33 #define GRPC_HAVE_IFADDRS 1
34 #define GRPC_HAVE_IPV6_RECVPKTINFO 1
35 #define GRPC_HAVE_IP_PKTINFO 1
36 #define GRPC_HAVE_MSG_NOSIGNAL 1
37 #define GRPC_HAVE_UNIX_SOCKET 1
38 #define GRPC_POSIX_FORK 1
39 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
40 #define GRPC_POSIX_SOCKET 1
41 #define GRPC_POSIX_SOCKETUTILS 1
42 #define GRPC_POSIX_WAKEUP_FD 1
43 #define GRPC_LINUX_EPOLL 1
44 #elif defined(GPR_WINDOWS)
45 #define GRPC_WINSOCK_SOCKET 1
46 #define GRPC_WINDOWS_SOCKETUTILS 1
47 #elif defined(GPR_ANDROID)
48 #define GRPC_HAVE_IPV6_RECVPKTINFO 1
49 #define GRPC_HAVE_IP_PKTINFO 1
50 #define GRPC_HAVE_MSG_NOSIGNAL 1
51 #define GRPC_HAVE_UNIX_SOCKET 1
52 #ifdef LINUX_VERSION_CODE
53 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
54 #define GRPC_HAVE_LINUX_VSOCK
55 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) */
56 #endif /* LINUX_VERSION_CODE */
57 #define GRPC_LINUX_EVENTFD 1
58 #define GRPC_POSIX_SOCKET 1
59 #define GRPC_POSIX_SOCKETUTILS 1
60 #define GRPC_POSIX_WAKEUP_FD 1
61 #elif defined(GPR_LINUX)
62 #define GRPC_HAVE_ARPA_NAMESER 1
63 #define GRPC_HAVE_IFADDRS 1
64 #define GRPC_HAVE_IPV6_RECVPKTINFO 1
65 #define GRPC_HAVE_IP_PKTINFO 1
66 #define GRPC_HAVE_MSG_NOSIGNAL 1
67 #define GRPC_HAVE_UNIX_SOCKET 1
68 #ifdef LINUX_VERSION_CODE
69 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)
70 #define GRPC_LINUX_ERRQUEUE 1
71 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) */
72 #endif /* LINUX_VERSION_CODE */
73 #ifdef LINUX_VERSION_CODE
74 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
75 #define GRPC_HAVE_LINUX_VSOCK
76 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) */
77 #endif /* LINUX_VERSION_CODE */
78 #define GRPC_LINUX_MULTIPOLL_WITH_EPOLL 1
79 #define GRPC_POSIX_FORK 1
80 #define GRPC_POSIX_HOST_NAME_MAX 1
81 #define GRPC_POSIX_SOCKET 1
82 #define GRPC_POSIX_WAKEUP_FD 1
83 #ifdef __GLIBC_PREREQ
84 #if __GLIBC_PREREQ(2, 4)
85 #define GRPC_LINUX_EPOLL 1
86 #endif
87 #if __GLIBC_PREREQ(2, 9)
88 #define GRPC_LINUX_EPOLL_CREATE1 1
89 #define GRPC_LINUX_EVENTFD 1
90 #endif
91 #if __GLIBC_PREREQ(2, 10)
92 #define GRPC_LINUX_SOCKETUTILS 1
93 #endif
94 #endif
95 #ifdef LINUX_VERSION_CODE
96 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
97 #define GRPC_HAVE_TCP_USER_TIMEOUT
98 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) */
99 #endif /* LINUX_VERSION_CODE */
100 #ifndef __GLIBC__
101 #define GRPC_LINUX_EPOLL 1
102 #define GRPC_LINUX_EPOLL_CREATE1 1
103 #define GRPC_LINUX_EVENTFD 1
104 #define GRPC_MSG_IOVLEN_TYPE int
105 #endif
106 #ifndef GRPC_LINUX_EVENTFD
107 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
108 #endif
109 #ifndef GRPC_LINUX_SOCKETUTILS
110 #define GRPC_POSIX_SOCKETUTILS
111 #endif
112 #elif defined(GPR_APPLE)
113 #define GRPC_HAVE_ARPA_NAMESER 1
114 #define GRPC_HAVE_IFADDRS 1
115 #define GRPC_HAVE_SO_NOSIGPIPE 1
116 #define GRPC_HAVE_UNIX_SOCKET 1
117 #define GRPC_MSG_IOVLEN_TYPE int
118 #define GRPC_POSIX_FORK 1
119 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
120 #ifdef GRPC_CFSTREAM
121 #define GRPC_CFSTREAM_IOMGR 1
122 #define GRPC_CFSTREAM_CLIENT 1
123 #define GRPC_CFSTREAM_ENDPOINT 1
124 #define GRPC_POSIX_SOCKET_ARES_EV_DRIVER 1
125 #define GRPC_POSIX_SOCKET_EV 1
126 #define GRPC_POSIX_SOCKET_EV_EPOLL1 1
127 #define GRPC_POSIX_SOCKET_EV_EPOLLEX 1
128 #define GRPC_POSIX_SOCKET_EV_EPOLLSIG 1
129 #define GRPC_POSIX_SOCKET_EV_POLL 1
130 #define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1
131 #define GRPC_POSIX_SOCKET_SOCKADDR 1
132 #define GRPC_POSIX_SOCKET_SOCKET_FACTORY 1
133 #define GRPC_POSIX_SOCKET_TCP 1
134 #define GRPC_POSIX_SOCKET_TCP_CLIENT 1
135 #define GRPC_POSIX_SOCKET_TCP_SERVER 1
136 #define GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON 1
137 #define GRPC_POSIX_SOCKET_UTILS_COMMON 1
138 #else
139 #define GRPC_POSIX_SOCKET 1
140 #endif
141 #define GRPC_POSIX_SOCKETUTILS 1
142 #define GRPC_POSIX_SYSCONF 1
143 #define GRPC_POSIX_WAKEUP_FD 1
144 #elif defined(GPR_FREEBSD)
145 #define GRPC_HAVE_ARPA_NAMESER 1
146 #define GRPC_HAVE_IFADDRS 1
147 #define GRPC_HAVE_IPV6_RECVPKTINFO 1
148 #define GRPC_HAVE_SO_NOSIGPIPE 1
149 #define GRPC_HAVE_UNIX_SOCKET 1
150 #define GRPC_POSIX_FORK 1
151 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
152 #define GRPC_POSIX_SOCKET 1
153 #define GRPC_POSIX_SOCKETUTILS 1
154 #define GRPC_POSIX_WAKEUP_FD 1
155 #elif defined(GPR_OPENBSD)
156 #define GRPC_HAVE_IFADDRS 1
157 #define GRPC_HAVE_IPV6_RECVPKTINFO 1
158 #define GRPC_HAVE_UNIX_SOCKET 1
159 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
160 #define GRPC_POSIX_SOCKET 1
161 #define GRPC_POSIX_SOCKETUTILS 1
162 #define GRPC_POSIX_WAKEUP_FD 1
163 #elif defined(GPR_SOLARIS)
164 #define GRPC_HAVE_UNIX_SOCKET 1
165 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
166 #define GRPC_POSIX_SOCKET 1
167 #define GRPC_POSIX_SOCKETUTILS 1
168 #define GRPC_POSIX_WAKEUP_FD 1
169 #elif defined(GPR_AIX)
170 #define GRPC_HAVE_UNIX_SOCKET 1
171 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
172 #define GRPC_POSIX_SOCKET 1
173 #define GRPC_POSIX_SOCKETUTILS 1
174 #define GRPC_POSIX_WAKEUP_FD 1
175 #elif defined(GPR_NACL)
176 #define GRPC_HAVE_ARPA_NAMESER 1
177 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1
178 #define GRPC_POSIX_SOCKET 1
179 #define GRPC_POSIX_SOCKETUTILS 1
180 #define GRPC_POSIX_WAKEUP_FD 1
181 #elif !defined(GPR_NO_AUTODETECT_PLATFORM)
182 #error "Platform not recognized"
183 #endif
184 
185 #if defined(GRPC_POSIX_SOCKET) + defined(GRPC_WINSOCK_SOCKET) + \
186         defined(GRPC_CUSTOM_SOCKET) + defined(GRPC_CFSTREAM) != \
187     1
188 #error \
189     "Must define exactly one of GRPC_POSIX_SOCKET, GRPC_WINSOCK_SOCKET, GRPC_CUSTOM_SOCKET"
190 #endif
191 
192 #ifdef GRPC_POSIX_SOCKET
193 #define GRPC_POSIX_SOCKET_ARES_EV_DRIVER 1
194 #define GRPC_POSIX_SOCKET_EV 1
195 #define GRPC_POSIX_SOCKET_EV_EPOLLEX 1
196 #define GRPC_POSIX_SOCKET_EV_EPOLLSIG 1
197 #define GRPC_POSIX_SOCKET_EV_POLL 1
198 #define GRPC_POSIX_SOCKET_EV_EPOLL1 1
199 #define GRPC_POSIX_SOCKET_IOMGR 1
200 #define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1
201 #define GRPC_POSIX_SOCKET_SOCKADDR 1
202 #define GRPC_POSIX_SOCKET_SOCKET_FACTORY 1
203 #define GRPC_POSIX_SOCKET_TCP 1
204 #define GRPC_POSIX_SOCKET_TCP_CLIENT 1
205 #define GRPC_POSIX_SOCKET_TCP_SERVER 1
206 #define GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON 1
207 #define GRPC_POSIX_SOCKET_UTILS_COMMON 1
208 #endif
209 
210 #if defined(GRPC_POSIX_HOST_NAME_MAX) && defined(GRPC_POSIX_SYSCONF)
211 #error "Cannot define both GRPC_POSIX_HOST_NAME_MAX and GRPC_POSIX_SYSCONF"
212 #endif
213 #if !defined(GRPC_POSIX_HOST_NAME_MAX) && !defined(GRPC_POSIX_SYSCONF)
214 #define GRPC_GETHOSTNAME_FALLBACK 1
215 #endif
216 
217 #endif /* GRPC_CORE_LIB_IOMGR_PORT_H */
218