From 385d8e2b15c8accce3b4e4b4f3dc90f63e3fbee4 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 9 Apr 2013 18:57:39 -0500 Subject: [PATCH] ChunkFile has allowed me to accidentally "Do" a non-POD for the last time! --- Source/Core/Common/Src/ChunkFile.h | 11 +++++++++-- Source/Core/Core/Src/HW/AudioInterface.cpp | 4 ++-- Source/Core/Core/Src/HW/DSP.cpp | 6 +++--- Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp | 4 ++-- Source/Core/Core/Src/HW/DVDInterface.cpp | 6 +++--- Source/Core/Core/Src/HW/EXI_Channel.cpp | 2 +- Source/Core/Core/Src/HW/SI.cpp | 4 ++-- Source/Core/Core/Src/HW/VideoInterface.cpp | 6 +++--- Source/Core/Core/Src/HW/WII_IPC.cpp | 2 +- .../Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp | 4 ++-- Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h | 6 ++++++ Source/Core/Core/Src/PowerPC/PowerPC.cpp | 2 +- Source/Core/DiscIO/Src/WbfsBlob.cpp | 2 +- Source/Core/VideoCommon/Src/CommandProcessor.cpp | 6 +++--- Source/Core/VideoCommon/Src/PixelEngine.cpp | 2 +- .../Plugin_VideoSoftware/Src/SWCommandProcessor.cpp | 2 +- .../Plugin_VideoSoftware/Src/SWPixelEngine.cpp | 2 +- Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp | 2 +- 18 files changed, 43 insertions(+), 30 deletions(-) diff --git a/Source/Core/Common/Src/ChunkFile.h b/Source/Core/Common/Src/ChunkFile.h index ecf641a27b..7633ea018e 100644 --- a/Source/Core/Common/Src/ChunkFile.h +++ b/Source/Core/Common/Src/ChunkFile.h @@ -32,6 +32,7 @@ #include #include #include +#include #include "Common.h" #include "FileUtil.h" @@ -139,11 +140,17 @@ public: template void Do(T& x) { - // TODO: Bad, Do(some_non_POD) will compile and fail at runtime - // type_traits are not fully supported everywhere yet + // Ideally this would be std::is_trivially_copyable, but not enough support yet + static_assert(std::is_pod::value, "Only sane for POD types"); DoVoid((void*)&x, sizeof(x)); } + + template + void DoPOD(T& x) + { + DoVoid((void*)&x, sizeof(x)); + } template void DoPointer(T*& x, T* const base) diff --git a/Source/Core/Core/Src/HW/AudioInterface.cpp b/Source/Core/Core/Src/HW/AudioInterface.cpp index 7c4f894072..0c121a1403 100644 --- a/Source/Core/Core/Src/HW/AudioInterface.cpp +++ b/Source/Core/Core/Src/HW/AudioInterface.cpp @@ -131,8 +131,8 @@ static unsigned int g_AIDSampleRate = 32000; void DoState(PointerWrap &p) { - p.Do(m_Control); - p.Do(m_Volume); + p.DoPOD(m_Control); + p.DoPOD(m_Volume); p.Do(m_SampleCounter); p.Do(m_InterruptTiming); p.Do(g_LastCPUTime); diff --git a/Source/Core/Core/Src/HW/DSP.cpp b/Source/Core/Core/Src/HW/DSP.cpp index a0c597326f..72d1eaa63c 100644 --- a/Source/Core/Core/Src/HW/DSP.cpp +++ b/Source/Core/Core/Src/HW/DSP.cpp @@ -223,9 +223,9 @@ void DoState(PointerWrap &p) { if (!g_ARAM.wii_mode) p.DoArray(g_ARAM.ptr, g_ARAM.size); - p.Do(g_dspState); - p.Do(g_audioDMA); - p.Do(g_arDMA); + p.DoPOD(g_dspState); + p.DoPOD(g_audioDMA); + p.DoPOD(g_arDMA); p.Do(g_ARAM_Info); p.Do(g_AR_MODE); p.Do(g_AR_REFRESH); diff --git a/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp b/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp index 0232605f91..3e73944e44 100644 --- a/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp +++ b/Source/Core/Core/Src/HW/DSPHLE/DSPHLE.cpp @@ -157,8 +157,8 @@ void DSPHLE::DoState(PointerWrap &p) } } - p.Do(m_DSPControl); - p.Do(m_dspState); + p.DoPOD(m_DSPControl); + p.DoPOD(m_dspState); int ucode_crc = IUCode::GetCRC(m_pUCode); int ucode_crc_beforeLoad = ucode_crc; diff --git a/Source/Core/Core/Src/HW/DVDInterface.cpp b/Source/Core/Core/Src/HW/DVDInterface.cpp index 1c688eb6d4..dd21fd7d93 100644 --- a/Source/Core/Core/Src/HW/DVDInterface.cpp +++ b/Source/Core/Core/Src/HW/DVDInterface.cpp @@ -229,14 +229,14 @@ void ExecuteCommand(UDICR& _DICR); void DoState(PointerWrap &p) { - p.Do(m_DISR); - p.Do(m_DICVR); + p.DoPOD(m_DISR); + p.DoPOD(m_DICVR); p.DoArray(m_DICMDBUF, 3); p.Do(m_DIMAR); p.Do(m_DILENGTH); p.Do(m_DICR); p.Do(m_DIIMMBUF); - p.Do(m_DICFG); + p.DoPOD(m_DICFG); p.Do(LoopStart); p.Do(AudioPos); diff --git a/Source/Core/Core/Src/HW/EXI_Channel.cpp b/Source/Core/Core/Src/HW/EXI_Channel.cpp index e3f4562f73..45b2fbae59 100644 --- a/Source/Core/Core/Src/HW/EXI_Channel.cpp +++ b/Source/Core/Core/Src/HW/EXI_Channel.cpp @@ -282,7 +282,7 @@ void CEXIChannel::Write32(const u32 _iValue, const u32 _iRegister) void CEXIChannel::DoState(PointerWrap &p) { - p.Do(m_Status); + p.DoPOD(m_Status); p.Do(m_DMAMemoryAddress); p.Do(m_DMALength); p.Do(m_Control); diff --git a/Source/Core/Core/Src/HW/SI.cpp b/Source/Core/Core/Src/HW/SI.cpp index 0f563806ce..684247764c 100644 --- a/Source/Core/Core/Src/HW/SI.cpp +++ b/Source/Core/Core/Src/HW/SI.cpp @@ -257,8 +257,8 @@ void DoState(PointerWrap &p) } } p.Do(g_Poll); - p.Do(g_ComCSR); - p.Do(g_StatusReg); + p.DoPOD(g_ComCSR); + p.DoPOD(g_StatusReg); p.Do(g_EXIClockCount); p.Do(g_SIBuffer); } diff --git a/Source/Core/Core/Src/HW/VideoInterface.cpp b/Source/Core/Core/Src/HW/VideoInterface.cpp index fc4b888549..f1829360db 100644 --- a/Source/Core/Core/Src/HW/VideoInterface.cpp +++ b/Source/Core/Core/Src/HW/VideoInterface.cpp @@ -72,8 +72,8 @@ static int fields = 2; void DoState(PointerWrap &p) { - p.Do(m_VerticalTimingRegister); - p.Do(m_DisplayControlRegister); + p.DoPOD(m_VerticalTimingRegister); + p.DoPOD(m_DisplayControlRegister); p.Do(m_HTiming0); p.Do(m_HTiming1); p.Do(m_VBlankTimingOdd); @@ -89,7 +89,7 @@ void DoState(PointerWrap &p) p.DoArray(m_InterruptRegister, 4); p.DoArray(m_LatchRegister, 2); p.Do(m_HorizontalStepping); - p.Do(m_HorizontalScaling); + p.DoPOD(m_HorizontalScaling); p.Do(m_FilterCoefTables); p.Do(m_UnkAARegister); p.Do(m_Clock); diff --git a/Source/Core/Core/Src/HW/WII_IPC.cpp b/Source/Core/Core/Src/HW/WII_IPC.cpp index f378c90ad5..48d8eae02f 100644 --- a/Source/Core/Core/Src/HW/WII_IPC.cpp +++ b/Source/Core/Core/Src/HW/WII_IPC.cpp @@ -111,7 +111,7 @@ void DoState(PointerWrap &p) { p.Do(ppc_msg); p.Do(arm_msg); - p.Do(ctrl); + p.DoPOD(ctrl); p.Do(ppc_irq_flags); p.Do(ppc_irq_masks); p.Do(arm_irq_flags); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp index 82728fba36..7189e6a4e9 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -109,8 +109,8 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::DoState(PointerWrap &p) p.Do(m_ControllerBD); p.Do(m_CtrlSetup); p.Do(m_ACLSetup); - p.Do(m_HCIEndpoint); - p.Do(m_ACLEndpoint); + p.DoPOD(m_HCIEndpoint); + p.DoPOD(m_ACLEndpoint); p.Do(m_last_ticks); p.DoArray(m_PacketCount,4); p.Do(m_ScanEnable); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h index eb091b1ff9..2883dbc61d 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h @@ -51,6 +51,12 @@ struct SQueuedEvent } }; +// Hacks for ChunkFile to accept SQueuedEvent as POD +namespace std +{ +template <> +struct is_pod : std::true_type {}; +} // Important to remember that this class is for /dev/usb/oh1/57e/305 ONLY // /dev/usb/oh1 -> internal usb bus diff --git a/Source/Core/Core/Src/PowerPC/PowerPC.cpp b/Source/Core/Core/Src/PowerPC/PowerPC.cpp index e65b310f5a..d4a98be226 100644 --- a/Source/Core/Core/Src/PowerPC/PowerPC.cpp +++ b/Source/Core/Core/Src/PowerPC/PowerPC.cpp @@ -80,7 +80,7 @@ void DoState(PointerWrap &p) // rSPR(SPR_DEC) = SystemTimers::GetFakeDecrementer(); // *((u64 *)&TL) = SystemTimers::GetFakeTimeBase(); //works since we are little endian and TL comes first :) - p.Do(ppcState); + p.DoPOD(ppcState); // SystemTimers::DecrementerSet(); // SystemTimers::TimeBaseSet(); diff --git a/Source/Core/DiscIO/Src/WbfsBlob.cpp b/Source/Core/DiscIO/Src/WbfsBlob.cpp index 0fd89243e3..ce8c1d2b55 100644 --- a/Source/Core/DiscIO/Src/WbfsBlob.cpp +++ b/Source/Core/DiscIO/Src/WbfsBlob.cpp @@ -133,7 +133,7 @@ bool WbfsFileReader::Read(u64 offset, u64 nbytes, u8* out_ptr) { while(nbytes) { - u64 read_size; + u64 read_size = 0; File::IOFile& data_file = SeekToCluster(offset, &read_size); read_size = (read_size > nbytes) ? nbytes : read_size; diff --git a/Source/Core/VideoCommon/Src/CommandProcessor.cpp b/Source/Core/VideoCommon/Src/CommandProcessor.cpp index 1958b1c1d9..733c99df69 100644 --- a/Source/Core/VideoCommon/Src/CommandProcessor.cpp +++ b/Source/Core/VideoCommon/Src/CommandProcessor.cpp @@ -80,9 +80,9 @@ void UpdateInterrupts_Wrapper(u64 userdata, int cyclesLate) void DoState(PointerWrap &p) { - p.Do(m_CPStatusReg); - p.Do(m_CPCtrlReg); - p.Do(m_CPClearReg); + p.DoPOD(m_CPStatusReg); + p.DoPOD(m_CPCtrlReg); + p.DoPOD(m_CPClearReg); p.Do(m_bboxleft); p.Do(m_bboxtop); p.Do(m_bboxright); diff --git a/Source/Core/VideoCommon/Src/PixelEngine.cpp b/Source/Core/VideoCommon/Src/PixelEngine.cpp index b014148d8d..348b704f5b 100644 --- a/Source/Core/VideoCommon/Src/PixelEngine.cpp +++ b/Source/Core/VideoCommon/Src/PixelEngine.cpp @@ -137,7 +137,7 @@ void DoState(PointerWrap &p) p.Do(m_DstAlphaConf); p.Do(m_AlphaModeConf); p.Do(m_AlphaRead); - p.Do(m_Control); + p.DoPOD(m_Control); p.Do(g_bSignalTokenInterrupt); p.Do(g_bSignalFinishInterrupt); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp index 6cc4ee4dc8..1cd92708a4 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWCommandProcessor.cpp @@ -56,7 +56,7 @@ CPReg cpreg; // shared between gfx and emulator thread void DoState(PointerWrap &p) { - p.Do(cpreg); + p.DoPOD(cpreg); p.DoArray(commandBuffer, commandBufferSize); p.Do(readPos); p.Do(writePos); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp index 118e59629e..2118728cd8 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWPixelEngine.cpp @@ -50,7 +50,7 @@ static int et_SetFinishOnMainThread; void DoState(PointerWrap &p) { - p.Do(pereg); + p.DoPOD(pereg); p.Do(g_bSignalTokenInterrupt); p.Do(g_bSignalFinishInterrupt); p.Do(et_SetTokenOnMainThread); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp index b524ded329..84987b4dcf 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SWmain.cpp @@ -112,7 +112,7 @@ void VideoSoftware::DoState(PointerWrap& p) Clipper::DoState(p); p.Do(swxfregs); p.Do(bpmem); - p.Do(swstats); + p.DoPOD(swstats); // CP Memory p.DoArray(arraybases, 16);