platform_sys.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #include <winsock2.h>
  25. #include <ws2tcpip.h>
  26. #include <ws2ipdef.h>
  27. #include <windows.h>
  28. #ifndef __MINGW32__
  29. #include <intrin.h>
  30. #endif
  31. #ifdef SRT_IMPORT_TIME
  32. #include <win/wintime.h>
  33. #endif
  34. #include <stdint.h>
  35. #include <inttypes.h>
  36. #else
  37. #if defined(__APPLE__) && __APPLE__
  38. // Warning: please keep this test as it is, do not make it
  39. // "#if __APPLE__" or "#ifdef __APPLE__". In applications with
  40. // a strict "no warning policy", "#if __APPLE__" triggers an "undef"
  41. // error. With GCC, an old & never fixed bug prevents muting this
  42. // warning (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431).
  43. // Before this fix, the solution was to "#define __APPLE__ 0" before
  44. // including srt.h. So, don't use "#ifdef __APPLE__" either.
  45. // XXX Check if this condition doesn't require checking of
  46. // also other macros, like TARGET_OS_IOS etc.
  47. #include "TargetConditionals.h"
  48. #define __APPLE_USE_RFC_3542 /* IPV6_PKTINFO */
  49. #ifdef SRT_IMPORT_TIME
  50. #include <mach/mach_time.h>
  51. #endif
  52. #ifdef SRT_IMPORT_EVENT
  53. #include <sys/types.h>
  54. #include <sys/event.h>
  55. #include <sys/time.h>
  56. #include <unistd.h>
  57. #endif
  58. #endif
  59. #ifdef BSD
  60. #ifdef SRT_IMPORT_EVENT
  61. #include <sys/types.h>
  62. #include <sys/event.h>
  63. #include <sys/time.h>
  64. #include <unistd.h>
  65. #endif
  66. #endif
  67. #ifdef LINUX
  68. #ifdef SRT_IMPORT_EVENT
  69. #include <sys/epoll.h>
  70. #include <unistd.h>
  71. #endif
  72. #endif
  73. #ifdef __ANDROID__
  74. #ifdef SRT_IMPORT_EVENT
  75. #include <sys/select.h>
  76. #endif
  77. #endif
  78. #include <sys/types.h>
  79. #include <sys/socket.h>
  80. #include <sys/ioctl.h>
  81. #include <sys/time.h>
  82. #include <netdb.h>
  83. #include <netinet/in.h>
  84. #include <arpa/inet.h>
  85. #include <unistd.h>
  86. #include <fcntl.h>
  87. #ifdef __cplusplus
  88. // Headers for errno, string and stdlib are
  89. // included indirectly correct C++ way.
  90. #else
  91. #include <errno.h>
  92. #include <string.h>
  93. #include <stdlib.h>
  94. #endif
  95. #endif
  96. #endif