From b06b0a689fcd328464c3217f1fc3d813418b50db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Fri, 25 May 2018 10:05:34 +0200 Subject: [PATCH] Delete rtc_base/basictypes.h Only remaining user was rtc_base/byteorder.h, which is changed to use rtc_base/system/arch.h. Bug: webrtc:6853 Change-Id: If3b21831adc60adfd989061027d661867c938a0f Reviewed-on: https://webrtc-review.googlesource.com/78740 Commit-Queue: Niels Moller Reviewed-by: Karl Wiberg Reviewed-by: Fredrik Solenberg Cr-Commit-Position: refs/heads/master@{#23406} --- rtc_base/BUILD.gn | 3 +-- rtc_base/atomicops.h | 5 ++-- rtc_base/basictypes.h | 45 ------------------------------- rtc_base/basictypes_unittest.cc | 48 --------------------------------- rtc_base/byteorder.h | 12 ++++----- rtc_base/criticalsection.h | 5 ++-- rtc_base/task_queue_win.cc | 5 ++-- 7 files changed, 13 insertions(+), 110 deletions(-) delete mode 100644 rtc_base/basictypes.h delete mode 100644 rtc_base/basictypes_unittest.cc diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index 96822ca3d3..b9cf3b9504 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -104,7 +104,6 @@ rtc_source_set("rtc_base_approved") { rtc_source_set("macromagic") { sources = [ "arraysize.h", - "basictypes.h", "constructormagic.h", "format_macros.h", "stringize_macros.h", @@ -385,6 +384,7 @@ rtc_source_set("rtc_base_approved_generic") { ":timeutils", ":type_traits", "../:typedefs", + "system:arch", ] sources = [ @@ -1104,7 +1104,6 @@ if (rtc_include_tests) { sources = [ "atomicops_unittest.cc", "base64_unittest.cc", - "basictypes_unittest.cc", "bind_unittest.cc", "bitbuffer_unittest.cc", "bitrateallocationstrategy_unittest.cc", diff --git a/rtc_base/atomicops.h b/rtc_base/atomicops.h index c0ff1a616b..a4f9a4fe05 100644 --- a/rtc_base/atomicops.h +++ b/rtc_base/atomicops.h @@ -13,9 +13,8 @@ #if defined(WEBRTC_WIN) // Include winsock2.h before including to maintain consistency with -// win32.h. We can't include win32.h directly here since it pulls in -// headers such as basictypes.h which causes problems in Chromium where webrtc -// exists as two separate projects, webrtc and libjingle. +// win32.h. To include win32.h directly, it must be broken out into its own +// build target. #include #include #endif // defined(WEBRTC_WIN) diff --git a/rtc_base/basictypes.h b/rtc_base/basictypes.h deleted file mode 100644 index 1d149d6ff4..0000000000 --- a/rtc_base/basictypes.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2004 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. - */ - -#ifndef RTC_BASE_BASICTYPES_H_ -#define RTC_BASE_BASICTYPES_H_ - -// 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(RTC_ARCH_CPU_BIG_ENDIAN) && !defined(RTC_ARCH_CPU_LITTLE_ENDIAN) -// x86, arm or GCC provided __BYTE_ORDER__ macros -#if defined(CPU_X86) || defined(CPU_ARM) || \ - (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) -#define RTC_ARCH_CPU_LITTLE_ENDIAN -#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -#define RTC_ARCH_CPU_BIG_ENDIAN -#else -#error RTC_ARCH_CPU_BIG_ENDIAN or RTC_ARCH_CPU_LITTLE_ENDIAN should be defined. -#endif -#endif - -#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 - -#endif // RTC_BASE_BASICTYPES_H_ diff --git a/rtc_base/basictypes_unittest.cc b/rtc_base/basictypes_unittest.cc deleted file mode 100644 index a8b0533967..0000000000 --- a/rtc_base/basictypes_unittest.cc +++ /dev/null @@ -1,48 +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. - */ - -#include "rtc_base/basictypes.h" - -#include "rtc_base/gunit.h" - -namespace rtc { - -TEST(BasicTypesTest, Endian) { - uint16_t v16 = 0x1234u; - uint8_t first_byte = *reinterpret_cast(&v16); -#if defined(RTC_ARCH_CPU_LITTLE_ENDIAN) - EXPECT_EQ(0x34u, first_byte); -#elif defined(RTC_ARCH_CPU_BIG_ENDIAN) - EXPECT_EQ(0x12u, first_byte); -#endif -} - -TEST(BasicTypesTest, SizeOfConstants) { - EXPECT_EQ(8u, sizeof(INT64_C(0))); - EXPECT_EQ(8u, sizeof(UINT64_C(0))); - EXPECT_EQ(8u, sizeof(INT64_C(0x1234567887654321))); - EXPECT_EQ(8u, sizeof(UINT64_C(0x8765432112345678))); -} - -// Test CPU_ macros -#if !defined(CPU_ARM) && defined(__arm__) -#error expected CPU_ARM to be defined. -#endif -#if !defined(CPU_X86) && (defined(WEBRTC_WIN) || defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)) -#error expected CPU_X86 to be defined. -#endif -#if !defined(RTC_ARCH_CPU_LITTLE_ENDIAN) && \ - (defined(WEBRTC_WIN) || defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) || defined(CPU_X86)) -#error expected RTC_ARCH_CPU_LITTLE_ENDIAN to be defined. -#endif - -// TODO(fbarchard): Test all macros in basictypes.h - -} // namespace rtc diff --git a/rtc_base/byteorder.h b/rtc_base/byteorder.h index 43cfb3694e..86546a5ca3 100644 --- a/rtc_base/byteorder.h +++ b/rtc_base/byteorder.h @@ -17,7 +17,7 @@ #include #endif -#include "rtc_base/basictypes.h" +#include "rtc_base/system/arch.h" #if defined(WEBRTC_MAC) #include @@ -53,7 +53,7 @@ #define be64toh(v) ntohll(v) #endif -#if defined(RTC_ARCH_CPU_LITTLE_ENDIAN) +#if defined(WEBRTC_ARCH_LITTLE_ENDIAN) #define htole16(v) (v) #define htole32(v) (v) #define htole64(v) (v) @@ -64,7 +64,7 @@ #define htobe64(v) __builtin_bswap64(v) #define be64toh(v) __builtin_bswap64(v) #endif -#elif defined(RTC_ARCH_CPU_BIG_ENDIAN) +#elif defined(WEBRTC_ARCH_BIG_ENDIAN) #define htole16(v) __builtin_bswap16(v) #define htole32(v) __builtin_bswap32(v) #define htole64(v) __builtin_bswap64(v) @@ -76,8 +76,8 @@ #define be64toh(v) (v) #endif #else -#error RTC_ARCH_CPU_BIG_ENDIAN or RTC_ARCH_CPU_LITTLE_ENDIAN must be defined. -#endif // defined(RTC_ARCH_CPU_LITTLE_ENDIAN) +#error WEBRTC_ARCH_BIG_ENDIAN or WEBRTC_ARCH_LITTLE_ENDIAN must be defined. +#endif // defined(WEBRTC_ARCH_LITTLE_ENDIAN) #elif defined(WEBRTC_POSIX) #include #endif @@ -144,7 +144,7 @@ inline uint64_t GetLE64(const void* memory) { // Check if the current host is big endian. inline bool IsHostBigEndian() { -#if defined(RTC_ARCH_CPU_BIG_ENDIAN) +#if defined(WEBRTC_ARCH_BIG_ENDIAN) return true; #else return false; diff --git a/rtc_base/criticalsection.h b/rtc_base/criticalsection.h index 569e1479bd..6abdbe57a6 100644 --- a/rtc_base/criticalsection.h +++ b/rtc_base/criticalsection.h @@ -19,9 +19,8 @@ #if defined(WEBRTC_WIN) // Include winsock2.h before including to maintain consistency with -// win32.h. We can't include win32.h directly here since it pulls in -// headers such as basictypes.h which causes problems in Chromium where webrtc -// exists as two separate projects, webrtc and libjingle. +// win32.h. To include win32.h directly, it must be broken out into its own +// build target. #include #include #include // must come after windows headers. diff --git a/rtc_base/task_queue_win.cc b/rtc_base/task_queue_win.cc index cbf86a6a11..5cc9f88d42 100644 --- a/rtc_base/task_queue_win.cc +++ b/rtc_base/task_queue_win.cc @@ -11,9 +11,8 @@ #include "rtc_base/task_queue.h" // Include winsock2.h before including to maintain consistency with -// win32.h. We can't include win32.h directly here since it pulls in -// headers such as basictypes.h which causes problems in Chromium where webrtc -// exists as two separate projects, webrtc and libjingle. +// win32.h. To include win32.h directly, it must be broken out into its own +// build target. #include #include #include // Must come after windows headers.