File threading.h
Threading abstraction layer.
Defines
-
MBEDTLS_ERR_THREADING_BAD_INPUT_DATA
Bad input parameters to function.
-
MBEDTLS_ERR_THREADING_MUTEX_ERROR
Locking / unlocking / free failed with error code.
Typedefs
-
typedef struct mbedtls_threading_mutex_t mbedtls_threading_mutex_t
Functions
-
void mbedtls_threading_set_alt(void (*mutex_init)(mbedtls_threading_mutex_t*), void (*mutex_free)(mbedtls_threading_mutex_t*), int (*mutex_lock)(mbedtls_threading_mutex_t*), int (*mutex_unlock)(mbedtls_threading_mutex_t*))
Set your alternate threading implementation function pointers and initialize global mutexes. If used, this function must be called once in the main thread before any other Mbed TLS function is called, and mbedtls_threading_free_alt() must be called once in the main thread after all other Mbed TLS functions.
Warning
mutex_initandmutex_freedon’t return a status code. Ifmutex_initfails, it should leave the mutex in a state such thatmutex_lockwill reliably return MBEDTLS_ERR_THREADING_MUTEX_ERROR called on this mutex, andmutex_freewill do nothing.- Parameters:
mutex_init –
The init function implementation.
The behavior is undefined if the mutex is already initialized and has not been destroyed. On platforms where mutex initialization can fail, since this function does not return a status code, it must leave the mutex object in a safe state where subsequent function calls will not cause undefined behavior: after a call to
mutex_init, the functionmutex_lockmust either succeed or fail with a nonzero status code, and the functionmutex_freemust free any resources associated with the mutex..mutex_free –
The destroy function implementation.
This function must free any resources associated with the mutex object.
This function must work reliably ifmutex_inithas been called on the mutex andmutex_freehas not yet been called.
The behavior is undefined if the mutex was not initialized, if it has already been destroyed, if it is currently locked, or if this function is called concurrently from multiple threads.
mutex_lock –
The lock function implementation.
This function must work reliably on any mutex which is not currently locked and on which
mutex_inithas already been called butmutex_freehas not been called yet.
The behavior is undefined if the mutex was not initialized, if it has already been destroyed, or if it is currently locked by the calling thread.
mutex_unlock –
The unlock function implementation.
The behavior is undefined if the mutex is not currently locked by the calling thread.
-
void mbedtls_threading_free_alt(void)
Free global mutexes.
Variables
-
void (*mbedtls_mutex_init)(mbedtls_threading_mutex_t *mutex)
-
void (*mbedtls_mutex_free)(mbedtls_threading_mutex_t *mutex)
-
int (*mbedtls_mutex_lock)(mbedtls_threading_mutex_t *mutex)
-
int (*mbedtls_mutex_unlock)(mbedtls_threading_mutex_t *mutex)
-
mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex
-
mbedtls_threading_mutex_t mbedtls_threading_key_slot_mutex
-
mbedtls_threading_mutex_t mbedtls_threading_psa_globaldata_mutex
-
mbedtls_threading_mutex_t mbedtls_threading_psa_rngdata_mutex
-
struct mbedtls_threading_mutex_t
- #include <threading.h>