From a0ad17dc058ef776ac8b84bd98fae9bb74559733 Mon Sep 17 00:00:00 2001 From: Jake Stine Date: Mon, 23 Nov 2020 13:17:51 -0800 Subject: [PATCH 1/4] add unistd.h to libretro.cpp, for ftruncate --- libretro.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libretro.cpp b/libretro.cpp index a6bdce6e7..f89626849 100644 --- a/libretro.cpp +++ b/libretro.cpp @@ -42,6 +42,7 @@ retro_input_state_t dbg_input_state_cb = 0; #endif #if defined(HAVE_SHM) || defined(HAVE_ASHMEM) +#include // for ftruncate #include #include #endif From b2dd3ec75e136a85c6a97732f6164f6c4164252b Mon Sep 17 00:00:00 2001 From: Jake Stine Date: Mon, 23 Nov 2020 21:02:15 -0800 Subject: [PATCH 2/4] FastSaveStates: Resolve linker error on msvc 2019 toolchain * Replace C bool macro with _Bool compiler type * C99 _Bool and C++ bool are considered matching types by the compiler --- libretro.cpp | 2 +- mednafen/state.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libretro.cpp b/libretro.cpp index f89626849..c813a589f 100644 --- a/libretro.cpp +++ b/libretro.cpp @@ -53,7 +53,7 @@ retro_input_state_t dbg_input_state_cb = 0; #endif /* HAVE_LIGHTREC */ //Fast Save States exclude string labels from variables in the savestate, and are at least 20% faster. -extern bool FastSaveStates; +extern "C" bool FastSaveStates; const int DEFAULT_STATE_SIZE = 16 * 1024 * 1024; static bool libretro_supports_bitmasks = false; diff --git a/mednafen/state.c b/mednafen/state.c index 5b809ceff..3055495b5 100644 --- a/mednafen/state.c +++ b/mednafen/state.c @@ -37,7 +37,7 @@ int StateAction(StateMem *sm, int load, int data_only); * variables in the savestate, and are at least 20% faster. * Only used for internal savestates which will not be written to a file. */ -bool FastSaveStates = false; +_Bool FastSaveStates = false; static INLINE void MDFN_en32lsb_(uint8_t *buf, uint32_t morp) { From 124a2d1c3ee5e854d3e0968a8a3f210112406c6a Mon Sep 17 00:00:00 2001 From: Jake Stine Date: Mon, 23 Nov 2020 21:07:33 -0800 Subject: [PATCH 3/4] libretro: EventCycles must match definition in gpu.cpp (signed) ... and as a rule of thumb, always favor signed int unless there is specific reason to use unsigned (normally limited to situations where full 4GB unsigned range is required during comparison operation) --- libretro.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro.cpp b/libretro.cpp index c813a589f..a256afd82 100644 --- a/libretro.cpp +++ b/libretro.cpp @@ -108,7 +108,7 @@ int memfd; #endif #endif -uint32 EventCycles = 128; +int32 EventCycles = 128; // CPU overclock factor (or 0 if disabled) int32_t psx_overclock_factor = 0; From 9933eae471c3c452c7aca1983434fc890ee60441 Mon Sep 17 00:00:00 2001 From: Jake Stine Date: Mon, 23 Nov 2020 11:57:48 -0800 Subject: [PATCH 4/4] msvc: fix syntax errors when compiling via msbuild 2019 compiler toolchain --- deps/libkirk/amctrl.c | 2 +- mednafen/clamp.h | 7 ++----- mednafen/mednafen-types.h | 7 +++++-- parallel-psx/util/util.hpp | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/deps/libkirk/amctrl.c b/deps/libkirk/amctrl.c index 0347dc39a..b1bb0b419 100644 --- a/deps/libkirk/amctrl.c +++ b/deps/libkirk/amctrl.c @@ -2,7 +2,7 @@ // Copyright (C) 2015 Hykem // Licensed under the terms of the GNU GPL, version 3 // http://www.gnu.org/licenses/gpl-3.0.txt - + #define _CRT_SECURE_NO_WARNINGS #include diff --git a/mednafen/clamp.h b/mednafen/clamp.h index 29d7c40aa..81dd60c0e 100644 --- a/mednafen/clamp.h +++ b/mednafen/clamp.h @@ -6,11 +6,8 @@ extern "C" { #endif #include -#ifndef _WIN32 -#include -#endif - -static INLINE void clamp(int32_t *val, ssize_t min, ssize_t max) +// ptrdiff_t (adopted by C99/C++) is generally a more portable version of ssize_t (POSIX only). +static INLINE void clamp(int32_t *val, ptrdiff_t min, ptrdiff_t max) { if(*val < min) *val = min; diff --git a/mednafen/mednafen-types.h b/mednafen/mednafen-types.h index 99eb5cedd..ec153cd0d 100644 --- a/mednafen/mednafen-types.h +++ b/mednafen/mednafen-types.h @@ -117,9 +117,9 @@ typedef uint64_t uint64; #define MDFN_MAKE_GCCV(maj,min,pl) (((maj)*100*100) + ((min) * 100) + (pl)) #define MDFN_GCC_VERSION MDFN_MAKE_GCCV(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#ifndef INLINE + #ifndef INLINE #define INLINE inline __attribute__((always_inline)) -#endif + #endif #define NO_INLINE __attribute__((noinline)) @@ -176,7 +176,10 @@ typedef uint64_t uint64; // Begin MSVC // + #if !defined(INLINE) #define INLINE __forceinline + #endif + #define NO_INLINE __declspec(noinline) #define NO_CLONE diff --git a/parallel-psx/util/util.hpp b/parallel-psx/util/util.hpp index b276b4411..84a710b7e 100644 --- a/parallel-psx/util/util.hpp +++ b/parallel-psx/util/util.hpp @@ -39,6 +39,7 @@ extern retro_log_printf_t libretro_log; #define LOGI(...) do { if (::Granite::libretro_log) ::Granite::libretro_log(RETRO_LOG_INFO, __VA_ARGS__); } while(0) #elif defined(_MSC_VER) #define WIN32_LEAN_AND_MEAN +#define NOMINMAX #include #define LOGE(...) do { \ fprintf(stderr, "[ERROR]: " __VA_ARGS__); \