blob: ca3b509c0006701bd003e3549287b63e4d4c8b5e [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:251/*
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.comce7c2a22011-08-04 01:50:0011// This file contains platform-specific typedefs and defines.
niklase@google.com470e71d2011-07-07 08:21:2512
ajm@google.comce7c2a22011-08-04 01:50:0013#ifndef WEBRTC_TYPEDEFS_H_
14#define WEBRTC_TYPEDEFS_H_
15
16// Reserved words definitions
andrew@webrtc.orgb8015712011-09-08 18:37:5917// TODO(andrew): Look at removing these.
niklase@google.com470e71d2011-07-07 08:21:2518#define WEBRTC_EXTERN extern
19#define G_CONST const
20#define WEBRTC_INLINE extern __inline
21
ajm@google.comce7c2a22011-08-04 01:50:0022// Define WebRTC preprocessor identifiers based on the current build platform.
andrew@webrtc.orgb8015712011-09-08 18:37:5923// TODO(andrew): Clean these up. We can probably remove everything in this
24// block.
ajm@google.comce7c2a22011-08-04 01:50:0025// - 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.com470e71d2011-07-07 08:21:2530#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.orgb8015712011-09-08 18:37:5937 #if defined(__LITTLE_ENDIAN__ )
niklase@google.com470e71d2011-07-07 08:21:2538 #if !defined(WEBRTC_TARGET_MAC_INTEL)
39 #define WEBRTC_TARGET_MAC_INTEL
ajm@google.comce7c2a22011-08-04 01:50:0040 #endif
niklase@google.com470e71d2011-07-07 08:21:2541 #else
42 #if !defined(WEBRTC_TARGET_MAC)
43 #define WEBRTC_TARGET_MAC
ajm@google.comce7c2a22011-08-04 01:50:0044 #endif
niklase@google.com470e71d2011-07-07 08:21:2545 #endif
46#else
47 // Linux etc.
48 #if !defined(WEBRTC_TARGET_PC)
49 #define WEBRTC_TARGET_PC
50 #endif
51#endif
52
ajm@google.comce7c2a22011-08-04 01:50:0053// 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.orgb8015712011-09-08 18:37:5958// TODO(andrew): replace WEBRTC_LITTLE_ENDIAN with WEBRTC_ARCH_LITTLE_ENDIAN?
ajm@google.comce7c2a22011-08-04 01:50:0059#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.orgb8015712011-09-08 18:37:5970// 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.comce7c2a22011-08-04 01:50:0075//#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.org86b85db2011-09-19 18:48:2583#if defined(__SSE2__) || defined(_MSC_VER)
ajm@google.comce7c2a22011-08-04 01:50:0084#define WEBRTC_USE_SSE2
85#endif
86
niklase@google.com470e71d2011-07-07 08:21:2587#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.comce7c2a22011-08-04 01:50:00120 // Define endian for the platform
niklase@google.com470e71d2011-07-07 08:21:25121 #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.comce7c2a22011-08-04 01:50:00135 // Define endian for the platform
niklase@google.com470e71d2011-07-07 08:21:25136 #define WEBRTC_LITTLE_ENDIAN
137
138#else
ajm@google.comce7c2a22011-08-04 01:50:00139 #error "No platform defined for WebRTC type definitions (typedefs.h)"
niklase@google.com470e71d2011-07-07 08:21:25140#endif
141
ajm@google.comce7c2a22011-08-04 01:50:00142#endif // WEBRTC_TYPEDEFS_H_