Merge branch 'development' into redcode/crythread-2nd-pass

Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com>
This commit is contained in:
AMZN-ScottR
2021-08-11 20:31:58 -07:00
1650 changed files with 39333 additions and 62370 deletions
+39 -382
View File
@@ -7,22 +7,18 @@
*/
// Description : Platform dependend stuff.
// Description : Platform dependent stuff.
// Include this file instead of windows h
#pragma once
#if defined(AZ_RESTRICTED_PLATFORM)
#undef AZ_RESTRICTED_SECTION
#define PLATFORM_H_SECTION_1 1
#define PLATFORM_H_SECTION_2 2
#define PLATFORM_H_SECTION_3 3
#define PLATFORM_H_SECTION_4 4
#define PLATFORM_H_SECTION_5 5
#define PLATFORM_H_SECTION_6 6
#define PLATFORM_H_SECTION_7 7
#define PLATFORM_H_SECTION_8 8
#define PLATFORM_H_SECTION_9 9
#define PLATFORM_H_SECTION_10 10
#define PLATFORM_H_SECTION_11 11
#define PLATFORM_H_SECTION_12 12
@@ -31,112 +27,12 @@
#define PLATFORM_H_SECTION_15 15
#endif
// certain C++ features are not available in some compiler versions
// turn them off here:
// #define _ALLOW_KEYWORD_MACROS
// #define _DISALLOW_INITIALIZER_LISTS
// #define _DISALLOW_ENUM_CLASS
#if defined(_MSC_VER)
#define _ALLOW_KEYWORD_MACROS
#define alignof _alignof
#if !defined(_HAS_EXCEPTIONS)
#define _HAS_EXCEPTIONS 0
#endif
#elif defined(__GNUC__)
#define alignof __alignof__
#endif
// Alignment|InitializerList support.
#define _ALLOW_INITIALIZER_LISTS
#if (defined(LINUX) && !defined(ANDROID)) || defined(APPLE)
#define _FILE_OFFSET_BITS 64 // define large file support > 2GB
#define _FILE_OFFSET_BITS 64 // define large file support > 2GB
#endif
#include <AzCore/PlatformIncl.h>
#include <cstring>
#if defined(_MSC_VER) // We want the class name to be included, but __FUNCTION__ doesn't contain that on GCC/clang
#define __FUNC__ __FUNCTION__
#else
#define __FUNC__ __PRETTY_FUNCTION__
#endif
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_1
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(_DEBUG) && !defined(LINUX) && !defined(APPLE)
#include <crtdbg.h>
#endif
#define RESTRICT_POINTER __restrict
// we have to use it because of VS doesn't support restrict reference variables
#if defined(APPLE) || defined(LINUX)
#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
#define GCC411_OR_LATER
#endif
#define RESTRICT_REFERENCE __restrict
#else
#define RESTRICT_REFERENCE
#endif
#ifndef CHECK_REFERENCE_COUNTS //define that in your StdAfx.h to override per-project
# define CHECK_REFERENCE_COUNTS 0 //default value
#endif
#if CHECK_REFERENCE_COUNTS
# define CHECK_REFCOUNT_CRASH(x) { if (!(x)) {*((int*)0) = 0; } \
}
#else
# define CHECK_REFCOUNT_CRASH(x)
#endif
#ifndef GARBAGE_MEMORY_ON_FREE //define that in your StdAfx.h to override per-project
# define GARBAGE_MEMORY_ON_FREE 0 //default value
#endif
#if GARBAGE_MEMORY_ON_FREE
# ifndef GARBAGE_MEMORY_RANDOM //define that in your StdAfx.h to override per-project
# define GARBAGE_MEMORY_RANDOM 1 //0 to change it to progressive pattern
# endif
#endif
//////////////////////////////////////////////////////////////////////////
// Available predefined compiler macros for Visual C++.
// _MSC_VER // Indicates MS Visual C compiler version
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_2
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
// _WIN32, _WIN64 // Indicates target OS
#endif
// _M_IX86, _M_PPC // Indicates target processor
// _DEBUG // Building in Debug mode
// _DLL // Linking with DLL runtime libs
// _MT // Linking with multi-threaded runtime libs
//////////////////////////////////////////////////////////////////////////
//
// Translate some predefined macros.
//
// NDEBUG disables std asserts, etc.
// Define it automatically if not compiling with Debug libs, or with ADEBUG flag.
#if !defined(_DEBUG) && !defined(ADEBUG) && !defined(NDEBUG)
#define NDEBUG
#endif
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_3
#include AZ_RESTRICTED_FILE(platform_h)
@@ -147,44 +43,6 @@
#define CONSOLE
#endif
//render thread settings, as this is accessed inside 3dengine and renderer and needs to be compile time defined, we need to do it here
//enable this macro to strip out the overhead for render thread
// #define STRIP_RENDER_THREAD
#ifdef STRIP_RENDER_THREAD
#define RT_COMMAND_BUF_COUNT 1
#else
//can be enhanced to triple buffering, FlushFrame needs to be adjusted and RenderObj would become 132 bytes
#define RT_COMMAND_BUF_COUNT 2
#endif
// We use WIN macros without _.
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_4
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
#if defined(_WIN32) && !defined(LINUX32) && !defined(LINUX64) && !defined(APPLE) && !defined(WIN32)
#define WIN32
#endif
#if defined(_WIN64) && !defined(WIN64)
#define WIN64
#endif
#endif
// In Win32 Release we use static linkage
#ifdef WIN32
#if !defined(_RELEASE) || defined(RESOURCE_COMPILER) || defined(EDITOR) || defined(_FORCEDLL)
// All windows targets not in Release built as DLLs.
#ifndef _USRDLL
#define _USRDLL
#endif
#endif
#endif //WIN32
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_5
#include AZ_RESTRICTED_FILE(platform_h)
@@ -205,19 +63,17 @@
#define PRId64 "lld"
#define PRIu64 "llu"
#endif
#define PLATFORM_I64(x) x##ll
#else
#include <inttypes.h>
#define PLATFORM_I64(x) x##i64
#endif
#if !defined(PRISIZE_T)
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_6
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_6
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(WIN64)
#define PRISIZE_T "I64u" //size_t defined as unsigned __int64
#elif defined(WIN32) || defined(LINUX32)
@@ -228,13 +84,14 @@
#error "Please defined PRISIZE_T for this platform"
#endif
#endif
#if !defined(PRI_THREADID)
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_7
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_7
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(MAC) || defined(IOS) && defined(__LP64__) && defined(__LP64__)
#define PRI_THREADID "lld"
#elif defined(LINUX64) || defined(ANDROID)
@@ -243,6 +100,7 @@
#define PRI_THREADID "d"
#endif
#endif
#include "ProjectDefines.h" // to get some defines available in every CryEngine project
// Function attribute for printf/scanf-style parameters.
@@ -277,43 +135,13 @@
#define PRINTF_EMPTY_FORMAT ""
#endif
//////////////////////////////////////////////////////////////////////////
// define Read Write Barrier macro needed for lockless programming
//////////////////////////////////////////////////////////////////////////
#if defined(__arm__)
/**
* (ARMv7) Full memory barriar.
*
* None of GCC 4.6/4.8 or clang 3.3/3.4 have a builtin intrinsic for ARM's ldrex/strex or dmb
* instructions. This is a placeholder until supplied by the toolchain.
*/
inline void __dmb()
{
// The linux kernel uses "dmb ish" to only sync with local monitor (arch/arm/include/asm/barrier.h):
//#define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
//#define smp_mb() dmb(ish)
__asm__ __volatile__ ("dmb ish" : : : "memory");
}
#define READ_WRITE_BARRIER {__dmb(); }
#else
#define READ_WRITE_BARRIER
#endif
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// define macro to prevent memory reoderings of reads/and writes
//TODO implement for all GCC platforms, else there are potential crashes with strict aliasing
#define MEMORY_RW_REORDERING_BARRIER do { /*not implemented*/} while (0)
//default stack size for threads, currently only used on pthread platforms
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_8
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(LINUX) || defined(APPLE)
#if !defined(_DEBUG)
#define SIMPLE_THREAD_STACK_SIZE_KB (256)
@@ -350,22 +178,6 @@ inline void __dmb()
#else
#define _HELP(x) ""
#endif
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// Globally Used Defines.
//////////////////////////////////////////////////////////////////////////
// CPU Types: _CPU_X86,_CPU_AMD64,_CPU_G5
// Platform: WIN23,WIN64,LINUX32,LINUX64,MAC
// CPU supported functionality: _CPU_SSE
//////////////////////////////////////////////////////////////////////////
#if defined(_MSC_VER)
#define PREFAST_SUPPRESS_WARNING(W) __pragma(warning(suppress: W))
#else
#define PREFAST_SUPPRESS_WARNING(W)
#endif
#ifdef _PREFAST_
# define PREFAST_ASSUME(cond) __analysis_assume(cond)
@@ -373,47 +185,21 @@ inline void __dmb()
# define PREFAST_ASSUME(cond)
#endif
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_9
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#else
#if defined(WIN32) && !defined(WIN64)
#include "Win32specific.h"
#endif
#if defined(WIN64)
#include "Win64specific.h"
#endif
#endif
#if defined(LINUX64) && !defined(ANDROID)
#include "Linux64Specific.h"
#endif
#if defined(LINUX32) && !defined(ANDROID)
#include "Linux32Specific.h"
#endif
#if defined(ANDROID)
#include "AndroidSpecific.h"
#endif
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_10
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(MAC)
#include "MacSpecific.h"
#endif
#if defined(IOS)
#include "iOSSpecific.h"
#else
#if defined(WIN64)
#include "Win64specific.h"
#elif defined(LINUX64) && !defined(ANDROID)
#include "Linux64Specific.h"
#elif defined(MAC)
#include "MacSpecific.h"
#elif defined(ANDROID)
#include "AndroidSpecific.h"
#elif defined(IOS)
#include "iOSSpecific.h"
#endif
#endif
@@ -468,12 +254,6 @@ ILINE DestinationType alias_cast(SourceType pPtr)
#define DEPRECATED
#endif
//////////////////////////////////////////////////////////////////////////
// compile time error stuff
//////////////////////////////////////////////////////////////////////////
#undef STATIC_CHECK
#define STATIC_CHECK(expr, msg) static_assert(expr, #msg)
// Assert dialog box macros
#include "CryAssert.h"
@@ -483,35 +263,12 @@ ILINE DestinationType alias_cast(SourceType pPtr)
#define assert CRY_ASSERT
#endif
#include "CompileTimeAssert.h"
//////////////////////////////////////////////////////////////////////////
// Platform dependent functions that emulate Win32 API.
// Mostly used only for debugging!
//////////////////////////////////////////////////////////////////////////
void CryDebugBreak();
void CrySleep(unsigned int dwMilliseconds);
void CryLowLatencySleep(unsigned int dwMilliseconds);
int CryMessageBox(const char* lpText, const char* lpCaption, unsigned int uType);
short CryGetAsyncKeyState(int vKey);
unsigned int CryGetFileAttributes(const char* lpFileName);
inline void CryHeapCheck()
{
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_11
#include AZ_RESTRICTED_FILE(platform_h)
#elif !defined(LINUX) && !defined(APPLE) // todo: this might be readded with later xdks?
#if !defined(NDEBUG)
int Result =
#endif
_heapchk();
assert(Result != _HEAPBADBEGIN);
assert(Result != _HEAPBADNODE);
assert(Result != _HEAPBADPTR);
assert(Result != _HEAPEMPTY);
assert(Result == _HEAPOK);
#endif
}
//---------------------------------------------------------------------------
// Useful function to clean the structure.
@@ -542,77 +299,6 @@ inline D check_cast(S const& s)
return d;
}
// Convert one type to another, asserting there is no conversion loss.
// Usage: DestType dest; check_convert(dest, src);
template<class D, class S>
inline D& check_convert(D& d, S const& s)
{
d = D(s);
assert(S(d) == s);
return d;
}
// Convert one type to another, asserting there is no conversion loss.
// Usage: DestType dest; check_convert(dest) = src;
template<class D>
struct CheckConvert
{
CheckConvert(D& d)
: dest(&d) {}
template<class S>
D& operator=(S const& s)
{
return check_convert(*dest, s);
}
protected:
D* dest;
};
template<class D>
inline CheckConvert<D> check_convert(D& d)
{
return d;
}
//---------------------------------------------------------------------------
// Use NoCopy as a base class to easily prevent copy init & assign for any class.
struct NoCopy
{
NoCopy() {}
private:
NoCopy(const NoCopy&);
NoCopy& operator =(const NoCopy&);
};
//---------------------------------------------------------------------------
// ZeroInit: base class to zero the memory of the derived class before initialization, so local objects initialize the same as static.
// Usage:
// class MyClass: ZeroInit<MyClass> {...}
// class MyChild: public MyClass, ZeroInit<MyChild> {...} // ZeroInit must be the last base class
template<class TDerived>
struct ZeroInit
{
#if defined(__clang__) || defined(__GNUC__)
bool __dummy; // Dummy var to create non-zero size, ensuring proper placement in TDerived
#endif
ZeroInit(bool bZero = true)
{
// Optional bool arg to selectively disable zeroing.
if (bZero)
{
// Infer offset of this base class by static casting to derived class.
// Zero only the additional memory of the derived class.
TDerived* struct_end = static_cast<TDerived*>(this) + 1;
size_t memory_size = (char*)struct_end - (char*)this;
memset(this, 0, memory_size);
}
}
};
//---------------------------------------------------------------------------
// Quick const-manipulation macros
@@ -675,9 +361,6 @@ void SetFlags(T& dest, U flags, bool b)
#include AZ_RESTRICTED_FILE(platform_h)
#endif
// Platform wrappers must be included before CryString.h
# include "CryString.h"
// Include support for meta-type data.
#include "TypeInfo_decl.h"
@@ -687,35 +370,19 @@ void SetFlags(T& dest, U flags, bool b)
bool CrySetFileAttributes(const char* lpFileName, uint32 dwFileAttributes);
threadID CryGetCurrentThreadId();
#if !defined(NOT_USE_CRY_STRING)
// Fixed-Sized (stack based string)
// put after the platform wrappers because of missing wcsicmp/wcsnicmp functions
#include "CryFixedString.h"
#ifdef __GNUC__
#define NO_INLINE __attribute__ ((noinline))
#define NO_INLINE_WEAK __attribute__ ((noinline)) __attribute__((weak)) // marks a function as no_inline, but also as weak to prevent multiple-defined errors
#define __PACKED __attribute__ ((packed))
#else
#define NO_INLINE _declspec(noinline)
#define NO_INLINE_WEAK _declspec(noinline) inline
#define __PACKED
#endif
// need this in a common header file and any other file would be too misleading
enum ETriState
{
eTS_false,
eTS_true,
eTS_maybe
};
#ifdef __GNUC__
#define NO_INLINE __attribute__ ((noinline))
# define NO_INLINE_WEAK __attribute__ ((noinline)) __attribute__((weak)) // marks a function as no_inline, but also as weak to prevent multiple-defined errors
# define __PACKED __attribute__ ((packed))
#else
#define NO_INLINE _declspec(noinline)
# define NO_INLINE_WEAK _declspec(noinline) inline
# define __PACKED
#endif
// Fallback for Alignment macro of GCC/CLANG (must be after the class definition)
#if !defined(_ALIGN)
#define _ALIGN(num) AZ_POP_DISABLE_WARNING
#define _ALIGN(num) AZ_POP_DISABLE_WARNING
#endif
// Fallback for Alignment macro of MSVC (must be before the class definition)
@@ -727,7 +394,7 @@ enum ETriState
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_13
#include AZ_RESTRICTED_FILE(platform_h)
#elif !defined(LINUX) && !defined(APPLE)
typedef int socklen_t;
typedef int socklen_t;
#endif
// In RELEASE disable printf and fprintf
@@ -738,19 +405,9 @@ typedef int socklen_t;
#endif
#endif
#define _STRINGIFY(x) #x
#define STRINGIFY(x) _STRINGIFY(x)
#if defined(AZ_RESTRICTED_PLATFORM)
#define AZ_RESTRICTED_SECTION PLATFORM_H_SECTION_15
#include AZ_RESTRICTED_FILE(platform_h)
#endif
#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED)
#undef AZ_RESTRICTED_SECTION_IMPLEMENTED
#elif defined(WIN32) || defined(WIN64)
#define MESSAGE(msg) message(__FILE__ "(" STRINGIFY(__LINE__) "): " msg)
#else
#define MESSAGE(msg)
#endif
void InitRootDir(char szExeFileName[] = nullptr, uint nExeSize = 0, char szExeRootName[] = nullptr, uint nRootSize = 0);