diff options
author | Tony Wasserka <neobrainx@gmail.com> | 2015-03-07 15:30:40 +0100 |
---|---|---|
committer | Tony Wasserka <neobrainx@gmail.com> | 2015-03-07 15:30:40 +0100 |
commit | 93e32bce72905ac1bd0a5e75066fda5e6b7bf250 (patch) | |
tree | 4530e9d8db22955416543899b6c0e59abf8b9732 /src/common/thread.h | |
parent | Merge pull request #630 from archshift/swap (diff) | |
parent | Profiler: Implement QPCClock to get better precision on Win32 (diff) | |
download | yuzu-93e32bce72905ac1bd0a5e75066fda5e6b7bf250.tar yuzu-93e32bce72905ac1bd0a5e75066fda5e6b7bf250.tar.gz yuzu-93e32bce72905ac1bd0a5e75066fda5e6b7bf250.tar.bz2 yuzu-93e32bce72905ac1bd0a5e75066fda5e6b7bf250.tar.lz yuzu-93e32bce72905ac1bd0a5e75066fda5e6b7bf250.tar.xz yuzu-93e32bce72905ac1bd0a5e75066fda5e6b7bf250.tar.zst yuzu-93e32bce72905ac1bd0a5e75066fda5e6b7bf250.zip |
Diffstat (limited to 'src/common/thread.h')
-rw-r--r-- | src/common/thread.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/thread.h b/src/common/thread.h index eaf1ba00c..a45728e1e 100644 --- a/src/common/thread.h +++ b/src/common/thread.h @@ -24,6 +24,25 @@ #include <unistd.h> #endif +// Support for C++11's thread_local keyword was surprisingly spotty in compilers until very +// recently. Fortunately, thread local variables have been well supported for compilers for a while, +// but with semantics supporting only POD types, so we can use a few defines to get some amount of +// backwards compat support. +// WARNING: This only works correctly with POD types. +#if defined(__clang__) +# if !__has_feature(cxx_thread_local) +# define thread_local __thread +# endif +#elif defined(__GNUC__) +# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8) +# define thread_local __thread +# endif +#elif defined(_MSC_VER) +# if _MSC_VER < 1900 +# define thread_local __declspec(thread) +# endif +#endif + namespace Common { |