Skip to content

Commit

Permalink
Merge pull request #833 from shuffle2/msvc-improvements
Browse files Browse the repository at this point in the history
misc improvements for msvc build. -Werror for msvc!
  • Loading branch information
shuffle2 committed Aug 20, 2014
2 parents a09cf1d + a9c3307 commit d29e333
Show file tree
Hide file tree
Showing 44 changed files with 516 additions and 514 deletions.
1 change: 1 addition & 0 deletions Externals/Bochs_disasm/Bochs_disasm.vcxproj
Expand Up @@ -39,6 +39,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\Source\VSProps\Base.props" />
<Import Project="..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Externals/LZO/LZO.vcxproj
Expand Up @@ -39,6 +39,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\Source\VSProps\Base.props" />
<Import Project="..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Externals/SFML/build/vc2010/SFML_Network.vcxproj
Expand Up @@ -39,6 +39,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\..\Source\VSProps\Base.props" />
<Import Project="..\..\..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Externals/SOIL/SOIL.vcxproj
Expand Up @@ -39,6 +39,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\Source\VSProps\Base.props" />
<Import Project="..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Externals/libpng/png/png.vcxproj
Expand Up @@ -39,6 +39,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\Source\VSProps\Base.props" />
<Import Project="..\..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Externals/libusbx/msvc/libusb_static_2013.vcxproj
Expand Up @@ -40,6 +40,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\Source\VSProps\Base.props" />
<Import Project="..\..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
Expand Down
1 change: 1 addition & 0 deletions Externals/miniupnpc/miniupnpc.vcxproj
Expand Up @@ -39,6 +39,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\Source\VSProps\Base.props" />
<Import Project="..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Externals/polarssl/visualc/PolarSSL.vcxproj
Expand Up @@ -39,6 +39,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\Source\VSProps\Base.props" />
<Import Project="..\..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Externals/portaudio/build/portaudio.vcxproj
Expand Up @@ -39,6 +39,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\..\Source\VSProps\Base.props" />
<Import Project="..\..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
Expand Down
1 change: 1 addition & 0 deletions Externals/soundtouch/SoundTouch.vcxproj
Expand Up @@ -39,6 +39,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\Source\VSProps\Base.props" />
<Import Project="..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemGroup>
Expand Down
4 changes: 3 additions & 1 deletion Externals/wxWidgets3/include/wx/defs.h
Expand Up @@ -1228,7 +1228,9 @@ typedef wxUint32 wxDword;
each time we cast it to a pointer or a handle (which results in hundreds
of warnings as Win32 API often passes pointers in them)
*/
#if wxCHECK_VISUALC_VERSION(7)
// (dolphin-emu) Just disable __w64 usage. It's not meant to be used anymore,
// even on 32bit builds.
#if 0
#define wxW64 __w64
#else
#define wxW64
Expand Down
2 changes: 1 addition & 1 deletion Externals/wxWidgets3/src/common/cmdproc.cpp
Expand Up @@ -333,7 +333,7 @@ bool wxCommandProcessor::IsDirty() const
{
// We have never been saved, so we are dirty if and only if we have any
// commands at all.
return m_currentCommand;
return !!m_currentCommand;
}

if ( !m_currentCommand )
Expand Down
2 changes: 1 addition & 1 deletion Externals/wxWidgets3/src/common/glcmn.cpp
Expand Up @@ -16,8 +16,8 @@
// ----------------------------------------------------------------------------

// for compilers that support precompilation, includes "wx.h".
#define GL_GLEXT_PROTOTYPES
#include "wx/wxprec.h"
#define GL_GLEXT_PROTOTYPES

#ifdef __BORLANDC__
#pragma hdrstop
Expand Down
1 change: 1 addition & 0 deletions Externals/zlib/zlib.vcxproj
Expand Up @@ -39,6 +39,7 @@
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\..\Source\VSProps\Base.props" />
<Import Project="..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
Expand Down
8 changes: 7 additions & 1 deletion Source/Core/Core/Core.vcxproj
Expand Up @@ -172,7 +172,13 @@
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_es.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_FileIO.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_fs.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_hid.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_hid.cpp">
<!--
Disable "nonstandard extension used : zero-sized array in struct/union" warning,
which is hit in libusb.h (and this is the only file which uses that header).
-->
<DisableSpecificWarnings>4200;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_net.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_net_ssl.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_sdio_slot0.cpp" />
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/FifoPlayer/FifoDataFile.cpp
Expand Up @@ -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());
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/FifoPlayer/FifoDataFile.h
Expand Up @@ -66,8 +66,8 @@ class FifoDataFile
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<u32>(m_Frames.size()); }

bool Save(const std::string& filename);

Expand All @@ -79,7 +79,7 @@ class FifoDataFile
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;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/FifoPlayer/FifoPlaybackAnalyzer.cpp
Expand Up @@ -48,7 +48,7 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile *file, std::vector<Analyze
frameInfo.clear();
frameInfo.resize(file->GetFrameCount());

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];
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/FifoPlayer/FifoPlayer.cpp
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion Source/Core/Core/HW/MMIO.cpp
Expand Up @@ -378,6 +378,8 @@ void WriteHandler<T>::ResetMethod(WriteHandlingMethod<T>* method)
}

// Define all the public specializations that are exported in MMIOHandlers.h.
MMIO_PUBLIC_SPECIALIZATIONS();
#define MaybeExtern
MMIO_PUBLIC_SPECIALIZATIONS()
#undef MaybeExtern

}
6 changes: 4 additions & 2 deletions Source/Core/Core/HW/MMIOHandlers.h
Expand Up @@ -216,12 +216,14 @@ class WriteHandler : public NonCopyable
MaybeExtern template ReadHandlingMethod<u8>* ReadToLarger(Mapping* mmio, u32 larger_addr, u32 shift); \
MaybeExtern template ReadHandlingMethod<u16>* 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

}
27 changes: 14 additions & 13 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp
Expand Up @@ -3,6 +3,7 @@
// Refer to the license.txt file included.

#include <errno.h>
#include <libusb.h>

#include "Core/Core.h"
#include "Core/Debugger/Debugger_SymbolMap.h"
Expand All @@ -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<std::mutex> lk(hid->s_device_list_reply);
std::lock_guard<std::mutex> 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));

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -238,7 +239,7 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
}
case IOCTL_HID_SHUTDOWN:
{
std::lock_guard<std::mutex> lk(s_device_list_reply);
std::lock_guard<std::mutex> lk(m_device_list_reply_mutex);
if (deviceCommandAddress != 0){
Memory::Write_U32(0xFFFFFFFF, Memory::Read_U32(deviceCommandAddress + 0x18));

Expand Down Expand Up @@ -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<std::mutex> lk(s_open_devices);
if (open_devices.find(i) != open_devices.end())
std::lock_guard<std::mutex> 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;
}
Expand Down Expand Up @@ -514,19 +515,19 @@ libusb_device_handle * CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum)
return nullptr;


std::lock_guard<std::mutex> lk(s_open_devices);
std::lock_guard<std::mutex> 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;
}
else
{
libusb_close(handle);
open_devices.erase(devNum);
m_open_devices.erase(devNum);
}
}

Expand Down Expand Up @@ -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
Expand Down
48 changes: 24 additions & 24 deletions Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.h
Expand Up @@ -4,20 +4,31 @@

#pragma once

#include <libusb.h>
#include <list>

#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:
Expand Down Expand Up @@ -45,7 +56,6 @@ class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device
IOCTL_HID_CANCEL_INTERRUPT = 0x08,
};

/* Device descriptor */
struct WiiHIDDeviceDescriptor
{
u8 bLength;
Expand Down Expand Up @@ -108,32 +118,22 @@ class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device
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<u32,libusb_device_handle*> open_devices;
std::mutex s_open_devices;
std::mutex s_device_list_reply;
std::map<std::string,int> device_identifiers;
libusb_device_handle* GetDeviceByDevNum(u32 devNum);
std::map<u32, libusb_device_handle*> 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;
};
2 changes: 1 addition & 1 deletion Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp
Expand Up @@ -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
{
Expand Down

0 comments on commit d29e333

Please sign in to comment.