murgatroid99 | 79b3227 | 2016-08-08 13:38:30 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright 2016, Google Inc. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above |
| 13 | * copyright notice, this list of conditions and the following disclaimer |
| 14 | * in the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | */ |
| 33 | |
| 34 | #include <grpc/support/port_platform.h> |
| 35 | |
| 36 | #ifndef GRPC_CORE_LIB_IOMGR_PORT_H |
| 37 | #define GRPC_CORE_LIB_IOMGR_PORT_H |
| 38 | |
murgatroid99 | 9030c81 | 2016-09-16 13:25:08 -0700 | [diff] [blame] | 39 | #if defined(GRPC_UV) |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 40 | // Do nothing |
murgatroid99 | 9030c81 | 2016-09-16 13:25:08 -0700 | [diff] [blame] | 41 | #elif defined(GPR_MANYLINUX1) |
Yuchen Zeng | f134206 | 2017-03-12 22:39:11 -0700 | [diff] [blame] | 42 | #define GRPC_HAVE_IFADDRS 1 |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 43 | #define GRPC_HAVE_IPV6_RECVPKTINFO 1 |
| 44 | #define GRPC_HAVE_IP_PKTINFO 1 |
| 45 | #define GRPC_HAVE_MSG_NOSIGNAL 1 |
| 46 | #define GRPC_HAVE_UNIX_SOCKET 1 |
| 47 | #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 |
| 48 | #define GRPC_POSIX_SOCKET 1 |
| 49 | #define GRPC_POSIX_SOCKETADDR 1 |
| 50 | #define GRPC_POSIX_SOCKETUTILS 1 |
| 51 | #define GRPC_POSIX_WAKEUP_FD 1 |
murgatroid99 | 9030c81 | 2016-09-16 13:25:08 -0700 | [diff] [blame] | 52 | #define GRPC_TIMER_USE_GENERIC 1 |
murgatroid99 | 192293d | 2016-08-09 10:24:22 -0700 | [diff] [blame] | 53 | #elif defined(GPR_WINDOWS) |
murgatroid99 | 9030c81 | 2016-09-16 13:25:08 -0700 | [diff] [blame] | 54 | #define GRPC_TIMER_USE_GENERIC 1 |
murgatroid99 | 192293d | 2016-08-09 10:24:22 -0700 | [diff] [blame] | 55 | #define GRPC_WINSOCK_SOCKET 1 |
| 56 | #define GRPC_WINDOWS_SOCKETUTILS 1 |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 57 | #elif defined(GPR_ANDROID) |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 58 | #define GRPC_HAVE_IPV6_RECVPKTINFO 1 |
| 59 | #define GRPC_HAVE_IP_PKTINFO 1 |
| 60 | #define GRPC_HAVE_MSG_NOSIGNAL 1 |
| 61 | #define GRPC_HAVE_UNIX_SOCKET 1 |
| 62 | #define GRPC_LINUX_EVENTFD 1 |
| 63 | #define GRPC_POSIX_SOCKET 1 |
| 64 | #define GRPC_POSIX_SOCKETADDR 1 |
| 65 | #define GRPC_POSIX_SOCKETUTILS 1 |
| 66 | #define GRPC_POSIX_WAKEUP_FD 1 |
murgatroid99 | 9030c81 | 2016-09-16 13:25:08 -0700 | [diff] [blame] | 67 | #define GRPC_TIMER_USE_GENERIC 1 |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 68 | #elif defined(GPR_LINUX) |
Yuchen Zeng | f134206 | 2017-03-12 22:39:11 -0700 | [diff] [blame] | 69 | #define GRPC_HAVE_IFADDRS 1 |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 70 | #define GRPC_HAVE_IPV6_RECVPKTINFO 1 |
| 71 | #define GRPC_HAVE_IP_PKTINFO 1 |
| 72 | #define GRPC_HAVE_MSG_NOSIGNAL 1 |
| 73 | #define GRPC_HAVE_UNIX_SOCKET 1 |
| 74 | #define GRPC_LINUX_MULTIPOLL_WITH_EPOLL 1 |
| 75 | #define GRPC_POSIX_SOCKET 1 |
| 76 | #define GRPC_POSIX_SOCKETADDR 1 |
| 77 | #define GRPC_POSIX_WAKEUP_FD 1 |
murgatroid99 | 9030c81 | 2016-09-16 13:25:08 -0700 | [diff] [blame] | 78 | #define GRPC_TIMER_USE_GENERIC 1 |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 79 | #ifdef __GLIBC_PREREQ |
| 80 | #if __GLIBC_PREREQ(2, 9) |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 81 | #define GRPC_LINUX_EPOLL 1 |
| 82 | #define GRPC_LINUX_EVENTFD 1 |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 83 | #endif |
| 84 | #if __GLIBC_PREREQ(2, 10) |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 85 | #define GRPC_LINUX_SOCKETUTILS 1 |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 86 | #endif |
| 87 | #endif |
Ken Payson | 975b510 | 2017-03-30 17:38:40 -0700 | [diff] [blame] | 88 | #ifndef __GLIBC__ |
| 89 | #define GRPC_LINUX_EPOLL 1 |
| 90 | #define GRPC_LINUX_EVENTFD 1 |
murgatroid99 | 9805833 | 2017-04-19 10:25:34 -0700 | [diff] [blame^] | 91 | #define GRPC_MSG_IOVLEN_TYPE int |
Ken Payson | 975b510 | 2017-03-30 17:38:40 -0700 | [diff] [blame] | 92 | #endif |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 93 | #ifndef GRPC_LINUX_EVENTFD |
| 94 | #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 95 | #endif |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 96 | #ifndef GRPC_LINUX_SOCKETUTILS |
| 97 | #define GRPC_POSIX_SOCKETUTILS |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 98 | #endif |
| 99 | #elif defined(GPR_APPLE) |
Yuchen Zeng | f134206 | 2017-03-12 22:39:11 -0700 | [diff] [blame] | 100 | #define GRPC_HAVE_IFADDRS 1 |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 101 | #define GRPC_HAVE_SO_NOSIGPIPE 1 |
| 102 | #define GRPC_HAVE_UNIX_SOCKET 1 |
| 103 | #define GRPC_MSG_IOVLEN_TYPE int |
| 104 | #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 |
| 105 | #define GRPC_POSIX_SOCKET 1 |
| 106 | #define GRPC_POSIX_SOCKETADDR 1 |
| 107 | #define GRPC_POSIX_SOCKETUTILS 1 |
| 108 | #define GRPC_POSIX_WAKEUP_FD 1 |
murgatroid99 | 9030c81 | 2016-09-16 13:25:08 -0700 | [diff] [blame] | 109 | #define GRPC_TIMER_USE_GENERIC 1 |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 110 | #elif defined(GPR_FREEBSD) |
Yuchen Zeng | f134206 | 2017-03-12 22:39:11 -0700 | [diff] [blame] | 111 | #define GRPC_HAVE_IFADDRS 1 |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 112 | #define GRPC_HAVE_IPV6_RECVPKTINFO 1 |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 113 | #define GRPC_HAVE_SO_NOSIGPIPE 1 |
| 114 | #define GRPC_HAVE_UNIX_SOCKET 1 |
| 115 | #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 |
| 116 | #define GRPC_POSIX_SOCKET 1 |
| 117 | #define GRPC_POSIX_SOCKETADDR 1 |
| 118 | #define GRPC_POSIX_SOCKETUTILS 1 |
| 119 | #define GRPC_POSIX_WAKEUP_FD 1 |
murgatroid99 | 9030c81 | 2016-09-16 13:25:08 -0700 | [diff] [blame] | 120 | #define GRPC_TIMER_USE_GENERIC 1 |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 121 | #elif defined(GPR_NACL) |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 122 | #define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 |
| 123 | #define GRPC_POSIX_SOCKET 1 |
| 124 | #define GRPC_POSIX_SOCKETADDR 1 |
| 125 | #define GRPC_POSIX_SOCKETUTILS 1 |
| 126 | #define GRPC_POSIX_WAKEUP_FD 1 |
murgatroid99 | 9030c81 | 2016-09-16 13:25:08 -0700 | [diff] [blame] | 127 | #define GRPC_TIMER_USE_GENERIC 1 |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 128 | #elif !defined(GPR_NO_AUTODETECT_PLATFORM) |
| 129 | #error "Platform not recognized" |
| 130 | #endif |
murgatroid99 | 79b3227 | 2016-08-08 13:38:30 -0700 | [diff] [blame] | 131 | |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 132 | #if defined(GRPC_POSIX_SOCKET) + defined(GRPC_WINSOCK_SOCKET) + \ |
murgatroid99 | dedb923 | 2016-09-26 13:54:04 -0700 | [diff] [blame] | 133 | defined(GRPC_CUSTOM_SOCKET) + defined(GRPC_UV) != \ |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 134 | 1 |
murgatroid99 | 623dd4f | 2016-08-08 17:31:27 -0700 | [diff] [blame] | 135 | #error Must define exactly one of GRPC_POSIX_SOCKET, GRPC_WINSOCK_SOCKET, GPR_CUSTOM_SOCKET |
murgatroid99 | 5407089 | 2016-08-08 17:01:18 -0700 | [diff] [blame] | 136 | #endif |
murgatroid99 | 79b3227 | 2016-08-08 13:38:30 -0700 | [diff] [blame] | 137 | |
murgatroid99 | 7e924a0 | 2016-08-10 10:06:43 -0700 | [diff] [blame] | 138 | #endif /* GRPC_CORE_LIB_IOMGR_PORT_H */ |