libmetal
Toggle main menu visibility
Loading...
Searching...
No Matches
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
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
rmutex_t
metal_mutex_t
;
26
27
/*
28
* METAL_MUTEX_INIT - used for initializing an mutex element in a static struct
29
* or global
30
*/
31
#define METAL_MUTEX_INIT(m) NXRMUTEX_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 = NXRMUTEX_INITIALIZER
37
38
static
inline
void
__metal_mutex_init
(
metal_mutex_t
*mutex)
39
{
40
nxrmutex_init(mutex);
41
}
42
43
static
inline
void
__metal_mutex_deinit
(
metal_mutex_t
*mutex)
44
{
45
nxrmutex_destroy(mutex);
46
}
47
48
static
inline
int
__metal_mutex_try_acquire
(
metal_mutex_t
*mutex)
49
{
50
return
nxrmutex_trylock(mutex);
51
}
52
53
static
inline
void
__metal_mutex_acquire
(
metal_mutex_t
*mutex)
54
{
55
nxrmutex_lock(mutex);
56
}
57
58
static
inline
void
__metal_mutex_release
(
metal_mutex_t
*mutex)
59
{
60
nxrmutex_unlock(mutex);
61
}
62
63
static
inline
int
__metal_mutex_is_acquired
(
metal_mutex_t
*mutex)
64
{
65
return
nxrmutex_is_locked(mutex);
66
}
67
68
#ifdef __cplusplus
69
}
70
#endif
71
72
#endif
/* __METAL_NUTTX_MUTEX__H__ */
metal_mutex_t
Definition
mutex.h:28
__metal_mutex_release
static void __metal_mutex_release(metal_mutex_t *mutex)
Definition
mutex.h:64
__metal_mutex_deinit
static void __metal_mutex_deinit(metal_mutex_t *mutex)
Definition
mutex.h:45
__metal_mutex_try_acquire
static int __metal_mutex_try_acquire(metal_mutex_t *mutex)
Definition
mutex.h:52
__metal_mutex_is_acquired
static int __metal_mutex_is_acquired(metal_mutex_t *mutex)
Definition
mutex.h:70
__metal_mutex_acquire
static void __metal_mutex_acquire(metal_mutex_t *mutex)
Definition
mutex.h:58
__metal_mutex_init
static void __metal_mutex_init(metal_mutex_t *mutex)
Definition
mutex.h:38
mutex.h
NuttX mutex primitives for libmetal.
Generated on
for libmetal by
1.17.0