diff --git a/Makefile.common b/Makefile.common index 3150817b75..2a6450021a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -26,6 +26,7 @@ SOURCES_C += $(CORE_DIR)/libretro-common/compat/compat_strl.c \ $(CORE_DIR)/libretro-common/streams/file_stream_transforms.c \ $(CORE_DIR)/libretro-common/streams/memory_stream.c \ $(CORE_DIR)/libretro-common/string/stdstring.c \ + $(CORE_DIR)/libretro-common/time/rtime.c \ $(CORE_DIR)/libretro-common/vfs/vfs_implementation.c endif diff --git a/src/DSi_NWifi.cpp b/src/DSi_NWifi.cpp index 57bd93c343..06e83c8f79 100644 --- a/src/DSi_NWifi.cpp +++ b/src/DSi_NWifi.cpp @@ -1002,7 +1002,7 @@ void DSi_NWifi::WMI_Command() case 0x000E: // get channel list { - int nchan = 11; // TODO: customize?? + const int nchan = 11; // TODO: customize?? u8 reply[2 + (nchan*2) + 2]; reply[0] = 0; diff --git a/src/GPU.cpp b/src/GPU.cpp index de229b3ca8..f94eb2acb7 100644 --- a/src/GPU.cpp +++ b/src/GPU.cpp @@ -23,6 +23,10 @@ #include "GPU2D_Soft.h" +#ifdef _MSC_VER +#include +#endif + namespace GPU { @@ -515,7 +519,11 @@ void SetRenderSettings(int renderer, RenderSettings& settings) u8* GetUniqueBankPtr(u32 mask, u32 offset) { if (!mask || (mask & (mask - 1)) != 0) return NULL; +#ifdef _MSC_VER + int num = std::countr_zero(mask); +#else int num = __builtin_ctz(mask); +#endif return &VRAM[num][offset & VRAMMask[num]]; } @@ -1211,7 +1219,11 @@ NonStupidBitField VRAMTrackingSet VRAMTrackingSet #include +#ifndef _MSC_VER #include +#endif #include #include "NDSCart_SRAMManager.h" #include "Platform.h" diff --git a/src/NonStupidBitfield.h b/src/NonStupidBitfield.h index 45b160e7fa..2998276ce6 100644 --- a/src/NonStupidBitfield.h +++ b/src/NonStupidBitfield.h @@ -26,6 +26,10 @@ #include #include +#ifdef _MSC_VER +#include +#endif + // like std::bitset but less stupid and optimised for // our use case (keeping track of memory invalidations) @@ -88,8 +92,11 @@ struct NonStupidBitField return; done:; } - +#ifdef _MSC_VER + BitIdx = std::countr_zero(RemainingBits); +#else BitIdx = __builtin_ctzll(RemainingBits); +#endif RemainingBits &= ~(1ULL << BitIdx); if ((Size & 0x3F) && BitIdx >= Size) @@ -144,7 +151,11 @@ struct NonStupidBitField { for (u32 i = 0; i < DataLength; i++) { +#ifdef _MSC_VER + u32 idx = std::countr_zero(Data[i]); +#else u32 idx = __builtin_ctzll(Data[i]); +#endif if (Data[i] && idx + i * 64 < Size) { return {*this, i, idx, Data[i] & ~(1ULL << idx)}; diff --git a/src/Platform.h b/src/Platform.h index 2240e458c9..2254b948e9 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -31,6 +31,10 @@ #define fread rfread #define fseek rfseek +#ifdef _MSC_VER +#include +#endif + #endif namespace Platform diff --git a/src/RTC.cpp b/src/RTC.cpp index 905a8d86b5..0e9f852833 100644 --- a/src/RTC.cpp +++ b/src/RTC.cpp @@ -130,8 +130,11 @@ void ByteIn(u8 val) { time_t timestamp = time(NULL); struct tm timedata; +#ifdef _MSC_VER + localtime_s(&timedata, ×tamp); +#else localtime_r(×tamp, &timedata); - +#endif Output[0] = BCD(timedata.tm_year - 100); Output[1] = BCD(timedata.tm_mon + 1); Output[2] = BCD(timedata.tm_mday); @@ -146,8 +149,11 @@ void ByteIn(u8 val) { time_t timestamp = time(NULL); struct tm timedata; +#ifdef _MSC_VER + localtime_s(&timedata, ×tamp); +#else localtime_r(×tamp, &timedata); - +#endif Output[0] = BCD(timedata.tm_hour); Output[1] = BCD(timedata.tm_min); Output[2] = BCD(timedata.tm_sec); diff --git a/src/fatfs/ff.h b/src/fatfs/ff.h index 6df78a8e40..cf48d510f7 100644 --- a/src/fatfs/ff.h +++ b/src/fatfs/ff.h @@ -35,15 +35,7 @@ extern "C" { /* Integer types used for FatFs API */ -#if defined(_WIN32) /* Windows VC++ (for development only) */ -#define FF_INTDEF 2 -#include -typedef unsigned __int64 QWORD; -#include -#define isnan(v) _isnan(v) -#define isinf(v) (!_finite(v)) - -#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */ #define FF_INTDEF 2 #include typedef unsigned int UINT; /* int must be 16-bit or 32-bit */ @@ -53,6 +45,12 @@ typedef uint32_t DWORD; /* 32-bit unsigned integer */ typedef uint64_t QWORD; /* 64-bit unsigned integer */ typedef WORD WCHAR; /* UTF-16 character type */ +#if defined(_WIN32) +#include +#define isnan(v) _isnan(v) +#define isinf(v) (!_finite(v)) +#endif + #else /* Earlier than C99 */ #define FF_INTDEF 1 typedef unsigned int UINT; /* int must be 16-bit or 32-bit */ diff --git a/src/fatfs/ffsystem.c b/src/fatfs/ffsystem.c index b0409efa69..3983978460 100644 --- a/src/fatfs/ffsystem.c +++ b/src/fatfs/ffsystem.c @@ -109,7 +109,11 @@ DWORD get_fattime() time_t timestamp = time(NULL); struct tm timedata; +#ifdef _MSC_VER + localtime_s(&timedata, ×tamp); +#else localtime_r(×tamp, &timedata); +#endif DWORD ret; ret = (timedata.tm_sec >> 1); diff --git a/src/libretro/libretro-common/.gitignore b/src/libretro/libretro-common/.gitignore index 5761abcfdf..4e88cc3908 100644 --- a/src/libretro/libretro-common/.gitignore +++ b/src/libretro/libretro-common/.gitignore @@ -1 +1,6 @@ -*.o +glsm/ +*.[od] +*.dll +*.so +*.dylib +*.exe diff --git a/src/libretro/libretro-common/audio/audio_mix.c b/src/libretro/libretro-common/audio/audio_mix.c index 15879ab248..eb138edd44 100644 --- a/src/libretro/libretro-common/audio/audio_mix.c +++ b/src/libretro/libretro-common/audio/audio_mix.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2018 The RetroArch team +/* Copyright (C) 2010-2020 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (audio_mix.c). @@ -20,7 +20,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include