init.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include <util/system/error.h>
  3. #if defined(_unix_)
  4. #include <fcntl.h>
  5. #include <netdb.h>
  6. #include <time.h>
  7. #include <unistd.h>
  8. #include <poll.h>
  9. #include <sys/uio.h>
  10. #include <sys/time.h>
  11. #include <sys/types.h>
  12. #include <sys/socket.h>
  13. #include <netinet/in.h>
  14. #include <netinet/tcp.h>
  15. #include <arpa/inet.h>
  16. using SOCKET = int;
  17. #define closesocket(s) close(s)
  18. #define SOCKET_ERROR -1
  19. #define INVALID_SOCKET -1
  20. #define WSAGetLastError() errno
  21. #elif defined(_win_)
  22. #include <util/system/winint.h>
  23. #include <io.h>
  24. #include <winsock2.h>
  25. #include <ws2tcpip.h>
  26. using nfds_t = ULONG;
  27. #undef Yield
  28. struct sockaddr_un {
  29. short sun_family;
  30. char sun_path[108];
  31. };
  32. #define PF_LOCAL AF_UNIX
  33. #define NETDB_INTERNAL -1
  34. #define NETDB_SUCCESS 0
  35. #endif
  36. #if defined(_win_) || defined(_darwin_)
  37. #ifndef MSG_NOSIGNAL
  38. #define MSG_NOSIGNAL 0
  39. #endif
  40. #endif // _win_ or _darwin_
  41. void InitNetworkSubSystem();
  42. static struct TNetworkInitializer {
  43. inline TNetworkInitializer() {
  44. InitNetworkSubSystem();
  45. }
  46. } NetworkInitializerObject;