libmetal
lib
system
nuttx
mutex.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2018, Pinecone Inc. and Contributors. All rights reserved.
3
*
4
* SPDX-License-Identifier: BSD-3-Clause
5
*/
6
7
/*
8
* @file nuttx/mutex.h
9
* @brief NuttX mutex primitives for libmetal.
10
*/
11
12
#ifndef __METAL_MUTEX__H__
13
#error "Include metal/mutex.h instead of metal/nuttx/mutex.h"
14
#endif
15
16
#ifndef __METAL_NUTTX_MUTEX__H__
17
#define __METAL_NUTTX_MUTEX__H__
18
19
#include <
nuttx/mutex.h
>
20
21
#ifdef __cplusplus
22
extern
"C"
{
23
#endif
24
25
typedef
mutex_t
metal_mutex_t
;
26
27
/*
28
* METAL_MUTEX_INIT - used for initializing an mutex elmenet in a static struct
29
* or global
30
*/
31
#define METAL_MUTEX_INIT(m) MUTEX_INITIALIZER
32
/*
33
* METAL_MUTEX_DEFINE - used for defining and initializing a global or
34
* static singleton mutex
35
*/
36
#define METAL_MUTEX_DEFINE(m) metal_mutex_t m = MUTEX_INITIALIZER
37
38
static
inline
void
__metal_mutex_init
(
metal_mutex_t
*mutex)
39
{
40
nxmutex_init(mutex);
41
}
42
43
static
inline
void
__metal_mutex_deinit
(
metal_mutex_t
*mutex)
44
{
45
nxmutex_destroy(mutex);
46
}
47
48
static
inline
int
__metal_mutex_try_acquire
(
metal_mutex_t
*mutex)
49
{
50
return
nxmutex_trylock(mutex);
51
}
52
53
static
inline
void
__metal_mutex_acquire
(
metal_mutex_t
*mutex)
54
{
55
nxmutex_lock(mutex);
56
}
57
58
static
inline
void
__metal_mutex_release
(
metal_mutex_t
*mutex)
59
{
60
nxmutex_unlock(mutex);
61
}
62
63
static
inline
int
__metal_mutex_is_acquired
(
metal_mutex_t
*mutex)
64
{
65
return
nxmutex_is_locked(mutex);
66
}
67
68
#ifdef __cplusplus
69
}
70
#endif
71
72
#endif
/* __METAL_NUTTX_MUTEX__H__ */
__metal_mutex_deinit
static void __metal_mutex_deinit(metal_mutex_t *mutex)
Definition:
mutex.h:43
__metal_mutex_try_acquire
static int __metal_mutex_try_acquire(metal_mutex_t *mutex)
Definition:
mutex.h:48
__metal_mutex_acquire
static void __metal_mutex_acquire(metal_mutex_t *mutex)
Definition:
mutex.h:53
mutex.h
metal_mutex_t
mutex_t metal_mutex_t
Definition:
mutex.h:25
__metal_mutex_init
static void __metal_mutex_init(metal_mutex_t *mutex)
Definition:
mutex.h:38
__metal_mutex_release
static void __metal_mutex_release(metal_mutex_t *mutex)
Definition:
mutex.h:58
__metal_mutex_is_acquired
static int __metal_mutex_is_acquired(metal_mutex_t *mutex)
Definition:
mutex.h:63
metal_mutex_t
Definition:
mutex.h:26
Generated on Sat Aug 1 2020 00:00:00 for libmetal by
1.8.18