1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

core/mutex: add mutex_init_locked()

This commit is contained in:
Benjamin Valentin 2024-11-06 11:39:27 +01:00
parent 27343666dc
commit 46ecf82e24

View File

@ -253,6 +253,17 @@ static inline void mutex_init(mutex_t *mutex)
mutex->queue.next = NULL; mutex->queue.next = NULL;
} }
/**
* @brief Initializes a mutex object in a locked state.
* @details For initialization of variables use MUTEX_INIT_LOCKED instead.
* Only use the function call for dynamically allocated mutexes.
* @param[out] mutex pre-allocated mutex structure, must not be NULL.
*/
static inline void mutex_init_locked(mutex_t *mutex)
{
*mutex = (mutex_t)MUTEX_INIT_LOCKED;
}
/** /**
* @brief Initialize a mutex cancellation structure * @brief Initialize a mutex cancellation structure
* @param mutex The mutex that the calling thread wants to lock * @param mutex The mutex that the calling thread wants to lock