12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include <errno.h>
- #include "pthreadP.h"
- #include <atomic.h>
- int
- attribute_protected
- __pthread_key_create (
- pthread_key_t *key,
- void (*destr) (void *))
- {
-
- size_t cnt;
- for (cnt = 0; cnt < PTHREAD_KEYS_MAX; ++cnt)
- {
- uintptr_t seq = __pthread_keys[cnt].seq;
- if (KEY_UNUSED (seq) && KEY_USABLE (seq)
-
- && ! atomic_compare_and_exchange_bool_acq (&__pthread_keys[cnt].seq,
- seq + 1, seq))
- {
-
- __pthread_keys[cnt].destr = destr;
-
- *key = cnt;
-
- return 0;
- }
- }
- return EAGAIN;
- }
- strong_alias (__pthread_key_create, pthread_key_create)
- strong_alias (__pthread_key_create, __pthread_key_create_internal)
|