VERY experimental Nintendo Switch 2 emulator
C++
Common: Remove many unnecessary cross-platform compatibility macros
Yuri Kunde Schlesnerbf12f270b3c7
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 516aba5540..b0fe285db6 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -8,8 +8,11 @@ if (NOT MSVC)set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread")set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")else()- # Silence deprecation warnings- add_definitions(/D_CRT_SECURE_NO_WARNINGS)+ # Silence "deprecation" warnings+ add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE)+ # Avoid windows.h junk+ add_definitions(/DNOMINMAX)+# set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms)set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)diff --git a/src/citra/citra.cpp b/src/citra/citra.cppindex 2c6ced920e..634faf76b3 100644--- a/src/citra/citra.cpp+++ b/src/citra/citra.cpp@@ -19,7 +19,7 @@#include "citra/emu_window/emu_window_glfw.h"/// Application entry point-int __cdecl main(int argc, char **argv) {+int main(int argc, char **argv) {std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger();Log::Filter log_filter(Log::Level::Debug);Log::SetFilter(&log_filter);diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cppindex dd0e4de8f9..b78594fb6a 100644--- a/src/citra_qt/main.cpp+++ b/src/citra_qt/main.cpp@@ -349,7 +349,7 @@ void GMainWindow::closeEvent(QCloseEvent* event)#undef main#endif-int __cdecl main(int argc, char* argv[])+int main(int argc, char* argv[]){std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger();Log::Filter log_filter(Log::Level::Info);diff --git a/src/common/common.h b/src/common/common.hindex a4a403fb96..00d1d14f94 100644--- a/src/common/common.h+++ b/src/common/common.h@@ -11,8 +11,6 @@#include <cstdio>#include <cstring>-#define STACKALIGN-#include "common/assert.h"#include "common/logging/log.h"#include "common/common_types.h"@@ -20,56 +18,25 @@#include "common/common_paths.h"#include "common/platform.h"-#ifdef __APPLE__-// The Darwin ABI requires that stack frames be aligned to 16-byte boundaries.-// This is only needed on i386 gcc - x86_64 already aligns to 16 bytes.- #if defined __i386__ && defined __GNUC__- #undef STACKALIGN- #define STACKALIGN __attribute__((__force_align_arg_pointer__))- #endif-#elif defined _WIN32-// Check MSC ver- #if defined _MSC_VER && _MSC_VER <= 1000- #error needs at least version 1000 of MSC- #endif-- #ifndef NOMINMAX- #define NOMINMAX- #endif--// Alignment+#ifdef _WIN32+ // Alignment#define MEMORY_ALIGNED16(x) __declspec(align(16)) x#define MEMORY_ALIGNED32(x) __declspec(align(32)) x#define MEMORY_ALIGNED64(x) __declspec(align(64)) x#define MEMORY_ALIGNED128(x) __declspec(align(128)) x- #define MEMORY_ALIGNED16_DECL(x) __declspec(align(16)) x- #define MEMORY_ALIGNED64_DECL(x) __declspec(align(64)) x-#endif--// Windows compatibility-#ifndef _WIN32+#else+ // Windows compatibility#ifdef _LP64#define _M_X64 1#else#define _M_IX86 1#endif+#define __forceinline inline __attribute__((always_inline))#define MEMORY_ALIGNED16(x) __attribute__((aligned(16))) x#define MEMORY_ALIGNED32(x) __attribute__((aligned(32))) x#define MEMORY_ALIGNED64(x) __attribute__((aligned(64))) x#define MEMORY_ALIGNED128(x) __attribute__((aligned(128))) x- #define MEMORY_ALIGNED16_DECL(x) __attribute__((aligned(16))) x- #define MEMORY_ALIGNED64_DECL(x) __attribute__((aligned(64))) x-#endif--#ifdef _MSC_VER- #define __strdup _strdup- #define __getcwd _getcwd- #define __chdir _chdir-#else- #define __strdup strdup- #define __getcwd getcwd- #define __chdir chdir#endif#if defined _M_GENERICdiff --git a/src/common/common_funcs.h b/src/common/common_funcs.hindex e76cb7d68c..9e666d77e8 100644--- a/src/common/common_funcs.h+++ b/src/common/common_funcs.h@@ -73,16 +73,12 @@ inline u64 _rotr64(u64 x, unsigned int shift){}#else // _MSC_VER-#include <locale.h>+ #include <locale.h>-// Function Cross-Compatibility- #define strcasecmp _stricmp- #define strncasecmp _strnicmp- #define unlink _unlink+ // Function Cross-Compatibility#define snprintf _snprintf- #define vscprintf _vscprintf-// Locale Cross-Compatibility+ // Locale Cross-Compatibility#define locale_t _locale_t#define freelocale _free_locale#define newlocale(mask, locale, base) _create_locale(mask, locale)diff --git a/src/common/file_util.cpp b/src/common/file_util.cppindex 4ef4918d75..25d7d4b9f4 100644--- a/src/common/file_util.cpp+++ b/src/common/file_util.cpp@@ -589,7 +589,7 @@ std::string GetCurrentDir(){char *dir;// Get the current working directory (getcwd uses malloc)- if (!(dir = __getcwd(nullptr, 0))) {+ if (!(dir = getcwd(nullptr, 0))) {LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: %s",GetLastErrorMsg());@@ -603,7 +603,7 @@ std::string GetCurrentDir()// Sets the current directory to the given directorybool SetCurrentDir(const std::string &directory){- return __chdir(directory.c_str()) == 0;+ return chdir(directory.c_str()) == 0;}#if defined(__APPLE__)diff --git a/src/common/platform.h b/src/common/platform.hindex e27d6e31ff..fc680d549a 100644--- a/src/common/platform.h+++ b/src/common/platform.h@@ -66,45 +66,5 @@////////////////////////////////////////////////////////////////////////////////////////////////////// Compiler-Specific Definitions-#if EMU_PLATFORM == PLATFORM_WINDOWS--#include <time.h>--#ifndef NOMINMAX-#define NOMINMAX-#endif-#define EMU_FASTCALL __fastcall--#ifdef _MSC_VER-inline struct tm* localtime_r(const time_t *clock, struct tm *result) {- if (localtime_s(result, clock) == 0)- return result;- return nullptr;-}-#endif--#else // EMU_PLATFORM != PLATFORM_WINDOWS--#define EMU_FASTCALL __attribute__((fastcall))-#define __stdcall-#define __cdecl--#define BOOL bool-#define DWORD u32--// TODO: Hacks..-#include <limits.h>--#include <strings.h>-#define stricmp(str1, str2) strcasecmp(str1, str2)-#define _stricmp(str1, str2) strcasecmp(str1, str2)-#define _snprintf snprintf-#define _getcwd getcwd-#define _tzset tzset--typedef void EXCEPTION_POINTERS;--#endif-#define GCC_VERSION_AVAILABLE(major, minor) (defined(__GNUC__) && (__GNUC__ > (major) || \(__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))diff --git a/src/common/profiler.cpp b/src/common/profiler.cppindex 65c3df167d..b8cde17853 100644--- a/src/common/profiler.cpp+++ b/src/common/profiler.cpp@@ -7,7 +7,6 @@#include "common/assert.h"#if defined(_MSC_VER) && _MSC_VER <= 1800 // MSVC 2013.-#define NOMINMAX#define WIN32_LEAN_AND_MEAN#include <Windows.h> // For QueryPerformanceCounter/Frequency#endif