Differences From Artifact [5550ceb6fb]:
- File
src/tlskey.m
— part of check-in
[49aee5736e]
at
2020-01-25 20:04:54
on branch trunk
— tlskey.m: Use hashtable from runtime on AmigaOS
tlskey.m used OFMapTable only on AmigaOS. This became a problem when
autorelease pools were moved into the runtime, as autorelease pools use
TLS. The build then broke, as there suddenly was a dependency from the
runtime on ObjFW.This now uses the hashtable from the runtime and also no longer uses
OFList, thus fixing the build. As we always use the runtime on AmigaOS
anyway, this is fine. (user: js, size: 3442) [annotate] [blame] [check-ins using]
To Artifact [dccef5e723]:
- File src/tlskey.m — part of check-in [aae9464778] at 2020-02-16 22:20:17 on branch trunk — tlskey.m: Gracefully handle ctor not called yet (user: js, size: 3821) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
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 { |
︙ | ︙ |