OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // This file overrides the inclusion of talk/base/basictypes.h to remove | |
6 // collisions with Chromium's base/basictypes.h. We then add back a few | |
7 // items that Chromium's version doesn't provide, but libjingle expects. | |
8 | |
9 #ifndef OVERRIDES_TALK_BASE_BASICTYPES_H__ | |
10 #define OVERRIDES_TALK_BASE_BASICTYPES_H__ | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "build/build_config.h" | |
14 | |
15 #ifndef INT_TYPES_DEFINED | |
16 #define INT_TYPES_DEFINED | |
17 | |
18 #ifdef COMPILER_MSVC | |
19 #if _MSC_VER >= 1600 | |
20 #include <stdint.h> | |
21 #else | |
22 typedef unsigned __int64 uint64; | |
23 typedef __int64 int64; | |
24 #endif | |
25 #ifndef INT64_C | |
26 #define INT64_C(x) x ## I64 | |
27 #endif | |
28 #ifndef UINT64_C | |
29 #define UINT64_C(x) x ## UI64 | |
30 #endif | |
31 #define INT64_F "I64" | |
32 #else // COMPILER_MSVC | |
33 #ifndef INT64_C | |
34 #define INT64_C(x) x ## LL | |
35 #endif | |
36 #ifndef UINT64_C | |
37 #define UINT64_C(x) x ## ULL | |
38 #endif | |
39 #ifndef INT64_F | |
40 #define INT64_F "ll" | |
41 #endif | |
42 #endif // COMPILER_MSVC | |
43 #endif // INT_TYPES_DEFINED | |
44 | |
45 // Detect compiler is for x86 or x64. | |
46 #if defined(__x86_64__) || defined(_M_X64) || \ | |
47 defined(__i386__) || defined(_M_IX86) | |
48 #define CPU_X86 1 | |
49 #endif | |
50 // Detect compiler is for arm. | |
51 #if defined(__arm__) || defined(_M_ARM) | |
52 #define CPU_ARM 1 | |
53 #endif | |
54 #if defined(CPU_X86) && defined(CPU_ARM) | |
55 #error CPU_X86 and CPU_ARM both defined. | |
56 #endif | |
57 #if !defined(ARCH_CPU_BIG_ENDIAN) && !defined(ARCH_CPU_LITTLE_ENDIAN) | |
58 // x86, arm or GCC provided __BYTE_ORDER__ macros | |
59 #if CPU_X86 || CPU_ARM || \ | |
60 (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) | |
61 #define ARCH_CPU_LITTLE_ENDIAN | |
62 #elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | |
63 #define ARCH_CPU_BIG_ENDIAN | |
64 #else | |
65 #error ARCH_CPU_BIG_ENDIAN or ARCH_CPU_LITTLE_ENDIAN should be defined. | |
66 #endif | |
67 #endif | |
68 #if defined(ARCH_CPU_BIG_ENDIAN) && defined(ARCH_CPU_LITTLE_ENDIAN) | |
69 #error ARCH_CPU_BIG_ENDIAN and ARCH_CPU_LITTLE_ENDIAN both defined. | |
70 #endif | |
71 | |
72 #ifdef WIN32 | |
73 typedef int socklen_t; | |
74 #endif | |
75 | |
76 namespace talk_base { | |
77 template<class T> inline T _min(T a, T b) { return (a > b) ? b : a; } | |
78 template<class T> inline T _max(T a, T b) { return (a < b) ? b : a; } | |
79 | |
80 // For wait functions that take a number of milliseconds, kForever indicates | |
81 // unlimited time. | |
82 const int kForever = -1; | |
83 } | |
84 | |
85 #ifdef WIN32 | |
86 #if _MSC_VER < 1700 | |
87 #define alignof(t) __alignof(t) | |
88 #endif | |
89 #else // !WIN32 | |
90 #define alignof(t) __alignof__(t) | |
91 #endif // !WIN32 | |
92 #define IS_ALIGNED(p, a) (0==(reinterpret_cast<uintptr_t>(p) & ((a)-1))) | |
93 #define ALIGNP(p, t) \ | |
94 (reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \ | |
95 ((t)-1)) & ~((t)-1)))) | |
96 | |
97 // LIBJINGLE_DEFINE_STATIC_LOCAL() is a libjingle's copy | |
98 // of CR_DEFINE_STATIC_LOCAL(). | |
99 #define LIBJINGLE_DEFINE_STATIC_LOCAL(type, name, arguments) \ | |
100 CR_DEFINE_STATIC_LOCAL(type, name, arguments) | |
101 | |
102 #endif // OVERRIDES_TALK_BASE_BASICTYPES_H__ | |
OLD | NEW |