BSHA3
0.17.99
P2P Blockchain, based on Bitcoin
src
compat.h
Go to the documentation of this file.
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-2018 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.
5
6
#ifndef BITCOIN_COMPAT_H
7
#define BITCOIN_COMPAT_H
8
9
#if defined(HAVE_CONFIG_H)
10
#include <
config/bitcoin-config.h
>
11
#endif
12
13
#include <type_traits>
14
15
// GCC 4.8 is missing some C++11 type_traits,
16
// https://www.gnu.org/software/gcc/gcc-5/changes.html
17
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
18
#define IS_TRIVIALLY_CONSTRUCTIBLE std::has_trivial_default_constructor
19
#else
20
#define IS_TRIVIALLY_CONSTRUCTIBLE std::is_trivially_default_constructible
21
#endif
22
23
#ifdef WIN32
24
#ifdef _WIN32_WINNT
25
#undef _WIN32_WINNT
26
#endif
27
#define _WIN32_WINNT 0x0501
28
#ifndef WIN32_LEAN_AND_MEAN
29
#define WIN32_LEAN_AND_MEAN 1
30
#endif
31
#ifndef NOMINMAX
32
#define NOMINMAX
33
#endif
34
#ifdef FD_SETSIZE
35
#undef FD_SETSIZE // prevent redefinition compiler warning
36
#endif
37
#define FD_SETSIZE 1024 // max number of fds in fd_set
38
39
#include <winsock2.h>
// Must be included before mswsock.h and windows.h
40
41
#include <mswsock.h>
42
#include <windows.h>
43
#include <ws2tcpip.h>
44
#include <stdint.h>
45
#else
46
#include <fcntl.h>
47
#include <sys/mman.h>
48
#include <sys/select.h>
49
#include <sys/socket.h>
50
#include <sys/types.h>
51
#include <net/if.h>
52
#include <netinet/in.h>
53
#include <netinet/tcp.h>
54
#include <arpa/inet.h>
55
#include <ifaddrs.h>
56
#include <limits.h>
57
#include <netdb.h>
58
#include <unistd.h>
59
#endif
60
61
#ifndef WIN32
62
typedef
unsigned
int
SOCKET
;
63
#include <errno.h>
64
#define WSAGetLastError() errno
65
#define WSAEINVAL EINVAL
66
#define WSAEALREADY EALREADY
67
#define WSAEWOULDBLOCK EWOULDBLOCK
68
#define WSAEMSGSIZE EMSGSIZE
69
#define WSAEINTR EINTR
70
#define WSAEINPROGRESS EINPROGRESS
71
#define WSAEADDRINUSE EADDRINUSE
72
#define WSAENOTSOCK EBADF
73
#define INVALID_SOCKET (SOCKET)(~0)
74
#define SOCKET_ERROR -1
75
#endif
76
77
#ifndef PRIO_MAX
78
#define PRIO_MAX 20
79
#endif
80
#define THREAD_PRIORITY_LOWEST PRIO_MAX
81
#define THREAD_PRIORITY_BELOW_NORMAL 2
82
#define THREAD_PRIORITY_LOWEST PRIO_MAX
83
#define THREAD_PRIORITY_BELOW_NORMAL 2
84
#define THREAD_PRIORITY_NORMAL 0
85
#define THREAD_PRIORITY_ABOVE_NORMAL (-2)
86
87
#ifdef WIN32
88
#ifndef S_IRUSR
89
#define S_IRUSR 0400
90
#define S_IWUSR 0200
91
#endif
92
#else
93
#define MAX_PATH 1024
94
#endif
95
#ifdef _MSC_VER
96
#if !defined(ssize_t)
97
#ifdef _WIN64
98
typedef
int64_t ssize_t;
99
#else
100
typedef
int32_t ssize_t;
101
#endif
102
#endif
103
#endif
104
105
#if HAVE_DECL_STRNLEN == 0
106
size_t
strnlen
(
const
char
*
start
,
size_t
max_len);
107
#endif // HAVE_DECL_STRNLEN
108
109
#ifndef WIN32
110
typedef
void
*
sockopt_arg_type
;
111
#else
112
typedef
char
*
sockopt_arg_type
;
113
#endif
114
115
bool
static
inline
IsSelectableSocket(
const
SOCKET
& s) {
116
#ifdef WIN32
117
return
true
;
118
#else
119
return
(s < FD_SETSIZE);
120
#endif
121
}
122
123
#endif // BITCOIN_COMPAT_H
start
auto start
Definition:
rpcwallet.cpp:1067
sockopt_arg_type
void * sockopt_arg_type
Definition:
compat.h:110
bitcoin-config.h
SOCKET
unsigned int SOCKET
Definition:
compat.h:62
strnlen
size_t strnlen(const char *start, size_t max_len)
Definition:
strnlen.cpp:12
Generated on Wed Nov 28 2018 15:30:27 for BSHA3 by
1.8.14