Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 08:35:03

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one
0003  * or more contributor license agreements. See the NOTICE file
0004  * distributed with this work for additional information
0005  * regarding copyright ownership. The ASF licenses this file
0006  * to you under the Apache License, Version 2.0 (the
0007  * "License"); you may not use this file except in compliance
0008  * with the License. You may obtain a copy of the License at
0009  *
0010  *   http://www.apache.org/licenses/LICENSE-2.0
0011  *
0012  * Unless required by applicable law or agreed to in writing,
0013  * software distributed under the License is distributed on an
0014  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0015  * KIND, either express or implied. See the License for the
0016  * specific language governing permissions and limitations
0017  * under the License.
0018  */
0019 
0020 // clang-format off
0021 
0022 #ifndef _THRIFT_TRANSPORT_PLATFORM_SOCKET_H_
0023 #  define _THRIFT_TRANSPORT_PLATFORM_SOCKET_H_
0024 
0025 #ifdef _WIN32
0026 #  include <winsock2.h>
0027 #  define THRIFT_GET_SOCKET_ERROR ::WSAGetLastError()
0028 #  define THRIFT_ERRNO (*_errno())
0029 #  define THRIFT_EINPROGRESS WSAEINPROGRESS
0030 #  define THRIFT_EAGAIN WSAEWOULDBLOCK
0031 #  define THRIFT_EINTR WSAEINTR
0032 #  define THRIFT_ECONNRESET WSAECONNRESET
0033 #  define THRIFT_ENOTCONN WSAENOTCONN
0034 #  define THRIFT_ETIMEDOUT WSAETIMEDOUT
0035 #  define THRIFT_EWOULDBLOCK WSAEWOULDBLOCK
0036 #  define THRIFT_EPIPE WSAECONNRESET
0037 #  define THRIFT_NO_SOCKET_CACHING SO_EXCLUSIVEADDRUSE
0038 #  define THRIFT_SOCKET SOCKET
0039 #  define THRIFT_INVALID_SOCKET INVALID_SOCKET
0040 #  define THRIFT_SOCKETPAIR thrift_socketpair
0041 #  define THRIFT_FCNTL thrift_fcntl
0042 #  define THRIFT_O_NONBLOCK 1
0043 #  define THRIFT_F_GETFL 0
0044 #  define THRIFT_F_SETFL 1
0045 #  define THRIFT_GETTIMEOFDAY thrift_gettimeofday
0046 #  define THRIFT_CLOSESOCKET closesocket
0047 #  define THRIFT_CLOSE _close
0048 #  define THRIFT_OPEN _open
0049 #  define THRIFT_FTRUNCATE _chsize_s
0050 #  define THRIFT_FSYNC _commit
0051 #  define THRIFT_LSEEK _lseek
0052 #  define THRIFT_WRITE _write
0053 #  define THRIFT_READ _read
0054 #  define THRIFT_IOCTL_SOCKET ioctlsocket
0055 #  define THRIFT_IOCTL_SOCKET_NUM_BYTES_TYPE u_long
0056 #  define THRIFT_FSTAT _fstat
0057 #  define THRIFT_STAT _stat
0058 #  ifdef _WIN32_WCE
0059 #    define THRIFT_GAI_STRERROR(...) thrift_wstr2str(gai_strerrorW(__VA_ARGS__))
0060 #  else
0061 #    define THRIFT_GAI_STRERROR gai_strerrorA
0062 #  endif
0063 #  define THRIFT_SSIZET ptrdiff_t
0064 #  if (_MSC_VER < 1900)
0065 #    define THRIFT_SNPRINTF _snprintf
0066 #  else
0067 #    define THRIFT_SNPRINTF snprintf
0068 #  endif
0069 #  define THRIFT_SLEEP_SEC thrift_sleep
0070 #  define THRIFT_SLEEP_USEC thrift_usleep
0071 #  define THRIFT_TIMESPEC thrift_timespec
0072 #  define THRIFT_CTIME_R thrift_ctime_r
0073 #  define THRIFT_POLL WSAPoll
0074 #  define THRIFT_POLLFD  pollfd
0075 #  define THRIFT_POLLIN  POLLIN
0076 #  define THRIFT_POLLOUT POLLOUT
0077 #  define THRIFT_SHUT_RDWR SD_BOTH
0078 #  if !defined(AI_ADDRCONFIG)
0079 #    define AI_ADDRCONFIG 0x00000400
0080 #  endif
0081 #else //not _WIN32
0082 #  include <errno.h>
0083 #  define THRIFT_GET_SOCKET_ERROR errno
0084 #  define THRIFT_ERRNO errno
0085 #  define THRIFT_EINTR       EINTR
0086 #  define THRIFT_EINPROGRESS EINPROGRESS
0087 #  define THRIFT_ECONNRESET  ECONNRESET
0088 #  define THRIFT_ENOTCONN    ENOTCONN
0089 #  define THRIFT_ETIMEDOUT   ETIMEDOUT
0090 #  define THRIFT_EWOULDBLOCK EWOULDBLOCK
0091 #  define THRIFT_EAGAIN      EAGAIN
0092 #  define THRIFT_EPIPE       EPIPE
0093 #  define THRIFT_NO_SOCKET_CACHING SO_REUSEADDR
0094 #  define THRIFT_SOCKET int
0095 #  define THRIFT_INVALID_SOCKET (-1)
0096 #  define THRIFT_SOCKETPAIR socketpair
0097 #  define THRIFT_FCNTL fcntl
0098 #  define THRIFT_O_NONBLOCK O_NONBLOCK
0099 #  define THRIFT_F_GETFL F_GETFL
0100 #  define THRIFT_F_SETFL F_SETFL
0101 #  define THRIFT_GETTIMEOFDAY gettimeofday
0102 #  define THRIFT_CLOSESOCKET close
0103 #  define THRIFT_CLOSE close
0104 #  define THRIFT_OPEN open
0105 #  define THRIFT_FTRUNCATE ftruncate
0106 #  define THRIFT_FSYNC fsync
0107 #  define THRIFT_LSEEK lseek
0108 #  define THRIFT_WRITE write
0109 #  define THRIFT_READ read
0110 #  define THRIFT_IOCTL_SOCKET ioctl
0111 #  define THRIFT_IOCTL_SOCKET_NUM_BYTES_TYPE int
0112 #  define THRIFT_STAT stat
0113 #  define THRIFT_FSTAT fstat
0114 #  define THRIFT_GAI_STRERROR gai_strerror
0115 #  define THRIFT_SSIZET ssize_t
0116 #  define THRIFT_SNPRINTF snprintf
0117 #  define THRIFT_SLEEP_SEC sleep
0118 #  define THRIFT_SLEEP_USEC usleep
0119 #  define THRIFT_TIMESPEC timespec
0120 #  define THRIFT_CTIME_R ctime_r
0121 #  define THRIFT_POLL poll
0122 #  define THRIFT_POLLFD  pollfd
0123 #  define THRIFT_POLLIN  POLLIN
0124 #  define THRIFT_POLLOUT POLLOUT
0125 #  define THRIFT_SHUT_RDWR SHUT_RDWR
0126 #endif
0127 
0128 #endif // _THRIFT_TRANSPORT_PLATFORM_SOCKET_H_