You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

compat.h 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. #ifndef BITCOIN_COMPAT_H
  6. #define BITCOIN_COMPAT_H
  7. #ifdef WIN32
  8. #ifdef _WIN32_WINNT
  9. #undef _WIN32_WINNT
  10. #endif
  11. #define _WIN32_WINNT 0x0501
  12. #ifndef WIN32_LEAN_AND_MEAN
  13. #define WIN32_LEAN_AND_MEAN 1
  14. #endif
  15. #ifndef NOMINMAX
  16. #define NOMINMAX
  17. #endif
  18. #ifdef FD_SETSIZE
  19. #undef FD_SETSIZE // prevent redefinition compiler warning
  20. #endif
  21. #define FD_SETSIZE 1024 // max number of fds in fd_set
  22. #include <winsock2.h> // Must be included before mswsock.h and windows.h
  23. #include <mswsock.h>
  24. #include <windows.h>
  25. #include <ws2tcpip.h>
  26. #else
  27. #include <sys/fcntl.h>
  28. #include <sys/mman.h>
  29. #include <sys/socket.h>
  30. #include <sys/types.h>
  31. #include <net/if.h>
  32. #include <netinet/in.h>
  33. #include <arpa/inet.h>
  34. #include <ifaddrs.h>
  35. #include <limits.h>
  36. #include <netdb.h>
  37. #include <unistd.h>
  38. #endif
  39. #ifdef WIN32
  40. #define MSG_DONTWAIT 0
  41. #else
  42. typedef u_int SOCKET;
  43. #include "errno.h"
  44. #define WSAGetLastError() errno
  45. #define WSAEINVAL EINVAL
  46. #define WSAEALREADY EALREADY
  47. #define WSAEWOULDBLOCK EWOULDBLOCK
  48. #define WSAEMSGSIZE EMSGSIZE
  49. #define WSAEINTR EINTR
  50. #define WSAEINPROGRESS EINPROGRESS
  51. #define WSAEADDRINUSE EADDRINUSE
  52. #define WSAENOTSOCK EBADF
  53. #define INVALID_SOCKET (SOCKET)(~0)
  54. #define SOCKET_ERROR -1
  55. #endif
  56. #ifdef WIN32
  57. #ifndef S_IRUSR
  58. #define S_IRUSR 0400
  59. #define S_IWUSR 0200
  60. #endif
  61. #else
  62. #define MAX_PATH 1024
  63. #endif
  64. // As Solaris does not have the MSG_NOSIGNAL flag for send(2) syscall, it is defined as 0
  65. #if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
  66. #define MSG_NOSIGNAL 0
  67. #endif
  68. #ifndef WIN32
  69. // PRIO_MAX is not defined on Solaris
  70. #ifndef PRIO_MAX
  71. #define PRIO_MAX 20
  72. #endif
  73. #define THREAD_PRIORITY_LOWEST PRIO_MAX
  74. #define THREAD_PRIORITY_BELOW_NORMAL 2
  75. #define THREAD_PRIORITY_NORMAL 0
  76. #define THREAD_PRIORITY_ABOVE_NORMAL (-2)
  77. #endif
  78. #if HAVE_DECL_STRNLEN == 0
  79. size_t strnlen( const char *start, size_t max_len);
  80. #endif // HAVE_DECL_STRNLEN
  81. #endif // BITCOIN_COMPAT_H