mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-05 22:09:59 +03:00
aarch64: fix android build
This commit is contained in:
46
public/tier0/memvirt.h
Normal file
46
public/tier0/memvirt.h
Normal file
@@ -0,0 +1,46 @@
|
||||
//========== Copyright (C) Valve Corporation, All rights reserved. ==========//
|
||||
//
|
||||
// Purpose: CVirtualMemoryManager interface
|
||||
//
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef MEM_VIRT_H
|
||||
#define MEM_VIRT_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#define VMM_KB ( 1024 )
|
||||
#define VMM_MB ( 1024 * VMM_KB )
|
||||
|
||||
#ifdef _PS3
|
||||
// Total virtual address space reserved by CVirtualMemoryManager on startup:
|
||||
#define VMM_VIRTUAL_SIZE ( 512 * VMM_MB )
|
||||
#define VMM_PAGE_SIZE ( 64 * VMM_KB )
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// Allocate virtual sections via IMemAlloc::AllocateVirtualMemorySection
|
||||
abstract_class IVirtualMemorySection
|
||||
{
|
||||
public:
|
||||
// Information about memory section
|
||||
virtual void * GetBaseAddress() = 0;
|
||||
virtual size_t GetPageSize() = 0;
|
||||
virtual size_t GetTotalSize() = 0;
|
||||
|
||||
// Functions to manage physical memory mapped to virtual memory
|
||||
virtual bool CommitPages( void *pvBase, size_t numBytes ) = 0;
|
||||
virtual void DecommitPages( void *pvBase, size_t numBytes ) = 0;
|
||||
|
||||
// Release the physical memory and associated virtual address space
|
||||
virtual void Release() = 0;
|
||||
};
|
||||
|
||||
// Get the IVirtualMemorySection associated with a given memory address (if any):
|
||||
extern IVirtualMemorySection *GetMemorySectionForAddress( void *pAddress );
|
||||
|
||||
|
||||
#endif // MEM_VIRT_H
|
||||
@@ -9,7 +9,7 @@
|
||||
#ifndef PLATFORM_H
|
||||
#define PLATFORM_H
|
||||
|
||||
#if defined(__x86_64__) || defined(_WIN64) || defined(__arm64__)
|
||||
#if defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__)
|
||||
#define PLATFORM_64BITS 1
|
||||
#endif
|
||||
|
||||
@@ -440,7 +440,7 @@ typedef void * HINSTANCE;
|
||||
// On OSX, SIGTRAP doesn't really stop the thread cold when debugging.
|
||||
// So if being debugged, use INT3 which is precise.
|
||||
#ifdef OSX
|
||||
#if defined(__arm__) || defined(__arm64__)
|
||||
#if defined(__arm__) || defined(__aarch64__)
|
||||
#ifdef __clang__
|
||||
#define DebuggerBreak() do { if ( Plat_IsInDebugSession() ) { __builtin_debugtrap(); } else { raise(SIGTRAP); } } while(0)
|
||||
#elif defined __GNUC__
|
||||
@@ -631,6 +631,7 @@ typedef void * HINSTANCE;
|
||||
#endif
|
||||
|
||||
// Used for standard calling conventions
|
||||
|
||||
#if defined( _WIN32 ) && !defined( _X360 )
|
||||
#define STDCALL __stdcall
|
||||
#define FASTCALL __fastcall
|
||||
@@ -687,6 +688,11 @@ typedef void * HINSTANCE;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifdef __SANITIZE_ADDRESS__
|
||||
#undef FORCEINLINE
|
||||
#define FORCEINLINE static
|
||||
#endif
|
||||
|
||||
// Remove warnings from warning level 4.
|
||||
#pragma warning(disable : 4514) // warning C4514: 'acosl' : unreferenced inline function has been removed
|
||||
#pragma warning(disable : 4100) // warning C4100: 'hwnd' : unreferenced formal parameter
|
||||
@@ -861,7 +867,7 @@ static FORCEINLINE double fsel(double fComparand, double fValGE, double fLT)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#elif defined (__arm__) || defined (__arm64__)
|
||||
#elif defined (__arm__) || defined (__aarch64__)
|
||||
inline void SetupFPUControlWord() {}
|
||||
#else
|
||||
inline void SetupFPUControlWord()
|
||||
@@ -1198,7 +1204,7 @@ PLATFORM_INTERFACE struct tm * Plat_localtime( const time_t *timep, struct tm *
|
||||
|
||||
inline uint64 Plat_Rdtsc()
|
||||
{
|
||||
#if (defined( __arm__ ) || defined( __arm64__ )) && defined (POSIX)
|
||||
#if (defined( __arm__ ) || defined( __aarch64__ )) && defined (POSIX)
|
||||
struct timespec t;
|
||||
clock_gettime( CLOCK_REALTIME, &t);
|
||||
return t.tv_sec * 1000000000ULL + t.tv_nsec;
|
||||
|
||||
@@ -81,7 +81,7 @@ enum ThreadPriorityEnum_t
|
||||
TP_PRIORITY_LOW = 2001,
|
||||
TP_PRIORITY_DEFAULT = 1001
|
||||
#error "Need PRIORITY_LOWEST/HIGHEST"
|
||||
#elif defined( PLATFORM_LINUX )
|
||||
#elif defined( LINUX )
|
||||
// We can use nice on Linux threads to change scheduling.
|
||||
// pthreads on Linux only allows priority setting on
|
||||
// real-time threads.
|
||||
@@ -103,7 +103,7 @@ enum ThreadPriorityEnum_t
|
||||
#endif // PLATFORM_PS3
|
||||
};
|
||||
|
||||
#if defined( PLATFORM_LINUX )
|
||||
#if defined( LINUX )
|
||||
#define TP_IS_PRIORITY_HIGHER( a, b ) ( ( a ) < ( b ) )
|
||||
#else
|
||||
#define TP_IS_PRIORITY_HIGHER( a, b ) ( ( a ) > ( b ) )
|
||||
@@ -229,6 +229,8 @@ inline void ThreadPause()
|
||||
{
|
||||
#if defined( COMPILER_PS3 )
|
||||
__db16cyc();
|
||||
#elif defined(__arm__) || defined(__aarch64__)
|
||||
sched_yield();
|
||||
#elif defined( COMPILER_GCC )
|
||||
__asm __volatile( "pause" );
|
||||
#elif defined ( COMPILER_MSVC64 )
|
||||
@@ -301,15 +303,7 @@ inline int32 ThreadInterlockedDecrement( int32 volatile *p )
|
||||
inline int32 ThreadInterlockedExchange( int32 volatile *p, int32 value )
|
||||
{
|
||||
Assert( (size_t)p % 4 == 0 );
|
||||
int32 nRet;
|
||||
|
||||
// Note: The LOCK instruction prefix is assumed on the XCHG instruction and GCC gets very confused on the Mac when we use it.
|
||||
__asm __volatile(
|
||||
"xchgl %2,(%1)"
|
||||
: "=r" (nRet)
|
||||
: "r" (p), "0" (value)
|
||||
: "memory");
|
||||
return nRet;
|
||||
return __sync_lock_test_and_set( p, value );
|
||||
}
|
||||
|
||||
inline int32 ThreadInterlockedExchangeAdd( int32 volatile *p, int32 value )
|
||||
|
||||
@@ -120,7 +120,7 @@ INLINE_ON_PS3 bool CThread::Start( unsigned nBytesStack, ThreadPriorityEnum_t nP
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
#ifdef _WIN32
|
||||
m_hThread = (HANDLE)CreateThread( NULL,
|
||||
nBytesStack,
|
||||
(LPTHREAD_START_ROUTINE)GetThreadProc(),
|
||||
@@ -168,7 +168,7 @@ INLINE_ON_PS3 bool CThread::Start( unsigned nBytesStack, ThreadPriorityEnum_t nP
|
||||
}
|
||||
|
||||
bInitSuccess = true;
|
||||
#elif PLATFORM_POSIX
|
||||
#elif POSIX
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init( &attr );
|
||||
pthread_attr_setstacksize( &attr, MAX( nBytesStack, 1024u*1024 ) );
|
||||
@@ -236,7 +236,7 @@ INLINE_ON_PS3 bool CThread::Start( unsigned nBytesStack, ThreadPriorityEnum_t nP
|
||||
|
||||
INLINE_ON_PS3 bool CThread::IsAlive()
|
||||
{
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
#ifdef _WIN32
|
||||
DWORD dwExitCode;
|
||||
return (
|
||||
m_hThread
|
||||
@@ -526,7 +526,7 @@ INLINE_ON_PS3 void CThread::ThreadProcRunWithMinidumpHandler( void *pv )
|
||||
pInit->pThread->m_result = pInit->pThread->Run();
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
#ifdef _WIN32
|
||||
unsigned long STDCALL CThread::ThreadProc(LPVOID pv)
|
||||
#else
|
||||
INLINE_ON_PS3 void* CThread::ThreadProc(LPVOID pv)
|
||||
|
||||
Reference in New Issue
Block a user