[K/N] Replace thread_local with THREAD_LOCAL_VARIABLE

For some reason using C++'s thread_local modifier
causes crashes during TLS access on runtime initialization
Kotlin dlls on Windows. This patch replaces the thread_local
modifier with __thread which doesn't have this problem
This commit is contained in:
Ilya Matveev
2021-05-01 15:44:53 +07:00
committed by Space
parent e2e173b92c
commit 1be39cb505
3 changed files with 5 additions and 4 deletions
@@ -18,7 +18,7 @@ class A : public KonanAllocatorAware {
public:
using DestructorHook = testing::StrictMock<testing::MockFunction<void(int)>>;
static thread_local DestructorHook* destructorHook;
static THREAD_LOCAL_VARIABLE DestructorHook* destructorHook;
explicit A(int value = -1) : value_(value) {}
@@ -33,7 +33,7 @@ private:
};
// static
thread_local A::DestructorHook* A::destructorHook = nullptr;
THREAD_LOCAL_VARIABLE A::DestructorHook* A::destructorHook = nullptr;
struct B {
explicit B(int value) : a(value) {}
@@ -40,4 +40,4 @@ mm::ThreadRegistry::ThreadRegistry() = default;
mm::ThreadRegistry::~ThreadRegistry() = default;
// static
thread_local mm::ThreadRegistry::Node* mm::ThreadRegistry::currentThreadDataNode_ = nullptr;
THREAD_LOCAL_VARIABLE mm::ThreadRegistry::Node* mm::ThreadRegistry::currentThreadDataNode_ = nullptr;
@@ -8,6 +8,7 @@
#include <pthread.h>
#include "Common.h"
#include "SingleLockList.hpp"
#include "Utils.hpp"
@@ -48,7 +49,7 @@ private:
ThreadRegistry();
~ThreadRegistry();
static thread_local Node* currentThreadDataNode_;
static THREAD_LOCAL_VARIABLE Node* currentThreadDataNode_;
SingleLockList<ThreadData> list_;
};