diff options
author | Mattes D <github@xoft.cz> | 2015-11-03 10:27:39 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-11-03 10:27:39 +0100 |
commit | 0946de1f3c50b3102e2f7eb2e79daf728a053942 (patch) | |
tree | 33cf4667605c2ff702fe5807e02abbd19a2eac9d /src/FastRandom.cpp | |
parent | Merge pull request #2464 from bibo38/assertfix (diff) | |
parent | Use an unreserved qualifier for thread local storage (diff) | |
download | cuberite-0946de1f3c50b3102e2f7eb2e79daf728a053942.tar cuberite-0946de1f3c50b3102e2f7eb2e79daf728a053942.tar.gz cuberite-0946de1f3c50b3102e2f7eb2e79daf728a053942.tar.bz2 cuberite-0946de1f3c50b3102e2f7eb2e79daf728a053942.tar.lz cuberite-0946de1f3c50b3102e2f7eb2e79daf728a053942.tar.xz cuberite-0946de1f3c50b3102e2f7eb2e79daf728a053942.tar.zst cuberite-0946de1f3c50b3102e2f7eb2e79daf728a053942.zip |
Diffstat (limited to 'src/FastRandom.cpp')
-rw-r--r-- | src/FastRandom.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/FastRandom.cpp b/src/FastRandom.cpp index c1716f026..0d9c361af 100644 --- a/src/FastRandom.cpp +++ b/src/FastRandom.cpp @@ -8,17 +8,19 @@ #include <random> -#ifdef _WIN32 - #define thread_local static __declspec(thread) -#elif defined __APPLE__ - #define thread_local static __thread +#if defined (__GNUC__) + #define ATTRIBUTE_TLS static __thread +#elif defined (_MSC_VER) + #define ATTRIBUTE_TLS static __declspec(thread) +#else + #error "Unknown thread local storage qualifier" #endif static unsigned int GetRandomSeed() { - thread_local bool SeedCounterInitialized = 0; - thread_local unsigned int SeedCounter = 0; - + ATTRIBUTE_TLS bool SeedCounterInitialized = 0; + ATTRIBUTE_TLS unsigned int SeedCounter = 0; + if (!SeedCounterInitialized) { std::random_device rd; @@ -47,8 +49,8 @@ public: TestInts(); TestFloats(); } - - + + void TestInts(void) { printf("Testing ints...\n"); |