niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 +0000 | [diff] [blame^] | 11 | // This file contains platform-specific typedefs and defines. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 +0000 | [diff] [blame^] | 13 | #ifndef WEBRTC_TYPEDEFS_H_ |
| 14 | #define WEBRTC_TYPEDEFS_H_ |
| 15 | |
| 16 | // Reserved words definitions |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 17 | #define WEBRTC_EXTERN extern |
| 18 | #define G_CONST const |
| 19 | #define WEBRTC_INLINE extern __inline |
| 20 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 +0000 | [diff] [blame^] | 21 | // Define WebRTC preprocessor identifiers based on the current build platform. |
| 22 | // TODO(ajm): Clean these up. We can probably remove everything in this block. |
| 23 | // - TARGET_MAC_INTEL and TARGET_MAC aren't used anywhere. |
| 24 | // - In the few places where TARGET_PC is used, it should be replaced by |
| 25 | // something more specific. |
| 26 | // - Do we really support PowerPC? Probably not. Remove WEBRTC_MAC_INTEL |
| 27 | // from build/common.gypi as well. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 28 | #if defined(WIN32) |
| 29 | // Windows & Windows Mobile |
| 30 | #if !defined(WEBRTC_TARGET_PC) |
| 31 | #define WEBRTC_TARGET_PC |
| 32 | #endif |
| 33 | #elif defined(__APPLE__) |
| 34 | // Mac OS X |
| 35 | #if defined(__LITTLE_ENDIAN__ ) //TODO: is this used? |
| 36 | #if !defined(WEBRTC_TARGET_MAC_INTEL) |
| 37 | #define WEBRTC_TARGET_MAC_INTEL |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 +0000 | [diff] [blame^] | 38 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | #else |
| 40 | #if !defined(WEBRTC_TARGET_MAC) |
| 41 | #define WEBRTC_TARGET_MAC |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 +0000 | [diff] [blame^] | 42 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | #endif |
| 44 | #else |
| 45 | // Linux etc. |
| 46 | #if !defined(WEBRTC_TARGET_PC) |
| 47 | #define WEBRTC_TARGET_PC |
| 48 | #endif |
| 49 | #endif |
| 50 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 +0000 | [diff] [blame^] | 51 | // Derived from Chromium's build/build_config.h |
| 52 | // Processor architecture detection. For more info on what's defined, see: |
| 53 | // http://msdn.microsoft.com/en-us/library/b0084kay.aspx |
| 54 | // http://www.agner.org/optimize/calling_conventions.pdf |
| 55 | // or with gcc, run: "echo | gcc -E -dM -" |
| 56 | // TODO(ajm): replace WEBRTC_LITTLE_ENDIAN with WEBRTC_ARCH_LITTLE_ENDIAN? |
| 57 | #if defined(_M_X64) || defined(__x86_64__) |
| 58 | #define WEBRTC_ARCH_X86_FAMILY |
| 59 | #define WEBRTC_ARCH_X86_64 |
| 60 | #define WEBRTC_ARCH_64_BITS |
| 61 | #define WEBRTC_ARCH_LITTLE_ENDIAN |
| 62 | #elif defined(_M_IX86) || defined(__i386__) |
| 63 | #define WEBRTC_ARCH_X86_FAMILY |
| 64 | #define WEBRTC_ARCH_X86 |
| 65 | #define WEBRTC_ARCH_32_BITS |
| 66 | #define WEBRTC_ARCH_LITTLE_ENDIAN |
| 67 | #elif defined(__ARMEL__) |
| 68 | // TODO(ajm): Chromium uses the two commented defines. Should we switch? |
| 69 | #define WEBRTC_ARCH_ARM |
| 70 | //#define WEBRTC_ARCH_ARM_FAMILY |
| 71 | //#define WEBRTC_ARCH_ARMEL |
| 72 | #define WEBRTC_ARCH_32_BITS |
| 73 | #define WEBRTC_ARCH_LITTLE_ENDIAN |
| 74 | #else |
| 75 | #error Please add support for your architecture in typedefs.h |
| 76 | #endif |
| 77 | |
| 78 | // TODO(ajm): SSE2 is disabled on Windows for the moment, because AEC |
| 79 | // optimization is broken. Enable it as soon as AEC is fixed. |
| 80 | //#if defined(__SSE2__) || defined(_MSC_VER) |
| 81 | #if defined(__SSE2__) |
| 82 | #define WEBRTC_USE_SSE2 |
| 83 | #endif |
| 84 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | #if defined(WEBRTC_TARGET_PC) |
| 86 | |
| 87 | #if !defined(_MSC_VER) |
| 88 | #include <stdint.h> |
| 89 | #else |
| 90 | // Define C99 equivalent types. |
| 91 | // Since MSVC doesn't include these headers, we have to write our own |
| 92 | // version to provide a compatibility layer between MSVC and the WebRTC |
| 93 | // headers. |
| 94 | typedef signed char int8_t; |
| 95 | typedef signed short int16_t; |
| 96 | typedef signed int int32_t; |
| 97 | typedef signed long long int64_t; |
| 98 | typedef unsigned char uint8_t; |
| 99 | typedef unsigned short uint16_t; |
| 100 | typedef unsigned int uint32_t; |
| 101 | typedef unsigned long long uint64_t; |
| 102 | #endif |
| 103 | |
| 104 | #if defined(WIN32) |
| 105 | typedef __int64 WebRtc_Word64; |
| 106 | typedef unsigned __int64 WebRtc_UWord64; |
| 107 | #else |
| 108 | typedef int64_t WebRtc_Word64; |
| 109 | typedef uint64_t WebRtc_UWord64; |
| 110 | #endif |
| 111 | typedef int32_t WebRtc_Word32; |
| 112 | typedef uint32_t WebRtc_UWord32; |
| 113 | typedef int16_t WebRtc_Word16; |
| 114 | typedef uint16_t WebRtc_UWord16; |
| 115 | typedef char WebRtc_Word8; |
| 116 | typedef uint8_t WebRtc_UWord8; |
| 117 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 +0000 | [diff] [blame^] | 118 | // Define endian for the platform |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | #define WEBRTC_LITTLE_ENDIAN |
| 120 | |
| 121 | #elif defined(WEBRTC_TARGET_MAC_INTEL) |
| 122 | #include <stdint.h> |
| 123 | |
| 124 | typedef int64_t WebRtc_Word64; |
| 125 | typedef uint64_t WebRtc_UWord64; |
| 126 | typedef int32_t WebRtc_Word32; |
| 127 | typedef uint32_t WebRtc_UWord32; |
| 128 | typedef int16_t WebRtc_Word16; |
| 129 | typedef char WebRtc_Word8; |
| 130 | typedef uint16_t WebRtc_UWord16; |
| 131 | typedef uint8_t WebRtc_UWord8; |
| 132 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 +0000 | [diff] [blame^] | 133 | // Define endian for the platform |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 134 | #define WEBRTC_LITTLE_ENDIAN |
| 135 | |
| 136 | #else |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 +0000 | [diff] [blame^] | 137 | #error "No platform defined for WebRTC type definitions (typedefs.h)" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 138 | #endif |
| 139 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 +0000 | [diff] [blame^] | 140 | #endif // WEBRTC_TYPEDEFS_H_ |