• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *   Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Description: OS Abstract Layer.
15  */
16 
17 /**
18  * @defgroup osal_rwlock osal_rwlock
19  */
20 #ifndef __OSAL_RWLOCK_H__
21 #define __OSAL_RWLOCK_H__
22 
23 #ifdef __cplusplus
24 #if __cplusplus
25 extern "C" {
26 #endif
27 #endif
28 
29 typedef struct {
30     void *rwlock;
31 } osal_rwlock;
32 
33 /**
34  * @ingroup osal_rwlock
35  *
36  * @brief We need to initialize when we need to.
37  *
38  * @par Description:
39  * Read/write lock initialization.
40  *
41  * @return OSAL_FAILURE/OSAL_SUCCESS
42  *
43  * @par Support System:
44  * linux.
45  */
46 int osal_rwlock_init(osal_rwlock *rw_lock);
47 
48 /**
49  * @ingroup osal_rwlock
50  *
51  * @brief Lock it when you go in and read it.
52  *
53  * @par Description:
54  * Read lock.
55  *
56  * @par Support System:
57  * linux.
58  */
59 void osal_rwlock_read_lock(osal_rwlock *rw_lock);
60 
61 /**
62  * @ingroup osal_rwlock
63  *
64  * @brief Unlock when you read it out.
65  *
66  * @par Description:
67  * Read Unlock.
68  *
69  * @par Support System:
70  * linux.
71  */
72 void osal_rwlock_read_unlock(osal_rwlock *rw_lock);
73 
74 /**
75  * @ingroup osal_rwlock
76  *
77  * @brief Lock when you want to write.
78  *
79  * @par Description:
80  * Write lock.
81  *
82  * @par Support System:
83  * linux.
84  */
85 void osal_rwlock_write_lock(osal_rwlock *rw_lock);
86 
87 /**
88  * @ingroup osal_rwlock
89  *
90  * @brief Unlock after writing.
91  *
92  * @par Description:
93  * Write Unlock.
94  *
95  * @par Support System:
96  * linux.
97  */
98 void osal_rwlock_write_unlock(osal_rwlock *rw_lock);
99 
100 /**
101  * @ingroup osal_rwlock
102  *
103  * @brief We release rw_locks when we don't need it.
104  *
105  * @par Description:
106  * Release Lock.
107  *
108  * @par Support System:
109  * linux.
110  */
111 void osal_rwlock_destory(osal_rwlock *rw_lock);
112 
113 #ifdef __cplusplus
114 #if __cplusplus
115 }
116 #endif
117 #endif
118 #endif /* __OSAL_RWLOCK_H__ */