rename tls -> tls_table
This commit is contained in:
parent
57a61aa119
commit
fec692b434
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
20
src/tls.h
20
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)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user