From 1711549b89950d0260adac290dd6df845f0ec3f1 Mon Sep 17 00:00:00 2001 From: Rob Parolin Date: Wed, 10 Jul 2019 13:32:43 -0700 Subject: [PATCH] 2.09.05 release --- include/Common/EABase/eabase.h | 140 +++++++++++++++++++-------------- test/source/TestEABase.cpp | 19 +++-- 2 files changed, 96 insertions(+), 63 deletions(-) diff --git a/include/Common/EABase/eabase.h b/include/Common/EABase/eabase.h index ab68c2c..c3ac598 100644 --- a/include/Common/EABase/eabase.h +++ b/include/Common/EABase/eabase.h @@ -204,7 +204,7 @@ // According to the C98/99 standard, FLT_EVAL_METHOD defines control the // width used for floating point _t types. - #if defined(_MSC_VER) && _MSC_VER >= 1800 + #if defined(_MSC_VER) && _MSC_VER >= 1800 // MSVC's math.h provides float_t, double_t under this condition. #elif defined(FLT_EVAL_METHOD) #if (FLT_EVAL_METHOD == 0) @@ -219,7 +219,7 @@ #endif #endif - #if defined(EA_COMPILER_MSVC) || defined(EA_COMPILER_BORLAND) + #if defined(EA_COMPILER_MSVC) typedef signed __int64 int64_t; typedef unsigned __int64 uint64_t; @@ -248,58 +248,33 @@ #ifndef INT8_C_DEFINED // If the user hasn't already defined these... #define INT8_C_DEFINED - // VC++ 7.0 and earlier don't handle the LL suffix. - #if defined(EA_COMPILER_MSVC) || defined(EA_COMPILER_BORLAND) - #ifndef INT8_C - #define INT8_C(x) int8_t(x) // x##i8 doesn't work satisfactorilly because -128i8 generates an out of range warning. - #endif - #ifndef UINT8_C - #define UINT8_C(x) uint8_t(x) - #endif - #ifndef INT16_C - #define INT16_C(x) int16_t(x) // x##i16 doesn't work satisfactorilly because -32768i8 generates an out of range warning. - #endif - #ifndef UINT16_C - #define UINT16_C(x) uint16_t(x) - #endif - #ifndef INT32_C - #define INT32_C(x) x##i32 - #endif - #ifndef UINT32_C - #define UINT32_C(x) x##ui32 - #endif - #ifndef INT64_C - #define INT64_C(x) x##i64 - #endif - #ifndef UINT64_C - #define UINT64_C(x) x##ui64 - #endif - #else - #ifndef INT8_C - #define INT8_C(x) int8_t(x) // For the majority of compilers and platforms, long is 32 bits and long long is 64 bits. - #endif - #ifndef UINT8_C - #define UINT8_C(x) uint8_t(x) - #endif - #ifndef INT16_C - #define INT16_C(x) int16_t(x) - #endif - #ifndef UINT16_C - #define UINT16_C(x) uint16_t(x) // Possibly we should make this be uint16_t(x##u). Let's see how compilers react before changing this. - #endif - #ifndef INT32_C - #define INT32_C(x) x##L - #endif - #ifndef UINT32_C - #define UINT32_C(x) x##UL - #endif - #ifndef INT64_C - #define INT64_C(x) x##LL // The way to deal with this is to compare ULONG_MAX to 0xffffffff and if not equal, then remove the L. - #endif - #ifndef UINT64_C - #define UINT64_C(x) x##ULL // We need to follow a similar approach for LL. - #endif + #ifndef INT8_C + #define INT8_C(x) int8_t(x) // For the majority of compilers and platforms, long is 32 bits and long long is 64 bits. + #endif + #ifndef UINT8_C + #define UINT8_C(x) uint8_t(x) + #endif + #ifndef INT16_C + #define INT16_C(x) int16_t(x) + #endif + #ifndef UINT16_C + #define UINT16_C(x) uint16_t(x) // Possibly we should make this be uint16_t(x##u). Let's see how compilers react before changing this. + #endif + #ifndef INT32_C + #define INT32_C(x) x##L + #endif + #ifndef UINT32_C + #define UINT32_C(x) x##UL + #endif + #ifndef INT64_C + #define INT64_C(x) x##LL // The way to deal with this is to compare ULONG_MAX to 0xffffffff and if not equal, then remove the L. #endif + #ifndef UINT64_C + #define UINT64_C(x) x##ULL // We need to follow a similar approach for LL. + #endif + #ifndef UINTMAX_C + #define UINTMAX_C(x) UINT64_C(x) + #endif #endif // ------------------------------------------------------------------------ @@ -320,6 +295,16 @@ #ifndef INT64_MAX #define INT64_MAX INT64_C(9223372036854775807) #endif + #ifndef INTMAX_MAX + #define INTMAX_MAX INT64_MAX + #endif + #ifndef INTPTR_MAX + #if EA_PLATFORM_PTR_SIZE == 4 + #define INTPTR_MAX INT32_MAX + #else + #define INTPTR_MAX INT64_MAX + #endif + #endif // The value must be either -2^(n-1) or 1-2(n-1). #ifndef INT8_MIN @@ -334,6 +319,16 @@ #ifndef INT64_MIN #define INT64_MIN (-INT64_MAX - 1) // -9223372036854775808 #endif + #ifndef INTMAX_MIN + #define INTMAX_MIN INT64_MIN + #endif + #ifndef INTPTR_MIN + #if EA_PLATFORM_PTR_SIZE == 4 + #define INTPTR_MIN INT32_MIN + #else + #define INTPTR_MIN INT64_MIN + #endif + #endif // The value must be 2^n-1 #ifndef UINT8_MAX @@ -348,6 +343,16 @@ #ifndef UINT64_MAX #define UINT64_MAX UINT64_C(0xffffffffffffffff) // 18446744073709551615 #endif + #ifndef UINTMAX_MAX + #define UINTMAX_MAX UINT64_MAX + #endif + #ifndef UINTPTR_MAX + #if EA_PLATFORM_PTR_SIZE == 4 + #define UINTPTR_MAX UINT32_MAX + #else + #define UINTPTR_MAX UINT64_MAX + #endif + #endif #endif #ifndef FLT_EVAL_METHOD @@ -621,6 +626,7 @@ // set to be the same thing as wchar_t in order to allow the // user to use char32_t with standard wchar_t functions. // +// EA_CHAR8_UNIQUE // EA_CHAR16_NATIVE // EA_CHAR32_NATIVE // EA_WCHAR_UNIQUE @@ -643,6 +649,9 @@ // the C++11 unicode character types often overloads must be provided to // support existing code that passes a wide char string to a function that // takes a unicode string. +// +// The EA_CHAR8_UNIQUE symbol is defined to 1 if char8_t is distinct type +// from char in the type system, and defined to 0 if otherwise. #if !defined(EA_CHAR16_NATIVE) // To do: Change this to be based on EA_COMPILER_NO_NEW_CHARACTER_TYPES. @@ -697,12 +706,25 @@ #define EA_WCHAR_UNIQUE 0 #endif -// Feature check for native char8_t support. Currently only enabled -// in Clang since r346892 when -std=c++2a is specified. -#if defined(__cpp_char8_t) + +// EA_CHAR8_UNIQUE +// +// Check for char8_t support in the cpp type system. Moving forward from c++20, +// the char8_t type allows users to overload function for character encoding. +// +// EA_CHAR8_UNIQUE is 1 when the type is a unique in the type system and +// can there be used as a valid overload. EA_CHAR8_UNIQUE is 0 otherwise. +// +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0482r6.html +// +#ifdef __cpp_char8_t #define CHAR8_T_DEFINED + #define EA_CHAR8_UNIQUE 1 +#else + #define EA_CHAR8_UNIQUE 0 #endif + #ifndef CHAR8_T_DEFINED // If the user hasn't already defined these... #define CHAR8_T_DEFINED #if defined(EA_PLATFORM_APPLE) @@ -793,7 +815,11 @@ // const char32_t c = EA_CHAR32('\x3001'); // #ifndef EA_CHAR8 - #define EA_CHAR8(s) s + #if EA_CHAR8_UNIQUE + #define EA_CHAR8(s) u8 ## s + #else + #define EA_CHAR8(s) s + #endif #endif #ifndef EA_WCHAR diff --git a/test/source/TestEABase.cpp b/test/source/TestEABase.cpp index 6bfb339..48c6890 100644 --- a/test/source/TestEABase.cpp +++ b/test/source/TestEABase.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #if !defined(EA_COMPILER_NO_STANDARD_CPP_LIBRARY) EA_DISABLE_ALL_VC_WARNINGS() @@ -38,13 +39,8 @@ EA_RESTORE_ALL_VC_WARNINGS() #if defined(EA_COMPILER_MSVC) && defined(EA_PLATFORM_MICROSOFT) EA_DISABLE_ALL_VC_WARNINGS() - #if defined(EA_PLATFORM_XENON) - #define NOD3D - #define NONET - #include - #else + #define NOMINMAX #include - #endif EA_RESTORE_ALL_VC_WARNINGS() #elif defined(EA_PLATFORM_ANDROID) #include @@ -1025,6 +1021,17 @@ int TestEABase() EA_RESTORE_VC_WARNING() } + { + static_assert(INTPTR_MIN == eastl::numeric_limits::min(), "INTPTR_MIN failure"); + static_assert(INTPTR_MAX == eastl::numeric_limits::max(), "INTPTR_MAX failure"); + //static_assert(UINTPTR_MIN == eastl::numeric_limits::min(), "UINTPTR_MIN failure"); // not specified by the standard + static_assert(UINTPTR_MAX == eastl::numeric_limits::max(), "UINTPTR_MAX failure"); + static_assert(INTMAX_MIN == eastl::numeric_limits::min(), "INTMAX_MIN failure"); + static_assert(INTMAX_MAX == eastl::numeric_limits::max(), "INTMAX_MAX failure"); + //static_assert(UINTMAX_MIN == eastl::numeric_limits::MIN(), "UINTMAX_MIN failure"); // not specified by the standard + static_assert(UINTMAX_MAX == eastl::numeric_limits::max(), "UINTMAX_MAX failure"); + } + //Test sized printf format specifiers { char buffer[256];