text stringlengths 0 2.2M |
|---|
#if defined(EA_COMPILER_MSVC)
|
#include <math.h> // VS2008 has an acknowledged bug that requires math.h (and possibly also string.h) to be #included before intrin.h.
|
#include <intrin.h>
|
#pragma intrinsic(_ReturnAddress)
|
#endif
|
///////////////////////////////////////////////////////////////////////////////
|
// EASTLTest_GetGeneralAllocator()
|
//
|
namespace EA
|
{
|
namespace Allocator
|
{
|
#ifdef EA_DEBUG
|
extern PPM_API GeneralAllocatorDebug* gpEAGeneralAllocatorDebug;
|
#else
|
extern PPM_API GeneralAllocator* gpEAGeneralAllocator;
|
#endif
|
static inline auto& EASTLTest_GetGeneralAllocator()
|
{
|
#ifdef EA_DEBUG
|
using GeneralAllocatorType = GeneralAllocatorDebug;
|
#else
|
using GeneralAllocatorType = GeneralAllocator;
|
#endif
|
static GeneralAllocatorType sGeneralAllocator;
|
return sGeneralAllocator;
|
}
|
}
|
}
|
///////////////////////////////////////////////////////////////////////////////
|
// allocator counts for debugging purposes
|
//
|
int gEASTLTest_AllocationCount = 0;
|
int gEASTLTest_TotalAllocationCount = 0;
|
///////////////////////////////////////////////////////////////////////////////
|
// EASTLTest_ValidateHeap
|
//
|
bool EASTLTest_ValidateHeap()
|
{
|
#ifdef EA_DEBUG
|
return EA::Allocator::EASTLTest_GetGeneralAllocator().ValidateHeap(EA::Allocator::GeneralAllocator::kHeapValidationLevelBasic);
|
#else
|
return true;
|
#endif
|
}
|
///////////////////////////////////////////////////////////////////////////////
|
// Microsoft function parameter annotations
|
// https://msdn.microsoft.com/en-CA/library/hh916382.aspx
|
//
|
#ifndef _Ret_maybenull_
|
#define _Ret_maybenull_
|
#endif
|
#ifndef _Post_writable_byte_size_
|
#define _Post_writable_byte_size_(x)
|
#endif
|
#ifndef _Ret_notnull_
|
#define _Ret_notnull_
|
#endif
|
///////////////////////////////////////////////////////////////////////////////
|
// operator new extensions
|
//
|
namespace
|
{
|
#ifdef EA_DEBUG
|
const char gUnattributedNewTag[] = "Anonymous new";
|
#endif
|
#if defined(EA_COMPILER_MSVC)
|
#define UNATTRIBUTED_NEW_FILE "raw_return_address"
|
#define UNATTRIBUTED_NEW_LINE ((int)(uintptr_t)_ReturnAddress())
|
#else
|
#define UNATTRIBUTED_NEW_FILE NULL
|
#define UNATTRIBUTED_NEW_LINE 0
|
#endif
|
}
|
///////////////////////////////////////////////////////////////////////////////
|
// system memory allocation helpers
|
//
|
namespace
|
{
|
void* PlatformMalloc(size_t size, size_t alignment = 16)
|
{
|
#ifdef EA_PLATFORM_MICROSOFT
|
return _aligned_malloc(size, alignment);
|
#else
|
void *p = nullptr;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.