20#include "objfw-defs.h"
26#if !defined(OF_HAVE_THREADS) || \
27 (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS))
28# error No thread-local storage available!
35#if defined(OF_HAVE_PTHREADS)
37typedef pthread_key_t OFTLSKey;
38#elif defined(OF_WINDOWS)
40typedef DWORD OFTLSKey;
41#elif defined(OF_MORPHOS)
42# include <proto/exec.h>
43typedef ULONG OFTLSKey;
44#elif defined(OF_AMIGAOS)
45typedef struct _OFTLSKey {
46 struct objc_hashtable *table;
47 struct _OFTLSKey *next, *previous;
75#if defined(OF_HAVE_PTHREADS) || defined(DOXYGEN)
82static OF_INLINE
void *
85 return pthread_getspecific(key);
97 return pthread_setspecific(key, value);
99#elif defined(OF_WINDOWS)
100static OF_INLINE
void *
103 return TlsGetValue(key);
109 return (TlsSetValue(key, value) ? 0 : EINVAL);
111#elif defined(OF_MORPHOS)
112static OF_INLINE
void *
115 return (
void *)TLSGetValue(key);
121 return (TLSSetValue(key, (APTR)value) ? 0 : EINVAL);
123#elif defined(OF_AMIGAOS)
int OFTLSKeyNew(OFTLSKey *key)
Creates a new Thread Local Storage key.
static OF_INLINE int OFTLSKeySet(OFTLSKey key, void *value)
Sets the current value for the specified Thread Local Storage key.
Definition OFTLSKey.h:95
int OFTLSKeyFree(OFTLSKey key)
Destroys the specified Thread Local Storage key.
static OF_INLINE void * OFTLSKeyGet(OFTLSKey key)
Returns the current value for the specified Thread Local Storage key.
Definition OFTLSKey.h:83