OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_BASE_BASICTYPES_H_ | 11 #ifndef WEBRTC_BASE_BASICTYPES_H_ |
12 #define WEBRTC_BASE_BASICTYPES_H_ | 12 #define WEBRTC_BASE_BASICTYPES_H_ |
13 | 13 |
14 #include <stddef.h> // for NULL, size_t | 14 #include <stddef.h> // for NULL, size_t |
Andrew MacDonald
2015/09/17 17:03:14
Needed?
Henrik Grunell WebRTC
2015/09/18 07:27:23
It seems that we rely on that it's here. We includ
| |
15 | |
16 #if !(defined(_MSC_VER) && (_MSC_VER < 1600)) | |
17 #include <stdint.h> // for uintptr_t | 15 #include <stdint.h> // for uintptr_t |
18 #endif | |
19 | 16 |
20 #ifdef HAVE_CONFIG_H | 17 #ifdef HAVE_CONFIG_H |
21 #include "config.h" // NOLINT | 18 #include "config.h" // NOLINT |
22 #endif | 19 #endif |
23 | 20 |
24 #include "webrtc/base/constructormagic.h" | 21 #include "webrtc/base/constructormagic.h" |
Andrew MacDonald
2015/09/17 17:03:13
This doesn't appear to be needed.
Henrik Grunell WebRTC
2015/09/18 07:27:23
Right, removed.
| |
25 | 22 |
26 #if !defined(INT_TYPES_DEFINED) | 23 // TODO(grunell): Use (u)intxx_t everywhere instead and remove these typedefs. |
27 #define INT_TYPES_DEFINED | 24 typedef int8_t int8; |
28 #ifdef COMPILER_MSVC | 25 typedef uint8_t uint8; |
29 typedef unsigned __int64 uint64; | 26 typedef int16_t int16; |
30 typedef __int64 int64; | 27 typedef uint16_t uint16; |
31 #ifndef INT64_C | 28 typedef int32_t int32; |
32 #define INT64_C(x) x ## I64 | 29 typedef uint32_t uint32; |
33 #endif | 30 typedef int64_t int64; |
34 #ifndef UINT64_C | |
35 #define UINT64_C(x) x ## UI64 | |
36 #endif | |
37 #define INT64_F "I64" | |
38 #else // COMPILER_MSVC | |
39 // On Mac OS X, cssmconfig.h defines uint64 as uint64_t | |
40 // TODO(fbarchard): Use long long for compatibility with chromium on BSD/OSX. | |
41 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) | |
42 typedef uint64_t uint64; | 31 typedef uint64_t uint64; |
43 typedef int64_t int64; | |
44 #ifndef INT64_C | |
45 #define INT64_C(x) x ## LL | |
46 #endif | |
47 #ifndef UINT64_C | |
48 #define UINT64_C(x) x ## ULL | |
49 #endif | |
50 #define INT64_F "l" | |
51 #elif defined(__LP64__) | |
52 typedef unsigned long long uint64; // NOLINT | |
53 typedef long long int64; // NOLINT | |
54 #ifndef INT64_C | |
55 #define INT64_C(x) x ## L | |
56 #endif | |
57 #ifndef UINT64_C | |
58 #define UINT64_C(x) x ## UL | |
59 #endif | |
60 #define INT64_F "l" | |
61 #else // __LP64__ | |
62 typedef unsigned long long uint64; // NOLINT | |
63 typedef long long int64; // NOLINT | |
64 #ifndef INT64_C | |
65 #define INT64_C(x) x ## LL | |
66 #endif | |
67 #ifndef UINT64_C | |
68 #define UINT64_C(x) x ## ULL | |
69 #endif | |
70 #define INT64_F "ll" | |
71 #endif // __LP64__ | |
72 #endif // COMPILER_MSVC | |
73 typedef unsigned int uint32; | |
74 typedef int int32; | |
75 typedef unsigned short uint16; // NOLINT | |
76 typedef short int16; // NOLINT | |
77 typedef unsigned char uint8; | |
78 typedef signed char int8; | |
79 #endif // INT_TYPES_DEFINED | |
80 | 32 |
81 // Detect compiler is for x86 or x64. | 33 // Detect compiler is for x86 or x64. |
82 #if defined(__x86_64__) || defined(_M_X64) || \ | 34 #if defined(__x86_64__) || defined(_M_X64) || \ |
83 defined(__i386__) || defined(_M_IX86) | 35 defined(__i386__) || defined(_M_IX86) |
84 #define CPU_X86 1 | 36 #define CPU_X86 1 |
85 #endif | 37 #endif |
86 // Detect compiler is for arm. | 38 // Detect compiler is for arm. |
87 #if defined(__arm__) || defined(_M_ARM) | 39 #if defined(__arm__) || defined(_M_ARM) |
88 #define CPU_ARM 1 | 40 #define CPU_ARM 1 |
89 #endif | 41 #endif |
90 #if defined(CPU_X86) && defined(CPU_ARM) | 42 #if defined(CPU_X86) && defined(CPU_ARM) |
91 #error CPU_X86 and CPU_ARM both defined. | 43 #error CPU_X86 and CPU_ARM both defined. |
92 #endif | 44 #endif |
93 #if !defined(ARCH_CPU_BIG_ENDIAN) && !defined(ARCH_CPU_LITTLE_ENDIAN) | 45 #if !defined(RTC_ARCH_CPU_BIG_ENDIAN) && !defined(RTC_ARCH_CPU_LITTLE_ENDIAN) |
Andrew MacDonald
2015/09/17 17:03:13
Just curious why you chose to rename these ARCH_CP
Henrik Grunell WebRTC
2015/09/18 07:27:23
Well, only this one is defined in Chromium so it c
| |
94 // x86, arm or GCC provided __BYTE_ORDER__ macros | 46 // x86, arm or GCC provided __BYTE_ORDER__ macros |
95 #if CPU_X86 || CPU_ARM || \ | 47 #if CPU_X86 || CPU_ARM || \ |
96 (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) | 48 (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) |
97 #define ARCH_CPU_LITTLE_ENDIAN | 49 #define RTC_ARCH_CPU_LITTLE_ENDIAN |
98 #elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | 50 #elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
99 #define ARCH_CPU_BIG_ENDIAN | 51 #define RTC_ARCH_CPU_BIG_ENDIAN |
100 #else | 52 #else |
101 #error ARCH_CPU_BIG_ENDIAN or ARCH_CPU_LITTLE_ENDIAN should be defined. | 53 #error RTC_ARCH_CPU_BIG_ENDIAN or RTC_ARCH_CPU_LITTLE_ENDIAN should be defined. |
102 #endif | 54 #endif |
103 #endif | 55 #endif |
104 #if defined(ARCH_CPU_BIG_ENDIAN) && defined(ARCH_CPU_LITTLE_ENDIAN) | 56 #if defined(RTC_ARCH_CPU_BIG_ENDIAN) && defined(RTC_ARCH_CPU_LITTLE_ENDIAN) |
105 #error ARCH_CPU_BIG_ENDIAN and ARCH_CPU_LITTLE_ENDIAN both defined. | 57 #error RTC_ARCH_CPU_BIG_ENDIAN and RTC_ARCH_CPU_LITTLE_ENDIAN both defined. |
106 #endif | 58 #endif |
107 | 59 |
108 #if defined(WEBRTC_WIN) | 60 #if defined(WEBRTC_WIN) |
109 typedef int socklen_t; | 61 typedef int socklen_t; |
110 #endif | 62 #endif |
111 | 63 |
112 // The following only works for C++ | 64 // The following only works for C++ |
113 #ifdef __cplusplus | 65 #ifdef __cplusplus |
114 #ifndef ALIGNP | 66 #ifndef ALIGNP |
115 #define ALIGNP(p, t) \ | 67 #define ALIGNP(p, t) \ |
116 (reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \ | 68 (reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \ |
Andrew MacDonald
2015/09/17 17:03:14
uint8_t
Henrik Grunell WebRTC
2015/09/18 07:27:23
Done.
| |
117 ((t) - 1)) & ~((t) - 1)))) | 69 ((t) - 1)) & ~((t) - 1)))) |
118 #endif | 70 #endif |
119 #define RTC_IS_ALIGNED(p, a) (!((uintptr_t)(p) & ((a) - 1))) | 71 #define RTC_IS_ALIGNED(p, a) (!((uintptr_t)(p) & ((a) - 1))) |
120 | 72 |
121 // Use these to declare and define a static local variable (static T;) so that | 73 // Use these to declare and define a static local variable (static T;) so that |
122 // it is leaked so that its destructors are not called at exit. | 74 // it is leaked so that its destructors are not called at exit. |
Andrew MacDonald
2015/09/17 17:03:13
Sorry, would you mind rewriting this?
Remove "(sta
Henrik Grunell WebRTC
2015/09/18 07:27:23
Absolutely. Done.
| |
123 #define RTC_DEFINE_STATIC_LOCAL(type, name, arguments) \ | 75 #define RTC_DEFINE_STATIC_LOCAL(type, name, arguments) \ |
124 static type& name = *new type arguments | 76 static type& name = *new type arguments |
125 | 77 |
126 #endif // __cplusplus | 78 #endif // __cplusplus |
127 #endif // WEBRTC_BASE_BASICTYPES_H_ | 79 #endif // WEBRTC_BASE_BASICTYPES_H_ |
OLD | NEW |