Index: src/OFSecureData.m ================================================================== --- src/OFSecureData.m +++ src/OFSecureData.m @@ -49,12 +49,12 @@ static thread_local struct page *firstPage = NULL; static thread_local struct page *lastPage = NULL; static thread_local struct page **preallocatedPages = NULL; static thread_local size_t numPreallocatedPages = 0; # elif defined(OF_HAVE_THREADS) -static of_tlskey_t firstPageKey, lastPageKey; -static of_tlskey_t preallocatedPagesKey, numPreallocatedPagesKey; +static OFTLSKey firstPageKey, lastPageKey; +static OFTLSKey preallocatedPagesKey, numPreallocatedPagesKey; # else static struct page *firstPage = NULL; static struct page *lastPage = NULL; static struct page **preallocatedPages = NULL; static size_t numPreallocatedPages = 0; @@ -107,32 +107,32 @@ # endif if (allowPreallocated) { # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) uintptr_t numPreallocatedPages = - (uintptr_t)of_tlskey_get(numPreallocatedPagesKey); + (uintptr_t)OFTLSKeyGet(numPreallocatedPagesKey); # endif if (numPreallocatedPages > 0) { # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) struct page **preallocatedPages = - of_tlskey_get(preallocatedPagesKey); + OFTLSKeyGet(preallocatedPagesKey); # endif numPreallocatedPages--; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - OF_ENSURE(of_tlskey_set(numPreallocatedPagesKey, + OF_ENSURE(OFTLSKeySet(numPreallocatedPagesKey, (void *)numPreallocatedPages) == 0); # endif page = preallocatedPages[numPreallocatedPages]; if (numPreallocatedPages == 0) { free(preallocatedPages); preallocatedPages = NULL; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - OF_ENSURE(of_tlskey_set(preallocatedPagesKey, + OF_ENSURE(OFTLSKeySet(preallocatedPagesKey, preallocatedPages) == 0); # endif } return page; @@ -154,11 +154,11 @@ @throw e; } of_explicit_memset(page->page, 0, pageSize); # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - lastPage = of_tlskey_get(lastPageKey); + lastPage = OFTLSKeyGet(lastPageKey); # endif page->previous = lastPage; page->next = NULL; @@ -169,14 +169,14 @@ lastPage = page; if (firstPage == NULL) firstPage = page; # else - OF_ENSURE(of_tlskey_set(lastPageKey, page) == 0); + OF_ENSURE(OFTLSKeySet(lastPageKey, page) == 0); - if (of_tlskey_get(firstPageKey) == NULL) - OF_ENSURE(of_tlskey_set(firstPageKey, page) == 0); + if (OFTLSKeyGet(firstPageKey) == NULL) + OF_ENSURE(OFTLSKeySet(firstPageKey, page) == 0); # endif return page; } @@ -204,14 +204,14 @@ if (firstPage == page) firstPage = page->next; if (lastPage == page) lastPage = page->previous; # else - if (of_tlskey_get(firstPageKey) == page) - OF_ENSURE(of_tlskey_set(firstPageKey, page->next) == 0); - if (of_tlskey_get(lastPageKey) == page) - OF_ENSURE(of_tlskey_set(lastPageKey, page->previous) == 0); + if (OFTLSKeyGet(firstPageKey) == page) + OF_ENSURE(OFTLSKeySet(firstPageKey, page->next) == 0); + if (OFTLSKeyGet(lastPageKey) == page) + OF_ENSURE(OFTLSKeySet(lastPageKey, page->previous) == 0); # endif free(page); } @@ -270,14 +270,13 @@ + (void)initialize { if (self != [OFSecureData class]) return; - if (of_tlskey_new(&firstPageKey) != 0 || - of_tlskey_new(&lastPageKey) != 0 || - of_tlskey_new(&preallocatedPagesKey) != 0 || - of_tlskey_new(&numPreallocatedPagesKey) != 0) + if (OFTLSKeyNew(&firstPageKey) != 0 || OFTLSKeyNew(&lastPageKey) != 0 || + OFTLSKeyNew(&preallocatedPagesKey) != 0 || + OFTLSKeyNew(&numPreallocatedPagesKey) != 0) @throw [OFInitializationFailedException exceptionWithClass: self]; } #endif @@ -285,21 +284,21 @@ { #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) size_t pageSize = [OFSystemInfo pageSize]; size_t numPages = OF_ROUND_UP_POW2(pageSize, size) / pageSize; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - struct page **preallocatedPages = of_tlskey_get(preallocatedPagesKey); + struct page **preallocatedPages = OFTLSKeyGet(preallocatedPagesKey); size_t numPreallocatedPages; # endif size_t i; if (preallocatedPages != NULL) @throw [OFInvalidArgumentException exception]; preallocatedPages = of_alloc_zeroed(numPages, sizeof(struct page)); # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - OF_ENSURE(of_tlskey_set(preallocatedPagesKey, preallocatedPages) == 0); + OF_ENSURE(OFTLSKeySet(preallocatedPagesKey, preallocatedPages) == 0); # endif @try { for (i = 0; i < numPages; i++) preallocatedPages[i] = addPage(false); @@ -313,11 +312,11 @@ @throw e; } numPreallocatedPages = numPages; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - OF_ENSURE(of_tlskey_set(numPreallocatedPagesKey, + OF_ENSURE(OFTLSKeySet(numPreallocatedPagesKey, (void *)(uintptr_t)numPreallocatedPages) == 0); # endif #else @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; @@ -423,11 +422,11 @@ } else if (count * itemSize >= pageSize) _items = mapPages(OF_ROUND_UP_POW2(pageSize, count * itemSize) / pageSize); else { # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - struct page *lastPage = of_tlskey_get(lastPageKey); + struct page *lastPage = OFTLSKeyGet(lastPageKey); # endif for (struct page *page = lastPage; page != NULL; page = page->previous) { _items = allocateMemory(page, count * itemSize); Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -85,11 +85,11 @@ # import "tlskey.h" # if defined(OF_AMIGAOS) && defined(OF_HAVE_SOCKETS) # import "socket.h" # endif -static of_tlskey_t threadSelfKey; +static OFTLSKey threadSelfKey; static OFThread *mainThread; #elif defined(OF_HAVE_SOCKETS) static OFDNSResolver *DNSResolver; #endif @@ -99,11 +99,11 @@ callMain(id object) { OFThread *thread = (OFThread *)object; OFString *name; - if (of_tlskey_set(threadSelfKey, thread) != 0) + if (OFTLSKeySet(threadSelfKey, thread) != 0) @throw [OFInitializationFailedException exceptionWithClass: thread.class]; #ifndef OF_OBJFW_RUNTIME thread->_pool = objc_autoreleasePoolPush(); @@ -162,11 +162,11 @@ + (void)initialize { if (self != [OFThread class]) return; - if (of_tlskey_new(&threadSelfKey) != 0) + if (OFTLSKeyNew(&threadSelfKey) != 0) @throw [OFInitializationFailedException exceptionWithClass: self]; } + (instancetype)thread @@ -181,11 +181,11 @@ } # endif + (OFThread *)currentThread { - return of_tlskey_get(threadSelfKey); + return OFTLSKeyGet(threadSelfKey); } + (OFThread *)mainThread { return mainThread; @@ -194,16 +194,16 @@ + (bool)isMainThread { if (mainThread == nil) return false; - return (of_tlskey_get(threadSelfKey) == mainThread); + return (OFTLSKeyGet(threadSelfKey) == mainThread); } + (OFMutableDictionary *)threadDictionary { - OFThread *thread = of_tlskey_get(threadSelfKey); + OFThread *thread = OFTLSKeyGet(threadSelfKey); if (thread == nil) return nil; if (thread->_threadDictionary == nil) @@ -215,11 +215,11 @@ #ifdef OF_HAVE_SOCKETS + (OFDNSResolver *)DNSResolver { # ifdef OF_HAVE_THREADS - OFThread *thread = of_tlskey_get(threadSelfKey); + OFThread *thread = OFTLSKeyGet(threadSelfKey); if (thread == nil) return nil; if (thread->_DNSResolver == nil) @@ -317,11 +317,11 @@ OF_UNREACHABLE } + (void)terminateWithObject: (id)object { - OFThread *thread = of_tlskey_get(threadSelfKey); + OFThread *thread = OFTLSKeyGet(threadSelfKey); if (thread == mainThread) @throw [OFInvalidArgumentException exception]; OF_ENSURE(thread != nil); @@ -352,11 +352,11 @@ { mainThread = [[OFThread alloc] init]; mainThread->_thread = of_thread_current(); mainThread->_running = OF_THREAD_RUNNING; - if (of_tlskey_set(threadSelfKey, mainThread) != 0) + if (OFTLSKeySet(threadSelfKey, mainThread) != 0) @throw [OFInitializationFailedException exceptionWithClass: self]; } - (instancetype)init Index: src/mutex.h ================================================================== --- src/mutex.h +++ src/mutex.h @@ -56,11 +56,11 @@ # define of_rmutex_t of_mutex_t #else # import "tlskey.h" typedef struct { of_mutex_t mutex; - of_tlskey_t count; + OFTLSKey count; } of_rmutex_t; #endif #ifdef __cplusplus extern "C" { Index: src/platform/amiga/thread.m ================================================================== --- src/platform/amiga/thread.m +++ src/platform/amiga/thread.m @@ -26,35 +26,35 @@ #include #include #include #ifndef OF_MORPHOS -extern void of_tlskey_thread_exited(void); +extern void OFTLSKeyThreadExited(void); #endif -static of_tlskey_t threadKey; +static OFTLSKey threadKey; OF_CONSTRUCTOR() { - OF_ENSURE(of_tlskey_new(&threadKey) == 0); + OF_ENSURE(OFTLSKeyNew(&threadKey) == 0); } static void functionWrapper(void) { bool detached = false; of_thread_t thread = (of_thread_t)((struct Process *)FindTask(NULL))->pr_ExitData; - OF_ENSURE(of_tlskey_set(threadKey, thread) == 0); + OF_ENSURE(OFTLSKeySet(threadKey, thread) == 0); thread->function(thread->object); ObtainSemaphore(&thread->semaphore); @try { thread->done = true; #ifndef OF_MORPHOS - of_tlskey_thread_exited(); + OFTLSKeyThreadExited(); #endif if (thread->detached) detached = true; else if (thread->joinTask != NULL) @@ -156,11 +156,11 @@ } of_thread_t of_thread_current(void) { - return of_tlskey_get(threadKey); + return OFTLSKeyGet(threadKey); } int of_thread_join(of_thread_t thread) { Index: src/platform/amiga/tlskey.m ================================================================== --- src/platform/amiga/tlskey.m +++ src/platform/amiga/tlskey.m @@ -24,11 +24,11 @@ * As we use this file in both the runtime and ObjFW, and since AmigaOS always * has the runtime, use the hashtable from the runtime. */ #import "runtime/private.h" -static of_tlskey_t firstKey = NULL, lastKey = NULL; +static OFTLSKey firstKey = NULL, lastKey = NULL; static struct SignalSemaphore semaphore; static bool semaphoreInitialized = false; static uint32_t hashFunc(const void *ptr) @@ -49,11 +49,11 @@ semaphoreInitialized = true; } } int -of_tlskey_new(of_tlskey_t *key) +OFTLSKeyNew(OFTLSKey *key) { if (!semaphoreInitialized) { /* * We might be called from another constructor, while ours has * not run yet. This is safe, as the constructor is definitely @@ -87,11 +87,11 @@ /* We create the hash table lazily. */ return 0; } int -of_tlskey_free(of_tlskey_t key) +OFTLSKeyFree(OFTLSKey key) { ObtainSemaphore(&semaphore); @try { if (key->previous != NULL) key->previous->next = key->next; @@ -111,11 +111,11 @@ return 0; } void * -of_tlskey_get(of_tlskey_t key) +OFTLSKeyGet(OFTLSKey key) { void *ret; ObtainSemaphore(&semaphore); @try { @@ -129,11 +129,11 @@ return ret; } int -of_tlskey_set(of_tlskey_t key, void *ptr) +OFTLSKeySet(OFTLSKey key, void *ptr) { ObtainSemaphore(&semaphore); @try { struct Task *task = FindTask(NULL); @@ -150,19 +150,18 @@ return 0; } void -of_tlskey_thread_exited(void) +OFTLSKeyThreadExited(void) { ObtainSemaphore(&semaphore); @try { struct Task *task = FindTask(NULL); - for (of_tlskey_t iter = firstKey; iter != NULL; - iter = iter->next) + for (OFTLSKey iter = firstKey; iter != NULL; iter = iter->next) if (iter->table != NULL) objc_hashtable_delete(iter->table, task); } @finally { ReleaseSemaphore(&semaphore); } } Index: src/platform/morphos/tlskey.m ================================================================== --- src/platform/morphos/tlskey.m +++ src/platform/morphos/tlskey.m @@ -16,11 +16,11 @@ #include "config.h" #import "tlskey.h" int -of_tlskey_new(of_tlskey_t *key) +OFTLSKeyNew(OFTLSKeyT *key) { *key = TLSAllocA(NULL); if (*key == TLS_INVALID_INDEX) return EAGAIN; @@ -27,9 +27,9 @@ return 0; } int -of_tlskey_free(of_tlskey_t key) +OFTLSKeyFree(OFTLSKeyT key) { return (TLSFree(key) ? 0 : EINVAL); } Index: src/platform/posix/mutex.m ================================================================== --- src/platform/posix/mutex.m +++ src/platform/posix/mutex.m @@ -100,34 +100,34 @@ int error; if ((error = of_mutex_new(&rmutex->mutex)) != 0) return error; - if ((error = of_tlskey_new(&rmutex->count)) != 0) + if ((error = OFTLSKeyNew(&rmutex->count)) != 0) return error; return 0; } int of_rmutex_lock(of_rmutex_t *rmutex) { - uintptr_t count = (uintptr_t)of_tlskey_get(rmutex->count); + uintptr_t count = (uintptr_t)OFTLSKeyGet(rmutex->count); int error; if (count > 0) { - if ((error = of_tlskey_set(rmutex->count, + if ((error = OFTLSKeySet(rmutex->count, (void *)(count + 1))) != 0) return error; return 0; } if ((error = of_mutex_lock(&rmutex->mutex)) != 0) return error; - if ((error = of_tlskey_set(rmutex->count, (void *)1)) != 0) { + if ((error = OFTLSKeySet(rmutex->count, (void *)1)) != 0) { of_mutex_unlock(&rmutex->mutex); return error; } return 0; @@ -134,25 +134,25 @@ } int of_rmutex_trylock(of_rmutex_t *rmutex) { - uintptr_t count = (uintptr_t)of_tlskey_get(rmutex->count); + uintptr_t count = (uintptr_t)OFTLSKeyGet(rmutex->count); int error; if (count > 0) { - if ((error = of_tlskey_set(rmutex->count, + if ((error = OFTLSKeySet(rmutex->count, (void *)(count + 1))) != 0) return error; return 0; } if ((error = of_mutex_trylock(&rmutex->mutex)) != 0) return error; - if ((error = of_tlskey_set(rmutex->count, (void *)1)) != 0) { + if ((error = OFTLSKeySet(rmutex->count, (void *)1)) != 0) { of_mutex_unlock(&rmutex->mutex); return error; } return 0; @@ -159,22 +159,22 @@ } int of_rmutex_unlock(of_rmutex_t *rmutex) { - uintptr_t count = (uintptr_t)of_tlskey_get(rmutex->count); + uintptr_t count = (uintptr_t)OFTLSKeyGet(rmutex->count); int error; if (count > 1) { - if ((error = of_tlskey_set(rmutex->count, + if ((error = OFTLSKeySet(rmutex->count, (void *)(count - 1))) != 0) return error; return 0; } - if ((error = of_tlskey_set(rmutex->count, (void *)0)) != 0) + if ((error = OFTLSKeySet(rmutex->count, (void *)0)) != 0) return error; if ((error = of_mutex_unlock(&rmutex->mutex)) != 0) return error; @@ -187,11 +187,11 @@ int error; if ((error = of_mutex_free(&rmutex->mutex)) != 0) return error; - if ((error = of_tlskey_free(rmutex->count)) != 0) + if ((error = OFTLSKeyFree(rmutex->count)) != 0) return error; return 0; } #endif Index: src/platform/posix/tlskey.m ================================================================== --- src/platform/posix/tlskey.m +++ src/platform/posix/tlskey.m @@ -16,15 +16,15 @@ #include "config.h" #import "tlskey.h" int -of_tlskey_new(of_tlskey_t *key) +OFTLSKeyNew(OFTLSKey *key) { return pthread_key_create(key, NULL); } int -of_tlskey_free(of_tlskey_t key) +OFTLSKeyFree(OFTLSKey key) { return pthread_key_delete(key); } Index: src/platform/windows/tlskey.m ================================================================== --- src/platform/windows/tlskey.m +++ src/platform/windows/tlskey.m @@ -16,11 +16,11 @@ #include "config.h" #import "tlskey.h" int -of_tlskey_new(of_tlskey_t *key) +OFTLSKeyNew(OFTLSKey *key) { *key = TlsAlloc(); if (*key == TLS_OUT_OF_INDEXES) return EAGAIN; @@ -27,9 +27,9 @@ return 0; } int -of_tlskey_free(of_tlskey_t key) +OFTLSKeyFree(OFTLSKey key) { return (TlsFree(key) ? 0 : EINVAL); } Index: src/runtime/autorelease.m ================================================================== --- src/runtime/autorelease.m +++ src/runtime/autorelease.m @@ -39,41 +39,41 @@ #if defined(OF_HAVE_COMPILER_TLS) static thread_local id *objects = NULL; static thread_local uintptr_t count = 0; static thread_local uintptr_t size = 0; #elif defined(OF_HAVE_THREADS) -static of_tlskey_t objectsKey, countKey, sizeKey; +static OFTLSKey objectsKey, countKey, sizeKey; #else static id *objects = NULL; static uintptr_t count = 0; static uintptr_t size = 0; #endif #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) OF_CONSTRUCTOR() { - OF_ENSURE(of_tlskey_new(&objectsKey) == 0); - OF_ENSURE(of_tlskey_new(&countKey) == 0); - OF_ENSURE(of_tlskey_new(&sizeKey) == 0); + OF_ENSURE(OFTLSKeyNew(&objectsKey) == 0); + OF_ENSURE(OFTLSKeyNew(&countKey) == 0); + OF_ENSURE(OFTLSKeyNew(&sizeKey) == 0); } #endif void * objc_autoreleasePoolPush() { #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - uintptr_t count = (uintptr_t)of_tlskey_get(countKey); + uintptr_t count = (uintptr_t)OFTLSKeyGet(countKey); #endif return (void *)count; } void objc_autoreleasePoolPop(void *pool) { #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - id *objects = of_tlskey_get(objectsKey); - uintptr_t count = (uintptr_t)of_tlskey_get(countKey); + id *objects = OFTLSKeyGet(objectsKey); + uintptr_t count = (uintptr_t)OFTLSKeyGet(countKey); #endif uintptr_t idx = (uintptr_t)pool; bool freeMem = false; if (idx == (uintptr_t)-1) { @@ -83,12 +83,12 @@ for (uintptr_t i = idx; i < count; i++) { [objects[i] release]; #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - objects = of_tlskey_get(objectsKey); - count = (uintptr_t)of_tlskey_get(countKey); + objects = OFTLSKeyGet(objectsKey); + count = (uintptr_t)OFTLSKeyGet(countKey); #endif } count = idx; @@ -96,27 +96,27 @@ free(objects); objects = NULL; #if defined(OF_HAVE_COMPILER_TLS) || !defined(OF_HAVE_THREADS) size = 0; #else - OF_ENSURE(of_tlskey_set(objectsKey, objects) == 0); - OF_ENSURE(of_tlskey_set(sizeKey, (void *)0) == 0); + OF_ENSURE(OFTLSKeySet(objectsKey, objects) == 0); + OF_ENSURE(OFTLSKeySet(sizeKey, (void *)0) == 0); #endif } #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - OF_ENSURE(of_tlskey_set(countKey, (void *)count) == 0); + OF_ENSURE(OFTLSKeySet(countKey, (void *)count) == 0); #endif } id _objc_rootAutorelease(id object) { #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - id *objects = of_tlskey_get(objectsKey); - uintptr_t count = (uintptr_t)of_tlskey_get(countKey); - uintptr_t size = (uintptr_t)of_tlskey_get(sizeKey); + id *objects = OFTLSKeyGet(objectsKey); + uintptr_t count = (uintptr_t)OFTLSKeyGet(countKey); + uintptr_t size = (uintptr_t)OFTLSKeyGet(sizeKey); #endif if (count >= size) { if (size == 0) size = 16; @@ -125,18 +125,18 @@ OF_ENSURE((objects = realloc(objects, size * sizeof(id))) != NULL); #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - OF_ENSURE(of_tlskey_set(objectsKey, objects) == 0); - OF_ENSURE(of_tlskey_set(sizeKey, (void *)size) == 0); + OF_ENSURE(OFTLSKeySet(objectsKey, objects) == 0); + OF_ENSURE(OFTLSKeySet(sizeKey, (void *)size) == 0); #endif } objects[count++] = object; #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) - OF_ENSURE(of_tlskey_set(countKey, (void *)count) == 0); + OF_ENSURE(OFTLSKeySet(countKey, (void *)count) == 0); #endif return object; } Index: src/socket.h ================================================================== --- src/socket.h +++ src/socket.h @@ -283,15 +283,15 @@ extern int of_getsockname(OFSocketHandle sock, struct sockaddr *restrict addr, socklen_t *restrict addrLen); #endif #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) -extern of_tlskey_t of_socket_base_key; +extern OFTLSKey of_socket_base_key; # ifdef OF_AMIGAOS4 -extern of_tlskey_t of_socket_interface_key; +extern OFTLSKey of_socket_interface_key; # endif #endif #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/socket.m ================================================================== --- src/socket.m +++ src/socket.m @@ -70,13 +70,13 @@ static bool initSuccessful = false; #endif #ifdef OF_AMIGAOS # if defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS) -of_tlskey_t of_socket_base_key; +OFTLSKey of_socket_base_key; # ifdef OF_AMIGAOS4 -of_tlskey_t of_socket_interface_key; +OFTLSKey of_socket_interface_key; # endif # else struct Library *SocketBase; # ifdef OF_AMIGAOS4 struct SocketIFace *ISocket = NULL; @@ -85,15 +85,15 @@ #endif #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) OF_CONSTRUCTOR() { - if (of_tlskey_new(&of_socket_base_key) != 0) + if (OFTLSKeyNew(&of_socket_base_key) != 0) @throw [OFInitializationFailedException exception]; # ifdef OF_AMIGAOS4 - if (of_tlskey_new(&of_socket_interface_key) != 0) + if (OFTLSKeyNew(&of_socket_interface_key) != 0) @throw [OFInitializationFailedException exception]; # endif } #endif @@ -172,13 +172,13 @@ # ifdef OF_AMIGAOS4 struct SocketIFace *socketInterface; # endif # ifdef OF_AMIGAOS4 - if ((socketInterface = of_tlskey_get(of_socket_interface_key)) != NULL) + if ((socketInterface = OFTLSKeyGet(of_socket_interface_key)) != NULL) # else - if ((socketBase = of_tlskey_get(of_socket_base_key)) != NULL) + if ((socketBase = OFTLSKeyGet(of_socket_base_key)) != NULL) # endif return true; if ((socketBase = OpenLibrary("bsdsocket.library", 4)) == NULL) return false; @@ -189,20 +189,20 @@ CloseLibrary(socketBase); return false; } # endif - if (of_tlskey_set(of_socket_base_key, socketBase) != 0) { + if (OFTLSKeySet(of_socket_base_key, socketBase) != 0) { CloseLibrary(socketBase); # ifdef OF_AMIGAOS4 DropInterface((struct Interface *)socketInterface); # endif return false; } # ifdef OF_AMIGAOS4 - if (of_tlskey_set(of_socket_interface_key, socketInterface) != 0) { + if (OFTLSKeySet(of_socket_interface_key, socketInterface) != 0) { CloseLibrary(socketBase); DropInterface((struct Interface *)socketInterface); return false; } # endif @@ -213,14 +213,14 @@ #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) void of_socket_deinit(void) { - struct Library *socketBase = of_tlskey_get(of_socket_base_key); + struct Library *socketBase = OFTLSKeyGet(of_socket_base_key); # ifdef OF_AMIGAOS4 struct SocketIFace *socketInterface = - of_tlskey_get(of_socket_interface_key); + OFTLSKeyGet(of_socket_interface_key); if (socketInterface != NULL) DropInterface((struct Interface *)socketInterface); # endif if (socketBase != NULL) Index: src/socket_helpers.h ================================================================== --- src/socket_helpers.h +++ src/socket_helpers.h @@ -56,14 +56,13 @@ # define closesocket(sock) CloseSocket(sock) # define ioctlsocket(fd, req, arg) IoctlSocket(fd, req, arg) # define hstrerror(err) "unknown (no hstrerror)" # define SOCKET_ERROR -1 # if defined(OF_HAVE_THREADS) && !defined(OF_MORPHOS) -# define SocketBase ((struct Library *)of_tlskey_get(of_socket_base_key)) +# define SocketBase ((struct Library *)OFTLSKeyGet(of_socket_base_key)) # ifdef OF_AMIGAOS4 -# define ISocket \ - ((struct SocketIFace *)of_tlskey_get(of_socket_interface_key)) +# define ISocket ((struct SocketIFace *)OFTLSKeyGet(of_socket_interface_key)) # endif # endif # ifdef OF_MORPHOS typedef uint32_t in_addr_t; # endif Index: src/tlskey.h ================================================================== --- src/tlskey.h +++ src/tlskey.h @@ -26,77 +26,77 @@ #import "macros.h" #if defined(OF_HAVE_PTHREADS) # include -typedef pthread_key_t of_tlskey_t; +typedef pthread_key_t OFTLSKey; #elif defined(OF_WINDOWS) # include -typedef DWORD of_tlskey_t; +typedef DWORD OFTLSKey; #elif defined(OF_MORPHOS) # include -typedef ULONG of_tlskey_t; +typedef ULONG OFTLSKey; #elif defined(OF_AMIGAOS) -typedef struct of_tlskey { +typedef struct OFTLSKey { struct objc_hashtable *table; - struct of_tlskey *next, *previous; -} *of_tlskey_t; + struct OFTLSKey *next, *previous; +} *OFTLSKey; #endif #ifdef __cplusplus extern "C" { #endif -extern int of_tlskey_new(of_tlskey_t *key); -extern int of_tlskey_free(of_tlskey_t key); +extern int OFTLSKeyNew(OFTLSKey *key); +extern int OFTLSKeyFree(OFTLSKey key); #ifdef __cplusplus } #endif /* TLS keys are inlined for performance. */ #if defined(OF_HAVE_PTHREADS) static OF_INLINE void * -of_tlskey_get(of_tlskey_t key) +OFTLSKeyGet(OFTLSKey key) { return pthread_getspecific(key); } static OF_INLINE int -of_tlskey_set(of_tlskey_t key, void *ptr) +OFTLSKeySet(OFTLSKey key, void *ptr) { return pthread_setspecific(key, ptr); } #elif defined(OF_WINDOWS) static OF_INLINE void * -of_tlskey_get(of_tlskey_t key) +OFTLSKeyGet(OFTLSKey key) { return TlsGetValue(key); } static OF_INLINE int -of_tlskey_set(of_tlskey_t key, void *ptr) +OFTLSKeySet(OFTLSKey key, void *ptr) { return (TlsSetValue(key, ptr) ? 0 : EINVAL); } #elif defined(OF_MORPHOS) static OF_INLINE void * -of_tlskey_get(of_tlskey_t key) +OFTLSKeyGet(OFTLSKey key) { return (void *)TLSGetValue(key); } static OF_INLINE int -of_tlskey_set(of_tlskey_t key, void *ptr) +OFTLSKeySet(OFTLSKey key, void *ptr) { return (TLSSetValue(key, (APTR)ptr) ? 0 : EINVAL); } #elif defined(OF_AMIGAOS) /* Those are too big too inline. */ # ifdef __cplusplus extern "C" { # endif -extern void *of_tlskey_get(of_tlskey_t key); -extern int of_tlskey_set(of_tlskey_t key, void *ptr); +extern void *OFTLSKeyGet(OFTLSKey key); +extern int OFTLSKeySet(OFTLSKey key, void *ptr); # ifdef __cplusplus } # endif #endif