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