diff --git a/include/libyuv/basic_types.h b/include/libyuv/basic_types.h index 7d98bb93f..ba7f36529 100644 --- a/include/libyuv/basic_types.h +++ b/include/libyuv/basic_types.h @@ -25,34 +25,13 @@ #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 #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) typedef unsigned long uint64; // NOLINT typedef 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 // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 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; @@ -64,27 +43,6 @@ typedef signed char int8; #endif // INT_TYPES_DEFINED #endif // GG_LONGLONG -// 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 - -#ifndef ALIGNP -#ifdef __cplusplus -#define ALIGNP(p, t) \ - reinterpret_cast( \ - ((reinterpret_cast(p) + ((t)-1)) & ~((t)-1))) -#else -#define ALIGNP(p, t) \ - (uint8*)((((uintptr_t)(p) + ((t)-1)) & ~((t)-1))) /* NOLINT */ -#endif -#endif - #if !defined(LIBYUV_API) #if defined(_WIN32) || defined(__CYGWIN__) #if defined(LIBYUV_BUILDING_SHARED_LIBRARY) @@ -107,11 +65,4 @@ typedef signed char int8; #define LIBYUV_FALSE 0 #define LIBYUV_TRUE 1 -// Visual C x86 or GCC little endian. -#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \ - defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) || \ - (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) -#define LIBYUV_LITTLE_ENDIAN -#endif - #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ diff --git a/source/cpu_id.cc b/source/cpu_id.cc index d08fc3659..446aad120 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -27,8 +27,6 @@ #include #include -#include "libyuv/basic_types.h" // For CPU_X86 - #ifdef __cplusplus namespace libyuv { extern "C" { @@ -218,7 +216,9 @@ static LIBYUV_BOOL TestEnv(const char*) { static SAFEBUFFERS int GetCpuFlags(void) { int cpu_info = 0; -#if !defined(__pnacl__) && !defined(__CLR_VER) && defined(CPU_X86) +#if !defined(__pnacl__) && !defined(__CLR_VER) && \ + (defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \ + defined(_M_IX86)) int cpu_info0[4] = {0, 0, 0, 0}; int cpu_info1[4] = {0, 0, 0, 0}; int cpu_info7[4] = {0, 0, 0, 0}; diff --git a/source/row_common.cc b/source/row_common.cc index c2093bae1..1770e1290 100644 --- a/source/row_common.cc +++ b/source/row_common.cc @@ -67,7 +67,10 @@ static __inline uint32 Clamp10(int32 val) { return (uint32)(clamp1023(v)); } -#ifdef LIBYUV_LITTLE_ENDIAN +// Little Endian +#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \ + defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) || \ + (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) #define WRITEWORD(p, v) *(uint32*)(p) = v #else static inline void WRITEWORD(uint8* p, uint32 v) { diff --git a/unit_test/basictypes_test.cc b/unit_test/basictypes_test.cc index 89f7644d5..1709cb9ec 100644 --- a/unit_test/basictypes_test.cc +++ b/unit_test/basictypes_test.cc @@ -13,16 +13,6 @@ namespace libyuv { -TEST_F(LibYUVBaseTest, Endian) { - uint16 v16 = 0x1234u; - uint8 first_byte = *reinterpret_cast(&v16); -#if defined(LIBYUV_LITTLE_ENDIAN) - EXPECT_EQ(0x34u, first_byte); -#else - EXPECT_EQ(0x12u, first_byte); -#endif -} - TEST_F(LibYUVBaseTest, SizeOfTypes) { int8 i8 = -1; uint8 u8 = 1u; @@ -50,11 +40,4 @@ TEST_F(LibYUVBaseTest, SizeOfTypes) { EXPECT_LT(0u, u64); } -TEST_F(LibYUVBaseTest, 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))); -} - } // namespace libyuv