6 #ifndef BITCOIN_COMPAT_H
7 #define BITCOIN_COMPAT_H
9 #if defined(HAVE_CONFIG_H)
18 #undef FD_SETSIZE // prevent redefinition compiler warning
20 #define FD_SETSIZE 1024 // max number of fds in fd_set
31 #include <sys/select.h>
32 #include <sys/socket.h>
33 #include <sys/types.h>
35 #include <netinet/in.h>
36 #include <netinet/tcp.h>
37 #include <arpa/inet.h>
47 #define WSAGetLastError() errno
48 #define WSAEINVAL EINVAL
49 #define WSAEALREADY EALREADY
50 #define WSAEWOULDBLOCK EWOULDBLOCK
51 #define WSAEMSGSIZE EMSGSIZE
52 #define WSAEINTR EINTR
53 #define WSAEINPROGRESS EINPROGRESS
54 #define WSAEADDRINUSE EADDRINUSE
55 #define WSAENOTSOCK EBADF
56 #define INVALID_SOCKET (SOCKET)(~0)
57 #define SOCKET_ERROR -1
71 typedef int64_t ssize_t;
73 typedef int32_t ssize_t;
78 #if HAVE_DECL_STRNLEN == 0
79 size_t strnlen(
const char *start,
size_t max_len);
80 #endif // HAVE_DECL_STRNLEN
91 #if defined(__linux__)
96 #if defined(USE_POLL) || defined(WIN32)
99 return (s < FD_SETSIZE);
103 #endif // BITCOIN_COMPAT_H
static bool IsSelectableSocket(const SOCKET &s)
size_t strnlen(const char *start, size_t max_len)