Fix Mono compilation on Windows/Ming
This commit is contained in:
parent
4491151aa9
commit
83140541dc
2 changed files with 19 additions and 10 deletions
|
@ -63,7 +63,13 @@ struct ThreadLocalStorage::Impl {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Impl(void (*p_destr_callback_func)(void *)) {
|
#ifdef WINDOWS_ENABLED
|
||||||
|
#define _CALLBACK_FUNC_ __stdcall
|
||||||
|
#else
|
||||||
|
#define _CALLBACK_FUNC_
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Impl(void _CALLBACK_FUNC_ (*p_destr_callback_func)(void *)) {
|
||||||
#ifdef WINDOWS_ENABLED
|
#ifdef WINDOWS_ENABLED
|
||||||
dwFlsIndex = FlsAlloc(p_destr_callback_func);
|
dwFlsIndex = FlsAlloc(p_destr_callback_func);
|
||||||
ERR_FAIL_COND(dwFlsIndex == FLS_OUT_OF_INDEXES);
|
ERR_FAIL_COND(dwFlsIndex == FLS_OUT_OF_INDEXES);
|
||||||
|
@ -89,10 +95,12 @@ void ThreadLocalStorage::set_value(void *p_value) const {
|
||||||
pimpl->set_value(p_value);
|
pimpl->set_value(p_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadLocalStorage::alloc(void (*p_destr_callback)(void *)) {
|
void ThreadLocalStorage::alloc(void _CALLBACK_FUNC_ (*p_destr_callback)(void *)) {
|
||||||
pimpl = memnew(ThreadLocalStorage::Impl(p_destr_callback));
|
pimpl = memnew(ThreadLocalStorage::Impl(p_destr_callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef _CALLBACK_FUNC_
|
||||||
|
|
||||||
void ThreadLocalStorage::free() {
|
void ThreadLocalStorage::free() {
|
||||||
memdelete(pimpl);
|
memdelete(pimpl);
|
||||||
pimpl = NULL;
|
pimpl = NULL;
|
||||||
|
|
|
@ -65,12 +65,18 @@
|
||||||
|
|
||||||
#include "core/typedefs.h"
|
#include "core/typedefs.h"
|
||||||
|
|
||||||
|
#ifdef WINDOWS_ENABLED
|
||||||
|
#define _CALLBACK_FUNC_ __stdcall
|
||||||
|
#else
|
||||||
|
#define _CALLBACK_FUNC_
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ThreadLocalStorage {
|
struct ThreadLocalStorage {
|
||||||
|
|
||||||
void *get_value() const;
|
void *get_value() const;
|
||||||
void set_value(void *p_value) const;
|
void set_value(void *p_value) const;
|
||||||
|
|
||||||
void alloc(void (*p_dest_callback)(void *));
|
void alloc(void _CALLBACK_FUNC_ (*p_dest_callback)(void *));
|
||||||
void free();
|
void free();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -85,17 +91,10 @@ class ThreadLocal {
|
||||||
|
|
||||||
T init_val;
|
T init_val;
|
||||||
|
|
||||||
#ifdef WINDOWS_ENABLED
|
|
||||||
#define _CALLBACK_FUNC_ __stdcall
|
|
||||||
#else
|
|
||||||
#define _CALLBACK_FUNC_
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void _CALLBACK_FUNC_ destr_callback(void *tls_data) {
|
static void _CALLBACK_FUNC_ destr_callback(void *tls_data) {
|
||||||
memdelete(static_cast<T *>(tls_data));
|
memdelete(static_cast<T *>(tls_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef _CALLBACK_FUNC_
|
|
||||||
|
|
||||||
T *_tls_get_value() const {
|
T *_tls_get_value() const {
|
||||||
void *tls_data = storage.get_value();
|
void *tls_data = storage.get_value();
|
||||||
|
@ -156,6 +155,8 @@ private:
|
||||||
bool &flag;
|
bool &flag;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#undef _CALLBACK_FUNC_
|
||||||
|
|
||||||
#define _TLS_RECURSION_GUARD_V_(m_ret) \
|
#define _TLS_RECURSION_GUARD_V_(m_ret) \
|
||||||
static _THREAD_LOCAL_(bool) _recursion_flag_ = false; \
|
static _THREAD_LOCAL_(bool) _recursion_flag_ = false; \
|
||||||
if (_recursion_flag_) \
|
if (_recursion_flag_) \
|
||||||
|
|
Loading…
Reference in a new issue