mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #9950 from libretro-mirrors/master
Mingw patches (pt. 3)
This commit is contained in:
commit
d23b438662
10 changed files with 72 additions and 6 deletions
|
@ -30,7 +30,7 @@
|
||||||
#include "CPUDetect.h"
|
#include "CPUDetect.h"
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#define _interlockedbittestandset workaround_ms_header_bug_platform_sdk6_set
|
#define _interlockedbittestandset workaround_ms_header_bug_platform_sdk6_set
|
||||||
|
|
|
@ -96,4 +96,4 @@
|
||||||
# elif defined __SSE2__
|
# elif defined __SSE2__
|
||||||
# define _M_SSE 0x200
|
# define _M_SSE 0x200
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -70,9 +70,11 @@ inline u64 __rotr64(u64 x, unsigned int shift){
|
||||||
#define __rotr64 _rotr64
|
#define __rotr64 _rotr64
|
||||||
|
|
||||||
// 64 bit offsets for windows
|
// 64 bit offsets for windows
|
||||||
|
#ifndef __MINGW32__
|
||||||
#define fseeko _fseeki64
|
#define fseeko _fseeki64
|
||||||
#define ftello _ftelli64
|
#define ftello _ftelli64
|
||||||
#define atoll _atoi64
|
#define atoll _atoi64
|
||||||
|
#endif
|
||||||
#if _M_IX86
|
#if _M_IX86
|
||||||
#define Crash() {__asm int 3}
|
#define Crash() {__asm int 3}
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -74,6 +74,22 @@ static u64 __RtcGetCurrentTick()
|
||||||
return CoreTiming::GetGlobalTimeUs() + rtcBaseTicks;
|
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)
|
#if defined(_WIN32)
|
||||||
#define FILETIME_FROM_UNIX_EPOCH_US (rtcMagicOffset - rtcFiletimeOffset)
|
#define FILETIME_FROM_UNIX_EPOCH_US (rtcMagicOffset - rtcFiletimeOffset)
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ namespace MIPSComp {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#if PPSSPP_PLATFORM(WINDOWS)
|
#if PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__)
|
||||||
#define DISASM_ALL 1
|
#define DISASM_ALL 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -650,7 +650,11 @@ void InitSysDirectories() {
|
||||||
|
|
||||||
// If installed.txt exists(and we can determine the Documents directory)
|
// If installed.txt exists(and we can determine the Documents directory)
|
||||||
if (installed && (result == S_OK)) {
|
if (installed && (result == S_OK)) {
|
||||||
|
#if defined(_WIN32) && defined(__MINGW32__)
|
||||||
|
std::ifstream inputFile(installedFile);
|
||||||
|
#else
|
||||||
std::ifstream inputFile(ConvertUTF8ToWString(installedFile));
|
std::ifstream inputFile(ConvertUTF8ToWString(installedFile));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!inputFile.fail() && inputFile.is_open()) {
|
if (!inputFile.fail() && inputFile.is_open()) {
|
||||||
std::string tempString;
|
std::string tempString;
|
||||||
|
|
|
@ -71,14 +71,14 @@ bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw) {
|
||||||
SetGPU(new SoftGPU(ctx, draw));
|
SetGPU(new SoftGPU(ctx, draw));
|
||||||
break;
|
break;
|
||||||
case GPUCORE_DIRECTX9:
|
case GPUCORE_DIRECTX9:
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32) && !defined(__LIBRETRO__)
|
||||||
SetGPU(new DIRECTX9_GPU(ctx, draw));
|
SetGPU(new DIRECTX9_GPU(ctx, draw));
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
case GPUCORE_DIRECTX11:
|
case GPUCORE_DIRECTX11:
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32) && !defined(__LIBRETRO__)
|
||||||
SetGPU(new GPU_D3D11(ctx, draw));
|
SetGPU(new GPU_D3D11(ctx, draw));
|
||||||
break;
|
break;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||||
typedef int pid_t;
|
typedef int pid_t;
|
||||||
#define getpid rand
|
#define getpid rand
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -264,6 +264,7 @@ void CheckGLExtensions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO__
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
const char *wglString = 0;
|
const char *wglString = 0;
|
||||||
if (wglGetExtensionsStringEXT)
|
if (wglGetExtensionsStringEXT)
|
||||||
|
@ -277,6 +278,7 @@ void CheckGLExtensions() {
|
||||||
#elif !defined(USING_GLES2)
|
#elif !defined(USING_GLES2)
|
||||||
// const char *glXString = glXQueryExtensionString();
|
// const char *glXString = glXQueryExtensionString();
|
||||||
// gl_extensions.EXT_swap_control_tear = strstr(glXString, "GLX_EXT_swap_control_tear") != 0;
|
// gl_extensions.EXT_swap_control_tear = strstr(glXString, "GLX_EXT_swap_control_tear") != 0;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check the desktop extension instead of the OES one. They are very similar.
|
// Check the desktop extension instead of the OES one. They are very similar.
|
||||||
|
|
|
@ -20,10 +20,52 @@
|
||||||
static __THREAD const char *curThreadName;
|
static __THREAD const char *curThreadName;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
#include <pshpack8.h>
|
||||||
|
typedef struct {
|
||||||
|
DWORD dwType;
|
||||||
|
LPCSTR szName;
|
||||||
|
DWORD dwThreadID;
|
||||||
|
DWORD dwFlags;
|
||||||
|
} THREADNAME_INFO;
|
||||||
|
#include <poppack.h>
|
||||||
|
|
||||||
|
static EXCEPTION_DISPOSITION NTAPI ignore_handler(EXCEPTION_RECORD *rec,
|
||||||
|
void *frame, CONTEXT *ctx,
|
||||||
|
void *disp)
|
||||||
|
{
|
||||||
|
return ExceptionContinueExecution;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void setCurrentThreadName(const char* threadName) {
|
void setCurrentThreadName(const char* threadName) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Set the debugger-visible threadname through an unholy magic hack
|
// Set the debugger-visible threadname through an unholy magic hack
|
||||||
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
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)
|
#pragma pack(push,8)
|
||||||
struct THREADNAME_INFO {
|
struct THREADNAME_INFO {
|
||||||
DWORD dwType; // must be 0x1000
|
DWORD dwType; // must be 0x1000
|
||||||
|
|
Loading…
Add table
Reference in a new issue