Skip to content

Commit

Permalink
2.09.05 release
Browse files Browse the repository at this point in the history
  • Loading branch information
rparolin committed Jul 10, 2019
1 parent 55f16cb commit 1711549
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 63 deletions.
140 changes: 83 additions & 57 deletions include/Common/EABase/eabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;

Expand Down Expand Up @@ -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

// ------------------------------------------------------------------------
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
19 changes: 13 additions & 6 deletions test/source/TestEABase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <EASTL/fixed_vector.h>
#include <EASTL/string.h>
#include <EASTL/sort.h>
#include <EASTL/numeric_limits.h>
#include <EAStdC/EAString.h>
#if !defined(EA_COMPILER_NO_STANDARD_CPP_LIBRARY)
EA_DISABLE_ALL_VC_WARNINGS()
Expand All @@ -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 <Xtl.h>
#else
#define NOMINMAX
#include <Windows.h>
#endif
EA_RESTORE_ALL_VC_WARNINGS()
#elif defined(EA_PLATFORM_ANDROID)
#include <android/log.h>
Expand Down Expand Up @@ -1025,6 +1021,17 @@ int TestEABase()
EA_RESTORE_VC_WARNING()
}

{
static_assert(INTPTR_MIN == eastl::numeric_limits<intptr_t>::min(), "INTPTR_MIN failure");
static_assert(INTPTR_MAX == eastl::numeric_limits<intptr_t>::max(), "INTPTR_MAX failure");
//static_assert(UINTPTR_MIN == eastl::numeric_limits<uintptr_t>::min(), "UINTPTR_MIN failure"); // not specified by the standard
static_assert(UINTPTR_MAX == eastl::numeric_limits<uintptr_t>::max(), "UINTPTR_MAX failure");
static_assert(INTMAX_MIN == eastl::numeric_limits<intmax_t>::min(), "INTMAX_MIN failure");
static_assert(INTMAX_MAX == eastl::numeric_limits<intmax_t>::max(), "INTMAX_MAX failure");
//static_assert(UINTMAX_MIN == eastl::numeric_limits<uintmax_t>::MIN(), "UINTMAX_MIN failure"); // not specified by the standard
static_assert(UINTMAX_MAX == eastl::numeric_limits<uintmax_t>::max(), "UINTMAX_MAX failure");
}

//Test sized printf format specifiers
{
char buffer[256];
Expand Down

0 comments on commit 1711549

Please sign in to comment.