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_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)

View File

@ -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);

View File

@ -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);

View File

@ -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_GENERIC

View File

@ -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)

View File

@ -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 directory
bool SetCurrentDir(const std::string &directory)
{
return __chdir(directory.c_str()) == 0;
return chdir(directory.c_str()) == 0;
}
#if defined(__APPLE__)

View File

@ -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))))

View File

@ -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