ChunkFile has allowed me to accidentally "Do" a non-POD for the last time!

This commit is contained in:
Jordan Woyak 2013-04-09 18:57:39 -05:00
parent 5c374b2718
commit 385d8e2b15
18 changed files with 43 additions and 30 deletions

View File

@ -32,6 +32,7 @@
#include <list> #include <list>
#include <deque> #include <deque>
#include <string> #include <string>
#include <type_traits>
#include "Common.h" #include "Common.h"
#include "FileUtil.h" #include "FileUtil.h"
@ -139,11 +140,17 @@ public:
template <typename T> template <typename T>
void Do(T& x) void Do(T& x)
{ {
// TODO: Bad, Do(some_non_POD) will compile and fail at runtime // Ideally this would be std::is_trivially_copyable, but not enough support yet
// type_traits are not fully supported everywhere yet static_assert(std::is_pod<T>::value, "Only sane for POD types");
DoVoid((void*)&x, sizeof(x)); DoVoid((void*)&x, sizeof(x));
} }
template <typename T>
void DoPOD(T& x)
{
DoVoid((void*)&x, sizeof(x));
}
template <typename T> template <typename T>
void DoPointer(T*& x, T* const base) void DoPointer(T*& x, T* const base)

View File

@ -131,8 +131,8 @@ static unsigned int g_AIDSampleRate = 32000;
void DoState(PointerWrap &p) void DoState(PointerWrap &p)
{ {
p.Do(m_Control); p.DoPOD(m_Control);
p.Do(m_Volume); p.DoPOD(m_Volume);
p.Do(m_SampleCounter); p.Do(m_SampleCounter);
p.Do(m_InterruptTiming); p.Do(m_InterruptTiming);
p.Do(g_LastCPUTime); p.Do(g_LastCPUTime);

View File

@ -223,9 +223,9 @@ void DoState(PointerWrap &p)
{ {
if (!g_ARAM.wii_mode) if (!g_ARAM.wii_mode)
p.DoArray(g_ARAM.ptr, g_ARAM.size); p.DoArray(g_ARAM.ptr, g_ARAM.size);
p.Do(g_dspState); p.DoPOD(g_dspState);
p.Do(g_audioDMA); p.DoPOD(g_audioDMA);
p.Do(g_arDMA); p.DoPOD(g_arDMA);
p.Do(g_ARAM_Info); p.Do(g_ARAM_Info);
p.Do(g_AR_MODE); p.Do(g_AR_MODE);
p.Do(g_AR_REFRESH); p.Do(g_AR_REFRESH);

View File

@ -157,8 +157,8 @@ void DSPHLE::DoState(PointerWrap &p)
} }
} }
p.Do(m_DSPControl); p.DoPOD(m_DSPControl);
p.Do(m_dspState); p.DoPOD(m_dspState);
int ucode_crc = IUCode::GetCRC(m_pUCode); int ucode_crc = IUCode::GetCRC(m_pUCode);
int ucode_crc_beforeLoad = ucode_crc; int ucode_crc_beforeLoad = ucode_crc;

View File

@ -229,14 +229,14 @@ void ExecuteCommand(UDICR& _DICR);
void DoState(PointerWrap &p) void DoState(PointerWrap &p)
{ {
p.Do(m_DISR); p.DoPOD(m_DISR);
p.Do(m_DICVR); p.DoPOD(m_DICVR);
p.DoArray(m_DICMDBUF, 3); p.DoArray(m_DICMDBUF, 3);
p.Do(m_DIMAR); p.Do(m_DIMAR);
p.Do(m_DILENGTH); p.Do(m_DILENGTH);
p.Do(m_DICR); p.Do(m_DICR);
p.Do(m_DIIMMBUF); p.Do(m_DIIMMBUF);
p.Do(m_DICFG); p.DoPOD(m_DICFG);
p.Do(LoopStart); p.Do(LoopStart);
p.Do(AudioPos); p.Do(AudioPos);

View File

@ -282,7 +282,7 @@ void CEXIChannel::Write32(const u32 _iValue, const u32 _iRegister)
void CEXIChannel::DoState(PointerWrap &p) void CEXIChannel::DoState(PointerWrap &p)
{ {
p.Do(m_Status); p.DoPOD(m_Status);
p.Do(m_DMAMemoryAddress); p.Do(m_DMAMemoryAddress);
p.Do(m_DMALength); p.Do(m_DMALength);
p.Do(m_Control); p.Do(m_Control);

View File

@ -257,8 +257,8 @@ void DoState(PointerWrap &p)
} }
} }
p.Do(g_Poll); p.Do(g_Poll);
p.Do(g_ComCSR); p.DoPOD(g_ComCSR);
p.Do(g_StatusReg); p.DoPOD(g_StatusReg);
p.Do(g_EXIClockCount); p.Do(g_EXIClockCount);
p.Do(g_SIBuffer); p.Do(g_SIBuffer);
} }

View File

@ -72,8 +72,8 @@ static int fields = 2;
void DoState(PointerWrap &p) void DoState(PointerWrap &p)
{ {
p.Do(m_VerticalTimingRegister); p.DoPOD(m_VerticalTimingRegister);
p.Do(m_DisplayControlRegister); p.DoPOD(m_DisplayControlRegister);
p.Do(m_HTiming0); p.Do(m_HTiming0);
p.Do(m_HTiming1); p.Do(m_HTiming1);
p.Do(m_VBlankTimingOdd); p.Do(m_VBlankTimingOdd);
@ -89,7 +89,7 @@ void DoState(PointerWrap &p)
p.DoArray(m_InterruptRegister, 4); p.DoArray(m_InterruptRegister, 4);
p.DoArray(m_LatchRegister, 2); p.DoArray(m_LatchRegister, 2);
p.Do(m_HorizontalStepping); p.Do(m_HorizontalStepping);
p.Do(m_HorizontalScaling); p.DoPOD(m_HorizontalScaling);
p.Do(m_FilterCoefTables); p.Do(m_FilterCoefTables);
p.Do(m_UnkAARegister); p.Do(m_UnkAARegister);
p.Do(m_Clock); p.Do(m_Clock);

View File

@ -111,7 +111,7 @@ void DoState(PointerWrap &p)
{ {
p.Do(ppc_msg); p.Do(ppc_msg);
p.Do(arm_msg); p.Do(arm_msg);
p.Do(ctrl); p.DoPOD(ctrl);
p.Do(ppc_irq_flags); p.Do(ppc_irq_flags);
p.Do(ppc_irq_masks); p.Do(ppc_irq_masks);
p.Do(arm_irq_flags); p.Do(arm_irq_flags);

View File

@ -109,8 +109,8 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::DoState(PointerWrap &p)
p.Do(m_ControllerBD); p.Do(m_ControllerBD);
p.Do(m_CtrlSetup); p.Do(m_CtrlSetup);
p.Do(m_ACLSetup); p.Do(m_ACLSetup);
p.Do(m_HCIEndpoint); p.DoPOD(m_HCIEndpoint);
p.Do(m_ACLEndpoint); p.DoPOD(m_ACLEndpoint);
p.Do(m_last_ticks); p.Do(m_last_ticks);
p.DoArray(m_PacketCount,4); p.DoArray(m_PacketCount,4);
p.Do(m_ScanEnable); p.Do(m_ScanEnable);

View File

@ -51,6 +51,12 @@ struct SQueuedEvent
} }
}; };
// Hacks for ChunkFile to accept SQueuedEvent as POD
namespace std
{
template <>
struct is_pod<SQueuedEvent> : std::true_type {};
}
// Important to remember that this class is for /dev/usb/oh1/57e/305 ONLY // Important to remember that this class is for /dev/usb/oh1/57e/305 ONLY
// /dev/usb/oh1 -> internal usb bus // /dev/usb/oh1 -> internal usb bus

View File

@ -80,7 +80,7 @@ void DoState(PointerWrap &p)
// rSPR(SPR_DEC) = SystemTimers::GetFakeDecrementer(); // rSPR(SPR_DEC) = SystemTimers::GetFakeDecrementer();
// *((u64 *)&TL) = SystemTimers::GetFakeTimeBase(); //works since we are little endian and TL comes first :) // *((u64 *)&TL) = SystemTimers::GetFakeTimeBase(); //works since we are little endian and TL comes first :)
p.Do(ppcState); p.DoPOD(ppcState);
// SystemTimers::DecrementerSet(); // SystemTimers::DecrementerSet();
// SystemTimers::TimeBaseSet(); // SystemTimers::TimeBaseSet();

View File

@ -133,7 +133,7 @@ bool WbfsFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr)
{ {
while(nbytes) while(nbytes)
{ {
u64 read_size; u64 read_size = 0;
File::IOFile& data_file = SeekToCluster(offset, &read_size); File::IOFile& data_file = SeekToCluster(offset, &read_size);
read_size = (read_size > nbytes) ? nbytes : read_size; read_size = (read_size > nbytes) ? nbytes : read_size;

View File

@ -80,9 +80,9 @@ void UpdateInterrupts_Wrapper(u64 userdata, int cyclesLate)
void DoState(PointerWrap &p) void DoState(PointerWrap &p)
{ {
p.Do(m_CPStatusReg); p.DoPOD(m_CPStatusReg);
p.Do(m_CPCtrlReg); p.DoPOD(m_CPCtrlReg);
p.Do(m_CPClearReg); p.DoPOD(m_CPClearReg);
p.Do(m_bboxleft); p.Do(m_bboxleft);
p.Do(m_bboxtop); p.Do(m_bboxtop);
p.Do(m_bboxright); p.Do(m_bboxright);

View File

@ -137,7 +137,7 @@ void DoState(PointerWrap &p)
p.Do(m_DstAlphaConf); p.Do(m_DstAlphaConf);
p.Do(m_AlphaModeConf); p.Do(m_AlphaModeConf);
p.Do(m_AlphaRead); p.Do(m_AlphaRead);
p.Do(m_Control); p.DoPOD(m_Control);
p.Do(g_bSignalTokenInterrupt); p.Do(g_bSignalTokenInterrupt);
p.Do(g_bSignalFinishInterrupt); p.Do(g_bSignalFinishInterrupt);

View File

@ -56,7 +56,7 @@ CPReg cpreg; // shared between gfx and emulator thread
void DoState(PointerWrap &p) void DoState(PointerWrap &p)
{ {
p.Do(cpreg); p.DoPOD(cpreg);
p.DoArray(commandBuffer, commandBufferSize); p.DoArray(commandBuffer, commandBufferSize);
p.Do(readPos); p.Do(readPos);
p.Do(writePos); p.Do(writePos);

View File

@ -50,7 +50,7 @@ static int et_SetFinishOnMainThread;
void DoState(PointerWrap &p) void DoState(PointerWrap &p)
{ {
p.Do(pereg); p.DoPOD(pereg);
p.Do(g_bSignalTokenInterrupt); p.Do(g_bSignalTokenInterrupt);
p.Do(g_bSignalFinishInterrupt); p.Do(g_bSignalFinishInterrupt);
p.Do(et_SetTokenOnMainThread); p.Do(et_SetTokenOnMainThread);

View File

@ -112,7 +112,7 @@ void VideoSoftware::DoState(PointerWrap& p)
Clipper::DoState(p); Clipper::DoState(p);
p.Do(swxfregs); p.Do(swxfregs);
p.Do(bpmem); p.Do(bpmem);
p.Do(swstats); p.DoPOD(swstats);
// CP Memory // CP Memory
p.DoArray(arraybases, 16); p.DoArray(arraybases, 16);