| 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 |
|
| 13 |
// INFORMATION |
| 14 |
// |
| 15 |
// This file collects all required platform-specific declarations |
| 16 |
// required to provide everything that the SRT library needs from system. |
| 17 |
// |
| 18 |
// There's also semi-modular system implemented using SRT_IMPORT_* macros. |
| 19 |
// To require a module to be imported, #define SRT_IMPORT_* where * is |
| 20 |
// the module name. Currently handled module macros: |
| 21 |
// |
| 22 |
// SRT_IMPORT_TIME (mach time on Mac, portability gettimeofday on WIN32) |
| 23 |
// SRT_IMPORT_EVENT (includes kevent on Mac) |
| 24 |
#ifdef _WIN32 |
| 25 |
#ifndef __MINGW32__ |
| 26 |
// Explicitly define 32-bit and 64-bit numbers |
| 27 |
typedef __int32 int32_t; |
| 28 |
typedef __int64 int64_t; |
| 29 |
typedef unsigned __int32 uint32_t; |
| 30 |
#ifndef LEGACY_WIN32 |
| 31 |
typedef unsigned __int64 uint64_t; |
| 32 |
#else |
| 33 |
// VC 6.0 does not support unsigned __int64: may cause potential problems. |
| 34 |
typedef __int64 uint64_t; |
| 35 |
#endif |
| 36 |
#endif |
| 37 |
#endif |
| 38 |
|
| 39 |
|
| 40 |
#ifdef _WIN32 |
| 41 |
#include <winsock2.h> |
| 42 |
#include <ws2tcpip.h> |
| 43 |
#include <ws2ipdef.h> |
| 44 |
#include <windows.h> |
| 45 |
|
| 46 |
#ifndef __MINGW32__ |
| 47 |
#include <intrin.h> |
| 48 |
#endif |
| 49 |
|
| 50 |
#ifdef SRT_IMPORT_TIME |
| 51 |
#include <win/wintime.h> |
| 52 |
#endif |
| 53 |
|
| 54 |
#include <stdint.h> |
| 55 |
#include <inttypes.h> |
| 56 |
#else |
| 57 |
|
| 58 |
#if defined(__APPLE__) && __APPLE__ |
| 59 |
// Warning: please keep this test as it is, do not make it |
| 60 |
// "#if __APPLE__" or "#ifdef __APPLE__". In applications with |
| 61 |
// a strict "no warning policy", "#if __APPLE__" triggers an "undef" |
| 62 |
// error. With GCC, an old & never fixed bug prevents muting this |
| 63 |
// warning (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431). |
| 64 |
// Before this fix, the solution was to "#define __APPLE__ 0" before |
| 65 |
// including srt.h. So, don't use "#ifdef __APPLE__" either. |
| 66 |
|
| 67 |
// XXX Check if this condition doesn't require checking of |
| 68 |
// also other macros, like TARGET_OS_IOS etc. |
| 69 |
|
| 70 |
#include "TargetConditionals.h" |
| 71 |
#ifndef __APPLE_USE_RFC_3542 |
| 72 |
#define __APPLE_USE_RFC_3542 /* IPV6_PKTINFO */ |
| 73 |
#endif |
| 74 |
|
| 75 |
#ifdef SRT_IMPORT_TIME |
| 76 |
#include <mach/mach_time.h> |
| 77 |
#endif |
| 78 |
|
| 79 |
#ifdef SRT_IMPORT_EVENT |
| 80 |
#include <sys/types.h> |
| 81 |
#include <sys/event.h> |
| 82 |
#include <sys/time.h> |
| 83 |
#include <unistd.h> |
| 84 |
#endif |
| 85 |
|
| 86 |
#endif |
| 87 |
|
| 88 |
#ifdef BSD |
| 89 |
#ifdef SRT_IMPORT_EVENT |
| 90 |
#include <sys/types.h> |
| 91 |
#include <sys/event.h> |
| 92 |
#include <sys/time.h> |
| 93 |
#include <unistd.h> |
| 94 |
#endif |
| 95 |
#endif |
| 96 |
|
| 97 |
#ifdef LINUX |
| 98 |
|
| 99 |
#ifdef SRT_IMPORT_EVENT |
| 100 |
#include <sys/epoll.h> |
| 101 |
#include <unistd.h> |
| 102 |
#endif |
| 103 |
|
| 104 |
#endif |
| 105 |
|
| 106 |
#ifdef __ANDROID__ |
| 107 |
|
| 108 |
#ifdef SRT_IMPORT_EVENT |
| 109 |
#include <sys/select.h> |
| 110 |
#endif |
| 111 |
|
| 112 |
#endif |
| 113 |
|
| 114 |
#include <sys/types.h> |
| 115 |
#include <sys/socket.h> |
| 116 |
#include <sys/ioctl.h> |
| 117 |
#include <sys/time.h> |
| 118 |
#include <netdb.h> |
| 119 |
#include <netinet/in.h> |
| 120 |
#include <arpa/inet.h> |
| 121 |
#include <unistd.h> |
| 122 |
#include <fcntl.h> |
| 123 |
|
| 124 |
#ifdef __cplusplus |
| 125 |
// Headers for errno, string and stdlib are |
| 126 |
// included indirectly correct C++ way. |
| 127 |
#else |
| 128 |
#include <errno.h> |
| 129 |
#include <string.h> |
| 130 |
#include <stdlib.h> |
| 131 |
#endif |
| 132 |
|
| 133 |
#endif |
| 134 |
|
| 135 |
#endif |