Index: src/platform/amiga/thread.m ================================================================== --- src/platform/amiga/thread.m +++ src/platform/amiga/thread.m @@ -27,11 +27,13 @@ #include #include #include +#ifndef OF_MORPHOS extern void of_tlskey_thread_exited(void); +#endif static of_tlskey_t threadKey; OF_CONSTRUCTOR() { OF_ENSURE(of_tlskey_new(&threadKey)); @@ -49,11 +51,13 @@ ObtainSemaphore(&thread->semaphore); @try { thread->done = true; +#ifndef OF_MORPHOS of_tlskey_thread_exited(); +#endif if (thread->detached) detached = true; else if (thread->joinTask != NULL) Signal(thread->joinTask, (1ul << thread->joinSigBit)); ADDED src/platform/morphos/tlskey.m Index: src/platform/morphos/tlskey.m ================================================================== --- src/platform/morphos/tlskey.m +++ src/platform/morphos/tlskey.m @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, + * 2018, 2019, 2020 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "tlskey.h" + +bool +of_tlskey_new(of_tlskey_t *key) +{ + return ((*key = TLSAllocA(NULL)) != TLS_INVALID_INDEX); +} + +bool +of_tlskey_free(of_tlskey_t key) +{ + return TLSFree(key); +} Index: src/tlskey.h ================================================================== --- src/tlskey.h +++ src/tlskey.h @@ -30,10 +30,13 @@ # include typedef pthread_key_t of_tlskey_t; #elif defined(OF_WINDOWS) # include typedef DWORD of_tlskey_t; +#elif defined(OF_MORPHOS) +# include +typedef ULONG of_tlskey_t; #elif defined(OF_AMIGAOS) typedef struct of_tlskey { struct objc_hashtable *table; struct of_tlskey *next, *previous; } *of_tlskey_t; @@ -72,10 +75,22 @@ static OF_INLINE bool of_tlskey_set(of_tlskey_t key, void *ptr) { return TlsSetValue(key, ptr); } +#elif defined(OF_MORPHOS) +static OF_INLINE void * +of_tlskey_get(of_tlskey_t key) +{ + return (void *)TLSGetValue(key); +} + +static OF_INLINE bool +of_tlskey_set(of_tlskey_t key, void *ptr) +{ + return TLSSetValue(key, (APTR)ptr); +} #elif defined(OF_AMIGAOS) /* Those are too big too inline. */ # ifdef __cplusplus extern "C" { # endif Index: src/tlskey.m ================================================================== --- src/tlskey.m +++ src/tlskey.m @@ -21,8 +21,10 @@ #if defined(OF_HAVE_PTHREADS) # include "platform/posix/tlskey.m" #elif defined(OF_WINDOWS) # include "platform/windows/tlskey.m" +#elif defined(OF_MORPHOS) +# include "platform/morphos/tlskey.m" #elif defined(OF_AMIGAOS) # include "platform/amiga/tlskey.m" #endif