From de8d8b5216650467661040b6b47ea649cf898c01 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 16 Nov 2018 22:12:35 -0800 Subject: Remove unused altss types and methods --- common/threads.c | 62 -------------------------------------------------------- common/threads.h | 35 -------------------------------- 2 files changed, 97 deletions(-) (limited to 'common') diff --git a/common/threads.c b/common/threads.c index 16604267..4cdb329d 100644 --- a/common/threads.c +++ b/common/threads.c @@ -38,9 +38,6 @@ extern inline int almtx_lock(almtx_t *mtx); extern inline int almtx_unlock(almtx_t *mtx); extern inline int almtx_trylock(almtx_t *mtx); -extern inline void *altss_get(altss_t tss_id); -extern inline int altss_set(altss_t tss_id, void *val); - #ifndef UNUSED #if defined(__cplusplus) @@ -72,13 +69,6 @@ extern inline int altss_set(altss_t tss_id, void *val); */ static UIntMap ThrdIdHandle = UINTMAP_STATIC_INITIALIZE; -/* An associative map of uint:void* pairs. The key is the TLS index (given by - * TlsAlloc), and the value is the altss_dtor_t callback. When a thread exits, - * we iterate over the TLS indices for their thread-local value and call the - * destructor function with it if they're both not NULL. - */ -static UIntMap TlsDestructors = UINTMAP_STATIC_INITIALIZE; - void althrd_setname(althrd_t thr, const char *name) { @@ -228,25 +218,6 @@ int alsem_trywait(alsem_t *sem) } -int altss_create(altss_t *tss_id, altss_dtor_t callback) -{ - DWORD key = TlsAlloc(); - if(key == TLS_OUT_OF_INDEXES) - return althrd_error; - - *tss_id = key; - if(callback != NULL) - InsertUIntMapEntry(&TlsDestructors, key, callback); - return althrd_success; -} - -void altss_delete(altss_t tss_id) -{ - RemoveUIntMapKey(&TlsDestructors, tss_id); - TlsFree(tss_id); -} - - void alcall_once(alonce_flag *once, void (*callback)(void)) { LONG ret; @@ -261,25 +232,6 @@ void alcall_once(alonce_flag *once, void (*callback)(void)) void althrd_deinit(void) { ResetUIntMap(&ThrdIdHandle); - ResetUIntMap(&TlsDestructors); -} - -void althrd_thread_detach(void) -{ - ALsizei i; - - LockUIntMapRead(&TlsDestructors); - for(i = 0;i < TlsDestructors.size;i++) - { - void *ptr = altss_get(TlsDestructors.keys[i]); - altss_dtor_t callback = (altss_dtor_t)TlsDestructors.values[i]; - if(ptr) - { - if(callback) callback(ptr); - altss_set(TlsDestructors.keys[i], NULL); - } - } - UnlockUIntMapRead(&TlsDestructors); } #else @@ -295,7 +247,6 @@ void althrd_thread_detach(void) extern inline void alcall_once(alonce_flag *once, void (*callback)(void)); extern inline void althrd_deinit(void); -extern inline void althrd_thread_detach(void); void althrd_setname(althrd_t thr, const char *name) { @@ -511,17 +462,4 @@ int alsem_trywait(alsem_t *sem) #endif /* __APPLE__ */ - -int altss_create(altss_t *tss_id, altss_dtor_t callback) -{ - if(pthread_key_create(tss_id, callback) != 0) - return althrd_error; - return althrd_success; -} - -void altss_delete(altss_t tss_id) -{ - pthread_key_delete(tss_id); -} - #endif diff --git a/common/threads.h b/common/threads.h index 2cc65557..2d1c228d 100644 --- a/common/threads.h +++ b/common/threads.h @@ -31,7 +31,6 @@ enum { }; typedef int (*althrd_start_t)(void*); -typedef void (*altss_dtor_t)(void*); #ifdef _WIN32 @@ -42,7 +41,6 @@ typedef void (*altss_dtor_t)(void*); typedef DWORD althrd_t; typedef CRITICAL_SECTION almtx_t; typedef HANDLE alsem_t; -typedef DWORD altss_t; typedef LONG alonce_flag; #define AL_ONCE_FLAG_INIT 0 @@ -50,8 +48,6 @@ typedef LONG alonce_flag; void alcall_once(alonce_flag *once, void (*callback)(void)); void althrd_deinit(void); -void althrd_thread_detach(void); - inline althrd_t althrd_current(void) { @@ -96,19 +92,6 @@ inline int almtx_trylock(almtx_t *mtx) return althrd_success; } - -inline void *altss_get(altss_t tss_id) -{ - return TlsGetValue(tss_id); -} - -inline int altss_set(altss_t tss_id, void *val) -{ - if(TlsSetValue(tss_id, val) == 0) - return althrd_error; - return althrd_success; -} - #else #include @@ -128,7 +111,6 @@ typedef dispatch_semaphore_t alsem_t; #else /* !__APPLE__ */ typedef sem_t alsem_t; #endif /* __APPLE__ */ -typedef pthread_key_t altss_t; typedef pthread_once_t alonce_flag; #define AL_ONCE_FLAG_INIT PTHREAD_ONCE_INIT @@ -181,19 +163,6 @@ inline int almtx_trylock(almtx_t *mtx) } -inline void *altss_get(altss_t tss_id) -{ - return pthread_getspecific(tss_id); -} - -inline int altss_set(altss_t tss_id, void *val) -{ - if(pthread_setspecific(tss_id, val) != 0) - return althrd_error; - return althrd_success; -} - - inline void alcall_once(alonce_flag *once, void (*callback)(void)) { pthread_once(once, callback); @@ -201,7 +170,6 @@ inline void alcall_once(alonce_flag *once, void (*callback)(void)) inline void althrd_deinit(void) { } -inline void althrd_thread_detach(void) { } #endif @@ -220,9 +188,6 @@ int alsem_post(alsem_t *sem); int alsem_wait(alsem_t *sem); int alsem_trywait(alsem_t *sem); -int altss_create(altss_t *tss_id, altss_dtor_t callback); -void altss_delete(altss_t tss_id); - #ifdef __cplusplus } // extern "C" -- cgit v1.2.3