1 /* 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 // This file contains platform-specific typedefs and defines. 12 13 #ifndef WEBRTC_TYPEDEFS_H_ 14 #define WEBRTC_TYPEDEFS_H_ 15 16 // Reserved words definitions 17 // TODO(andrew): Look at removing these. 18 #define WEBRTC_EXTERN extern 19 #define G_CONST const 20 #define WEBRTC_INLINE extern __inline 21 22 // Define WebRTC preprocessor identifiers based on the current build platform. 23 // TODO(andrew): Clean these up. We can probably remove everything in this 24 // block. 25 // - TARGET_MAC_INTEL and TARGET_MAC aren't used anywhere. 26 // - In the few places where TARGET_PC is used, it should be replaced by 27 // something more specific. 28 // - Do we really support PowerPC? Probably not. Remove WEBRTC_MAC_INTEL 29 // from build/common.gypi as well. 30 #if defined(WIN32) 31 // Windows & Windows Mobile. 32 #if !defined(WEBRTC_TARGET_PC) 33 #define WEBRTC_TARGET_PC 34 #endif 35 #elif defined(__APPLE__) 36 // Mac OS X. 37 #if defined(__LITTLE_ENDIAN__ ) 38 #if !defined(WEBRTC_TARGET_MAC_INTEL) 39 #define WEBRTC_TARGET_MAC_INTEL 40 #endif 41 #else 42 #if !defined(WEBRTC_TARGET_MAC) 43 #define WEBRTC_TARGET_MAC 44 #endif 45 #endif 46 #else 47 // Linux etc. 48 #if !defined(WEBRTC_TARGET_PC) 49 #define WEBRTC_TARGET_PC 50 #endif 51 #endif 52 53 // Derived from Chromium's build/build_config.h 54 // Processor architecture detection. For more info on what's defined, see: 55 // http://msdn.microsoft.com/en-us/library/b0084kay.aspx 56 // http://www.agner.org/optimize/calling_conventions.pdf 57 // or with gcc, run: "echo | gcc -E -dM -" 58 // TODO(andrew): replace WEBRTC_LITTLE_ENDIAN with WEBRTC_ARCH_LITTLE_ENDIAN? 59 #if defined(_M_X64) || defined(__x86_64__) 60 #define WEBRTC_ARCH_X86_FAMILY 61 #define WEBRTC_ARCH_X86_64 62 #define WEBRTC_ARCH_64_BITS 63 #define WEBRTC_ARCH_LITTLE_ENDIAN 64 #elif defined(_M_IX86) || defined(__i386__) 65 #define WEBRTC_ARCH_X86_FAMILY 66 #define WEBRTC_ARCH_X86 67 #define WEBRTC_ARCH_32_BITS 68 #define WEBRTC_ARCH_LITTLE_ENDIAN 69 #elif defined(__ARMEL__) 70 // TODO(andrew): We'd prefer to control platform defines here, but this is 71 // currently provided by the Android makefiles. Commented to avoid duplicate 72 // definition warnings. 73 //#define WEBRTC_ARCH_ARM 74 // TODO(andrew): Chromium uses the following two defines. Should we switch? 75 //#define WEBRTC_ARCH_ARM_FAMILY 76 //#define WEBRTC_ARCH_ARMEL 77 #define WEBRTC_ARCH_32_BITS 78 #define WEBRTC_ARCH_LITTLE_ENDIAN 79 #elif defined(__aarch64__) 80 #define WEBRTC_ARCH_64_BITS 81 #define WEBRTC_ARCH_LITTLE_ENDIAN 82 #elif defined(__mips__) 83 #define WEBRTC_ARCH_32_BITS 84 #define WEBRTC_ARCH_LITTLE_ENDIAN 85 #else 86 #error Please add support for your architecture in typedefs.h 87 #endif 88 89 #if defined(__SSE2__) || defined(_MSC_VER) 90 #define WEBRTC_USE_SSE2 91 #endif 92 93 #if defined(WEBRTC_TARGET_PC) 94 95 #if !defined(_MSC_VER) 96 #include <stdint.h> 97 #else 98 // Define C99 equivalent types. 99 // Since MSVC doesn't include these headers, we have to write our own 100 // version to provide a compatibility layer between MSVC and the WebRTC 101 // headers. 102 typedef signed char int8_t; 103 typedef signed short int16_t; 104 typedef signed int int32_t; 105 typedef signed long long int64_t; 106 typedef unsigned char uint8_t; 107 typedef unsigned short uint16_t; 108 typedef unsigned int uint32_t; 109 typedef unsigned long long uint64_t; 110 #endif 111 112 #if defined(WIN32) 113 typedef __int64 WebRtc_Word64; 114 typedef unsigned __int64 WebRtc_UWord64; 115 #else 116 typedef int64_t WebRtc_Word64; 117 typedef uint64_t WebRtc_UWord64; 118 #endif 119 typedef int32_t WebRtc_Word32; 120 typedef uint32_t WebRtc_UWord32; 121 typedef int16_t WebRtc_Word16; 122 typedef uint16_t WebRtc_UWord16; 123 typedef char WebRtc_Word8; 124 typedef uint8_t WebRtc_UWord8; 125 126 // Define endian for the platform 127 #define WEBRTC_LITTLE_ENDIAN 128 129 #elif defined(WEBRTC_TARGET_MAC_INTEL) 130 #include <stdint.h> 131 132 typedef int64_t WebRtc_Word64; 133 typedef uint64_t WebRtc_UWord64; 134 typedef int32_t WebRtc_Word32; 135 typedef uint32_t WebRtc_UWord32; 136 typedef int16_t WebRtc_Word16; 137 typedef char WebRtc_Word8; 138 typedef uint16_t WebRtc_UWord16; 139 typedef uint8_t WebRtc_UWord8; 140 141 // Define endian for the platform 142 #define WEBRTC_LITTLE_ENDIAN 143 144 #else 145 #error "No platform defined for WebRTC type definitions (typedefs.h)" 146 #endif 147 148 #endif // WEBRTC_TYPEDEFS_H_ 149