platform_sys.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * SRT - Secure, Reliable, Transport
  3. * Copyright (c) 2018 Haivision Systems Inc.
  4. *
  5. * This Source Code Form is subject to the terms of the Mozilla Public
  6. * License, v. 2.0. If a copy of the MPL was not distributed with this
  7. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  8. *
  9. */
  10. #ifndef INC_SRT_PLATFORM_SYS_H
  11. #define INC_SRT_PLATFORM_SYS_H
  12. // INFORMATION
  13. //
  14. // This file collects all required platform-specific declarations
  15. // required to provide everything that the SRT library needs from system.
  16. //
  17. // There's also semi-modular system implemented using SRT_IMPORT_* macros.
  18. // To require a module to be imported, #define SRT_IMPORT_* where * is
  19. // the module name. Currently handled module macros:
  20. //
  21. // SRT_IMPORT_TIME (mach time on Mac, portability gettimeofday on WIN32)
  22. // SRT_IMPORT_EVENT (includes kevent on Mac)
  23. #ifdef _WIN32
  24. #define _CRT_SECURE_NO_WARNINGS 1 // silences windows complaints for sscanf
  25. #include <winsock2.h>
  26. #include <ws2tcpip.h>
  27. #include <ws2ipdef.h>
  28. #include <windows.h>
  29. #ifndef __MINGW__
  30. #include <intrin.h>
  31. #endif
  32. #ifdef SRT_IMPORT_TIME
  33. #include <win/wintime.h>
  34. #endif
  35. #include <stdint.h>
  36. #include <inttypes.h>
  37. #if defined(_MSC_VER)
  38. #pragma warning(disable:4251)
  39. #endif
  40. #else
  41. #if __APPLE__
  42. // XXX Check if this condition doesn't require checking of
  43. // also other macros, like TARGET_OS_IOS etc.
  44. #include "TargetConditionals.h"
  45. #define __APPLE_USE_RFC_3542 /* IPV6_PKTINFO */
  46. #ifdef SRT_IMPORT_TIME
  47. #include <mach/mach_time.h>
  48. #endif
  49. #ifdef SRT_IMPORT_EVENT
  50. #include <sys/types.h>
  51. #include <sys/event.h>
  52. #include <sys/time.h>
  53. #include <unistd.h>
  54. #endif
  55. #endif
  56. #ifdef BSD
  57. #ifdef SRT_IMPORT_EVENT
  58. #include <sys/types.h>
  59. #include <sys/event.h>
  60. #include <sys/time.h>
  61. #include <unistd.h>
  62. #endif
  63. #endif
  64. #ifdef LINUX
  65. #ifdef SRT_IMPORT_EVENT
  66. #include <sys/epoll.h>
  67. #include <unistd.h>
  68. #endif
  69. #endif
  70. #ifdef __ANDROID__
  71. #ifdef SRT_IMPORT_EVENT
  72. #include <sys/select.h>
  73. #endif
  74. #endif
  75. #include <sys/types.h>
  76. #include <sys/socket.h>
  77. #include <sys/ioctl.h>
  78. #include <sys/time.h>
  79. #include <netdb.h>
  80. #include <netinet/in.h>
  81. #include <arpa/inet.h>
  82. #include <unistd.h>
  83. #include <fcntl.h>
  84. #ifdef __cplusplus
  85. // Headers for errno, string and stdlib are
  86. // included indirectly correct C++ way.
  87. #else
  88. #include <errno.h>
  89. #include <string.h>
  90. #include <stdlib.h>
  91. #endif
  92. #endif
  93. #endif