Add M_THREAD_ATTR

This commit is contained in:
Patrick Pelissier committed 2018-11-26 23:26:08 +01:00
1 parent 8cf780a60f
commit 1fb1fa2e0a
1 file changed
+9
+9
View File
@@ -120,6 +120,7 @@ static inline void m_oncei_call(m_oncei_t o, void (*func)(void))
call_once(o,func);
}
#define M_THREAD_ATTR _Thread_local
// MSYS2 doesn't define _WIN32 by default.
@@ -237,6 +238,12 @@ static inline void m_oncei_call(m_oncei_t o, void (*func)(void))
InitOnceExecuteOnce(o, m_oncei_callback, (void*)(intptr_t)func, NULL);
}
#if defined(_MSC_VER)
# define M_THREAD_ATTR __declspec( thread )
#else
# define M_THREAD_ATTR __thread
#endif
#else
/**************************** PTHREAD version ******************************/
@@ -348,6 +355,8 @@ static inline void m_oncei_call(m_oncei_t o, void (*func)(void))
pthread_once(o,func);
}
#define M_THREAD_ATTR __thread
#endif
// TODO: m_thread_sleep doesn't yield thread during waiting, making it a poor choice for active waiting.