arm64 : fix intptr_t size

This commit is contained in:
hymei
2022-06-05 01:12:32 +03:00
committed by nillerusr
parent 2690e6c85a
commit 4e4039d756
143 changed files with 1015 additions and 674 deletions
+19 -19
View File
@@ -37,8 +37,8 @@
static const char * s_LastFileLoadingFrom = "unknown"; // just needed for error messages
// Statics for the growable string table
int (*KeyValues::s_pfGetSymbolForString)( const char *name, bool bCreate ) = &KeyValues::GetSymbolForStringClassic;
const char *(*KeyValues::s_pfGetStringForSymbol)( int symbol ) = &KeyValues::GetStringForSymbolClassic;
intp (*KeyValues::s_pfGetSymbolForString)( const char *name, bool bCreate ) = &KeyValues::GetSymbolForStringClassic;
const char *(*KeyValues::s_pfGetStringForSymbol)( intp symbol ) = &KeyValues::GetStringForSymbolClassic;
CKeyValuesGrowableStringTable *KeyValues::s_pGrowableStringTable = NULL;
#define KEYVALUES_TOKEN_SIZE 4096
@@ -63,7 +63,7 @@ public:
// entering a new keyvalues block, save state for errors
// Not save symbols instead of pointers because the pointers can move!
int Push( int symName )
int Push( intp symName )
{
if ( m_errorIndex < MAX_ERROR_STACK )
{
@@ -82,7 +82,7 @@ public:
}
// Allows you to keep the same stack level, but change the name as you parse peers
void Reset( int stackLevel, int symName )
void Reset( int stackLevel, intp symName )
{
Assert( stackLevel >= 0 );
Assert( stackLevel < m_errorIndex );
@@ -118,7 +118,7 @@ public:
}
private:
int m_errorStack[MAX_ERROR_STACK];
intp m_errorStack[MAX_ERROR_STACK];
const char *m_pFilename;
int m_errorIndex;
int m_maxErrorIndex;
@@ -138,11 +138,11 @@ public:
{
g_KeyValuesErrorStack.Pop();
}
CKeyErrorContext( int symName )
CKeyErrorContext( intp symName )
{
Init( symName );
}
void Reset( int symName )
void Reset( intp symName )
{
g_KeyValuesErrorStack.Reset( m_stackLevel, symName );
}
@@ -151,7 +151,7 @@ public:
return m_stackLevel;
}
private:
void Init( int symName )
void Init( intp symName )
{
m_stackLevel = g_KeyValuesErrorStack.Push( symName );
}
@@ -242,7 +242,7 @@ public:
}
// Translates a string to an index
int GetSymbolForString( const char *name, bool bCreate = true )
intp GetSymbolForString( const char *name, bool bCreate = true )
{
AUTO_LOCK( m_mutex );
@@ -273,7 +273,7 @@ public:
}
// Translates an index back to a string
const char *GetStringForSymbol( int symbol )
const char *GetStringForSymbol( intp symbol )
{
return (const char *)m_vecStrings.Base() + symbol;
}
@@ -292,7 +292,7 @@ private:
void SetCurStringBase( const char *pchCurBase ) { m_pchCurBase = pchCurBase; }
// The compare function.
bool operator()( int nLhs, int nRhs ) const
bool operator()( intp nLhs, intp nRhs ) const
{
const char *pchLhs = nLhs > 0 ? m_pchCurBase + nLhs : m_pchCurString;
const char *pchRhs = nRhs > 0 ? m_pchCurBase + nRhs : m_pchCurString;
@@ -313,7 +313,7 @@ private:
CThreadFastMutex m_mutex;
CLookupFunctor m_Functor;
CUtlHash<int, CLookupFunctor &, CLookupFunctor &> m_hashLookup;
CUtlHash<intp, CLookupFunctor &, CLookupFunctor &> m_hashLookup;
CUtlVector<char> m_vecStrings;
};
@@ -348,22 +348,22 @@ void KeyValues::SetUseGrowableStringTable( bool bUseGrowableTable )
// Purpose: Bodys of the function pointers used for interacting with the key
// name string table
//-----------------------------------------------------------------------------
int KeyValues::GetSymbolForStringClassic( const char *name, bool bCreate )
intp KeyValues::GetSymbolForStringClassic( const char *name, bool bCreate )
{
return KeyValuesSystem()->GetSymbolForString( name, bCreate );
}
const char *KeyValues::GetStringForSymbolClassic( int symbol )
const char *KeyValues::GetStringForSymbolClassic( intp symbol )
{
return KeyValuesSystem()->GetStringForSymbol( symbol );
}
int KeyValues::GetSymbolForStringGrowable( const char *name, bool bCreate )
intp KeyValues::GetSymbolForStringGrowable( const char *name, bool bCreate )
{
return s_pGrowableStringTable->GetSymbolForString( name, bCreate );
}
const char *KeyValues::GetStringForSymbolGrowable( int symbol )
const char *KeyValues::GetStringForSymbolGrowable( intp symbol )
{
return s_pGrowableStringTable->GetStringForSymbol( symbol );
}
@@ -970,7 +970,7 @@ void KeyValues::SaveKeyToFile( KeyValues *dat, IBaseFileSystem *filesystem, File
//-----------------------------------------------------------------------------
// Purpose: looks up a key by symbol name
//-----------------------------------------------------------------------------
KeyValues *KeyValues::FindKey(int keySymbol) const
KeyValues *KeyValues::FindKey(intp keySymbol) const
{
for (KeyValues *dat = m_pSub; dat != NULL; dat = dat->m_pPeer)
{
@@ -2658,7 +2658,7 @@ bool KeyValues::WriteAsBinary( CUtlBuffer &buffer )
}
case TYPE_PTR:
{
buffer.PutUnsignedInt( (int)dat->m_pValue );
buffer.PutPtr( dat->m_pValue );
}
default:
@@ -2762,7 +2762,7 @@ bool KeyValues::ReadAsBinary( CUtlBuffer &buffer, int nStackDepth )
}
case TYPE_PTR:
{
dat->m_pValue = (void*)buffer.GetUnsignedInt();
dat->m_pValue = buffer.GetPtr();
}
default:
+37 -37
View File
@@ -42,14 +42,14 @@ inline unsigned int CountTrailingZeros( unsigned int elem )
inline unsigned int CountLeadingZeros(unsigned int x)
{
unsigned long firstBit;
uint32 firstBit;
if ( _BitScanReverse(&firstBit,x) )
return 31 - firstBit;
return 32;
}
inline unsigned int CountTrailingZeros(unsigned int elem)
{
unsigned long out;
uint32 out;
if ( _BitScanForward(&out, elem) )
return out;
return 32;
@@ -83,14 +83,14 @@ void SetBitBufErrorHandler( BitBufErrorHandler fn )
// #define BB_PROFILING
unsigned long g_LittleBits[32];
uint32 g_LittleBits[32];
// Precalculated bit masks for WriteUBitLong. Using these tables instead of
// doing the calculations gives a 33% speedup in WriteUBitLong.
unsigned long g_BitWriteMasks[32][33];
uint32 g_BitWriteMasks[32][33];
// (1 << i) - 1
unsigned long g_ExtraMasks[33];
uint32 g_ExtraMasks[33];
class CBitWriteMasksInit
{
@@ -110,7 +110,7 @@ public:
for ( unsigned int maskBit=0; maskBit < 32; maskBit++ )
g_ExtraMasks[maskBit] = BitForBitnum(maskBit) - 1;
g_ExtraMasks[32] = ~0ul;
g_ExtraMasks[32] = ~0u;
for ( unsigned int littleBit=0; littleBit < 32; littleBit++ )
StoreLittleDWord( &g_LittleBits[littleBit], 0, 1u<<littleBit );
@@ -152,12 +152,12 @@ void bf_write::StartWriting( void *pData, int nBytes, int iStartBit, int nBits )
{
// Make sure it's dword aligned and padded.
Assert( (nBytes % 4) == 0 );
Assert(((unsigned long)pData & 3) == 0);
Assert(((uintp)pData & 3) == 0);
// The writing code will overrun the end of the buffer if it isn't dword aligned, so truncate to force alignment
nBytes &= ~3;
m_pData = (unsigned long*)pData;
m_pData = (uint32*)pData;
m_nDataBytes = nBytes;
if ( nBits == -1 )
@@ -462,7 +462,7 @@ bool bf_write::WriteBits(const void *pInData, int nBits)
}
// Align output to dword boundary
while (((unsigned long)pOut & 3) != 0 && nBitsLeft >= 8)
while (((uintp)pOut & 3) != 0 && nBitsLeft >= 8)
{
WriteUBitLong( *pOut, 8, false );
@@ -485,18 +485,18 @@ bool bf_write::WriteBits(const void *pInData, int nBits)
// X360TBD: Can't write dwords in WriteBits because they'll get swapped
if ( IsPC() && nBitsLeft >= 32 )
{
unsigned long iBitsRight = (m_iCurBit & 31);
unsigned long iBitsLeft = 32 - iBitsRight;
unsigned long bitMaskLeft = g_BitWriteMasks[iBitsRight][32];
unsigned long bitMaskRight = g_BitWriteMasks[0][iBitsRight];
uint32 iBitsRight = (m_iCurBit & 31);
uint32 iBitsLeft = 32 - iBitsRight;
uint32 bitMaskLeft = g_BitWriteMasks[iBitsRight][32];
uint32 bitMaskRight = g_BitWriteMasks[0][iBitsRight];
unsigned long *pData = &m_pData[m_iCurBit>>5];
uint32 *pData = &m_pData[m_iCurBit>>5];
// Read dwords.
while(nBitsLeft >= 32)
{
unsigned long curData = *(unsigned long*)pOut;
pOut += sizeof(unsigned long);
uint32 curData = *(uint32*)pOut;
pOut += sizeof(uint32);
*pData &= bitMaskLeft;
*pData |= curData << iBitsRight;
@@ -736,9 +736,9 @@ void bf_write::WriteWord(int val)
WriteUBitLong(val, sizeof(unsigned short) << 3);
}
void bf_write::WriteLong(long val)
void bf_write::WriteLong(int32 val)
{
WriteSBitLong(val, sizeof(long) << 3);
WriteSBitLong(val, sizeof(int32) << 3);
}
void bf_write::WriteLongLong(int64 val)
@@ -748,8 +748,8 @@ void bf_write::WriteLongLong(int64 val)
// Insert the two DWORDS according to network endian
const short endianIndex = 0x0100;
byte *idx = (byte*)&endianIndex;
WriteUBitLong(pLongs[*idx++], sizeof(long) << 3);
WriteUBitLong(pLongs[*idx], sizeof(long) << 3);
WriteUBitLong(pLongs[*idx++], sizeof(int32) << 3);
WriteUBitLong(pLongs[*idx], sizeof(int32) << 3);
}
void bf_write::WriteFloat(float val)
@@ -898,8 +898,8 @@ void bf_read::ReadBits(void *pOutData, int nBits)
// read dwords
while ( nBitsLeft >= 32 )
{
*((unsigned long*)pOut) = ReadUBitLong(32);
pOut += sizeof(unsigned long);
*((uint32*)pOut) = ReadUBitLong(32);
pOut += sizeof(uint32);
nBitsLeft -= 32;
}
}
@@ -1349,8 +1349,8 @@ int64 bf_read::ReadLongLong()
// Read the two DWORDs according to network endian
const short endianIndex = 0x0100;
byte *idx = (byte*)&endianIndex;
pLongs[*idx++] = ReadUBitLong(sizeof(long) << 3);
pLongs[*idx] = ReadUBitLong(sizeof(long) << 3);
pLongs[*idx++] = ReadUBitLong(sizeof(int32) << 3);
pLongs[*idx] = ReadUBitLong(sizeof(int32) << 3);
return retval;
}
@@ -1448,7 +1448,7 @@ void bf_read::ExciseBits( int startbit, int bitstoremove )
int bf_read::CompareBitsAt( int offset, bf_read * RESTRICT other, int otherOffset, int numbits ) RESTRICT
{
extern unsigned long g_ExtraMasks[33];
extern uint32 g_ExtraMasks[33];
if ( numbits == 0 )
return 0;
@@ -1462,17 +1462,17 @@ int bf_read::CompareBitsAt( int offset, bf_read * RESTRICT other, int otherOffse
unsigned int iStartBit1 = offset & 31u;
unsigned int iStartBit2 = otherOffset & 31u;
unsigned long *pData1 = (unsigned long*)m_pData + (offset >> 5);
unsigned long *pData2 = (unsigned long*)other->m_pData + (otherOffset >> 5);
unsigned long *pData1End = pData1 + ((offset + numbits - 1) >> 5);
unsigned long *pData2End = pData2 + ((otherOffset + numbits - 1) >> 5);
uint32 *pData1 = (uint32*)m_pData + (offset >> 5);
uint32 *pData2 = (uint32*)other->m_pData + (otherOffset >> 5);
uint32 *pData1End = pData1 + ((offset + numbits - 1) >> 5);
uint32 *pData2End = pData2 + ((otherOffset + numbits - 1) >> 5);
while ( numbits > 32 )
{
x = LoadLittleDWord( (unsigned long*)pData1, 0 ) >> iStartBit1;
x ^= LoadLittleDWord( (unsigned long*)pData1, 1 ) << (32 - iStartBit1);
x ^= LoadLittleDWord( (unsigned long*)pData2, 0 ) >> iStartBit2;
x ^= LoadLittleDWord( (unsigned long*)pData2, 1 ) << (32 - iStartBit2);
x = LoadLittleDWord( (uint32*)pData1, 0 ) >> iStartBit1;
x ^= LoadLittleDWord( (uint32*)pData1, 1 ) << (32 - iStartBit1);
x ^= LoadLittleDWord( (uint32*)pData2, 0 ) >> iStartBit2;
x ^= LoadLittleDWord( (uint32*)pData2, 1 ) << (32 - iStartBit2);
if ( x != 0 )
{
return x;
@@ -1482,9 +1482,9 @@ int bf_read::CompareBitsAt( int offset, bf_read * RESTRICT other, int otherOffse
numbits -= 32;
}
x = LoadLittleDWord( (unsigned long*)pData1, 0 ) >> iStartBit1;
x ^= LoadLittleDWord( (unsigned long*)pData1End, 0 ) << (32 - iStartBit1);
x ^= LoadLittleDWord( (unsigned long*)pData2, 0 ) >> iStartBit2;
x ^= LoadLittleDWord( (unsigned long*)pData2End, 0 ) << (32 - iStartBit2);
x = LoadLittleDWord( (uint32*)pData1, 0 ) >> iStartBit1;
x ^= LoadLittleDWord( (uint32*)pData1End, 0 ) << (32 - iStartBit1);
x ^= LoadLittleDWord( (uint32*)pData2, 0 ) >> iStartBit2;
x ^= LoadLittleDWord( (uint32*)pData2End, 0 ) << (32 - iStartBit2);
return x & g_ExtraMasks[ numbits ];
}
+1 -1
View File
@@ -150,7 +150,7 @@ JustAfew:
// The low-order two bits of pb and nBuffer in total control the
// upfront work.
//
nFront = ((unsigned int)pb) & 3;
nFront = ((uintp)pb) & 3;
nBuffer -= nFront;
switch (nFront)
{
+8 -8
View File
@@ -92,9 +92,9 @@ bool CCommandBuffer::ParseArgV0( CUtlBuffer &buf, char *pArgV0, int nMaxLen, con
//-----------------------------------------------------------------------------
// Insert a command into the command queue
//-----------------------------------------------------------------------------
void CCommandBuffer::InsertCommandAtAppropriateTime( int hCommand )
void CCommandBuffer::InsertCommandAtAppropriateTime( CommandHandle_t hCommand )
{
int i;
intp i;
Command_t &command = m_Commands[hCommand];
for ( i = m_Commands.Head(); i != m_Commands.InvalidIndex(); i = m_Commands.Next(i) )
{
@@ -108,7 +108,7 @@ void CCommandBuffer::InsertCommandAtAppropriateTime( int hCommand )
//-----------------------------------------------------------------------------
// Insert a command into the command queue at the appropriate time
//-----------------------------------------------------------------------------
void CCommandBuffer::InsertImmediateCommand( int hCommand )
void CCommandBuffer::InsertImmediateCommand( CommandHandle_t hCommand )
{
m_Commands.LinkBefore( m_hNextCommand, hCommand );
}
@@ -137,7 +137,7 @@ bool CCommandBuffer::InsertCommand( const char *pArgS, int nCommandSize, int nTi
m_pArgSBuffer[m_nArgSBufferSize + nCommandSize] = 0;
++nCommandSize;
int hCommand = m_Commands.Alloc();
intp hCommand = m_Commands.Alloc();
Command_t &command = m_Commands[hCommand];
command.m_nTick = nTick;
command.m_nFirstArgS = m_nArgSBufferSize;
@@ -264,7 +264,7 @@ void CCommandBuffer::DelayAllQueuedCommands( int nDelay )
if ( nDelay <= 0 )
return;
for ( int i = m_Commands.Head(); i != m_Commands.InvalidIndex(); i = m_Commands.Next(i) )
for ( intp i = m_Commands.Head(); i != m_Commands.InvalidIndex(); i = m_Commands.Next(i) )
{
m_Commands[i].m_nTick += nDelay;
}
@@ -299,7 +299,7 @@ bool CCommandBuffer::DequeueNextCommand( )
if ( m_Commands.Count() == 0 )
return false;
int nHead = m_Commands.Head();
intp nHead = m_Commands.Head();
Command_t &command = m_Commands[ nHead ];
if ( command.m_nTick > m_nLastTickToProcess )
return false;
@@ -354,7 +354,7 @@ void CCommandBuffer::Compact()
m_nArgSBufferSize = 0;
char pTempBuffer[ ARGS_BUFFER_LENGTH ];
for ( int i = m_Commands.Head(); i != m_Commands.InvalidIndex(); i = m_Commands.Next(i) )
for ( intp i = m_Commands.Head(); i != m_Commands.InvalidIndex(); i = m_Commands.Next(i) )
{
Command_t &command = m_Commands[ i ];
@@ -382,7 +382,7 @@ void CCommandBuffer::EndProcessingCommands()
// Extract commands that are before the end time
// NOTE: This is a bug for this to
int i = m_Commands.Head();
intp i = m_Commands.Head();
if ( i == m_Commands.InvalidIndex() )
{
m_nArgSBufferSize = 0;
+2 -2
View File
@@ -145,7 +145,7 @@ bool KVPacker::WriteAsBinary( KeyValues *pNode, CUtlBuffer &buffer )
}
case KeyValues::TYPE_PTR:
{
buffer.PutUnsignedInt( (int)dat->GetPtr() );
buffer.PutUnsignedInt( (uintptr_t)dat->GetPtr() );
break;
}
@@ -258,7 +258,7 @@ bool KVPacker::ReadAsBinary( KeyValues *pNode, CUtlBuffer &buffer )
}
case PACKTYPE_PTR:
{
dat->SetPtr( NULL, (void*)buffer.GetUnsignedInt() );
dat->SetPtr( NULL, buffer.GetPtr() );
break;
}
+1 -1
View File
@@ -54,7 +54,7 @@ void CLZSS::BuildHash( const unsigned char *pData )
lzss_list_t *pList;
lzss_node_t *pTarget;
int targetindex = (unsigned int)pData & ( m_nWindowSize - 1 );
intp targetindex = (intp)pData & ( m_nWindowSize - 1 );
pTarget = &m_pHashTarget[targetindex];
if ( pTarget->pData )
{