Changeset View
Changeset View
Standalone View
Standalone View
src/compat.h
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
#include <sys/fcntl.h> | #include <sys/fcntl.h> | ||||
#include <sys/mman.h> | #include <sys/mman.h> | ||||
#include <sys/select.h> | #include <sys/select.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#endif | #endif | ||||
#ifdef WIN32 | #ifndef WIN32 | ||||
#define MSG_DONTWAIT 0 | typedef unsigned int SOCKET; | ||||
#else | |||||
typedef u_int SOCKET; | |||||
#include "errno.h" | #include "errno.h" | ||||
#define WSAGetLastError() errno | #define WSAGetLastError() errno | ||||
#define WSAEINVAL EINVAL | #define WSAEINVAL EINVAL | ||||
#define WSAEALREADY EALREADY | #define WSAEALREADY EALREADY | ||||
#define WSAEWOULDBLOCK EWOULDBLOCK | #define WSAEWOULDBLOCK EWOULDBLOCK | ||||
#define WSAEMSGSIZE EMSGSIZE | #define WSAEMSGSIZE EMSGSIZE | ||||
#define WSAEINTR EINTR | #define WSAEINTR EINTR | ||||
#define WSAEINPROGRESS EINPROGRESS | #define WSAEINPROGRESS EINPROGRESS | ||||
#define WSAEADDRINUSE EADDRINUSE | #define WSAEADDRINUSE EADDRINUSE | ||||
#define WSAENOTSOCK EBADF | #define WSAENOTSOCK EBADF | ||||
#define INVALID_SOCKET (SOCKET)(~0) | #define INVALID_SOCKET (SOCKET)(~0) | ||||
#define SOCKET_ERROR -1 | #define SOCKET_ERROR -1 | ||||
#endif | #endif | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#ifndef S_IRUSR | #ifndef S_IRUSR | ||||
#define S_IRUSR 0400 | #define S_IRUSR 0400 | ||||
#define S_IWUSR 0200 | #define S_IWUSR 0200 | ||||
#endif | #endif | ||||
#else | #else | ||||
#define MAX_PATH 1024 | #define MAX_PATH 1024 | ||||
#endif | #endif | ||||
// 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 | |||||
#if HAVE_DECL_STRNLEN == 0 | #if HAVE_DECL_STRNLEN == 0 | ||||
size_t strnlen(const char *start, size_t max_len); | size_t strnlen(const char *start, size_t max_len); | ||||
#endif // HAVE_DECL_STRNLEN | #endif // HAVE_DECL_STRNLEN | ||||
static bool inline IsSelectableSocket(SOCKET s) { | static bool inline IsSelectableSocket(SOCKET s) { | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
return true; | return true; | ||||
#else | #else | ||||
return (s < FD_SETSIZE); | return (s < FD_SETSIZE); | ||||
#endif | #endif | ||||
} | } | ||||
#endif // BITCOIN_COMPAT_H | #endif // BITCOIN_COMPAT_H |