1 /******************************************************************************
2 /******************************************************************************
4 * Copyright (c) 2020 ICT/CAS.
6 * Licensed under the O-RAN Software License, Version 1.0 (the "Software License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * https://www.o-ran.org/software
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 *******************************************************************************/
30 #endif /* __cplusplus */
33 #define VOS_WAIT_FOREVER -1
36 #define VOS_WAIT_NO_WAIT 0
42 VOS_SEM_EMPTY, ///< 0: semaphore not available
43 VOS_SEM_FULL ///< 1: semaphore available
46 /** 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO */
48 VOS_SEM_Q_FIFO = 0x0, ///< first in first out queue
49 VOS_SEM_Q_PRIORITY = 0x1, ///< priority sorted queue
50 VOS_SEM_DELETE_SAFE = 0x4, ///< owner delete safe (mutex opt.)
51 VOS_SEM_INVERSION_SAFE = 0x8, ///< no priority inversion (mutex opt.)
56 * 创建Bianary类型的信号量,linux中 与Count类型 一致
57 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
58 * @param[in] enInitialState 初始化状态,VOS_SEM_B_STATE 类型的枚举值
59 * @return 返回SEM_ID,失败则返回 0
61 #define VOS_SemBCreate(lOption, enInitialState) __VOS_SemBCreate(lOption, enInitialState, __FUNCTION__, __LINE__)
66 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
67 * @param[in] enInitialState 初始化状态,VOS_SEM_B_STATE 类型的枚举值
68 * @return 返回SEM_ID,失败则返回 0
70 #define VOS_SemCCreate(lOption, enInitialState) __VOS_SemCCreate(lOption, enInitialState, __FUNCTION__, __LINE__)
75 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
76 * @return 返回SEM_ID,失败则返回 0
78 #define VOS_SemMCreate(lOption) __VOS_SemMCreate(lOption, __FUNCTION__, __LINE__)
83 * @param[in] semID 信号量ID
84 * @param[in] lMsec 超时等待的时间,单位毫秒,也可以为VOS_WAIT_FOREVER或VOS_NO_WAIT
85 * @return VOS_OK - 成功,其他 - 失败/超时
87 LONG VOS_SemTake(ULONG semID, LONG lMsec);
92 * @param[in] semID 信号量ID
93 * @return VOS_OK - 成功,其他 - 失败
95 LONG VOS_SemGive(ULONG semID);
100 * @param[in] semID 信号量ID
101 * @return VOS_OK - 成功,其他 - 失败
103 LONG VOS_SemDelete(ULONG semID);
110 /* ###### 下面的函数不要直接调用,使用上面提供的宏 ###### */
114 * 不要直接调用该API,通过宏 VOS_SemBCreate 使用
115 * 创建Bianary类型的信号量,linux中 与Count类型 一致
116 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
117 * @param[in] enInitialState 初始化状态,VOS_SEM_B_STATE 类型
118 * @param[in] pFunc 调用该API的文件名
119 * @param[in] iLine 调用该API的行号
120 * @return 返回SEM_ID,失败则返回 0
122 ULONG __VOS_SemBCreate(LONG lOption, VOS_SEM_B_STATE enInitialState,const CHAR *pFunc, INT iLine);
126 * 不要直接调用该API,通过宏 VOS_SemCCreate 使用
127 * 创建Count类型的信号量,linux中 与Count类型 一致
128 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
129 * @param[in] lInitialCount 初始值
130 * @param[in] pFunc 调用该API的文件名
131 * @param[in] iLine 调用该API的行号
132 * @return 返回SEM_ID,失败则返回 0
134 ULONG __VOS_SemCCreate(LONG lOption, LONG lInitialCount,const CHAR *pFunc, INT iLine);
138 * 不要直接调用该API,通过宏 VOS_SemMCreate 使用
140 * @param[in] lOption 信号量选项,linux 中无效,使用 VOS_SEM_Q_FIFO
141 * @param[in] pFunc 调用该API的文件名
142 * @param[in] iLine 调用该API的行号
143 * @return 返回SEM_ID,失败则返回 0
145 ULONG __VOS_SemMCreate(LONG lOption,const CHAR *pFunc, INT iLine);
149 #endif /* __cplusplus */
152 #endif /* __VOS_SEM_H__ */