niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [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 | [diff] [blame] | 11 | // This file contains platform-specific typedefs and defines. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 12 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 13 | #ifndef WEBRTC_TYPEDEFS_H_ |
| 14 | #define WEBRTC_TYPEDEFS_H_ |
| 15 | |
| 16 | // Reserved words definitions |
andrew@webrtc.org | b801571 | 2011-09-08 18:37:59 | [diff] [blame] | 17 | // TODO(andrew): Look at removing these. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 18 | #define WEBRTC_EXTERN extern |
| 19 | #define G_CONST const |
| 20 | #define WEBRTC_INLINE extern __inline |
| 21 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 22 | // Define WebRTC preprocessor identifiers based on the current build platform. |
andrew@webrtc.org | b801571 | 2011-09-08 18:37:59 | [diff] [blame] | 23 | // TODO(andrew): Clean these up. We can probably remove everything in this |
| 24 | // block. |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 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. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 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 |
andrew@webrtc.org | b801571 | 2011-09-08 18:37:59 | [diff] [blame] | 37 | #if defined(__LITTLE_ENDIAN__ ) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 38 | #if !defined(WEBRTC_TARGET_MAC_INTEL) |
| 39 | #define WEBRTC_TARGET_MAC_INTEL |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 40 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 41 | #else |
| 42 | #if !defined(WEBRTC_TARGET_MAC) |
| 43 | #define WEBRTC_TARGET_MAC |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 44 | #endif |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 45 | #endif |
| 46 | #else |
| 47 | // Linux etc. |
| 48 | #if !defined(WEBRTC_TARGET_PC) |
| 49 | #define WEBRTC_TARGET_PC |
| 50 | #endif |
| 51 | #endif |
| 52 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 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 -" |
andrew@webrtc.org | b801571 | 2011-09-08 18:37:59 | [diff] [blame] | 58 | // TODO(andrew): replace WEBRTC_LITTLE_ENDIAN with WEBRTC_ARCH_LITTLE_ENDIAN? |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 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__) |
andrew@webrtc.org | b801571 | 2011-09-08 18:37:59 | [diff] [blame] | 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? |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 75 | //#define WEBRTC_ARCH_ARM_FAMILY |
| 76 | //#define WEBRTC_ARCH_ARMEL |
| 77 | #define WEBRTC_ARCH_32_BITS |
| 78 | #define WEBRTC_ARCH_LITTLE_ENDIAN |
| 79 | #else |
| 80 | #error Please add support for your architecture in typedefs.h |
| 81 | #endif |
| 82 | |
andrew@webrtc.org | 86b85db | 2011-09-19 18:48:25 | [diff] [blame^] | 83 | #if defined(__SSE2__) || defined(_MSC_VER) |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 84 | #define WEBRTC_USE_SSE2 |
| 85 | #endif |
| 86 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 87 | #if defined(WEBRTC_TARGET_PC) |
| 88 | |
| 89 | #if !defined(_MSC_VER) |
| 90 | #include <stdint.h> |
| 91 | #else |
| 92 | // Define C99 equivalent types. |
| 93 | // Since MSVC doesn't include these headers, we have to write our own |
| 94 | // version to provide a compatibility layer between MSVC and the WebRTC |
| 95 | // headers. |
| 96 | typedef signed char int8_t; |
| 97 | typedef signed short int16_t; |
| 98 | typedef signed int int32_t; |
| 99 | typedef signed long long int64_t; |
| 100 | typedef unsigned char uint8_t; |
| 101 | typedef unsigned short uint16_t; |
| 102 | typedef unsigned int uint32_t; |
| 103 | typedef unsigned long long uint64_t; |
| 104 | #endif |
| 105 | |
| 106 | #if defined(WIN32) |
| 107 | typedef __int64 WebRtc_Word64; |
| 108 | typedef unsigned __int64 WebRtc_UWord64; |
| 109 | #else |
| 110 | typedef int64_t WebRtc_Word64; |
| 111 | typedef uint64_t WebRtc_UWord64; |
| 112 | #endif |
| 113 | typedef int32_t WebRtc_Word32; |
| 114 | typedef uint32_t WebRtc_UWord32; |
| 115 | typedef int16_t WebRtc_Word16; |
| 116 | typedef uint16_t WebRtc_UWord16; |
| 117 | typedef char WebRtc_Word8; |
| 118 | typedef uint8_t WebRtc_UWord8; |
| 119 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 120 | // Define endian for the platform |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 121 | #define WEBRTC_LITTLE_ENDIAN |
| 122 | |
| 123 | #elif defined(WEBRTC_TARGET_MAC_INTEL) |
| 124 | #include <stdint.h> |
| 125 | |
| 126 | typedef int64_t WebRtc_Word64; |
| 127 | typedef uint64_t WebRtc_UWord64; |
| 128 | typedef int32_t WebRtc_Word32; |
| 129 | typedef uint32_t WebRtc_UWord32; |
| 130 | typedef int16_t WebRtc_Word16; |
| 131 | typedef char WebRtc_Word8; |
| 132 | typedef uint16_t WebRtc_UWord16; |
| 133 | typedef uint8_t WebRtc_UWord8; |
| 134 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 135 | // Define endian for the platform |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 136 | #define WEBRTC_LITTLE_ENDIAN |
| 137 | |
| 138 | #else |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 139 | #error "No platform defined for WebRTC type definitions (typedefs.h)" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 140 | #endif |
| 141 | |
ajm@google.com | ce7c2a2 | 2011-08-04 01:50:00 | [diff] [blame] | 142 | #endif // WEBRTC_TYPEDEFS_H_ |