Overview
Comment: | tlskey.m: Gracefully handle ctor not called yet |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
aae946477869484cc7d16be1cfe977a7 |
User & Date: | js on 2020-02-16 22:20:17 |
Other Links: | manifest | tags |
Context
2020-02-18
| ||
00:48 | Add optional completions for the fish shell check-in: d13292673e user: js tags: trunk | |
2020-02-16
| ||
22:20 | tlskey.m: Gracefully handle ctor not called yet check-in: aae9464778 user: js tags: trunk | |
21:27 | Disable compiler TLS on AmigaOS (m68k & PPC) check-in: fe8d99125e user: js tags: trunk | |
Changes
Modified src/tlskey.m from [5550ceb6fb] to [dccef5e723].
︙ | ︙ | |||
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | * 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 struct SignalSemaphore semaphore; static uint32_t hashFunc(const void *ptr) { return (uint32_t)(uintptr_t)ptr; } static bool equalFunc(const void *ptr1, const void *ptr2) { return (ptr1 == ptr2); } OF_CONSTRUCTOR() { | > > | > > > > > > > > > > > > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 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 | * 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 struct SignalSemaphore semaphore; static bool semaphoreInitialized = false; static uint32_t hashFunc(const void *ptr) { return (uint32_t)(uintptr_t)ptr; } static bool equalFunc(const void *ptr1, const void *ptr2) { return (ptr1 == ptr2); } OF_CONSTRUCTOR() { if (!semaphoreInitialized) { InitSemaphore(&semaphore); semaphoreInitialized = true; } } #endif bool of_tlskey_new(of_tlskey_t *key) { #if defined(OF_HAVE_PTHREADS) return (pthread_key_create(key, NULL) == 0); #elif defined(OF_WINDOWS) return ((*key = TlsAlloc()) != TLS_OUT_OF_INDEXES); #elif defined(OF_AMIGAOS) if (!semaphoreInitialized) { /* * We might be called from another constructor, while ours has * not run yet. This is safe, as the constructor is definitely * run before a thread is spawned. */ InitSemaphore(&semaphore); semaphoreInitialized = true; } if ((*key = malloc(sizeof(**key))) == NULL) return false; (*key)->table = NULL; ObtainSemaphore(&semaphore); @try { |
︙ | ︙ |