user/lib/libc/src/threads/c11_threadlocal.c
/**
 * Sets the value of a thread local storage slot.
 */
Sets the value of a thread local storage slot.
Sets the value of a thread local storage slot .
int tss_set(tss_t key, void *value) {
    int err;
    struct tls_slot_info info, *item;
    info.key = key;
    err = mtx_lock(&gState.lock);
    if(err != thrd_success) {
        return thrd_error;
    }
    void *_item = hashmap_get(gState.entries, &info);
    if(!_item) {
        goto fail;
    }
    item = (struct tls_slot_info *) _item;
    if(__libc_thread_tss) {
        tss_entry_t e;
        e.key = key;
        e.value = value;
        hashmap_set(__libc_thread_tss, &e);
    } else {
        fprintf(stderr, "tss_set() unimplemented: key %08x value %p\n", key, value);
    }
    mtx_unlock(&gState.lock);
    return thrd_success;
fail:;
    mtx_unlock(&gState.lock);
    return thrd_error;
}
int tss_set ( tss_t key , void * value ) { int err ; struct tls_slot_info info , * item ; info . key = key ; err = mtx_lock ( & gState . lock ) ; if ( err != thrd_success ) { return thrd_error ; } void * _item = hashmap_get ( gState . entries , & info ) ; if ( ! _item ) { goto fail ; } item = ( struct tls_slot_info * ) _item ; if ( __libc_thread_tss ) { tss_entry_t e ; e . key = key ; e . value = value ; hashmap_set ( __libc_thread_tss , & e ) ; } else { fprintf ( stderr , " \n " , key , value ) ; } mtx_unlock ( & gState . lock ) ; return thrd_success ; fail : ; mtx_unlock ( & gState . lock ) ; return thrd_error ; }
Sets the value of a thread local storage slot.
Sets the value of a thread local storage slot .
// acquire lock over the TLS data structures // look up the thread local index for it and store it // store item // clean up // handle error conditions