From bf12f270b3c74f694c789a57cc69f414753ca080 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 6 May 2015 22:59:59 -0300 Subject: Common: Remove many unnecessary cross-platform compatibility macros --- src/common/common_funcs.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/common/common_funcs.h') 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 + #include -// 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) -- cgit v1.2.3 From f3c096951be57a02467bfda74ab539e69b2eff5e Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 6 May 2015 23:06:01 -0300 Subject: Common: Move IO-specific compatibility macros to file_util.cpp --- src/common/common_funcs.h | 8 -------- src/common/file_util.cpp | 44 ++++++++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src/common/common_funcs.h') diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 9e666d77..56ae791d 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -117,14 +117,6 @@ inline u64 _rotr64(u64 x, unsigned int shift){ return old_locale; } -// 64 bit offsets for windows - #define fseeko _fseeki64 - #define ftello _ftelli64 - #define atoll _atoi64 - #define stat64 _stat64 - #define fstat64 _fstat64 - #define fileno _fileno - extern "C" { __declspec(dllimport) void __stdcall DebugBreak(void); } diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 25d7d4b9..946c4261 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -7,37 +7,45 @@ #include "common/file_util.h" #ifdef _WIN32 -#include -#include // for SHGetFolderPath -#include -#include // for GetSaveFileName -#include -#include // getcwd -#include + #include + #include // for SHGetFolderPath + #include + #include // for GetSaveFileName + #include + #include // getcwd + #include + + // 64 bit offsets for windows + #define fseeko _fseeki64 + #define ftello _ftelli64 + #define atoll _atoi64 + #define stat64 _stat64 + #define fstat64 _fstat64 + #define fileno _fileno #else -#include -#include -#include -#include -#include + #include + #include + #include + #include + #include #endif #if defined(__APPLE__) -#include -#include -#include + #include + #include + #include #endif #include #include #ifndef S_ISDIR -#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) + #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) #endif #ifdef BSD4_4 -#define stat64 stat -#define fstat64 fstat + #define stat64 stat + #define fstat64 fstat #endif // This namespace has various generic functions related to files and paths. -- cgit v1.2.3 From a594fdb66e70f6dd45ed8ed1a0969262b0529395 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 6 May 2015 23:13:27 -0300 Subject: Common: Remove more unused compatibility defines --- src/common/common_funcs.h | 45 --------------------------------------------- 1 file changed, 45 deletions(-) (limited to 'src/common/common_funcs.h') diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 56ae791d..973d8354 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -7,13 +7,6 @@ #include "common_types.h" #include -#ifdef _WIN32 -#define SLEEP(x) Sleep(x) -#else -#include -#define SLEEP(x) usleep(x*1000) -#endif - #define b2(x) ( (x) | ( (x) >> 1) ) #define b4(x) ( b2(x) | ( b2(x) >> 2) ) @@ -73,49 +66,11 @@ inline u64 _rotr64(u64 x, unsigned int shift){ } #else // _MSC_VER - #include - // Function Cross-Compatibility #define snprintf _snprintf // Locale Cross-Compatibility #define locale_t _locale_t - #define freelocale _free_locale - #define newlocale(mask, locale, base) _create_locale(mask, locale) - - #define LC_GLOBAL_LOCALE ((locale_t)-1) - #define LC_ALL_MASK LC_ALL - #define LC_COLLATE_MASK LC_COLLATE - #define LC_CTYPE_MASK LC_CTYPE - #define LC_MONETARY_MASK LC_MONETARY - #define LC_NUMERIC_MASK LC_NUMERIC - #define LC_TIME_MASK LC_TIME - - inline locale_t uselocale(locale_t new_locale) - { - // Retrieve the current per thread locale setting - bool bIsPerThread = (_configthreadlocale(0) == _ENABLE_PER_THREAD_LOCALE); - - // Retrieve the current thread-specific locale - locale_t old_locale = bIsPerThread ? _get_current_locale() : LC_GLOBAL_LOCALE; - - if(new_locale == LC_GLOBAL_LOCALE) - { - // Restore the global locale - _configthreadlocale(_DISABLE_PER_THREAD_LOCALE); - } - else if(new_locale != nullptr) - { - // Configure the thread to set the locale only for this thread - _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); - - // Set all locale categories - for(int i = LC_MIN; i <= LC_MAX; i++) - setlocale(i, new_locale->locinfo->lc_category[i].locale); - } - - return old_locale; - } extern "C" { __declspec(dllimport) void __stdcall DebugBreak(void); -- cgit v1.2.3 From 1bd1a13a02e317a50252b0b5d5077b6ab2dbef53 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Wed, 6 May 2015 23:26:19 -0300 Subject: Common: Move alignment macros to common_funcs.h --- src/common/common.h | 21 --------------------- src/common/common_funcs.h | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src/common/common_funcs.h') diff --git a/src/common/common.h b/src/common/common.h index e8d32bc9..a9d3a6e6 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -18,25 +18,4 @@ #include "common/common_paths.h" #include "common/platform.h" -#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 -#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 -#endif - #include "swap.h" diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 973d8354..4f9e514c 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -27,6 +27,27 @@ #define INSERT_PADDING_BYTES(num_bytes) u8 CONCAT2(pad, __LINE__)[(num_bytes)] #define INSERT_PADDING_WORDS(num_words) u32 CONCAT2(pad, __LINE__)[(num_words)] +#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 +#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 +#endif + #ifndef _MSC_VER #include -- cgit v1.2.3