Master Core
v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
src
compat.h
Go to the documentation of this file.
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-2013 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
#ifdef WIN32
10
#ifdef _WIN32_WINNT
11
#undef _WIN32_WINNT
12
#endif
13
#define _WIN32_WINNT 0x0501
14
#ifndef WIN32_LEAN_AND_MEAN
15
#define WIN32_LEAN_AND_MEAN 1
16
#endif
17
#ifndef NOMINMAX
18
#define NOMINMAX
19
#endif
20
#ifdef FD_SETSIZE
21
#undef FD_SETSIZE // prevent redefinition compiler warning
22
#endif
23
#define FD_SETSIZE 1024 // max number of fds in fd_set
24
25
#include <winsock2.h>
// Must be included before mswsock.h and windows.h
26
27
#include <mswsock.h>
28
#include <windows.h>
29
#include <ws2tcpip.h>
30
#else
31
#include <sys/fcntl.h>
32
#include <sys/mman.h>
33
#include <sys/socket.h>
34
#include <sys/types.h>
35
#include <net/if.h>
36
#include <netinet/in.h>
37
#include <arpa/inet.h>
38
#include <ifaddrs.h>
39
#include <limits.h>
40
#include <netdb.h>
41
#include <unistd.h>
42
#endif
43
44
#ifdef WIN32
45
#define MSG_DONTWAIT 0
46
#else
47
typedef
u_int
SOCKET
;
48
#include "errno.h"
49
#define WSAGetLastError() errno
50
#define WSAEINVAL EINVAL
51
#define WSAEALREADY EALREADY
52
#define WSAEWOULDBLOCK EWOULDBLOCK
53
#define WSAEMSGSIZE EMSGSIZE
54
#define WSAEINTR EINTR
55
#define WSAEINPROGRESS EINPROGRESS
56
#define WSAEADDRINUSE EADDRINUSE
57
#define WSAENOTSOCK EBADF
58
#define INVALID_SOCKET (SOCKET)(~0)
59
#define SOCKET_ERROR -1
60
#endif
61
62
inline
int
myclosesocket
(
SOCKET
& hSocket)
63
{
64
if
(hSocket ==
INVALID_SOCKET
)
65
return
WSAENOTSOCK
;
66
#ifdef WIN32
67
int
ret =
closesocket
(hSocket);
68
#else
69
int
ret = close(hSocket);
70
#endif
71
hSocket =
INVALID_SOCKET
;
72
return
ret;
73
}
74
#define closesocket(s) myclosesocket(s)
75
76
77
#endif
closesocket
#define closesocket(s)
Definition:
compat.h:74
SOCKET
u_int SOCKET
Definition:
compat.h:47
INVALID_SOCKET
#define INVALID_SOCKET
Definition:
compat.h:58
myclosesocket
int myclosesocket(SOCKET &hSocket)
Definition:
compat.h:62
WSAENOTSOCK
#define WSAENOTSOCK
Definition:
compat.h:57
Generated on Tue Dec 23 2014 23:20:38 for Master Core by
1.8.8