From e0a1f82bdb557bd65cd251fc4806cca997e7017e Mon Sep 17 00:00:00 2001 From: Alberto Fustinoni Date: Fri, 5 Jan 2018 17:44:34 +0900 Subject: [PATCH] Enable CHD on UWP --- Makefile | 2 -- .../src/libFLAC/windows_unicode_filenames.c | 11 +++++++++++ deps/libchdr/coretypes.h | 4 ++++ deps/lzma-16.04/C/CpuArch.c | 4 ++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ff52ea9..5ee81bb 100644 --- a/Makefile +++ b/Makefile @@ -240,8 +240,6 @@ else ifneq (,$(findstring windows_msvc2017,$(platform))) MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_APP -DWINDLL -D_UNICODE -DUNICODE -DWRL_NO_DEFAULT_LIB -FS LDFLAGS += -APPCONTAINER -NXCOMPAT -DYNAMICBASE -MANIFEST:NO -LTCG -OPT:REF -SUBSYSTEM:CONSOLE -MANIFESTUAC:NO -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1 -DEBUG:FULL -WINMD:NO LIBS += WindowsApp.lib - - HAVE_CHD = 0 endif CFLAGS += $(MSVC2017CompileFlags) diff --git a/deps/flac-1.3.2/src/libFLAC/windows_unicode_filenames.c b/deps/flac-1.3.2/src/libFLAC/windows_unicode_filenames.c index 2404e31..3c91668 100644 --- a/deps/flac-1.3.2/src/libFLAC/windows_unicode_filenames.c +++ b/deps/flac-1.3.2/src/libFLAC/windows_unicode_filenames.c @@ -185,6 +185,16 @@ int flac_internal_rename_utf8(const char *oldname, const char *newname) HANDLE WINAPI flac_internal_CreateFile_utf8(const char *lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { +#if _MSC_VER > 1900 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) + wchar_t *wname; + HANDLE handle = INVALID_HANDLE_VALUE; + + if ((wname = wchar_from_utf8(lpFileName)) != NULL) { + + handle = CreateFile2(wname, dwDesiredAccess, dwShareMode, CREATE_ALWAYS, NULL); + free(wname); + } +#else if (!utf8_filenames) { return CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); } else { @@ -198,4 +208,5 @@ HANDLE WINAPI flac_internal_CreateFile_utf8(const char *lpFileName, DWORD dwDesi return handle; } +#endif } diff --git a/deps/libchdr/coretypes.h b/deps/libchdr/coretypes.h index 80f161f..6264bea 100644 --- a/deps/libchdr/coretypes.h +++ b/deps/libchdr/coretypes.h @@ -4,6 +4,10 @@ #include #include +#ifdef __LIBRETRO__ +#include +#endif + #define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0])) typedef uint64_t UINT64; diff --git a/deps/lzma-16.04/C/CpuArch.c b/deps/lzma-16.04/C/CpuArch.c index f835c2b..098e301 100644 --- a/deps/lzma-16.04/C/CpuArch.c +++ b/deps/lzma-16.04/C/CpuArch.c @@ -177,11 +177,15 @@ Bool CPU_Is_InOrder() #include static Bool CPU_Sys_Is_SSE_Supported() { +#if _MSC_VER >= 1900 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) + return True; +#else OSVERSIONINFO vi; vi.dwOSVersionInfoSize = sizeof(vi); if (!GetVersionEx(&vi)) return False; return (vi.dwMajorVersion >= 5); +#endif } #define CHECK_SYS_SSE_SUPPORT if (!CPU_Sys_Is_SSE_Supported()) return False; #else