aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/common
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-05-06 22:59:59 -0300
committerGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-05-06 23:50:08 -0300
commitbf12f270b3c74f694c789a57cc69f414753ca080 (patch)
treea80e6ee9863a46966fe43496f1ccbbfa07cc98aa /src/common
parentc0eaa662d47daa7a148fd63b2634ea59a559296c (diff)
Common: Remove many unnecessary cross-platform compatibility macros
Diffstat (limited to 'src/common')
-rw-r--r--src/common/common.h43
-rw-r--r--src/common/common_funcs.h10
-rw-r--r--src/common/file_util.cpp4
-rw-r--r--src/common/platform.h40
-rw-r--r--src/common/profiler.cpp1
5 files changed, 10 insertions, 88 deletions
diff --git a/src/common/common.h b/src/common/common.h
index a4a403fb..00d1d14f 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_GENERIC
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index e76cb7d6..9e666d77 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.cpp
index 4ef4918d..25d7d4b9 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 directory
bool 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.h
index e27d6e31..fc680d54 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.cpp
index 65c3df16..b8cde178 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