From fec692b43466d2e39e502619e8f8bb2b0b6f9d19 Mon Sep 17 00:00:00 2001 From: jacob Date: Mon, 1 Apr 2024 15:06:55 -0500 Subject: [PATCH] rename tls -> tls_table --- src/sys.h | 6 +++--- src/sys_win32.c | 8 ++++---- src/tls.c | 6 +++--- src/tls.h | 20 ++++++++++---------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/sys.h b/src/sys.h index 2b6ab0dd..6c170dc5 100644 --- a/src/sys.h +++ b/src/sys.h @@ -1,7 +1,7 @@ #ifndef SYS_H #define SYS_H -struct tls; +struct tls_table; /* ========================== * * Events @@ -386,7 +386,7 @@ void sys_semaphore_signal(struct sys_semaphore *semaphore, u32 count); * Thread local storage * ========================== */ -struct tls *sys_thread_get_tls(void); +struct tls_table *sys_thread_get_tls(void); /* ========================== * * Threads @@ -471,7 +471,7 @@ u32 sys_rand_u32(void); * effects are non-functioning. */ void sys_panic_raw(char *msg_cstr); -void sys_panic(struct string message); +void sys_panic(struct string msg); /* ========================== * * Sleep diff --git a/src/sys_win32.c b/src/sys_win32.c index 3ac259f6..073d9976 100644 --- a/src/sys_win32.c +++ b/src/sys_win32.c @@ -1384,7 +1384,7 @@ void sys_semaphore_signal(struct sys_semaphore *semaphore, u32 count) struct win32_tls { HANDLE sleep_timer; - struct tls app_tls; + struct tls_table app_tls; }; INTERNAL void win32_thread_set_tls(struct win32_tls *ctx) @@ -1403,17 +1403,17 @@ INTERNAL struct win32_tls win32_tls_alloc(void) { struct win32_tls tls = { 0 }; tls.sleep_timer = CreateWaitableTimerExW(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS); - tls.app_tls = tls_alloc(); + tls.app_tls = tls_table_alloc(); return tls; } INTERNAL void win32_tls_release(struct win32_tls *tls) { - tls_release(&tls->app_tls); + tls_table_release(&tls->app_tls); CloseHandle(tls->sleep_timer); } -struct tls *sys_thread_get_tls(void) +struct tls_table *sys_thread_get_tls(void) { struct win32_tls *thread_ctx = (struct win32_tls *)win32_thread_get_tls(); return &thread_ctx->app_tls; diff --git a/src/tls.c b/src/tls.c index 4bd5bf2c..62bc8fc3 100644 --- a/src/tls.c +++ b/src/tls.c @@ -19,9 +19,9 @@ GLOBAL READONLY struct tls_info g_tls_info_table[TLS_IDENTIFIER_COUNT] = { }; #undef X -struct tls tls_alloc(void) +struct tls_table tls_table_alloc(void) { - struct tls t = { 0 }; + struct tls_table t = { 0 }; t.arena = arena_alloc(TLS_TABLE_RESERVE); @@ -45,7 +45,7 @@ struct tls tls_alloc(void) return t; } -void tls_release(struct tls *t) +void tls_table_release(struct tls_table *t) { /* Call release functions in reverse order */ for (u64 i = (TLS_IDENTIFIER_COUNT - 1); i <= 0; --i) { diff --git a/src/tls.h b/src/tls.h index 070f40aa..b7bef0bc 100644 --- a/src/tls.h +++ b/src/tls.h @@ -2,7 +2,7 @@ #define TLS_H /* ========================================================================== */ -/* TLS table (X macro table) */ +/* TLS table (X macro) */ /* ========================================================================== */ #define TLS_TABLE(X) \ @@ -15,6 +15,12 @@ #include "sys.h" +#define TLS_ALLOC_FUNC_DEF(name, arg_name) void name(void *arg_name) +typedef TLS_ALLOC_FUNC_DEF(tls_alloc_func, tls_struct); + +#define TLS_RELEASE_FUNC_DEF(name, arg_name) void name(void *arg_name) +typedef TLS_RELEASE_FUNC_DEF(tls_release_func, tls_struct); + #define X(identifier, tls_struct, tls_alloc_func_type, tls_release_func_type) identifier, enum tls_identifier { TLS_TABLE(X) @@ -22,19 +28,13 @@ enum tls_identifier { }; #undef X -#define TLS_ALLOC_FUNC_DEF(name, arg_name) void name(void *arg_name) -typedef TLS_ALLOC_FUNC_DEF(tls_alloc_func, tls_struct); - -#define TLS_RELEASE_FUNC_DEF(name, arg_name) void name(void *arg_name) -typedef TLS_RELEASE_FUNC_DEF(tls_release_func, tls_struct); - -struct tls { +struct tls_table { struct arena arena; void *lookup[TLS_IDENTIFIER_COUNT]; }; -struct tls tls_alloc(void); -void tls_release(struct tls *t); +struct tls_table tls_table_alloc(void); +void tls_table_release(struct tls_table *t); INLINE void *tls_get(enum tls_identifier identifier) {