From 60142252760361849dcd72b0dc3f75806d02a455 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Sun, 6 Nov 2022 15:47:44 -0800 Subject: [PATCH] Cross platform thread local --- debugdraw.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/debugdraw.c b/debugdraw.c index 44cd5fb..5ae2843 100644 --- a/debugdraw.c +++ b/debugdraw.c @@ -27,8 +27,15 @@ typedef struct Command // thread local variables so debug drawing in server thread // doesn't fuck up main thread -static __declspec(thread) Command commands[MAX_COMMANDS] = {0}; -static __declspec(thread) int command_i = 0; + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) +#define THREADLOCAL __declspec(thread) +#else +#define THREADLOCAL __thread +#endif + +static THREADLOCAL Command commands[MAX_COMMANDS] = {0}; +static THREADLOCAL int command_i = 0; void dbg_drawall() {