Merge pull request #2941 from lioncash/gp

GPFifo: Remove pointer casts
This commit is contained in:
Scott Mansell 2015-09-03 13:47:26 +12:00
commit a1538a30ef
2 changed files with 32 additions and 33 deletions

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cstring>
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
@ -104,58 +106,55 @@ void CheckGatherPipe()
}
}
void Write8(const u8 _iValue)
void Write8(const u8 value)
{
// LOG(GPFIFO, "GPFIFO #%x: 0x%02x",ProcessorInterface::Fifo_CPUWritePointer+m_gatherPipeCount, _iValue);
FastWrite8(_iValue);
FastWrite8(value);
CheckGatherPipe();
}
void Write16(const u16 _iValue)
void Write16(const u16 value)
{
// LOG(GPFIFO, "GPFIFO #%x: 0x%04x",ProcessorInterface::Fifo_CPUWritePointer+m_gatherPipeCount, _iValue);
FastWrite16(_iValue);
FastWrite16(value);
CheckGatherPipe();
}
void Write32(const u32 _iValue)
void Write32(const u32 value)
{
//#ifdef _DEBUG
// float floatvalue = *(float*)&_iValue;
// LOG(GPFIFO, "GPFIFO #%x: 0x%08x / %f",ProcessorInterface::Fifo_CPUWritePointer+m_gatherPipeCount, _iValue, floatvalue);
//#endif
FastWrite32(_iValue);
FastWrite32(value);
CheckGatherPipe();
}
void Write64(const u64 _iValue)
void Write64(const u64 value)
{
FastWrite64(_iValue);
FastWrite64(value);
CheckGatherPipe();
}
void FastWrite8(const u8 _iValue)
void FastWrite8(const u8 value)
{
m_gatherPipe[m_gatherPipeCount] = _iValue;
m_gatherPipe[m_gatherPipeCount] = value;
++m_gatherPipeCount;
}
void FastWrite16(const u16 _iValue)
void FastWrite16(u16 value)
{
*(u16*)(&m_gatherPipe[m_gatherPipeCount]) = Common::swap16(_iValue);
m_gatherPipeCount += 2;
value = Common::swap16(value);
std::memcpy(&m_gatherPipe[m_gatherPipeCount], &value, sizeof(u16));
m_gatherPipeCount += sizeof(u16);
}
void FastWrite32(const u32 _iValue)
void FastWrite32(u32 value)
{
*(u32*)(&m_gatherPipe[m_gatherPipeCount]) = Common::swap32(_iValue);
m_gatherPipeCount += 4;
value = Common::swap32(value);
std::memcpy(&m_gatherPipe[m_gatherPipeCount], &value, sizeof(u32));
m_gatherPipeCount += sizeof(u32);
}
void FastWrite64(const u64 _iValue)
void FastWrite64(u64 value)
{
*(u64*)(&m_gatherPipe[m_gatherPipeCount]) = Common::swap64(_iValue);
m_gatherPipeCount += 8;
value = Common::swap64(value);
std::memcpy(&m_gatherPipe[m_gatherPipeCount], &value, sizeof(u64));
m_gatherPipeCount += sizeof(u64);
}
} // end of namespace GPFifo

View File

@ -34,16 +34,16 @@ void FastCheckGatherPipe();
bool IsEmpty();
// Write
void Write8(const u8 _iValue);
void Write16(const u16 _iValue);
void Write32(const u32 _iValue);
void Write64(const u64 _iValue);
void Write8(u8 value);
void Write16(u16 value);
void Write32(u32 value);
void Write64(u64 value);
// These expect pre-byteswapped values
// Also there's an upper limit of about 512 per batch
// Most likely these should be inlined into JIT instead
void FastWrite8(const u8 _iValue);
void FastWrite16(const u16 _iValue);
void FastWrite32(const u32 _iValue);
void FastWrite64(const u64 _iValue);
void FastWrite8(u8 value);
void FastWrite16(u16 value);
void FastWrite32(u32 value);
void FastWrite64(u64 value);
}