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.

Note

mutex_init() and mutex_free() don’t return a status code. If mutex_init() fails, it should leave its argument (the mutex) in a state such that mutex_lock() will fail when called with this argument.

Parameters
  • mutex_init – the init function implementation

  • mutex_free – the free function implementation

  • mutex_lock – the lock function implementation

  • mutex_unlock – the unlock function implementation

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>

Public Members

pthread_mutex_t private_mutex
char private_state