summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/common.h4
-rw-r--r--src/common/common_funcs.h8
-rw-r--r--src/common/log.h12
-rw-r--r--src/common/msg_handler.h2
-rw-r--r--src/common/platform.h4
-rw-r--r--src/common/string_util.cpp6
-rw-r--r--src/common/thread.cpp23
7 files changed, 38 insertions, 21 deletions
diff --git a/src/common/common.h b/src/common/common.h
index 66f0ccd0c..ba33373ae 100644
--- a/src/common/common.h
+++ b/src/common/common.h
@@ -50,11 +50,13 @@ private:
50#elif defined _WIN32 50#elif defined _WIN32
51 51
52// Check MSC ver 52// Check MSC ver
53 #if !defined _MSC_VER || _MSC_VER <= 1000 53 #if defined _MSC_VER && _MSC_VER <= 1000
54 #error needs at least version 1000 of MSC 54 #error needs at least version 1000 of MSC
55 #endif 55 #endif
56 56
57 #ifndef NOMINMAX
57 #define NOMINMAX 58 #define NOMINMAX
59 #endif
58 60
59// Memory leak checks 61// Memory leak checks
60 #define CHECK_HEAP_INTEGRITY() 62 #define CHECK_HEAP_INTEGRITY()
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index ca7abbea6..c2750a63c 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -31,7 +31,7 @@ template<> struct CompileTimeAssert<true> {};
31 31
32#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) 32#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
33 33
34#ifndef _WIN32 34#ifndef _MSC_VER
35 35
36#include <errno.h> 36#include <errno.h>
37#ifdef __linux__ 37#ifdef __linux__
@@ -75,7 +75,7 @@ inline u64 _rotr64(u64 x, unsigned int shift){
75 return (x >> n) | (x << (64 - n)); 75 return (x >> n) | (x << (64 - n));
76} 76}
77 77
78#else // WIN32 78#else // _MSC_VER
79#include <locale.h> 79#include <locale.h>
80 80
81// Function Cross-Compatibility 81// Function Cross-Compatibility
@@ -140,7 +140,7 @@ extern "C" {
140} 140}
141 #define Crash() {DebugBreak();} 141 #define Crash() {DebugBreak();}
142 #endif // M_IX86 142 #endif // M_IX86
143#endif // WIN32 ndef 143#endif // _MSC_VER ndef
144 144
145// Dolphin's min and max functions 145// Dolphin's min and max functions
146#undef min 146#undef min
@@ -168,7 +168,7 @@ inline u32 swap24(const u8* _data) {return (_data[0] << 16) | (_data[1] << 8) |
168#undef swap64 168#undef swap64
169#endif 169#endif
170 170
171#ifdef _WIN32 171#ifdef _MSC_VER
172inline u16 swap16(u16 _data) {return _byteswap_ushort(_data);} 172inline u16 swap16(u16 _data) {return _byteswap_ushort(_data);}
173inline u32 swap32(u32 _data) {return _byteswap_ulong (_data);} 173inline u32 swap32(u32 _data) {return _byteswap_ulong (_data);}
174inline u64 swap64(u64 _data) {return _byteswap_uint64(_data);} 174inline u64 swap64(u64 _data) {return _byteswap_uint64(_data);}
diff --git a/src/common/log.h b/src/common/log.h
index 96d97249f..667f2fbb9 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -8,7 +8,7 @@
8#include "common/msg_handler.h" 8#include "common/msg_handler.h"
9#include "common/logging/log.h" 9#include "common/logging/log.h"
10 10
11#ifdef _WIN32 11#ifdef _MSC_VER
12#ifndef __func__ 12#ifndef __func__
13#define __func__ __FUNCTION__ 13#define __func__ __FUNCTION__
14#endif 14#endif
@@ -39,14 +39,18 @@
39 39
40#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_) 40#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
41 41
42#ifdef _WIN32 42#ifndef GEKKO
43#ifdef _MSC_VER
43#define _assert_msg_(_t_, _a_, _fmt_, ...) \ 44#define _assert_msg_(_t_, _a_, _fmt_, ...) \
44 if (!(_a_)) {\ 45 if (!(_a_)) {\
45 if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \ 46 if (!PanicYesNo(_fmt_, __VA_ARGS__)) {Crash();} \
46 } 47 }
47#else // not win32 48#else // not msvc
48#define _assert_msg_(_t_, _a_, _fmt_, ...) \ 49#define _assert_msg_(_t_, _a_, _fmt_, ...) \
49 if (!(_a_)) {\ 50 if (!(_a_)) {\
50 if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \ 51 if (!PanicYesNo(_fmt_, ##__VA_ARGS__)) {Crash();} \
51 } 52 }
52#endif // WIN32 53#endif // _WIN32
54#else // GEKKO
55#define _assert_msg_(_t_, _a_, _fmt_, ...)
56#endif \ No newline at end of file
diff --git a/src/common/msg_handler.h b/src/common/msg_handler.h
index 7bb216e98..5a483ddb4 100644
--- a/src/common/msg_handler.h
+++ b/src/common/msg_handler.h
@@ -30,7 +30,7 @@ extern bool MsgAlert(bool yes_no, int Style, const char* format, ...)
30void SetEnableAlert(bool enable); 30void SetEnableAlert(bool enable);
31 31
32#ifndef GEKKO 32#ifndef GEKKO
33#ifdef _WIN32 33#ifdef _MSC_VER
34 #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__) 34 #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__)
35 #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__) 35 #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__)
36 #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__) 36 #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__)
diff --git a/src/common/platform.h b/src/common/platform.h
index 53d98fe74..ce9cfd4a2 100644
--- a/src/common/platform.h
+++ b/src/common/platform.h
@@ -71,14 +71,18 @@
71 71
72#include <time.h> 72#include <time.h>
73 73
74#ifndef NOMINMAX
74#define NOMINMAX 75#define NOMINMAX
76#endif
75#define EMU_FASTCALL __fastcall 77#define EMU_FASTCALL __fastcall
76 78
79#ifdef _MSC_VER
77inline struct tm* localtime_r(const time_t *clock, struct tm *result) { 80inline struct tm* localtime_r(const time_t *clock, struct tm *result) {
78 if (localtime_s(result, clock) == 0) 81 if (localtime_s(result, clock) == 0)
79 return result; 82 return result;
80 return nullptr; 83 return nullptr;
81} 84}
85#endif
82 86
83#else 87#else
84 88
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index d919b7a4c..b3b772bd9 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -7,7 +7,7 @@
7#include "common/common.h" 7#include "common/common.h"
8#include "common/string_util.h" 8#include "common/string_util.h"
9 9
10#ifdef _WIN32 10#ifdef _MSC_VER
11 #include <Windows.h> 11 #include <Windows.h>
12 #include <codecvt> 12 #include <codecvt>
13#else 13#else
@@ -45,7 +45,7 @@ bool CharArrayFromFormatV(char* out, int outsize, const char* format, va_list ar
45{ 45{
46 int writtenCount; 46 int writtenCount;
47 47
48#ifdef _WIN32 48#ifdef _MSC_VER
49 // You would think *printf are simple, right? Iterate on each character, 49 // You would think *printf are simple, right? Iterate on each character,
50 // if it's a format specifier handle it properly, etc. 50 // if it's a format specifier handle it properly, etc.
51 // 51 //
@@ -410,7 +410,7 @@ std::string UriEncode(const std::string & sSrc)
410 return sResult; 410 return sResult;
411} 411}
412 412
413#ifdef _WIN32 413#ifdef _MSC_VER
414 414
415std::string UTF16ToUTF8(const std::u16string& input) 415std::string UTF16ToUTF8(const std::u16string& input)
416{ 416{
diff --git a/src/common/thread.cpp b/src/common/thread.cpp
index 8c83d67b5..8bf005857 100644
--- a/src/common/thread.cpp
+++ b/src/common/thread.cpp
@@ -17,7 +17,7 @@ namespace Common
17 17
18int CurrentThreadId() 18int CurrentThreadId()
19{ 19{
20#ifdef _WIN32 20#ifdef _MSC_VER
21 return GetCurrentThreadId(); 21 return GetCurrentThreadId();
22#elif defined __APPLE__ 22#elif defined __APPLE__
23 return mach_thread_self(); 23 return mach_thread_self();
@@ -27,6 +27,14 @@ int CurrentThreadId()
27} 27}
28 28
29#ifdef _WIN32 29#ifdef _WIN32
30// Supporting functions
31void SleepCurrentThread(int ms)
32{
33 Sleep(ms);
34}
35#endif
36
37#ifdef _MSC_VER
30 38
31void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) 39void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)
32{ 40{
@@ -38,12 +46,6 @@ void SetCurrentThreadAffinity(u32 mask)
38 SetThreadAffinityMask(GetCurrentThread(), mask); 46 SetThreadAffinityMask(GetCurrentThread(), mask);
39} 47}
40 48
41// Supporting functions
42void SleepCurrentThread(int ms)
43{
44 Sleep(ms);
45}
46
47void SwitchCurrentThread() 49void SwitchCurrentThread()
48{ 50{
49 SwitchToThread(); 51 SwitchToThread();
@@ -82,7 +84,7 @@ void SetCurrentThreadName(const char* szThreadName)
82 {} 84 {}
83} 85}
84 86
85#else // !WIN32, so must be POSIX threads 87#else // !MSVC_VER, so must be POSIX threads
86 88
87void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) 89void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)
88{ 90{
@@ -106,6 +108,7 @@ void SetCurrentThreadAffinity(u32 mask)
106 SetThreadAffinity(pthread_self(), mask); 108 SetThreadAffinity(pthread_self(), mask);
107} 109}
108 110
111#ifndef _WIN32
109void SleepCurrentThread(int ms) 112void SleepCurrentThread(int ms)
110{ 113{
111 usleep(1000 * ms); 114 usleep(1000 * ms);
@@ -115,7 +118,10 @@ void SwitchCurrentThread()
115{ 118{
116 usleep(1000 * 1); 119 usleep(1000 * 1);
117} 120}
121#endif
118 122
123// MinGW with the POSIX threading model does not support pthread_setname_np
124#if !defined(_WIN32) || defined(_MSC_VER)
119void SetCurrentThreadName(const char* szThreadName) 125void SetCurrentThreadName(const char* szThreadName)
120{ 126{
121#ifdef __APPLE__ 127#ifdef __APPLE__
@@ -126,6 +132,7 @@ void SetCurrentThreadName(const char* szThreadName)
126 pthread_setname_np(pthread_self(), szThreadName); 132 pthread_setname_np(pthread_self(), szThreadName);
127#endif 133#endif
128} 134}
135#endif
129 136
130#endif 137#endif
131 138