From ea12433a8d0ba913b129cd83c97992263e512d4a Mon Sep 17 00:00:00 2001 From: Victor Arino Date: Wed, 14 Dec 2016 10:10:41 +0100 Subject: [PATCH] core/mutex: support locked initialization --- core/include/mutex.h | 12 ++++++++++++ core/mutex.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/include/mutex.h b/core/include/mutex.h index 0069108cc3..0f7c0fd8c9 100644 --- a/core/include/mutex.h +++ b/core/include/mutex.h @@ -49,6 +49,18 @@ typedef struct { */ #define MUTEX_INIT { { NULL } } +/** + * @brief Static initializer for mutex_t with a locked mutex + */ +#define MUTEX_INIT_LOCKED { { MUTEX_LOCKED } } + +/** + * @internal + * @brief This is the value of the mutex when locked and no threads are waiting + * for it + */ +#define MUTEX_LOCKED ((void *)-1) + /** * @brief Initializes a mutex object. * @details For initialization of variables use MUTEX_INIT instead. diff --git a/core/mutex.c b/core/mutex.c index 609ca26199..434386fb25 100644 --- a/core/mutex.c +++ b/core/mutex.c @@ -35,8 +35,6 @@ #define ENABLE_DEBUG (0) #include "debug.h" -#define MUTEX_LOCKED ((void*)-1) - int _mutex_lock(mutex_t *mutex, int blocking) { unsigned irqstate = irq_disable();