1
0
Fork 0

Common: Remove many unnecessary cross-platform compatibility macros

This commit is contained in:
Yuri Kunde Schlesner 2015-05-06 22:59:59 -03:00
parent c0eaa662d4
commit bf12f270b3
8 changed files with 17 additions and 92 deletions

View File

@ -8,8 +8,11 @@ if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
else() else()
# Silence deprecation warnings # Silence "deprecation" warnings
add_definitions(/D_CRT_SECURE_NO_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 up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

View File

@ -19,7 +19,7 @@
#include "citra/emu_window/emu_window_glfw.h" #include "citra/emu_window/emu_window_glfw.h"
/// Application entry point /// Application entry point
int __cdecl main(int argc, char **argv) { int main(int argc, char **argv) {
std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger(); std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger();
Log::Filter log_filter(Log::Level::Debug); Log::Filter log_filter(Log::Level::Debug);
Log::SetFilter(&log_filter); Log::SetFilter(&log_filter);

View File

@ -349,7 +349,7 @@ void GMainWindow::closeEvent(QCloseEvent* event)
#undef main #undef main
#endif #endif
int __cdecl main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger(); std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger();
Log::Filter log_filter(Log::Level::Info); Log::Filter log_filter(Log::Level::Info);

View File

@ -11,8 +11,6 @@
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#define STACKALIGN
#include "common/assert.h" #include "common/assert.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/common_types.h" #include "common/common_types.h"
@ -20,56 +18,25 @@
#include "common/common_paths.h" #include "common/common_paths.h"
#include "common/platform.h" #include "common/platform.h"
#ifdef __APPLE__ #ifdef _WIN32
// The Darwin ABI requires that stack frames be aligned to 16-byte boundaries. // Alignment
// 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
#define MEMORY_ALIGNED16(x) __declspec(align(16)) x #define MEMORY_ALIGNED16(x) __declspec(align(16)) x
#define MEMORY_ALIGNED32(x) __declspec(align(32)) x #define MEMORY_ALIGNED32(x) __declspec(align(32)) x
#define MEMORY_ALIGNED64(x) __declspec(align(64)) x #define MEMORY_ALIGNED64(x) __declspec(align(64)) x
#define MEMORY_ALIGNED128(x) __declspec(align(128)) x #define MEMORY_ALIGNED128(x) __declspec(align(128)) x
#define MEMORY_ALIGNED16_DECL(x) __declspec(align(16)) x #else
#define MEMORY_ALIGNED64_DECL(x) __declspec(align(64)) x // Windows compatibility
#endif
// Windows compatibility
#ifndef _WIN32
#ifdef _LP64 #ifdef _LP64
#define _M_X64 1 #define _M_X64 1
#else #else
#define _M_IX86 1 #define _M_IX86 1
#endif #endif
#define __forceinline inline __attribute__((always_inline)) #define __forceinline inline __attribute__((always_inline))
#define MEMORY_ALIGNED16(x) __attribute__((aligned(16))) x #define MEMORY_ALIGNED16(x) __attribute__((aligned(16))) x
#define MEMORY_ALIGNED32(x) __attribute__((aligned(32))) x #define MEMORY_ALIGNED32(x) __attribute__((aligned(32))) x
#define MEMORY_ALIGNED64(x) __attribute__((aligned(64))) x #define MEMORY_ALIGNED64(x) __attribute__((aligned(64))) x
#define MEMORY_ALIGNED128(x) __attribute__((aligned(128))) 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 #endif
#if defined _M_GENERIC #if defined _M_GENERIC

View File

@ -73,16 +73,12 @@ inline u64 _rotr64(u64 x, unsigned int shift){
} }
#else // _MSC_VER #else // _MSC_VER
#include <locale.h> #include <locale.h>
// Function Cross-Compatibility // Function Cross-Compatibility
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define unlink _unlink
#define snprintf _snprintf #define snprintf _snprintf
#define vscprintf _vscprintf
// Locale Cross-Compatibility // Locale Cross-Compatibility
#define locale_t _locale_t #define locale_t _locale_t
#define freelocale _free_locale #define freelocale _free_locale
#define newlocale(mask, locale, base) _create_locale(mask, locale) #define newlocale(mask, locale, base) _create_locale(mask, locale)

View File

@ -589,7 +589,7 @@ std::string GetCurrentDir()
{ {
char *dir; char *dir;
// Get the current working directory (getcwd uses malloc) // 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", LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: %s",
GetLastErrorMsg()); GetLastErrorMsg());
@ -603,7 +603,7 @@ std::string GetCurrentDir()
// Sets the current directory to the given directory // Sets the current directory to the given directory
bool SetCurrentDir(const std::string &directory) bool SetCurrentDir(const std::string &directory)
{ {
return __chdir(directory.c_str()) == 0; return chdir(directory.c_str()) == 0;
} }
#if defined(__APPLE__) #if defined(__APPLE__)

View File

@ -66,45 +66,5 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Compiler-Specific Definitions // 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) || \ #define GCC_VERSION_AVAILABLE(major, minor) (defined(__GNUC__) && (__GNUC__ > (major) || \
(__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))) (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))

View File

@ -7,7 +7,6 @@
#include "common/assert.h" #include "common/assert.h"
#if defined(_MSC_VER) && _MSC_VER <= 1800 // MSVC 2013. #if defined(_MSC_VER) && _MSC_VER <= 1800 // MSVC 2013.
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <Windows.h> // For QueryPerformanceCounter/Frequency #include <Windows.h> // For QueryPerformanceCounter/Frequency
#endif #endif