1 // Copyright (c) 2012 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.
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.
9 #ifndef OVERRIDES_TALK_BASE_BASICTYPES_H__
10 #define OVERRIDES_TALK_BASE_BASICTYPES_H__
12 #include "base/basictypes.h"
13 #include "build/build_config.h"
15 #ifndef INT_TYPES_DEFINED
16 #define INT_TYPES_DEFINED
22 typedef unsigned __int64 uint64;
23 typedef __int64 int64;
26 #define INT64_C(x) x ## I64
29 #define UINT64_C(x) x ## UI64
32 #else // COMPILER_MSVC
34 #define INT64_C(x) x ## LL
37 #define UINT64_C(x) x ## ULL
42 #endif // COMPILER_MSVC
43 #endif // INT_TYPES_DEFINED
45 // Detect compiler is for x86 or x64.
46 #if defined(__x86_64__) || defined(_M_X64) || \
47 defined(__i386__) || defined(_M_IX86)
50 // Detect compiler is for arm.
51 #if defined(__arm__) || defined(_M_ARM)
54 #if defined(CPU_X86) && defined(CPU_ARM)
55 #error CPU_X86 and CPU_ARM both defined.
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
65 #error ARCH_CPU_BIG_ENDIAN or ARCH_CPU_LITTLE_ENDIAN should be defined.
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.
73 typedef int socklen_t;
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; }
80 // For wait functions that take a number of milliseconds, kForever indicates
82 const int kForever = -1;
87 #define alignof(t) __alignof(t)
90 #define alignof(t) __alignof__(t)
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))))
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)
102 #endif // OVERRIDES_TALK_BASE_BASICTYPES_H__