2012-01-03 23:33:31 +01:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2014-06-16 15:55:39 +02:00
|
|
|
// Copyright (c) 2009-2014 The Bitcoin developers
|
2012-01-03 23:33:31 +01:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
2012-05-18 16:02:28 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2013-04-13 07:13:08 +02:00
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#ifndef BITCOIN_COMPAT_H
|
|
|
|
#define BITCOIN_COMPAT_H
|
2012-01-03 23:33:31 +01:00
|
|
|
|
2014-11-26 08:19:07 +01:00
|
|
|
#if defined(HAVE_CONFIG_H)
|
2015-04-03 00:51:08 +02:00
|
|
|
#include "config/dash-config.h"
|
2014-11-26 08:19:07 +01:00
|
|
|
#endif
|
2012-01-03 23:33:31 +01:00
|
|
|
|
2012-04-15 22:10:54 +02:00
|
|
|
#ifdef WIN32
|
2013-10-11 15:37:36 +02:00
|
|
|
#ifdef _WIN32_WINNT
|
|
|
|
#undef _WIN32_WINNT
|
|
|
|
#endif
|
2012-04-15 22:10:54 +02:00
|
|
|
#define _WIN32_WINNT 0x0501
|
2013-11-27 16:13:04 +01:00
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
2012-04-15 22:10:54 +02:00
|
|
|
#define WIN32_LEAN_AND_MEAN 1
|
2013-11-27 16:13:04 +01:00
|
|
|
#endif
|
2012-04-15 22:10:54 +02:00
|
|
|
#ifndef NOMINMAX
|
|
|
|
#define NOMINMAX
|
|
|
|
#endif
|
2013-10-11 15:37:36 +02:00
|
|
|
#ifdef FD_SETSIZE
|
|
|
|
#undef FD_SETSIZE // prevent redefinition compiler warning
|
|
|
|
#endif
|
2013-04-26 01:05:35 +02:00
|
|
|
#define FD_SETSIZE 1024 // max number of fds in fd_set
|
2013-04-13 07:13:08 +02:00
|
|
|
|
|
|
|
#include <winsock2.h> // Must be included before mswsock.h and windows.h
|
|
|
|
|
|
|
|
#include <mswsock.h>
|
|
|
|
#include <windows.h>
|
2012-04-15 22:10:54 +02:00
|
|
|
#include <ws2tcpip.h>
|
|
|
|
#else
|
2014-05-02 20:45:03 +02:00
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/socket.h>
|
2013-11-22 14:22:53 +01:00
|
|
|
#include <sys/types.h>
|
2014-05-02 20:45:03 +02:00
|
|
|
#include <net/if.h>
|
|
|
|
#include <netinet/in.h>
|
2012-04-15 22:10:54 +02:00
|
|
|
#include <arpa/inet.h>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <ifaddrs.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <unistd.h>
|
2012-04-15 22:10:54 +02:00
|
|
|
#endif
|
|
|
|
|
2012-01-03 23:33:31 +01:00
|
|
|
#ifdef WIN32
|
|
|
|
#define MSG_DONTWAIT 0
|
|
|
|
#else
|
2013-07-24 14:53:45 +02:00
|
|
|
typedef u_int SOCKET;
|
2012-01-03 23:33:31 +01:00
|
|
|
#include "errno.h"
|
|
|
|
#define WSAGetLastError() errno
|
|
|
|
#define WSAEINVAL EINVAL
|
|
|
|
#define WSAEALREADY EALREADY
|
|
|
|
#define WSAEWOULDBLOCK EWOULDBLOCK
|
|
|
|
#define WSAEMSGSIZE EMSGSIZE
|
|
|
|
#define WSAEINTR EINTR
|
|
|
|
#define WSAEINPROGRESS EINPROGRESS
|
|
|
|
#define WSAEADDRINUSE EADDRINUSE
|
|
|
|
#define WSAENOTSOCK EBADF
|
|
|
|
#define INVALID_SOCKET (SOCKET)(~0)
|
|
|
|
#define SOCKET_ERROR -1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WIN32
|
2014-08-21 15:50:59 +02:00
|
|
|
#ifndef S_IRUSR
|
|
|
|
#define S_IRUSR 0400
|
|
|
|
#define S_IWUSR 0200
|
|
|
|
#endif
|
2012-01-03 23:33:31 +01:00
|
|
|
#else
|
2014-08-21 15:50:59 +02:00
|
|
|
#define MAX_PATH 1024
|
2012-01-03 23:33:31 +01:00
|
|
|
#endif
|
|
|
|
|
2014-08-21 15:50:59 +02:00
|
|
|
// As Solaris does not have the MSG_NOSIGNAL flag for send(2) syscall, it is defined as 0
|
|
|
|
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
|
|
|
|
#define MSG_NOSIGNAL 0
|
|
|
|
#endif
|
2012-04-15 22:10:54 +02:00
|
|
|
|
2014-08-20 17:43:56 +02:00
|
|
|
#ifndef WIN32
|
|
|
|
// PRIO_MAX is not defined on Solaris
|
|
|
|
#ifndef PRIO_MAX
|
|
|
|
#define PRIO_MAX 20
|
2012-01-03 23:33:31 +01:00
|
|
|
#endif
|
2014-08-20 17:43:56 +02:00
|
|
|
#define THREAD_PRIORITY_LOWEST PRIO_MAX
|
|
|
|
#define THREAD_PRIORITY_BELOW_NORMAL 2
|
|
|
|
#define THREAD_PRIORITY_NORMAL 0
|
|
|
|
#define THREAD_PRIORITY_ABOVE_NORMAL (-2)
|
|
|
|
#endif
|
|
|
|
|
2015-02-17 22:15:01 +01:00
|
|
|
size_t strnlen_int( const char *start, size_t max_len);
|
2014-11-21 10:38:27 +01:00
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#endif // BITCOIN_COMPAT_H
|