Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual studio build fixes #202

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/DSi_NWifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions src/GPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

#include "GPU2D_Soft.h"

#ifdef _MSC_VER
#include <bit>
#endif

namespace GPU
{

Expand Down Expand Up @@ -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]];
}

Expand Down Expand Up @@ -1211,7 +1219,11 @@ NonStupidBitField<Size/VRAMDirtyGranularity> VRAMTrackingSet<Size, MappingGranul

while (mapping != 0)
{
#ifdef _MSC_VER
u32 num = std::countr_zero(mapping);
#else
u32 num = __builtin_ctz(mapping);
#endif
mapping &= ~(1 << num);

// hack for **speed**
Expand Down Expand Up @@ -1246,7 +1258,11 @@ NonStupidBitField<Size/VRAMDirtyGranularity> VRAMTrackingSet<Size, MappingGranul

while (banksToBeZeroed != 0)
{
#ifdef _MSC_VER
u32 num = std::countr_zero(banksToBeZeroed);
#else
u32 num = __builtin_ctz(banksToBeZeroed);
#endif
banksToBeZeroed &= ~(1 << num);
VRAMDirty[num].Clear();
}
Expand Down
4 changes: 4 additions & 0 deletions src/GPU3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2420,7 +2420,11 @@ void ExecuteCommand()
break;

default:
#ifdef _MSC_VER
__assume(0);
#else
__builtin_unreachable();
#endif
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/NDSCart_SRAMManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

#include <stdio.h>
#include <string.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include <time.h>
#include "NDSCart_SRAMManager.h"
#include "Platform.h"
Expand Down
13 changes: 12 additions & 1 deletion src/NonStupidBitfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
#include <initializer_list>
#include <algorithm>

#ifdef _MSC_VER
#include <bit>
#endif

// like std::bitset but less stupid and optimised for
// our use case (keeping track of memory invalidations)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)};
Expand Down
4 changes: 4 additions & 0 deletions src/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#define fread rfread
#define fseek rfseek

#ifdef _MSC_VER
#include <compat/msvc.h>
#endif

#endif

namespace Platform
Expand Down
10 changes: 8 additions & 2 deletions src/RTC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ void ByteIn(u8 val)
{
time_t timestamp = time(NULL);
struct tm timedata;
#ifdef _MSC_VER
localtime_s(&timedata, &timestamp);
#else
localtime_r(&timestamp, &timedata);

#endif
Output[0] = BCD(timedata.tm_year - 100);
Output[1] = BCD(timedata.tm_mon + 1);
Output[2] = BCD(timedata.tm_mday);
Expand All @@ -146,8 +149,11 @@ void ByteIn(u8 val)
{
time_t timestamp = time(NULL);
struct tm timedata;
#ifdef _MSC_VER
localtime_s(&timedata, &timestamp);
#else
localtime_r(&timestamp, &timedata);

#endif
Output[0] = BCD(timedata.tm_hour);
Output[1] = BCD(timedata.tm_min);
Output[2] = BCD(timedata.tm_sec);
Expand Down
16 changes: 7 additions & 9 deletions src/fatfs/ff.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <windows.h>
typedef unsigned __int64 QWORD;
#include <float.h>
#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 <stdint.h>
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
Expand All @@ -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 <float.h>
#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 */
Expand Down
4 changes: 4 additions & 0 deletions src/fatfs/ffsystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ DWORD get_fattime()

time_t timestamp = time(NULL);
struct tm timedata;
#ifdef _MSC_VER
localtime_s(&timedata, &timestamp);
#else
localtime_r(&timestamp, &timedata);
#endif

DWORD ret;
ret = (timedata.tm_sec >> 1);
Expand Down
7 changes: 6 additions & 1 deletion src/libretro/libretro-common/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
*.o
glsm/
*.[od]
*.dll
*.so
*.dylib
*.exe
Loading
Loading