KallistiOS
##version##
|
Thread-local storage support. More...
#include <sys/cdefs.h>
#include <sys/queue.h>
Go to the source code of this file.
Data Structures | |
struct | kthread_tls_kv |
Thread-local storage key-value pair. More... | |
Typedefs | |
typedef int | kthread_key_t |
Thread-local storage key type. More... | |
typedef struct kthread_tls_kv | kthread_tls_kv_t |
Thread-local storage key-value pair. More... | |
Functions | |
int | kthread_key_create (kthread_key_t *key, void(*destructor)(void *)) |
Create a new thread-local storage key. More... | |
void * | kthread_getspecific (kthread_key_t key) |
Retrieve a value associated with a TLS key. More... | |
int | kthread_setspecific (kthread_key_t key, const void *value) |
Set thread specific data for a key. More... | |
int | kthread_key_delete (kthread_key_t key) |
Delete a TLS key. More... | |
Thread-local storage support.
This file contains the definitions used to support key/value pairs of thread-local storage in KOS.
typedef int kthread_key_t |
Thread-local storage key type.
typedef struct kthread_tls_kv kthread_tls_kv_t |
Thread-local storage key-value pair.
This is the structure that is actually used to store the specific value for a thread for a single TLS key.
You will not end up using these directly at all in programs, as they are only used internally.
void* kthread_getspecific | ( | kthread_key_t | key | ) |
Retrieve a value associated with a TLS key.
This function retrieves the thread-specific data associated with the given key.
key | The key to look up data for. |
int kthread_key_create | ( | kthread_key_t * | key, |
void(*)(void *) | destructor | ||
) |
Create a new thread-local storage key.
This function creates a new thread-local storage key that shall be visible to all threads. Each thread is then responsible for associating any data with the key that it deems fit (by default a thread will have no data associated with a newly created key).
key | The key to use. |
destructor | A destructor for use with this key. If it is non-NULL, and a value associated with the key is non-NULL at thread exit, then the destructor will be called with the value as its argument. |
-1 | On failure, and sets errno to one of the following: EPERM if called inside an interrupt and another call is in progress, ENOMEM if out of memory. |
0 | On success. |
int kthread_key_delete | ( | kthread_key_t | key | ) |
Delete a TLS key.
This function deletes a TLS key, removing all threads' values for the given key. This function does not cause any destructors to be called.
key | The key to delete. |
-1 | On failure, and sets errno to one of the following: EINVAL if the key is invalid, EPERM if unsafe to call free. |
0 | On success. |
int kthread_setspecific | ( | kthread_key_t | key, |
const void * | value | ||
) |
Set thread specific data for a key.
This function sets the thread-specific data associated with the given key.
key | The key to set data for. |
value | The thread-specific value to use. |
-1 | On failure, and sets errno to one of the following: EINVAL if the key is not valid, ENOMEM if out of memory, or EPERM if called inside an interrupt and another call is in progress. |
0 | On success. |