--- thread local storage --- Keys are stored as (TLS index + 1) so that a zero-initialised key reliably reads as "uninitialised" (TLS index 0 is itself a valid slot). */
| 94 | Keys are stored as (TLS index + 1) so that a zero-initialised key reliably |
| 95 | reads as "uninitialised" (TLS index 0 is itself a valid slot). */ |
| 96 | int pthread_key_create(pthread_key_t* key, void (*destructor)(void*)) { |
| 97 | DWORD idx; |
| 98 | (void)destructor; /* per-key destructors are not supported */ |
| 99 | idx = TlsAlloc(); |
| 100 | if (idx == TLS_OUT_OF_INDEXES) { |
| 101 | return EAGAIN; |
| 102 | } |
| 103 | *key = (pthread_key_t)(idx + 1); |
| 104 | return 0; |
| 105 | } |
| 106 | |
| 107 | int pthread_key_delete(pthread_key_t key) { |
| 108 | if (key == 0) { |