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#else
80#error Please add support for your architecture in typedefs.h
81#endif
82
83#if defined(__SSE2__) || defined(_MSC_VER)
84#define WEBRTC_USE_SSE2
85#endif
86
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
120    // Define endian for the platform
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
135    // Define endian for the platform
136    #define WEBRTC_LITTLE_ENDIAN
137
138#else
139    #error "No platform defined for WebRTC type definitions (typedefs.h)"
140#endif
141
142#endif  // WEBRTC_TYPEDEFS_H_
143