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

Merge pull request #20954 from benpicco/mutex_init_locked

core/mutex: add `mutex_init_locked()`
This commit is contained in:
benpicco 2024-11-06 12:09:56 +00:00 committed by GitHub
commit 9c55be7237
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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