libobs/util: Add THREAD_LOCAL macro

Adds a thread local storage macro to declare thread local storage
independent of platform.
master
jp9000 2017-12-25 12:01:10 -08:00
parent 0ffc9bbf05
commit b56c33a260
3 changed files with 9 additions and 12 deletions

View File

@ -28,11 +28,7 @@
#include "effect-parser.h"
#include "effect.h"
#ifdef _MSC_VER
static __declspec(thread) graphics_t *thread_graphics = NULL;
#else /* assume GCC or that other compiler we dare not mention */
static __thread graphics_t *thread_graphics = NULL;
#endif
static THREAD_LOCAL graphics_t *thread_graphics = NULL;
static inline bool gs_obj_valid(const void *obj, const char *f,
const char *name)

View File

@ -260,13 +260,8 @@ static bool enabled = false;
static pthread_mutex_t root_mutex = PTHREAD_MUTEX_INITIALIZER;
static DARRAY(profile_root_entry) root_entries;
#ifdef _MSC_VER
static __declspec(thread) profile_call *thread_context = NULL;
static __declspec(thread) bool thread_enabled = true;
#else
static __thread profile_call *thread_context = NULL;
static __thread bool thread_enabled = true;
#endif
static THREAD_LOCAL profile_call *thread_context = NULL;
static THREAD_LOCAL bool thread_enabled = true;
void profiler_start(void)
{

View File

@ -78,6 +78,12 @@ EXPORT int os_sem_wait(os_sem_t *sem);
EXPORT void os_set_thread_name(const char *name);
#ifdef _MSC_VER
#define THREAD_LOCAL __declspec(thread)
#else
#define THREAD_LOCAL __thread
#endif
#ifdef __cplusplus
}