Differences From Artifact [19e6f1fad4]:
- File src/tlskey.h — part of check-in [c75596237e] at 2020-12-06 01:54:02 on branch trunk — Use OS-native TLS keys on MorphOS (user: js, size: 2349) [annotate] [blame] [check-ins using] [more...]
To Artifact [bf467b6736]:
- File
src/tlskey.h
— part of check-in
[5b37fbeb82]
at
2020-12-20 21:26:08
on branch trunk
— Return error instead of using errno for threading
errno is problematic for Amiga libraries and is also not thread-safe on
some systems, even though it should. (user: js, size: 2386) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * 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 "objfw-defs.h" #include "platform.h" #if !defined(OF_HAVE_THREADS) || \ (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS)) # error No thread-local storage available! #endif | > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * 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 "objfw-defs.h" #include <errno.h> #include "platform.h" #if !defined(OF_HAVE_THREADS) || \ (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS)) # error No thread-local storage available! #endif |
︙ | ︙ | |||
41 42 43 44 45 46 47 | struct of_tlskey *next, *previous; } *of_tlskey_t; #endif #ifdef __cplusplus extern "C" { #endif | | | | | | | | | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | struct of_tlskey *next, *previous; } *of_tlskey_t; #endif #ifdef __cplusplus extern "C" { #endif extern int of_tlskey_new(of_tlskey_t *key); extern int of_tlskey_free(of_tlskey_t 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) { return pthread_getspecific(key); } static OF_INLINE int of_tlskey_set(of_tlskey_t key, void *ptr) { return pthread_setspecific(key, ptr); } #elif defined(OF_WINDOWS) static OF_INLINE void * of_tlskey_get(of_tlskey_t key) { return TlsGetValue(key); } static OF_INLINE int of_tlskey_set(of_tlskey_t key, void *ptr) { return (TlsSetValue(key, ptr) ? 0 : EINVAL); } #elif defined(OF_MORPHOS) static OF_INLINE void * of_tlskey_get(of_tlskey_t key) { return (void *)TLSGetValue(key); } static OF_INLINE int of_tlskey_set(of_tlskey_t 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); # ifdef __cplusplus } # endif #endif |