From 043ea31f14a330bfdddfb6d5ab14794675efdd74 Mon Sep 17 00:00:00 2001 From: Shawn Hoffman Date: Tue, 19 Aug 2014 20:15:56 -0700 Subject: [PATCH] msvc: resolve all warnings in Core. Note: vs14 will support empty macro parameter as used by MMIO. --- Source/Core/Core/Core.vcxproj | 8 +++- Source/Core/Core/FifoPlayer/FifoDataFile.cpp | 2 +- Source/Core/Core/FifoPlayer/FifoDataFile.h | 6 +-- .../Core/FifoPlayer/FifoPlaybackAnalyzer.cpp | 2 +- Source/Core/Core/FifoPlayer/FifoPlayer.cpp | 2 +- Source/Core/Core/HW/MMIO.cpp | 4 +- Source/Core/Core/HW/MMIOHandlers.h | 6 ++- .../Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp | 27 ++++++----- .../Core/IPC_HLE/WII_IPC_HLE_Device_hid.h | 48 +++++++++---------- .../PowerPC/Jit64/Jit_SystemRegisters.cpp | 2 +- Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp | 4 +- .../Core/PowerPC/JitCommon/JitBackpatch.cpp | 2 +- .../Core/Core/PowerPC/JitCommon/Jit_Util.cpp | 2 +- 13 files changed, 63 insertions(+), 52 deletions(-) diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index e775eb741a..371e00b405 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -172,7 +172,13 @@ - + + + 4200;%(DisableSpecificWarnings) + diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp index 4c39d68639..6610d8b0a6 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.cpp +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.cpp @@ -195,7 +195,7 @@ FifoDataFile *FifoDataFile::Load(const std::string &filename, bool flagsOnly) return dataFile; } -void FifoDataFile::PadFile(u32 numBytes, File::IOFile& file) +void FifoDataFile::PadFile(size_t numBytes, File::IOFile& file) { const u8 zero = 0; fwrite(&zero, sizeof(zero), numBytes, file.GetHandle()); diff --git a/Source/Core/Core/FifoPlayer/FifoDataFile.h b/Source/Core/Core/FifoPlayer/FifoDataFile.h index 9be14296b4..a5e8027c73 100644 --- a/Source/Core/Core/FifoPlayer/FifoDataFile.h +++ b/Source/Core/Core/FifoPlayer/FifoDataFile.h @@ -66,8 +66,8 @@ public: u32 *GetXFRegs() { return m_XFRegs; } void AddFrame(const FifoFrameInfo &frameInfo); - const FifoFrameInfo &GetFrame(size_t frame) const { return m_Frames[frame]; } - size_t GetFrameCount() { return m_Frames.size(); } + const FifoFrameInfo &GetFrame(u32 frame) const { return m_Frames[frame]; } + u32 GetFrameCount() { return static_cast(m_Frames.size()); } bool Save(const std::string& filename); @@ -79,7 +79,7 @@ private: FLAG_IS_WII = 1 }; - void PadFile(u32 numBytes, File::IOFile &file); + void PadFile(size_t numBytes, File::IOFile &file); void SetFlag(u32 flag, bool set); bool GetFlag(u32 flag) const; diff --git a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp index 2090ad34d9..cc006a295b 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp @@ -48,7 +48,7 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile *file, std::vectorGetFrameCount()); - for (size_t frameIdx = 0; frameIdx < file->GetFrameCount(); ++frameIdx) + for (u32 frameIdx = 0; frameIdx < file->GetFrameCount(); ++frameIdx) { const FifoFrameInfo& frame = file->GetFrame(frameIdx); AnalyzedFrameInfo& analyzed = frameInfo[frameIdx]; diff --git a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp index 96fada80b0..25c20b0374 100644 --- a/Source/Core/Core/FifoPlayer/FifoPlayer.cpp +++ b/Source/Core/Core/FifoPlayer/FifoPlayer.cpp @@ -259,7 +259,7 @@ void FifoPlayer::WriteAllMemoryUpdates() { _assert_(m_File); - for (size_t frameNum = 0; frameNum < m_File->GetFrameCount(); ++frameNum) + for (u32 frameNum = 0; frameNum < m_File->GetFrameCount(); ++frameNum) { const FifoFrameInfo &frame = m_File->GetFrame(frameNum); for (auto& update : frame.memoryUpdates) diff --git a/Source/Core/Core/HW/MMIO.cpp b/Source/Core/Core/HW/MMIO.cpp index e1cd422f57..6a1c2ec297 100644 --- a/Source/Core/Core/HW/MMIO.cpp +++ b/Source/Core/Core/HW/MMIO.cpp @@ -378,6 +378,8 @@ void WriteHandler::ResetMethod(WriteHandlingMethod* method) } // Define all the public specializations that are exported in MMIOHandlers.h. -MMIO_PUBLIC_SPECIALIZATIONS(); +#define MaybeExtern +MMIO_PUBLIC_SPECIALIZATIONS() +#undef MaybeExtern } diff --git a/Source/Core/Core/HW/MMIOHandlers.h b/Source/Core/Core/HW/MMIOHandlers.h index 8fc3c25e6d..4e9a2f4242 100644 --- a/Source/Core/Core/HW/MMIOHandlers.h +++ b/Source/Core/Core/HW/MMIOHandlers.h @@ -216,12 +216,14 @@ private: MaybeExtern template ReadHandlingMethod* ReadToLarger(Mapping* mmio, u32 larger_addr, u32 shift); \ MaybeExtern template ReadHandlingMethod* ReadToLarger(Mapping* mmio, u32 larger_addr, u32 shift) -#define MMIO_PUBLIC_SPECIALIZATIONS(MaybeExtern) \ +#define MMIO_PUBLIC_SPECIALIZATIONS() \ MMIO_GENERIC_PUBLIC_SPECIALIZATIONS(MaybeExtern, u8); \ MMIO_GENERIC_PUBLIC_SPECIALIZATIONS(MaybeExtern, u16); \ MMIO_GENERIC_PUBLIC_SPECIALIZATIONS(MaybeExtern, u32); \ MMIO_SPECIAL_PUBLIC_SPECIALIZATIONS(MaybeExtern); -MMIO_PUBLIC_SPECIALIZATIONS(extern) +#define MaybeExtern extern +MMIO_PUBLIC_SPECIALIZATIONS() +#undef MaybeExtern } diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp index a1bda5250a..b6f746f8b7 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include "Core/Core.h" #include "Core/Debugger/Debugger_SymbolMap.h" @@ -25,7 +26,7 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid) static u16 timeToFill = 0; if (timeToFill == 0) { - std::lock_guard lk(hid->s_device_list_reply); + std::lock_guard lk(hid->m_device_list_reply_mutex); if (hid->deviceCommandAddress != 0){ hid->FillOutDevices(Memory::Read_U32(hid->deviceCommandAddress + 0x18), Memory::Read_U32(hid->deviceCommandAddress + 0x1C)); @@ -97,11 +98,11 @@ CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid() deinit_libusb = true; } - for (const auto& device : open_devices) + for (const auto& device : m_open_devices) { libusb_close(device.second); } - open_devices.clear(); + m_open_devices.clear(); if (deinit_libusb) libusb_exit(nullptr); @@ -238,7 +239,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) } case IOCTL_HID_SHUTDOWN: { - std::lock_guard lk(s_device_list_reply); + std::lock_guard lk(m_device_list_reply_mutex); if (deviceCommandAddress != 0){ Memory::Write_U32(0xFFFFFFFF, Memory::Read_U32(deviceCommandAddress + 0x18)); @@ -479,12 +480,12 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize) if (hidDeviceAliases[i] != 0 && check_cur != check) { DEBUG_LOG(WII_IPC_HID, "Removing: device %d %hX %hX", i, check, check_cur); - std::lock_guard lk(s_open_devices); - if (open_devices.find(i) != open_devices.end()) + std::lock_guard lk(m_open_devices_mutex); + if (m_open_devices.find(i) != m_open_devices.end()) { - libusb_device_handle *handle = open_devices[i]; + libusb_device_handle *handle = m_open_devices[i]; libusb_close(handle); - open_devices.erase(i); + m_open_devices.erase(i); } hidDeviceAliases[i] = 0; } @@ -514,11 +515,11 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) return nullptr; - std::lock_guard lk(s_open_devices); + std::lock_guard lk(m_open_devices_mutex); - if (open_devices.find(devNum) != open_devices.end()) + if (m_open_devices.find(devNum) != m_open_devices.end()) { - handle = open_devices[devNum]; + handle = m_open_devices[devNum]; if (libusb_kernel_driver_active(handle, 0) != LIBUSB_ERROR_NO_DEVICE) { return handle; @@ -526,7 +527,7 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) else { libusb_close(handle); - open_devices.erase(devNum); + m_open_devices.erase(devNum); } } @@ -597,7 +598,7 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) continue; } - open_devices[devNum] = handle; + m_open_devices[devNum] = handle; break; } else diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.h b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.h index ea2fd535be..e5dd5d14cf 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.h +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.h @@ -4,20 +4,31 @@ #pragma once -#include #include #include "Common/Thread.h" #include "Core/IPC_HLE/WII_IPC_HLE.h" #include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +// Forward declare things which we need from libusb header. +// This prevents users of this file from indirectly pulling in libusb. +#if defined(_WIN32) +#define LIBUSB_CALL WINAPI +#else +#define LIBUSB_CALL +#endif +struct libusb_device_handle; +struct libusb_device_descriptor; +struct libusb_config_descriptor; +struct libusb_interface_descriptor; +struct libusb_endpoint_descriptor; +struct libusb_transfer; + #define HID_ID_MASK 0x0000FFFFFFFFFFFF #define MAX_HID_INTERFACES 1 #define HIDERR_NO_DEVICE_FOUND -4 -/* Connection timed out */ - class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device { public: @@ -45,7 +56,6 @@ private: IOCTL_HID_CANCEL_INTERRUPT = 0x08, }; - /* Device descriptor */ struct WiiHIDDeviceDescriptor { u8 bLength; @@ -108,32 +118,22 @@ private: u32 deviceCommandAddress; void FillOutDevices(u32 BufferOut, u32 BufferOutSize); int GetAvaiableDevNum(u16 idVendor, u16 idProduct, u8 bus, u8 port, u16 check); - bool ClaimDevice(libusb_device_handle * dev); + bool ClaimDevice(libusb_device_handle* dev); - void ConvertDeviceToWii(WiiHIDDeviceDescriptor *dest, const struct libusb_device_descriptor *src); - void ConvertConfigToWii(WiiHIDConfigDescriptor *dest, const struct libusb_config_descriptor *src); - void ConvertInterfaceToWii(WiiHIDInterfaceDescriptor *dest, const struct libusb_interface_descriptor *src); - void ConvertEndpointToWii(WiiHIDEndpointDescriptor *dest, const struct libusb_endpoint_descriptor *src); + void ConvertDeviceToWii(WiiHIDDeviceDescriptor* dest, const libusb_device_descriptor* src); + void ConvertConfigToWii(WiiHIDConfigDescriptor* dest, const libusb_config_descriptor* src); + void ConvertInterfaceToWii(WiiHIDInterfaceDescriptor* dest, const libusb_interface_descriptor* src); + void ConvertEndpointToWii(WiiHIDEndpointDescriptor* dest, const libusb_endpoint_descriptor* src); int Align(int num, int alignment); static void checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid); - static void LIBUSB_CALL handleUsbUpdates(struct libusb_transfer *transfer); + static void LIBUSB_CALL handleUsbUpdates(libusb_transfer* transfer); - struct libusb_device_handle * GetDeviceByDevNum(u32 devNum); - std::map open_devices; - std::mutex s_open_devices; - std::mutex s_device_list_reply; - std::map device_identifiers; + libusb_device_handle* GetDeviceByDevNum(u32 devNum); + std::map m_open_devices; + std::mutex m_open_devices_mutex; + std::mutex m_device_list_reply_mutex; std::thread usb_thread; bool usb_thread_running; - - typedef struct - { - u32 enq_address; - u32 type; - void * context; - } _hidevent; - - std::list<_hidevent> event_list; }; diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp index 546594803b..e3e9c7df15 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp @@ -312,7 +312,7 @@ void Jit64::mtcrf(UGeckoInstruction inst) u64 newcrval = PPCCRToInternal(newcr); if ((s64)newcrval == (s32)newcrval) { - MOV(64, M(&PowerPC::ppcState.cr_val[i]), Imm32(newcrval)); + MOV(64, M(&PowerPC::ppcState.cr_val[i]), Imm32((s32)newcrval)); } else { diff --git a/Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp b/Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp index 783c37e3c6..85b15ffc1c 100644 --- a/Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp +++ b/Source/Core/Core/PowerPC/Jit64IL/IR_X86.cpp @@ -1665,9 +1665,9 @@ static void DoWriteCode(IRBuilder* ibuild, JitIL* Jit, u32 exitAddress) { X64Reg reg = regFindFreeReg(RI); u64 val = ibuild->GetImmValue64(I); if ((u32)val == val) - Jit->MOV(32, R(reg), Imm32(val)); + Jit->MOV(32, R(reg), Imm32((u32)val)); else if ((s32)val == (s64)val) - Jit->MOV(64, R(reg), Imm32(val)); + Jit->MOV(64, R(reg), Imm32((s32)val)); else Jit->MOV(64, R(reg), Imm64(val)); RI.regs[reg] = I; diff --git a/Source/Core/Core/PowerPC/JitCommon/JitBackpatch.cpp b/Source/Core/Core/PowerPC/JitCommon/JitBackpatch.cpp index 047901ad46..dde1e16d1f 100644 --- a/Source/Core/Core/PowerPC/JitCommon/JitBackpatch.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/JitBackpatch.cpp @@ -266,7 +266,7 @@ const u8 *Jitx86Base::BackPatch(u8 *codePtr, u32 emAddress, void *ctx_void) XEmitter emitter(start); const u8 *trampoline = trampolines.GetWriteTrampoline(info, registersInUse, pc); emitter.CALL((void *)trampoline); - int padding = codePtr + info.instructionSize - emitter.GetCodePtr(); + ptrdiff_t padding = (codePtr - emitter.GetCodePtr()) + info.instructionSize; if (padding > 0) { emitter.NOP(padding); diff --git a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp index cc233846a5..5a71aa2be5 100644 --- a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp @@ -413,7 +413,7 @@ void EmuCodeBlock::SafeWriteRegToReg(X64Reg reg_value, X64Reg reg_addr, int acce { const u8* backpatchStart = GetCodePtr(); u8* mov = UnsafeWriteRegToReg(reg_value, reg_addr, accessSize, offset, !(flags & SAFE_LOADSTORE_NO_SWAP)); - int padding = BACKPATCH_SIZE - (GetCodePtr() - backpatchStart); + ptrdiff_t padding = BACKPATCH_SIZE - (GetCodePtr() - backpatchStart); if (padding > 0) { NOP(padding);