1 /*
2  * Copyright 2017, NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef __SRTM_MUTEX_H__
10 #define __SRTM_MUTEX_H__
11 
12 #include <srtm_defs.h>
13 
14 /*!
15  * @addtogroup srtm
16  * @{
17  */
18 
19 /*******************************************************************************
20  * Definitions
21  ******************************************************************************/
22 /**
23  * @brief SRTM mutex handle
24  */
25 typedef void *srtm_mutex_t;
26 
27 /*******************************************************************************
28  * API
29  ******************************************************************************/
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /*!
35  * @brief Create a mutex.
36  *
37  * @param stack Stack for mutex data.
38  *
39  * @return Created mutex handle, or NULL on failure.
40  */
41 #if defined(SRTM_STATIC_API) && SRTM_STATIC_API
42 srtm_mutex_t SRTM_Mutex_Create(srtm_mutex_buf_t *stack);
43 #else
44 srtm_mutex_t SRTM_Mutex_Create(void);
45 #endif
46 
47 /*!
48  * @brief Destroy the mutex.
49  *
50  * @param mutex The mutex to destroy.
51  */
52 void SRTM_Mutex_Destroy(srtm_mutex_t mutex);
53 
54 /*!
55  * @brief Lock a mutex.
56  *
57  * @param mutex Mutex handle
58  * @return SRTM_Status_Success on success and others on failure.
59  */
60 srtm_status_t SRTM_Mutex_Lock(srtm_mutex_t mutex);
61 
62 /*!
63  * @brief Unlock on a mutex.
64  *
65  * @param mutex Mutex handle
66  * @return SRTM_Status_Success on success and others on failure.
67  */
68 srtm_status_t SRTM_Mutex_Unlock(srtm_mutex_t mutex);
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 /*! @} */
75 
76 #endif /* __SRTM_MUTEX_H__ */
77