Raven Core  3.0.0
P2P Digital Currency
compat.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 The Bitcoin Core developers
3 // Copyright (c) 2017-2019 The Raven Core developers
4 // Distributed under the MIT software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef RAVEN_COMPAT_H
8 #define RAVEN_COMPAT_H
9 
10 #if defined(HAVE_CONFIG_H)
11 #include "config/raven-config.h"
12 #endif
13 
14 #ifdef WIN32
15 #ifdef _WIN32_WINNT
16 #undef _WIN32_WINNT
17 #endif
18 #define _WIN32_WINNT 0x0501
19 #ifndef WIN32_LEAN_AND_MEAN
20 #define WIN32_LEAN_AND_MEAN 1
21 #endif
22 #ifndef NOMINMAX
23 #define NOMINMAX
24 #endif
25 #ifdef FD_SETSIZE
26 #undef FD_SETSIZE // prevent redefinition compiler warning
27 #endif
28 #define FD_SETSIZE 1024 // max number of fds in fd_set
29 
30 #include <winsock2.h> // Must be included before mswsock.h and windows.h
31 
32 #include <mswsock.h>
33 #include <windows.h>
34 #include <ws2tcpip.h>
35 #else
36 #include <sys/fcntl.h>
37 #include <sys/mman.h>
38 #include <sys/select.h>
39 #include <sys/socket.h>
40 #include <sys/types.h>
41 #include <net/if.h>
42 #include <netinet/in.h>
43 #include <netinet/tcp.h>
44 #include <arpa/inet.h>
45 #include <ifaddrs.h>
46 #include <limits.h>
47 #include <netdb.h>
48 #include <unistd.h>
49 #endif
50 
51 #ifndef WIN32
52 typedef unsigned int SOCKET;
53 #include "errno.h"
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
65 #endif
66 
67 #ifndef PRIO_MAX
68 #define PRIO_MAX 20
69 #endif
70 #ifndef THREAD_PRIORITY_LOWEST
71 #define THREAD_PRIORITY_LOWEST PRIO_MAX
72 #endif
73 #ifndef THREAD_PRIORITY_BELOW_NORMAL
74 #define THREAD_PRIORITY_BELOW_NORMAL 2
75 #endif
76 #ifndef THREAD_PRIORITY_NORMAL
77 #define THREAD_PRIORITY_NORMAL 0
78 #endif
79 #ifndef THREAD_PRIORITY_ABOVE_NORMAL
80 #define THREAD_PRIORITY_ABOVE_NORMAL (-2)
81 #endif
82 
83 #ifdef WIN32
84 #ifndef S_IRUSR
85 #define S_IRUSR 0400
86 #define S_IWUSR 0200
87 #endif
88 #else
89 #define MAX_PATH 1024
90 #endif
91 
92 #if HAVE_DECL_STRNLEN == 0
93 size_t strnlen( const char *start, size_t max_len);
94 #endif // HAVE_DECL_STRNLEN
95 
96 bool static inline IsSelectableSocket(const SOCKET& s) {
97 #ifdef WIN32
98  return true;
99 #else
100  return (s < FD_SETSIZE);
101 #endif
102 }
103 
104 #endif // RAVEN_COMPAT_H
unsigned int SOCKET
Definition: compat.h:52
size_t strnlen(const char *start, size_t max_len)
Definition: strnlen.cpp:13