diff --git a/Common/CPUDetect.cpp b/Common/CPUDetect.cpp index cb50ce8079..96cf1319a2 100644 --- a/Common/CPUDetect.cpp +++ b/Common/CPUDetect.cpp @@ -30,7 +30,7 @@ #include "CPUDetect.h" #include "StringUtils.h" -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) #define WIN32_LEAN_AND_MEAN #include #define _interlockedbittestandset workaround_ms_header_bug_platform_sdk6_set diff --git a/Common/Common.h b/Common/Common.h index 187b36858a..ec69b6022b 100644 --- a/Common/Common.h +++ b/Common/Common.h @@ -96,4 +96,4 @@ # elif defined __SSE2__ # define _M_SSE 0x200 # endif -#endif \ No newline at end of file +#endif diff --git a/Common/CommonFuncs.h b/Common/CommonFuncs.h index 77f466bcd4..b8a9aea66d 100644 --- a/Common/CommonFuncs.h +++ b/Common/CommonFuncs.h @@ -70,9 +70,11 @@ inline u64 __rotr64(u64 x, unsigned int shift){ #define __rotr64 _rotr64 // 64 bit offsets for windows +#ifndef __MINGW32__ #define fseeko _fseeki64 #define ftello _ftelli64 #define atoll _atoi64 +#endif #if _M_IX86 #define Crash() {__asm int 3} #else diff --git a/Core/HLE/sceRtc.cpp b/Core/HLE/sceRtc.cpp index 43cbdc5ee9..b5b4cfe807 100644 --- a/Core/HLE/sceRtc.cpp +++ b/Core/HLE/sceRtc.cpp @@ -74,6 +74,22 @@ static u64 __RtcGetCurrentTick() return CoreTiming::GetGlobalTimeUs() + rtcBaseTicks; } +#if defined(__MINGW32__) +errno_t _get_timezone(long *seconds) +{ + time_t now = time(NULL); + + struct tm *gm = gmtime(&now); + time_t gmt = mktime(gm); + + struct tm *loc = localtime(&now); + time_t local = mktime(loc); + + *seconds = local - gmt; + return 0; +} +#endif + #if defined(_WIN32) #define FILETIME_FROM_UNIX_EPOCH_US (rtcMagicOffset - rtcFiletimeOffset) diff --git a/Core/MIPS/JitCommon/JitCommon.cpp b/Core/MIPS/JitCommon/JitCommon.cpp index 7c0289f07e..55409c77c6 100644 --- a/Core/MIPS/JitCommon/JitCommon.cpp +++ b/Core/MIPS/JitCommon/JitCommon.cpp @@ -61,7 +61,7 @@ namespace MIPSComp { } } -#if PPSSPP_PLATFORM(WINDOWS) +#if PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__) #define DISASM_ALL 1 #endif diff --git a/Core/System.cpp b/Core/System.cpp index 05e47333eb..04c93deeb1 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -650,7 +650,11 @@ void InitSysDirectories() { // If installed.txt exists(and we can determine the Documents directory) if (installed && (result == S_OK)) { +#if defined(_WIN32) && defined(__MINGW32__) + std::ifstream inputFile(installedFile); +#else std::ifstream inputFile(ConvertUTF8ToWString(installedFile)); +#endif if (!inputFile.fail() && inputFile.is_open()) { std::string tempString; diff --git a/GPU/GPU.cpp b/GPU/GPU.cpp index 0cd5c85c49..72f6bf1f4a 100644 --- a/GPU/GPU.cpp +++ b/GPU/GPU.cpp @@ -71,14 +71,14 @@ bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw) { SetGPU(new SoftGPU(ctx, draw)); break; case GPUCORE_DIRECTX9: -#if defined(_WIN32) +#if defined(_WIN32) && !defined(__LIBRETRO__) SetGPU(new DIRECTX9_GPU(ctx, draw)); break; #else return false; #endif case GPUCORE_DIRECTX11: -#if defined(_WIN32) +#if defined(_WIN32) && !defined(__LIBRETRO__) SetGPU(new GPU_D3D11(ctx, draw)); break; #else diff --git a/ext/native/ext/libzip/mkstemp.c b/ext/native/ext/libzip/mkstemp.c index 0dbaaf0572..c61e279f9d 100644 --- a/ext/native/ext/libzip/mkstemp.c +++ b/ext/native/ext/libzip/mkstemp.c @@ -45,7 +45,7 @@ #include #include -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__MINGW32__) typedef int pid_t; #define getpid rand #endif diff --git a/ext/native/gfx_es2/gpu_features.cpp b/ext/native/gfx_es2/gpu_features.cpp index 92f8c75c68..a97a0f39f4 100644 --- a/ext/native/gfx_es2/gpu_features.cpp +++ b/ext/native/gfx_es2/gpu_features.cpp @@ -264,6 +264,7 @@ void CheckGLExtensions() { } } +#ifndef __LIBRETRO__ #ifdef WIN32 const char *wglString = 0; if (wglGetExtensionsStringEXT) @@ -277,6 +278,7 @@ void CheckGLExtensions() { #elif !defined(USING_GLES2) // const char *glXString = glXQueryExtensionString(); // gl_extensions.EXT_swap_control_tear = strstr(glXString, "GLX_EXT_swap_control_tear") != 0; +#endif #endif // Check the desktop extension instead of the OES one. They are very similar. diff --git a/ext/native/thread/threadutil.cpp b/ext/native/thread/threadutil.cpp index 87a22ffa14..fcd050e98f 100644 --- a/ext/native/thread/threadutil.cpp +++ b/ext/native/thread/threadutil.cpp @@ -20,10 +20,52 @@ static __THREAD const char *curThreadName; #endif +#ifdef __MINGW32__ +#include +typedef struct { + DWORD dwType; + LPCSTR szName; + DWORD dwThreadID; + DWORD dwFlags; +} THREADNAME_INFO; +#include + +static EXCEPTION_DISPOSITION NTAPI ignore_handler(EXCEPTION_RECORD *rec, + void *frame, CONTEXT *ctx, + void *disp) +{ + return ExceptionContinueExecution; +} +#endif + void setCurrentThreadName(const char* threadName) { #ifdef _WIN32 // Set the debugger-visible threadname through an unholy magic hack static const DWORD MS_VC_EXCEPTION = 0x406D1388; +#endif + +#if defined(_WIN32) && defined(__MINGW32__) + // Thread information for VS compatible debugger. -1 sets current thread. + THREADNAME_INFO ti; + ti.dwType = 0x1000; + ti.szName = threadName; + ti.dwThreadID = -1; + + // Push an exception handler to ignore all following exceptions + NT_TIB *tib = ((NT_TIB*)NtCurrentTeb()); + EXCEPTION_REGISTRATION_RECORD rec; + rec.Next = tib->ExceptionList; + rec.Handler = ignore_handler; + tib->ExceptionList = &rec; + + // Visual Studio and compatible debuggers receive thread names from the + // program through a specially crafted exception + RaiseException(MS_VC_EXCEPTION, 0, sizeof(ti) / sizeof(ULONG_PTR), + (ULONG_PTR*)&ti); + + // Pop exception handler + tib->ExceptionList = tib->ExceptionList->Next; +#elif defined(_WIN32) #pragma pack(push,8) struct THREADNAME_INFO { DWORD dwType; // must be 0x1000