From 3f550183053576bcbc0e5ee0a9e31dab7ef26c23 Mon Sep 17 00:00:00 2001 From: zoltanvb Date: Wed, 23 Oct 2024 12:59:28 +0200 Subject: [PATCH] More #ifdef cleanup, HAVE_STRLCPY introduction --- src/b2/misc.cpp | 6 ++---- src/b2/roms.cpp | 1 + src/beeb/include/beeb/DiscInterface.h | 1 + src/libretro/core.cpp | 3 ++- src/shared/c/system_windows.cpp | 8 ++++++-- src/shared/h/shared/log.h | 2 ++ src/shared/h/shared/mutex.h | 1 + src/shared/h/shared/system.h | 7 ++----- src/shared/h/shared/system_windows.h | 3 +-- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/b2/misc.cpp b/src/b2/misc.cpp index f841686c..b39ea8b3 100644 --- a/src/b2/misc.cpp +++ b/src/b2/misc.cpp @@ -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 } } @@ -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 ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// diff --git a/src/b2/roms.cpp b/src/b2/roms.cpp index 44a193bf..daf8b518 100644 --- a/src/b2/roms.cpp +++ b/src/b2/roms.cpp @@ -6,6 +6,7 @@ #else #include "../libretro/adapters.h" #endif // B2_LIBRETRO_CORE + #include #include "roms.inl" #include diff --git a/src/beeb/include/beeb/DiscInterface.h b/src/beeb/include/beeb/DiscInterface.h index 719dc4bb..87e0cd98 100644 --- a/src/beeb/include/beeb/DiscInterface.h +++ b/src/beeb/include/beeb/DiscInterface.h @@ -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; diff --git a/src/libretro/core.cpp b/src/libretro/core.cpp index 24daa6ac..d5b3d611 100644 --- a/src/libretro/core.cpp +++ b/src/libretro/core.cpp @@ -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 @@ -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"); diff --git a/src/shared/c/system_windows.cpp b/src/shared/c/system_windows.cpp index 90b164d6..2107cc8d 100644 --- a/src/shared/c/system_windows.cpp +++ b/src/shared/c/system_windows.cpp @@ -134,6 +134,7 @@ char **GetBacktraceSymbols(void *const *array, int size) { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// +#ifndef B2_LIBRETRO_CORE const char *GetLastErrorDescription(void) { return GetErrorDescription(GetLastError()); } @@ -147,7 +148,7 @@ const char *GetErrorDescription(DWORD error) { if (n == 0) { /* Bleargh. */ -#ifndef B2_LIBRETRO_CORE + #define CASE(X) \ case (X): \ return #X @@ -182,7 +183,7 @@ const char *GetErrorDescription(DWORD error) { } #undef CASE -#endif + } else { /* For some reason, Windows error strings end with a carriage * return. */ @@ -195,6 +196,7 @@ const char *GetErrorDescription(DWORD error) { return g_last_error_description; } +#endif ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// @@ -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 struct THREADNAME_INFO { @@ -362,6 +365,7 @@ void SetCurrentThreadNameInternal(const char *name) { #else void SetCurrentThreadNameInternal(const char *name) {} #endif + ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// diff --git a/src/shared/h/shared/log.h b/src/shared/h/shared/log.h index 36258448..c8a4642f 100644 --- a/src/shared/h/shared/log.h +++ b/src/shared/h/shared/log.h @@ -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 diff --git a/src/shared/h/shared/mutex.h b/src/shared/h/shared/mutex.h index d8126785..715e427c 100644 --- a/src/shared/h/shared/mutex.h +++ b/src/shared/h/shared/mutex.h @@ -10,6 +10,7 @@ #ifdef B2_LIBRETRO_CORE #include "system.h" #endif + #ifndef MUTEX_DEBUGGING #define MUTEX_DEBUGGING 1 #endif diff --git a/src/shared/h/shared/system.h b/src/shared/h/shared/system.h index 0c44cbc9..f89e7639 100644 --- a/src/shared/h/shared/system.h +++ b/src/shared/h/shared/system.h @@ -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 ////////////////////////////////////////////////////////////////////////// diff --git a/src/shared/h/shared/system_windows.h b/src/shared/h/shared/system_windows.h index 5dd91946..cbfd237b 100644 --- a/src/shared/h/shared/system_windows.h +++ b/src/shared/h/shared/system_windows.h @@ -6,6 +6,7 @@ ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// + #ifndef B2_LIBRETRO_CORE #ifdef _WIN32_WINNT // 0x600 = Vista+; 0x601 = Win7+; 0x602 = Win8+; @@ -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