14 ABTD_ATOMIC_UINT32_STATIC_INITIALIZER(ABTI_KEY_ID_END_);
68 ABTI_UB_ASSERT(ABTI_initialized());
69 ABTI_UB_ASSERT(newkey);
72 int abt_errno =
ABTU_malloc(
sizeof(ABTI_key), (
void **)&p_newkey);
73 ABTI_CHECK_ERROR(abt_errno);
75 p_newkey->f_destructor = destructor;
76 p_newkey->id = ABTD_atomic_fetch_add_uint32(&
g_key_id, 1);
78 *newkey = ABTI_key_get_handle(p_newkey);
114 ABTI_UB_ASSERT(ABTI_initialized());
118 ABTI_key *p_key = ABTI_key_get_ptr(h_key);
119 ABTI_CHECK_NULL_KEY_PTR(p_key);
164 #ifdef ABT_CONFIG_ENABLE_VER_20_API
165 ABTI_UB_ASSERT(ABTI_initialized());
168 ABTI_key *p_key = ABTI_key_get_ptr(key);
169 ABTI_CHECK_NULL_KEY_PTR(p_key);
171 ABTI_global *p_global;
172 ABTI_SETUP_GLOBAL(&p_global);
174 ABTI_xstream *p_local_xstream;
175 ABTI_SETUP_LOCAL_XSTREAM(&p_local_xstream);
179 ABTI_ktable_set(p_global, ABTI_xstream_get_local(p_local_xstream),
180 &p_local_xstream->p_thread->p_keytable, p_key, value);
181 ABTI_CHECK_ERROR(abt_errno);
223 ABTI_UB_ASSERT(value);
224 #ifdef ABT_CONFIG_ENABLE_VER_20_API
225 ABTI_UB_ASSERT(ABTI_initialized());
228 ABTI_key *p_key = ABTI_key_get_ptr(key);
229 ABTI_CHECK_NULL_KEY_PTR(p_key);
232 ABTI_xstream *p_local_xstream;
233 #ifndef ABT_CONFIG_ENABLE_VER_20_API
234 ABTI_SETUP_GLOBAL(NULL);
236 ABTI_SETUP_LOCAL_XSTREAM(&p_local_xstream);
239 *value = ABTI_ktable_get(&p_local_xstream->p_thread->p_keytable, p_key);
247 void ABTI_ktable_free(ABTI_global *p_global, ABTI_local *p_local,
248 ABTI_ktable *p_ktable)
253 for (i = 0; i < p_ktable->size; i++) {
255 (ABTI_ktelem *)ABTD_atomic_relaxed_load_ptr(&p_ktable->p_elems[i]);
258 if (p_elem->f_destructor && p_elem->value) {
259 p_elem->f_destructor(p_elem->value);
262 (ABTI_ktelem *)ABTD_atomic_relaxed_load_ptr(&p_elem->p_next);
265 ABTI_ktable_mem_header *p_header =
266 (ABTI_ktable_mem_header *)p_ktable->p_used_mem;
268 ABTI_ktable_mem_header *p_next = p_header->p_next;
270 ABTI_mem_free_desc(p_global, p_local, (
void *)p_header);