muteki
Loading...
Searching...
No Matches
ktls.h File Reference

Kernel TLS (KTLS) control. More...

#include <muteki/threading.h>

Go to the source code of this file.

Functions

int osdep_ktls_init (thread_t *thr)
 Initialize the TLS container on a specific thread.
 
void ** osdep_ktls_get (thread_t *thr, unsigned int key)
 Get the pointer to the TLS slot on the thread descriptor.
 
void * osdep_ktls_getvalue (thread_t *thr, unsigned int key)
 Get the value stored in the TLS slot on the thread descriptor.
 
int osdep_ktls_set (thread_t *thr, unsigned int key, void *value)
 Store a value in the TLS slot.
 
void * osdep_ktls_alloc (thread_t *thr, unsigned int key, size_t bytes)
 Allocate memory and store the resulting pointer in the TLS slot.
 
int osdep_ktls_free (thread_t *thr, unsigned int key)
 Free memory previously allocated by osdep_ktls_alloc().
 
int osdep_ktls_init_self (void)
 Initialize the TLS container on the current thread.
 
void ** osdep_ktls_get_self (unsigned int key)
 Get the pointer to the TLS slot on the current thread.
 
void * osdep_ktls_getvalue_self (unsigned int key)
 Get the value stored in a TLS slot of the current thread.
 
int osdep_ktls_set_self (unsigned int key, void *value)
 Store a value in the TLS slot on the current thread.
 
void * osdep_ktls_alloc_self (unsigned int key, size_t bytes)
 Allocate memory and store the resulting pointer in a TLS slot of the current thread.
 
int osdep_ktls_free_self (unsigned int key)
 Free memory previously allocated by osdep_ktls_alloc().
 

Detailed Description

Kernel TLS (KTLS) control.

This is what TLSv1 used as the backend. Provided here in case one wants to hold data across applets/modules within the same thread.

Function Documentation

◆ osdep_ktls_alloc()

void * osdep_ktls_alloc ( thread_t thr,
unsigned int  key,
size_t  bytes 
)
extern

Allocate memory and store the resulting pointer in the TLS slot.

Parameters
thrPointer to a thread descriptor.
keyNumerical key. Must be in the range of (0, 8).
bytesNumber of bytes to allocate.
Returns
Allocated buffer, or NULL if the slot is not NULL, or if the allocation fails.

◆ osdep_ktls_alloc_self()

void * osdep_ktls_alloc_self ( unsigned int  key,
size_t  bytes 
)
extern

Allocate memory and store the resulting pointer in a TLS slot of the current thread.

Parameters
keyNumerical key. Must be in the range of (0, 8).
bytesNumber of bytes to allocate.
Returns
Allocated buffer, or NULL if the slot is not NULL, or if the allocation fails.

◆ osdep_ktls_free()

int osdep_ktls_free ( thread_t thr,
unsigned int  key 
)
extern

Free memory previously allocated by osdep_ktls_alloc().

Parameters
thrPointer to a thread descriptor.
keyNumerical key. Must be in the range of (0, 8).
Return values
0The operation was completed successfully.

◆ osdep_ktls_free_self()

int osdep_ktls_free_self ( unsigned int  key)
extern

Free memory previously allocated by osdep_ktls_alloc().

Parameters
keyNumerical key. Must be in the range of (0, 8).
Return values
0The operation was completed successfully.

◆ osdep_ktls_get()

void ** osdep_ktls_get ( thread_t thr,
unsigned int  key 
)
extern

Get the pointer to the TLS slot on the thread descriptor.

Parameters
thrPointer to a thread descriptor.
keyNumerical key. Must be in the range of (0, 8).
Returns
Pointer to the TLS slot. Or NULL when an invalid key was supplied.

◆ osdep_ktls_get_self()

void ** osdep_ktls_get_self ( unsigned int  key)
extern

Get the pointer to the TLS slot on the current thread.

Parameters
keyNumerical key. Must be in the range of (0, 8).
Returns
Pointer to the TLS slot. Or NULL when an invalid key was supplied.

◆ osdep_ktls_getvalue()

void * osdep_ktls_getvalue ( thread_t thr,
unsigned int  key 
)
extern

Get the value stored in the TLS slot on the thread descriptor.

Parameters
thrPointer to a thread descriptor.
keyNumerical key. Must be in the range of (0, 8).
Returns
Value stored in the TLS slot. Or NULL when an error occurres.

◆ osdep_ktls_getvalue_self()

void * osdep_ktls_getvalue_self ( unsigned int  key)
extern

Get the value stored in a TLS slot of the current thread.

Parameters
keyNumerical key. Must be in the range of (0, 8).
Returns
void*

◆ osdep_ktls_init()

int osdep_ktls_init ( thread_t thr)
extern

Initialize the TLS container on a specific thread.

Parameters
thrPointer to a thread descriptor.
Return values
0The operation was completed successfully.

◆ osdep_ktls_init_self()

int osdep_ktls_init_self ( void  )
extern

Initialize the TLS container on the current thread.

Parameters
None.

Return values
0The operation was completed successfully.

◆ osdep_ktls_set()

int osdep_ktls_set ( thread_t thr,
unsigned int  key,
void *  value 
)
extern

Store a value in the TLS slot.

Warning
If osdep_ktls_alloc() was called on this previously, the memory won't be freed properly.
Parameters
thrPointer to a thread descriptor.
keyNumerical key. Must be in the range of (0, 8).
valueValue to be stored into the TLS slot.
Return values
0The operation was completed successfully.
-1The operation failed with error.

◆ osdep_ktls_set_self()

int osdep_ktls_set_self ( unsigned int  key,
void *  value 
)
extern

Store a value in the TLS slot on the current thread.

Parameters
keyNumerical key. Must be in the range of (0, 8).
valueValue to be stored into the TLS slot.
Return values
0The operation was completed successfully.
-1The operation failed with error.