提交 eca03e5e 编写于 作者: O openharmony_ci 提交者: Gitee

!195 feat: L0新增posix接口sem_getvalue

Merge pull request !195 from x_xiny/master
......@@ -186,3 +186,21 @@ int sem_timedwait(sem_t *sem, const struct timespec *timeout)
return 0;
}
int sem_getvalue(sem_t *sem, int *currVal)
{
UINT32 ret;
if ((sem == NULL) || (currVal == NULL)) {
errno = EINVAL;
return -1;
}
ret = LOS_SemGetValue(sem->s_handle, currVal);
if (ret) {
errno = EINVAL;
return -1;
}
return LOS_OK;
}
\ No newline at end of file
......@@ -285,6 +285,8 @@ extern UINT32 LOS_SemPend(UINT32 semHandle, UINT32 timeout);
*/
extern UINT32 LOS_SemPost(UINT32 semHandle);
extern UINT32 LOS_SemGetValue(UINT32 semHandle, INT32 *currVal);
/**
* @ingroup los_sem
* Semaphore control structure.
......
......@@ -312,4 +312,16 @@ LITE_OS_SEC_TEXT UINT32 LOS_SemPost(UINT32 semHandle)
return LOS_OK;
}
LITE_OS_SEC_TEXT UINT32 LOS_SemGetValue(UINT32 semHandle, INT32 *currVal)
{
LosSemCB *sem = GET_SEM(semHandle);
if (semHandle >= (UINT32)LOSCFG_BASE_IPC_SEM_LIMIT) {
OS_RETURN_ERROR(LOS_ERRNO_SEM_INVALID);
}
*currVal = sem->semCount;
return 0;
}
#endif /* (LOSCFG_BASE_IPC_SEM == 1) */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册