PRCYCoin  2.0.0.7rc1
P2P Digital Currency
compat.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_COMPAT_H
7 #define BITCOIN_COMPAT_H
8 
9 #if defined(HAVE_CONFIG_H)
10 #include "config/prcycoin-config.h"
11 #endif
12 
13 #ifdef WIN32
14 #ifndef NOMINMAX
15 #define NOMINMAX
16 #endif
17 #ifdef FD_SETSIZE
18 #undef FD_SETSIZE // prevent redefinition compiler warning
19 #endif
20 #define FD_SETSIZE 1024 // max number of fds in fd_set
21 
22 #include <winsock2.h> // Must be included before mswsock.h and windows.h
23 
24 #include <mswsock.h>
25 #include <windows.h>
26 #include <ws2tcpip.h>
27 #else
28 #include <arpa/inet.h>
29 #include <ifaddrs.h>
30 #include <limits.h>
31 #include <net/if.h>
32 #include <netdb.h>
33 #include <netinet/in.h>
34 #include <sys/fcntl.h>
35 #include <sys/mman.h>
36 #include <sys/socket.h>
37 #include <sys/types.h>
38 #include <unistd.h>
39 #endif
40 
41 #ifdef WIN32
42 #define MSG_DONTWAIT 0
43 #else
44 typedef u_int SOCKET;
45 #include "errno.h"
46 #define WSAGetLastError() errno
47 #define WSAEINVAL EINVAL
48 #define WSAEALREADY EALREADY
49 #define WSAEWOULDBLOCK EWOULDBLOCK
50 #define WSAEMSGSIZE EMSGSIZE
51 #define WSAEINTR EINTR
52 #define WSAEINPROGRESS EINPROGRESS
53 #define WSAEADDRINUSE EADDRINUSE
54 #define WSAENOTSOCK EBADF
55 #define INVALID_SOCKET (SOCKET)(~0)
56 #define SOCKET_ERROR -1
57 #endif
58 
59 #ifdef WIN32
60 #ifndef S_IRUSR
61 #define S_IRUSR 0400
62 #define S_IWUSR 0200
63 #endif
64 #else
65 #define MAX_PATH 1024
66 #endif
67 
68 // As Solaris does not have the MSG_NOSIGNAL flag for send(2) syscall, it is defined as 0
69 #if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
70 #define MSG_NOSIGNAL 0
71 #endif
72 
73 #ifndef WIN32
74 // PRIO_MAX is not defined on Solaris
75 #ifndef PRIO_MAX
76 #define PRIO_MAX 20
77 #endif
78 #define THREAD_PRIORITY_LOWEST PRIO_MAX
79 #define THREAD_PRIORITY_BELOW_NORMAL 2
80 #define THREAD_PRIORITY_NORMAL 0
81 #define THREAD_PRIORITY_ABOVE_NORMAL (-2)
82 #endif
83 
84 #if HAVE_DECL_STRNLEN == 0
85 size_t strnlen( const char *start, size_t max_len);
86 #endif // HAVE_DECL_STRNLEN
87 
88 bool static inline IsSelectableSocket(SOCKET s)
89 {
90 #ifdef WIN32
91  return true;
92 #else
93  return (s < FD_SETSIZE);
94 #endif
95 }
96 
97 #endif // BITCOIN_COMPAT_H
SOCKET
u_int SOCKET
Definition: compat.h:44
prcycoin-config.h
strnlen
size_t strnlen(const char *start, size_t max_len)
Definition: strnlen.cpp:12