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!
33#if defined(OF_HAVE_PTHREADS)
35typedef pthread_key_t OFTLSKey;
36#elif defined(OF_WINDOWS)
38typedef DWORD OFTLSKey;
39#elif defined(OF_MORPHOS)
40# include <proto/exec.h>
41typedef ULONG OFTLSKey;
42#elif defined(OF_AMIGAOS)
43typedef struct _OFTLSKey {
44 struct objc_hashtable *table;
45 struct _OFTLSKey *next, *previous;
52extern int OFTLSKeyNew(OFTLSKey *key);
53extern int OFTLSKeyFree(OFTLSKey key);
60#if defined(OF_HAVE_PTHREADS)
61static OF_INLINE
void *
62OFTLSKeyGet(OFTLSKey key)
64 return pthread_getspecific(key);
68OFTLSKeySet(OFTLSKey key,
void *ptr)
70 return pthread_setspecific(key, ptr);
72#elif defined(OF_WINDOWS)
73static OF_INLINE
void *
74OFTLSKeyGet(OFTLSKey key)
76 return TlsGetValue(key);
80OFTLSKeySet(OFTLSKey key,
void *ptr)
82 return (TlsSetValue(key, ptr) ? 0 : EINVAL);
84#elif defined(OF_MORPHOS)
85static OF_INLINE
void *
86OFTLSKeyGet(OFTLSKey key)
88 return (
void *)TLSGetValue(key);
92OFTLSKeySet(OFTLSKey key,
void *ptr)
94 return (TLSSetValue(key, (APTR)ptr) ? 0 : EINVAL);
96#elif defined(OF_AMIGAOS)
101extern void *OFTLSKeyGet(OFTLSKey key);
102extern int OFTLSKeySet(OFTLSKey key,
void *ptr);