Skip to content

Commit

Permalink
More #ifdef cleanup, HAVE_STRLCPY introduction
Browse files Browse the repository at this point in the history
  • Loading branch information
zoltanvb committed Oct 23, 2024
1 parent ce6ac2c commit 3f55018
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 14 deletions.
6 changes: 2 additions & 4 deletions src/b2/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,11 @@ std::string GetTimeString(const struct tm &t) {
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

#ifndef B2_LIBRETRO_CORE
AudioDeviceLock::AudioDeviceLock(uint32_t device)
: m_device(device) {
if (m_device != 0) {
#ifndef B2_LIBRETRO_CORE
SDL_LockAudioDevice(m_device);
#endif // B2_LIBRETRO_CORE
}
}

Expand All @@ -401,11 +400,10 @@ AudioDeviceLock::AudioDeviceLock(uint32_t device)

AudioDeviceLock::~AudioDeviceLock() {
if (m_device != 0) {
#ifndef B2_LIBRETRO_CORE
SDL_UnlockAudioDevice(m_device);
#endif // B2_LIBRETRO_CORE
}
}
#endif // B2_LIBRETRO_CORE

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions src/b2/roms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#else
#include "../libretro/adapters.h"
#endif // B2_LIBRETRO_CORE

#include <shared/enum_def.h>
#include "roms.inl"
#include <shared/enum_end.h>
Expand Down
1 change: 1 addition & 0 deletions src/beeb/include/beeb/DiscInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ extern const DiscInterfaceDef DISC_INTERFACE_OPUS;
extern const DiscInterfaceDef DISC_INTERFACE_CHALLENGER_256K;
extern const DiscInterfaceDef DISC_INTERFACE_CHALLENGER_512K;
#endif

// This disc interface is used for the Master 128.
extern const DiscInterfaceDef DISC_INTERFACE_MASTER128;

Expand Down
3 changes: 2 additions & 1 deletion src/libretro/core.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* TODO
sudo docker run -it --rm -v "/media/storage/Documents/dev/b2-libretro:/build" git.libretro.com:5050/libretro-infrastructure/libretro-build-amd64-ubuntu:xenial-gcc9 bash
sudo docker run -it --rm -v "/media/storage/Documents/dev/b2-libretro:/build" git.libretro.com:5050/libretro-infrastructure/libretro-build-mxe-win32-cross:gcc10 bash
Expand Down Expand Up @@ -659,7 +660,7 @@ void retro_get_system_info(struct retro_system_info *info)
{
memset(info, 0, sizeof(*info));
info->library_name = "b2";
info->library_version = "v0.2";
info->library_version = "v0.3";
info->need_fullpath = true;
info->valid_extensions = "ssd|dsd";
//printf("retro_get_system_info \n");
Expand Down
8 changes: 6 additions & 2 deletions src/shared/c/system_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ char **GetBacktraceSymbols(void *const *array, int size) {
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

#ifndef B2_LIBRETRO_CORE
const char *GetLastErrorDescription(void) {
return GetErrorDescription(GetLastError());
}
Expand All @@ -147,7 +148,7 @@ const char *GetErrorDescription(DWORD error) {

if (n == 0) {
/* Bleargh. */
#ifndef B2_LIBRETRO_CORE

#define CASE(X) \
case (X): \
return #X
Expand Down Expand Up @@ -182,7 +183,7 @@ const char *GetErrorDescription(DWORD error) {
}

#undef CASE
#endif

} else {
/* For some reason, Windows error strings end with a carriage
* return. */
Expand All @@ -195,6 +196,7 @@ const char *GetErrorDescription(DWORD error) {

return g_last_error_description;
}
#endif

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -308,6 +310,7 @@ int GetTerminalWidth(void) {
// https://msdn.microsoft.com/en-us/library/windows/desktop/mt774976(v=vs.85).aspx...
// but that's only from Windows 10 build 1607! Seems a bit rude to
// require that when everything else only needs Vista+.

#ifndef B2_LIBRETRO_CORE
#include <shared/pshpack8.h>
struct THREADNAME_INFO {
Expand Down Expand Up @@ -362,6 +365,7 @@ void SetCurrentThreadNameInternal(const char *name) {
#else
void SetCurrentThreadNameInternal(const char *name) {}
#endif

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

Expand Down
2 changes: 2 additions & 0 deletions src/shared/h/shared/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,13 @@ void LogStackTrace(Log *log);
// the log is enabled).

#define LOG__IS_ENABLED(X) ((X).enabled)

#ifndef B2_LIBRETRO_CORE
#define LOG(X) g_log_##X
#else
#define LOG(X) log_info_##X
#endif // B2_LIBRETRO_CORE

#define LOG_EXTERN(X) extern Log LOG(X)

// C4456: declaration of 'IDENTIFIER' hides previous local
Expand Down
1 change: 1 addition & 0 deletions src/shared/h/shared/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifdef B2_LIBRETRO_CORE
#include "system.h"
#endif

#ifndef MUTEX_DEBUGGING
#define MUTEX_DEBUGGING 1
#endif
Expand Down
7 changes: 2 additions & 5 deletions src/shared/h/shared/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,9 @@ int vasprintf(char **buf, const char *fmt, va_list v);
// BSD extension.
//
// See https://lwn.net/Articles/612244/
#ifndef B2_LIBRETRO_CORE
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dest, const char *src, size_t size);
#endif // B2_LIBRETRO_CORE
#if SYSTEM_WINDOWS
size_t strlcpy(char *dest, const char *src, size_t size);
#endif // SYSTEM_WINDOWS
#endif // HAVE_STRLCPY
#endif

//////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 1 addition & 2 deletions src/shared/h/shared/system_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

#ifndef B2_LIBRETRO_CORE
#ifdef _WIN32_WINNT
// 0x600 = Vista+; 0x601 = Win7+; 0x602 = Win8+;
Expand All @@ -15,8 +16,6 @@
#else
#define _WIN32_WINNT 0x601
#endif
#else
size_t strlcpy(char *dest, const char *src, size_t size);
#endif

#define NOMINMAX
Expand Down

0 comments on commit 3f55018

Please sign in to comment.