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 /* This needs to be separate from the other conditions because it needs to 30 * apply to custom sockets too */ 31 #ifdef GPR_WINDOWS 32 #define GRPC_ARES_RESOLVE_LOCALHOST_MANUALLY 1 33 #endif 34 #if defined(GRPC_CUSTOM_SOCKET) 35 // Do Nothing 36 #elif defined(GPR_WINDOWS) 37 #define GRPC_WINSOCK_SOCKET 1 38 #define GRPC_WINDOWS_SOCKETUTILS 1 39 #define GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER 1 40 #elif defined(GPR_ANDROID) 41 #define GRPC_HAVE_IPV6_RECVPKTINFO 1 42 #define GRPC_HAVE_IP_PKTINFO 1 43 #define GRPC_HAVE_MSG_NOSIGNAL 1 44 #define GRPC_HAVE_UNIX_SOCKET 1 45 #define GRPC_LINUX_EVENTFD 1 46 #define GRPC_POSIX_SOCKET 1 47 #define GRPC_POSIX_SOCKETUTILS 1 48 #define GRPC_POSIX_WAKEUP_FD 1 49 #elif defined(GPR_LINUX) 50 #define GRPC_HAVE_ARPA_NAMESER 1 51 #define GRPC_HAVE_IFADDRS 1 52 #define GRPC_HAVE_IPV6_RECVPKTINFO 1 53 #define GRPC_HAVE_IP_PKTINFO 1 54 #define GRPC_HAVE_MSG_NOSIGNAL 1 55 #define GRPC_HAVE_UNIX_SOCKET 1 56 /* Linux has TCP_INQ support since 4.18, but it is safe to set 57 the socket option on older kernels. */ 58 #define GRPC_HAVE_TCP_INQ 1 59 #ifdef LINUX_VERSION_CODE 60 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) 61 #define GRPC_LINUX_ERRQUEUE 1 62 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) */ 63 #endif /* LINUX_VERSION_CODE */ 64 #define GRPC_LINUX_MULTIPOLL_WITH_EPOLL 1 65 #define GRPC_POSIX_FORK 1 66 #define GRPC_POSIX_HOST_NAME_MAX 1 67 #define GRPC_POSIX_SOCKET 1 68 #define GRPC_POSIX_WAKEUP_FD 1 69 #ifdef __GLIBC_PREREQ 70 #if __GLIBC_PREREQ(2, 4) 71 #define GRPC_LINUX_EPOLL 1 72 #endif 73 #if __GLIBC_PREREQ(2, 9) 74 #define GRPC_LINUX_EPOLL_CREATE1 1 75 #define GRPC_LINUX_EVENTFD 1 76 #endif 77 #if __GLIBC_PREREQ(2, 10) 78 #define GRPC_LINUX_SOCKETUTILS 1 79 #endif 80 #if !(__GLIBC_PREREQ(2, 17)) 81 /* 82 * TCP_USER_TIMEOUT wasn't imported to glibc until 2.17. Use Linux system 83 * header instead. 84 */ 85 #define GRPC_LINUX_TCP_H 1 86 #endif /* __GLIBC_PREREQ(2, 17) */ 87 #endif 88 #ifndef __GLIBC__ 89 #define GRPC_LINUX_EPOLL 1 90 #define GRPC_LINUX_EPOLL_CREATE1 1 91 #define GRPC_LINUX_EVENTFD 1 92 #define GRPC_MSG_IOVLEN_TYPE int 93 #endif 94 #ifndef GRPC_LINUX_EVENTFD 95 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 96 #endif 97 #ifndef GRPC_LINUX_SOCKETUTILS 98 #define GRPC_POSIX_SOCKETUTILS 99 #endif 100 #elif defined(GPR_APPLE) 101 #define GRPC_HAVE_ARPA_NAMESER 1 102 #define GRPC_HAVE_IFADDRS 1 103 #define GRPC_HAVE_SO_NOSIGPIPE 1 104 #define GRPC_HAVE_UNIX_SOCKET 1 105 #define GRPC_MSG_IOVLEN_TYPE int 106 #define GRPC_POSIX_FORK 1 107 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 108 #ifdef GRPC_CFSTREAM 109 #define GRPC_CFSTREAM_IOMGR 1 110 #define GRPC_CFSTREAM_CLIENT 1 111 #define GRPC_CFSTREAM_ENDPOINT 1 112 #define GRPC_APPLE_EV 1 113 #define GRPC_POSIX_SOCKET_ARES_EV_DRIVER 1 114 #define GRPC_POSIX_SOCKET_EV 1 115 #define GRPC_POSIX_SOCKET_EV_EPOLL1 1 116 #define GRPC_POSIX_SOCKET_EV_EPOLLEX 1 117 #define GRPC_POSIX_SOCKET_EV_POLL 1 118 #define GRPC_POSIX_SOCKET_IF_NAMETOINDEX 1 119 #define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1 120 #define GRPC_POSIX_SOCKET_SOCKADDR 1 121 #define GRPC_POSIX_SOCKET_SOCKET_FACTORY 1 122 #define GRPC_POSIX_SOCKET_TCP 1 123 #define GRPC_POSIX_SOCKET_TCP_CLIENT 1 124 #define GRPC_POSIX_SOCKET_TCP_SERVER 1 125 #define GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON 1 126 #define GRPC_POSIX_SOCKET_UDP_SERVER 1 127 #define GRPC_POSIX_SOCKET_UTILS_COMMON 1 128 #else 129 #define GRPC_POSIX_SOCKET 1 130 #endif 131 #define GRPC_POSIX_SOCKETUTILS 1 132 #define GRPC_POSIX_SYSCONF 1 133 #define GRPC_POSIX_WAKEUP_FD 1 134 #elif defined(GPR_FREEBSD) 135 #define GRPC_HAVE_ARPA_NAMESER 1 136 #define GRPC_HAVE_IFADDRS 1 137 #define GRPC_HAVE_IPV6_RECVPKTINFO 1 138 #define GRPC_HAVE_SO_NOSIGPIPE 1 139 #define GRPC_HAVE_UNIX_SOCKET 1 140 #define GRPC_POSIX_FORK 1 141 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 142 #define GRPC_POSIX_SOCKET 1 143 #define GRPC_POSIX_SOCKETUTILS 1 144 #define GRPC_POSIX_WAKEUP_FD 1 145 #elif defined(GPR_OPENBSD) 146 #define GRPC_HAVE_IFADDRS 1 147 #define GRPC_HAVE_IPV6_RECVPKTINFO 1 148 #define GRPC_HAVE_UNIX_SOCKET 1 149 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 150 #define GRPC_POSIX_SOCKET 1 151 #define GRPC_POSIX_SOCKETUTILS 1 152 #define GRPC_POSIX_WAKEUP_FD 1 153 #elif defined(GPR_SOLARIS) 154 #define GRPC_HAVE_UNIX_SOCKET 1 155 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 156 #define GRPC_POSIX_SOCKET 1 157 #define GRPC_POSIX_SOCKETUTILS 1 158 #define GRPC_POSIX_WAKEUP_FD 1 159 #elif defined(GPR_AIX) 160 #define GRPC_HAVE_UNIX_SOCKET 1 161 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 162 #define GRPC_POSIX_SOCKET 1 163 #define GRPC_POSIX_SOCKETUTILS 1 164 #define GRPC_POSIX_WAKEUP_FD 1 165 #elif defined(GPR_NACL) 166 #define GRPC_HAVE_ARPA_NAMESER 1 167 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 168 #define GRPC_POSIX_SOCKET 1 169 #define GRPC_POSIX_SOCKETUTILS 1 170 #define GRPC_POSIX_WAKEUP_FD 1 171 #elif defined(GPR_FUCHSIA) 172 #define GRPC_HAVE_IFADDRS 1 173 #define GRPC_HAVE_IPV6_RECVPKTINFO 1 174 #define GRPC_HAVE_IP_PKTINFO 1 175 // Zircon does not support the MSG_NOSIGNAL flag since it doesn't support 176 // signals. 177 #undef GRPC_HAVE_MSG_NOSIGNAL 178 #define GRPC_HAVE_UNIX_SOCKET 1 179 #define GRPC_POSIX_WAKEUP_FD 1 180 // TODO(rudominer) Check that this does something we want. 181 #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 182 #define GRPC_POSIX_SOCKET 1 183 #define GRPC_POSIX_SOCKETADDR 1 184 // TODO(rudominer) Check this does something we want. 185 #define GRPC_POSIX_SOCKETUTILS 1 186 #define GRPC_TIMER_USE_GENERIC 1 187 #elif !defined(GPR_NO_AUTODETECT_PLATFORM) 188 #error "Platform not recognized" 189 #endif 190 191 #if defined(GRPC_POSIX_SOCKET) + defined(GRPC_WINSOCK_SOCKET) + \ 192 defined(GRPC_CUSTOM_SOCKET) + defined(GRPC_CFSTREAM) != \ 193 1 194 #error \ 195 "Must define exactly one of GRPC_POSIX_SOCKET, GRPC_WINSOCK_SOCKET, GRPC_CUSTOM_SOCKET" 196 #endif 197 198 #ifdef GRPC_POSIX_SOCKET 199 #define GRPC_POSIX_SOCKET_ARES_EV_DRIVER 1 200 #define GRPC_POSIX_SOCKET_EV 1 201 #define GRPC_POSIX_SOCKET_EV_EPOLLEX 1 202 #define GRPC_POSIX_SOCKET_EV_POLL 1 203 #define GRPC_POSIX_SOCKET_EV_EPOLL1 1 204 #define GRPC_POSIX_SOCKET_IF_NAMETOINDEX 1 205 #define GRPC_POSIX_SOCKET_IOMGR 1 206 #define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1 207 #define GRPC_POSIX_SOCKET_SOCKADDR 1 208 #define GRPC_POSIX_SOCKET_SOCKET_FACTORY 1 209 #define GRPC_POSIX_SOCKET_TCP 1 210 #define GRPC_POSIX_SOCKET_TCP_CLIENT 1 211 #define GRPC_POSIX_SOCKET_TCP_SERVER 1 212 #define GRPC_POSIX_SOCKET_TCP_SERVER_UTILS_COMMON 1 213 #define GRPC_POSIX_SOCKET_UDP_SERVER 1 214 #define GRPC_POSIX_SOCKET_UTILS_COMMON 1 215 #endif 216 217 #if defined(GRPC_POSIX_HOST_NAME_MAX) && defined(GRPC_POSIX_SYSCONF) 218 #error "Cannot define both GRPC_POSIX_HOST_NAME_MAX and GRPC_POSIX_SYSCONF" 219 #endif 220 #if !defined(GRPC_POSIX_HOST_NAME_MAX) && !defined(GRPC_POSIX_SYSCONF) 221 #define GRPC_GETHOSTNAME_FALLBACK 1 222 #endif 223 224 #endif /* GRPC_CORE_LIB_IOMGR_PORT_H */ 225