Remove overridden basictypes.h.
* Use (u)intxx_t for (u)intxx typedefs for all platforms. * Always include stdint.h. * Add RTC_ prefix to ARCH_XXX macros. Chromium did the (u)intxx_t change in https://codereview.chromium.org/117323010 and https://codereview.chromium.org/639293007 BUG=chromium:468375 TBR=perkj@webrtc.org (for trivial talk/* changes) NOTRY=true NOPRESUBMIT=true Review URL: https://codereview.webrtc.org/1349213003 Cr-Commit-Position: refs/heads/master@{#9983}
This commit is contained in:
@ -28,7 +28,7 @@
|
||||
#ifndef TALK_MEDIA_BASE_CPUID_H_
|
||||
#define TALK_MEDIA_BASE_CPUID_H_
|
||||
|
||||
#include "webrtc/base/basictypes.h" // For RTC_DISALLOW_IMPLICIT_CONSTRUCTORS
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
|
@ -40,6 +40,7 @@
|
||||
#define TALK_MEDIA_BASE_YUVFRAMEGENERATOR_H_
|
||||
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
|
||||
namespace cricket {
|
||||
|
||||
|
@ -158,12 +158,7 @@ static_library("rtc_base_approved") {
|
||||
"trace_event.h",
|
||||
]
|
||||
|
||||
if (build_with_chromium) {
|
||||
sources += [
|
||||
"../overrides/webrtc/base/basictypes.h",
|
||||
"../overrides/webrtc/base/constructormagic.h",
|
||||
]
|
||||
} else {
|
||||
if (!build_with_chromium) {
|
||||
sources += [
|
||||
"basictypes.h",
|
||||
"constructormagic.h",
|
||||
|
@ -29,8 +29,6 @@
|
||||
'target_name': 'rtc_base_approved',
|
||||
'type': 'static_library',
|
||||
'sources': [
|
||||
'../overrides/webrtc/base/basictypes.h',
|
||||
'../overrides/webrtc/base/constructormagic.h',
|
||||
'atomicops.h',
|
||||
'basictypes.h',
|
||||
'bitbuffer.cc',
|
||||
@ -94,11 +92,6 @@
|
||||
'logging.cc',
|
||||
'logging.h',
|
||||
],
|
||||
}, {
|
||||
'sources!': [
|
||||
'../overrides/webrtc/base/basictypes.h',
|
||||
'../overrides/webrtc/base/constructormagic.h',
|
||||
],
|
||||
}],
|
||||
],
|
||||
},
|
||||
|
@ -12,97 +12,51 @@
|
||||
#define WEBRTC_BASE_BASICTYPES_H_
|
||||
|
||||
#include <stddef.h> // for NULL, size_t
|
||||
|
||||
#if !(defined(_MSC_VER) && (_MSC_VER < 1600))
|
||||
#include <stdint.h> // for uintptr_t
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h" // NOLINT
|
||||
#endif
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
|
||||
#if !defined(INT_TYPES_DEFINED)
|
||||
#define INT_TYPES_DEFINED
|
||||
#ifdef COMPILER_MSVC
|
||||
typedef unsigned __int64 uint64;
|
||||
typedef __int64 int64;
|
||||
#ifndef INT64_C
|
||||
#define INT64_C(x) x ## I64
|
||||
#endif
|
||||
#ifndef UINT64_C
|
||||
#define UINT64_C(x) x ## UI64
|
||||
#endif
|
||||
#define INT64_F "I64"
|
||||
#else // COMPILER_MSVC
|
||||
// On Mac OS X, cssmconfig.h defines uint64 as uint64_t
|
||||
// TODO(fbarchard): Use long long for compatibility with chromium on BSD/OSX.
|
||||
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
|
||||
typedef uint64_t uint64;
|
||||
// TODO(grunell): Use (u)intxx_t everywhere instead and remove these typedefs.
|
||||
typedef int8_t int8;
|
||||
typedef uint8_t uint8;
|
||||
typedef int16_t int16;
|
||||
typedef uint16_t uint16;
|
||||
typedef int32_t int32;
|
||||
typedef uint32_t uint32;
|
||||
typedef int64_t int64;
|
||||
#ifndef INT64_C
|
||||
#define INT64_C(x) x ## LL
|
||||
#endif
|
||||
#ifndef UINT64_C
|
||||
#define UINT64_C(x) x ## ULL
|
||||
#endif
|
||||
#define INT64_F "l"
|
||||
#elif defined(__LP64__)
|
||||
typedef unsigned long long uint64; // NOLINT
|
||||
typedef long long int64; // NOLINT
|
||||
#ifndef INT64_C
|
||||
#define INT64_C(x) x ## L
|
||||
#endif
|
||||
#ifndef UINT64_C
|
||||
#define UINT64_C(x) x ## UL
|
||||
#endif
|
||||
#define INT64_F "l"
|
||||
#else // __LP64__
|
||||
typedef unsigned long long uint64; // NOLINT
|
||||
typedef long long int64; // NOLINT
|
||||
#ifndef INT64_C
|
||||
#define INT64_C(x) x ## LL
|
||||
#endif
|
||||
#ifndef UINT64_C
|
||||
#define UINT64_C(x) x ## ULL
|
||||
#endif
|
||||
#define INT64_F "ll"
|
||||
#endif // __LP64__
|
||||
#endif // COMPILER_MSVC
|
||||
typedef unsigned int uint32;
|
||||
typedef int int32;
|
||||
typedef unsigned short uint16; // NOLINT
|
||||
typedef short int16; // NOLINT
|
||||
typedef unsigned char uint8;
|
||||
typedef signed char int8;
|
||||
#endif // INT_TYPES_DEFINED
|
||||
typedef uint64_t uint64;
|
||||
|
||||
// Detect compiler is for x86 or x64.
|
||||
#if defined(__x86_64__) || defined(_M_X64) || \
|
||||
defined(__i386__) || defined(_M_IX86)
|
||||
#define CPU_X86 1
|
||||
#endif
|
||||
|
||||
// Detect compiler is for arm.
|
||||
#if defined(__arm__) || defined(_M_ARM)
|
||||
#define CPU_ARM 1
|
||||
#endif
|
||||
|
||||
#if defined(CPU_X86) && defined(CPU_ARM)
|
||||
#error CPU_X86 and CPU_ARM both defined.
|
||||
#endif
|
||||
#if !defined(ARCH_CPU_BIG_ENDIAN) && !defined(ARCH_CPU_LITTLE_ENDIAN)
|
||||
|
||||
#if !defined(RTC_ARCH_CPU_BIG_ENDIAN) && !defined(RTC_ARCH_CPU_LITTLE_ENDIAN)
|
||||
// x86, arm or GCC provided __BYTE_ORDER__ macros
|
||||
#if CPU_X86 || CPU_ARM || \
|
||||
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
||||
#define ARCH_CPU_LITTLE_ENDIAN
|
||||
#define RTC_ARCH_CPU_LITTLE_ENDIAN
|
||||
#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#define ARCH_CPU_BIG_ENDIAN
|
||||
#define RTC_ARCH_CPU_BIG_ENDIAN
|
||||
#else
|
||||
#error ARCH_CPU_BIG_ENDIAN or ARCH_CPU_LITTLE_ENDIAN should be defined.
|
||||
#error RTC_ARCH_CPU_BIG_ENDIAN or RTC_ARCH_CPU_LITTLE_ENDIAN should be defined.
|
||||
#endif
|
||||
#endif
|
||||
#if defined(ARCH_CPU_BIG_ENDIAN) && defined(ARCH_CPU_LITTLE_ENDIAN)
|
||||
#error ARCH_CPU_BIG_ENDIAN and ARCH_CPU_LITTLE_ENDIAN both defined.
|
||||
|
||||
#if defined(RTC_ARCH_CPU_BIG_ENDIAN) && defined(RTC_ARCH_CPU_LITTLE_ENDIAN)
|
||||
#error RTC_ARCH_CPU_BIG_ENDIAN and RTC_ARCH_CPU_LITTLE_ENDIAN both defined.
|
||||
#endif
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
@ -111,17 +65,20 @@ typedef int socklen_t;
|
||||
|
||||
// The following only works for C++
|
||||
#ifdef __cplusplus
|
||||
|
||||
#ifndef ALIGNP
|
||||
#define ALIGNP(p, t) \
|
||||
(reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \
|
||||
((t) - 1)) & ~((t) - 1))))
|
||||
#define ALIGNP(p, t) \
|
||||
(reinterpret_cast<uint8_t*>(((reinterpret_cast<uintptr_t>(p) + \
|
||||
((t) - 1)) & ~((t) - 1))))
|
||||
#endif
|
||||
|
||||
#define RTC_IS_ALIGNED(p, a) (!((uintptr_t)(p) & ((a) - 1)))
|
||||
|
||||
// Use these to declare and define a static local variable (static T;) so that
|
||||
// it is leaked so that its destructors are not called at exit.
|
||||
// Use these to declare and define a static local variable that gets leaked so
|
||||
// that its destructors are not called at exit.
|
||||
#define RTC_DEFINE_STATIC_LOCAL(type, name, arguments) \
|
||||
static type& name = *new type arguments
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // WEBRTC_BASE_BASICTYPES_H_
|
||||
|
@ -26,9 +26,9 @@ static_assert(sizeof(uint64) == 8, "Unexpected size");
|
||||
TEST(BasicTypesTest, Endian) {
|
||||
uint16 v16 = 0x1234u;
|
||||
uint8 first_byte = *reinterpret_cast<uint8*>(&v16);
|
||||
#if defined(ARCH_CPU_LITTLE_ENDIAN)
|
||||
#if defined(RTC_ARCH_CPU_LITTLE_ENDIAN)
|
||||
EXPECT_EQ(0x34u, first_byte);
|
||||
#elif defined(ARCH_CPU_BIG_ENDIAN)
|
||||
#elif defined(RTC_ARCH_CPU_BIG_ENDIAN)
|
||||
EXPECT_EQ(0x12u, first_byte);
|
||||
#endif
|
||||
}
|
||||
@ -74,9 +74,9 @@ TEST(BasicTypesTest, SizeOfConstants) {
|
||||
#if !defined(CPU_X86) && (defined(WEBRTC_WIN) || defined(WEBRTC_MAC) && !defined(WEBRTC_IOS))
|
||||
#error expected CPU_X86 to be defined.
|
||||
#endif
|
||||
#if !defined(ARCH_CPU_LITTLE_ENDIAN) && \
|
||||
#if !defined(RTC_ARCH_CPU_LITTLE_ENDIAN) && \
|
||||
(defined(WEBRTC_WIN) || defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) || defined(CPU_X86))
|
||||
#error expected ARCH_CPU_LITTLE_ENDIAN to be defined.
|
||||
#error expected RTC_ARCH_CPU_LITTLE_ENDIAN to be defined.
|
||||
#endif
|
||||
|
||||
// TODO(fbarchard): Test all macros in basictypes.h
|
||||
|
@ -23,13 +23,13 @@
|
||||
// TODO: Avoid memcmpy - hash directly from memory.
|
||||
#include <string.h> // for memcpy().
|
||||
|
||||
#include "webrtc/base/byteorder.h" // for ARCH_CPU_LITTLE_ENDIAN.
|
||||
#include "webrtc/base/byteorder.h" // for RTC_ARCH_CPU_LITTLE_ENDIAN.
|
||||
|
||||
namespace rtc {
|
||||
|
||||
#ifdef ARCH_CPU_LITTLE_ENDIAN
|
||||
#ifdef RTC_ARCH_CPU_LITTLE_ENDIAN
|
||||
#define ByteReverse(buf, len) // Nothing.
|
||||
#else // ARCH_CPU_BIG_ENDIAN
|
||||
#else // RTC_ARCH_CPU_BIG_ENDIAN
|
||||
static void ByteReverse(uint32* buf, int len) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
buf[i] = rtc::GetLE32(&buf[i]);
|
||||
|
@ -116,7 +116,7 @@ namespace {
|
||||
// blk0() and blk() perform the initial expand.
|
||||
// I got the idea of expanding during the round function from SSLeay
|
||||
// FIXME: can we do this in an endian-proof way?
|
||||
#ifdef ARCH_CPU_BIG_ENDIAN
|
||||
#ifdef RTC_ARCH_CPU_BIG_ENDIAN
|
||||
#define blk0(i) block->l[i]
|
||||
#else
|
||||
#define blk0(i) (block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) | \
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/basictypes.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/win32.h"
|
||||
|
||||
namespace rtc {
|
||||
|
@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
// This file overrides the inclusion of webrtc/base/basictypes.h to remove
|
||||
// collisions with Chromium's base/basictypes.h. We then add back a few
|
||||
// items that Chromium's version doesn't provide, but libjingle expects.
|
||||
|
||||
#ifndef OVERRIDES_WEBRTC_BASE_BASICTYPES_H__
|
||||
#define OVERRIDES_WEBRTC_BASE_BASICTYPES_H__
|
||||
|
||||
// We can't include these files directly via "base/foo.h" since we might
|
||||
// inadvertently include the very files we're overriding.
|
||||
#include "../../../../../base/basictypes.h"
|
||||
#include "../../../../../build/build_config.h"
|
||||
|
||||
#ifndef INT_TYPES_DEFINED
|
||||
#define INT_TYPES_DEFINED
|
||||
|
||||
#ifdef COMPILER_MSVC
|
||||
#if _MSC_VER >= 1600
|
||||
#include <stdint.h>
|
||||
#else
|
||||
typedef unsigned __int64 uint64;
|
||||
typedef __int64 int64;
|
||||
#endif
|
||||
#ifndef INT64_C
|
||||
#define INT64_C(x) x ## I64
|
||||
#endif
|
||||
#ifndef UINT64_C
|
||||
#define UINT64_C(x) x ## UI64
|
||||
#endif
|
||||
#define INT64_F "I64"
|
||||
#else // COMPILER_MSVC
|
||||
#ifndef INT64_C
|
||||
#define INT64_C(x) x ## LL
|
||||
#endif
|
||||
#ifndef UINT64_C
|
||||
#define UINT64_C(x) x ## ULL
|
||||
#endif
|
||||
#ifndef INT64_F
|
||||
#define INT64_F "ll"
|
||||
#endif
|
||||
#endif // COMPILER_MSVC
|
||||
#endif // INT_TYPES_DEFINED
|
||||
|
||||
// Detect compiler is for x86 or x64.
|
||||
#if defined(__x86_64__) || defined(_M_X64) || \
|
||||
defined(__i386__) || defined(_M_IX86)
|
||||
#define CPU_X86 1
|
||||
#endif
|
||||
// Detect compiler is for arm.
|
||||
#if defined(__arm__) || defined(_M_ARM)
|
||||
#define CPU_ARM 1
|
||||
#endif
|
||||
#if defined(CPU_X86) && defined(CPU_ARM)
|
||||
#error CPU_X86 and CPU_ARM both defined.
|
||||
#endif
|
||||
#if !defined(ARCH_CPU_BIG_ENDIAN) && !defined(ARCH_CPU_LITTLE_ENDIAN)
|
||||
// x86, arm or GCC provided __BYTE_ORDER__ macros
|
||||
#if CPU_X86 || CPU_ARM || \
|
||||
(defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
||||
#define ARCH_CPU_LITTLE_ENDIAN
|
||||
#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
#define ARCH_CPU_BIG_ENDIAN
|
||||
#else
|
||||
#error ARCH_CPU_BIG_ENDIAN or ARCH_CPU_LITTLE_ENDIAN should be defined.
|
||||
#endif
|
||||
#endif
|
||||
#if defined(ARCH_CPU_BIG_ENDIAN) && defined(ARCH_CPU_LITTLE_ENDIAN)
|
||||
#error ARCH_CPU_BIG_ENDIAN and ARCH_CPU_LITTLE_ENDIAN both defined.
|
||||
#endif
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
typedef int socklen_t;
|
||||
#endif
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
#if _MSC_VER < 1700
|
||||
#define alignof(t) __alignof(t)
|
||||
#endif
|
||||
#else // !WEBRTC_WIN
|
||||
#define alignof(t) __alignof__(t)
|
||||
#endif // !WEBRTC_WIN
|
||||
#ifndef ALIGNP
|
||||
#define ALIGNP(p, t) \
|
||||
(reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \
|
||||
((t)-1)) & ~((t)-1))))
|
||||
#endif
|
||||
#define RTC_IS_ALIGNED(p, a) (0==(reinterpret_cast<uintptr_t>(p) & ((a)-1)))
|
||||
|
||||
// RTC_DEFINE_STATIC_LOCAL() is libjingle's copy of CR_DEFINE_STATIC_LOCAL().
|
||||
#define RTC_DEFINE_STATIC_LOCAL(type, name, arguments) \
|
||||
CR_DEFINE_STATIC_LOCAL(type, name, arguments)
|
||||
|
||||
#endif // OVERRIDES_WEBRTC_BASE_BASICTYPES_H__
|
Reference in New Issue
Block a user