1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 #ifndef BITCOIN_COMPAT_H
7 #define BITCOIN_COMPAT_H
9 #if defined(HAVE_CONFIG_H)
10 #include "config/bitcoin-config.h"
17 #define _WIN32_WINNT 0x0501
18 #ifndef WIN32_LEAN_AND_MEAN
19 #define WIN32_LEAN_AND_MEAN 1
25 #undef FD_SETSIZE // prevent redefinition compiler warning
27 #define FD_SETSIZE 1024 // max number of fds in fd_set
29 #include <winsock2.h> // Must be included before mswsock.h and windows.h
37 #include <sys/socket.h>
38 #include <sys/types.h>
40 #include <netinet/in.h>
41 #include <netinet/tcp.h>
42 #include <arpa/inet.h>
50 #define MSG_DONTWAIT 0
54 #define WSAGetLastError() errno
55 #define WSAEINVAL EINVAL
56 #define WSAEALREADY EALREADY
57 #define WSAEWOULDBLOCK EWOULDBLOCK
58 #define WSAEMSGSIZE EMSGSIZE
59 #define WSAEINTR EINTR
60 #define WSAEINPROGRESS EINPROGRESS
61 #define WSAEADDRINUSE EADDRINUSE
62 #define WSAENOTSOCK EBADF
63 #define INVALID_SOCKET (SOCKET)(~0)
64 #define SOCKET_ERROR -1
76 // As Solaris does not have the MSG_NOSIGNAL flag for send(2) syscall, it is defined as 0
77 #if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
78 #define MSG_NOSIGNAL 0
82 // PRIO_MAX is not defined on Solaris
86 #define THREAD_PRIORITY_LOWEST PRIO_MAX
87 #define THREAD_PRIORITY_BELOW_NORMAL 2
88 #define THREAD_PRIORITY_NORMAL 0
89 #define THREAD_PRIORITY_ABOVE_NORMAL (-2)
92 #if HAVE_DECL_STRNLEN == 0
93 size_t strnlen( const char *start, size_t max_len);
94 #endif // HAVE_DECL_STRNLEN
96 bool static inline IsSelectableSocket(SOCKET s) {
100 return (s < FD_SETSIZE);
104 #endif // BITCOIN_COMPAT_H