diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2024-06-11 11:00:26 +0200 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2024-06-11 11:00:26 +0200 |
commit | 17c110d190eca49cbbb12efd67aee39302456972 (patch) | |
tree | 552f3c18a75d67d7951cedce154697d67197cc0d | |
parent | 885d7075cc85f2ec94a23fe1296069c64e32c886 (diff) | |
download | kit-17c110d190eca49cbbb12efd67aee39302456972.zip |
Remove tss
-rw-r--r-- | source/kit/shared_memory.win32.c | 6 | ||||
-rw-r--r-- | source/kit/threads.h | 3 | ||||
-rw-r--r-- | source/kit/threads.win32.c | 37 |
3 files changed, 4 insertions, 42 deletions
diff --git a/source/kit/shared_memory.win32.c b/source/kit/shared_memory.win32.c index 61b7317..f1d24d0 100644 --- a/source/kit/shared_memory.win32.c +++ b/source/kit/shared_memory.win32.c @@ -18,7 +18,7 @@ kit_shared_memory_t kit_shared_memory_open(kit_str_t name, i64 size, assert(size > 0); assert(name.size > 0); - assert(name.size + 8 < sizeof buf); + assert(name.size + 8 < (i64) sizeof buf); assert(name.values != NULL); if (name.size <= 0) { @@ -26,7 +26,7 @@ kit_shared_memory_t kit_shared_memory_open(kit_str_t name, i64 size, return mem; } - if (name.size + 8 >= sizeof buf) { + if (name.size + 8 >= (i64) sizeof buf) { mem.status = KIT_ERROR_NAME_TOO_LONG; return mem; } @@ -84,6 +84,8 @@ s32 kit_shared_memory_clean(kit_str_t name) { // Do nothing. // + (void) name; + return KIT_OK; } #endif diff --git a/source/kit/threads.h b/source/kit/threads.h index 8ff46ed..a636e99 100644 --- a/source/kit/threads.h +++ b/source/kit/threads.h @@ -86,16 +86,13 @@ typedef struct { void *handle; } thrd_t; -typedef unsigned long tss_t; # else typedef pthread_mutex_t mtx_t; typedef pthread_cond_t cnd_t; typedef pthread_once_t once_flag; typedef pthread_t thrd_t; -typedef pthread_key_t tss_t; # endif -typedef void (*tss_dtor_t)(void *); typedef int (*thrd_start_t)(void *); void mtx_destroy(mtx_t *mtx_); diff --git a/source/kit/threads.win32.c b/source/kit/threads.win32.c index 72f0ba1..ac185f7 100644 --- a/source/kit/threads.win32.c +++ b/source/kit/threads.win32.c @@ -25,9 +25,6 @@ Configuration macro: Use native WindowsAPI one-time initialization function. (requires WinVista or later) Otherwise emulate by mtx_trylock() + *busy loop* for WinXP. - - EMULATED_THREADS_TSS_DTOR_SLOTNUM - Max registerable TSS dtor number. */ # if _WIN32_WINNT >= 0x0600 @@ -36,8 +33,6 @@ Configuration macro: # define EMULATED_THREADS_USE_NATIVE_CALL_ONCE # endif # endif -# define EMULATED_THREADS_TSS_DTOR_SLOTNUM \ - 64 /* see TLS_MINIMUM_AVAILABLE */ /* check configuration */ # if defined(EMULATED_THREADS_USE_NATIVE_CALL_ONCE) && \ @@ -49,8 +44,6 @@ static_assert(sizeof(cnd_t) == sizeof(CONDITION_VARIABLE), "The size of cnd_t must equal to CONDITION_VARIABLE"); static_assert(sizeof(thrd_t) == sizeof(HANDLE), "The size of thrd_t must equal to HANDLE"); -static_assert(sizeof(tss_t) == sizeof(DWORD), - "The size of tss_t must equal to DWORD"); static_assert(sizeof(mtx_t) == sizeof(CRITICAL_SECTION), "The size of mtx_t must equal to CRITICAL_SECTION"); static_assert(sizeof(once_flag) == sizeof(INIT_ONCE), @@ -119,36 +112,6 @@ static BOOL CALLBACK impl_call_once_callback(PINIT_ONCE InitOnce, } # endif /* ifdef EMULATED_THREADS_USE_NATIVE_CALL_ONCE */ -static struct impl_tss_dtor_entry { - tss_t key; - tss_dtor_t dtor; -} impl_tss_dtor_tbl[EMULATED_THREADS_TSS_DTOR_SLOTNUM]; - -static int impl_tss_dtor_register(tss_t key, tss_dtor_t dtor) { - int i; - for (i = 0; i < EMULATED_THREADS_TSS_DTOR_SLOTNUM; i++) { - if (!impl_tss_dtor_tbl[i].dtor) - break; - } - if (i == EMULATED_THREADS_TSS_DTOR_SLOTNUM) - return 1; - impl_tss_dtor_tbl[i].key = key; - impl_tss_dtor_tbl[i].dtor = dtor; - return 0; -} - -static void impl_tss_dtor_invoke(void) { - int i; - for (i = 0; i < EMULATED_THREADS_TSS_DTOR_SLOTNUM; i++) { - if (impl_tss_dtor_tbl[i].dtor) { - void *val = (void *) (size_t) TlsGetValue( - impl_tss_dtor_tbl[i].key); - if (val) - (impl_tss_dtor_tbl[i].dtor)(val); - } - } -} - void call_once(once_flag *flag, void (*func)(void)) { assert(flag && func); # ifdef EMULATED_THREADS_USE_NATIVE_CALL_ONCE |