Remove intr param from pthread_sem_take

This commit is contained in:
Marco Casaroli 2022-12-07 11:47:08 +01:00 committed by Xiang Xiao
parent e2b00a9fcc
commit 4cc7f3747c
4 changed files with 8 additions and 26 deletions

View File

@ -88,8 +88,7 @@ FAR struct join_s *pthread_findjoininfo(FAR struct task_group_s *group,
pid_t pid); pid_t pid);
void pthread_release(FAR struct task_group_s *group); void pthread_release(FAR struct task_group_s *group);
int pthread_sem_take(FAR sem_t *sem, FAR const struct timespec *abs_timeout, int pthread_sem_take(FAR sem_t *sem, FAR const struct timespec *abs_timeout);
bool intr);
#ifdef CONFIG_PTHREAD_MUTEX_UNSAFE #ifdef CONFIG_PTHREAD_MUTEX_UNSAFE
int pthread_sem_trytake(sem_t *sem); int pthread_sem_trytake(sem_t *sem);
#endif #endif
@ -102,7 +101,7 @@ int pthread_mutex_trytake(FAR struct pthread_mutex_s *mutex);
int pthread_mutex_give(FAR struct pthread_mutex_s *mutex); int pthread_mutex_give(FAR struct pthread_mutex_s *mutex);
void pthread_mutex_inconsistent(FAR struct tcb_s *tcb); void pthread_mutex_inconsistent(FAR struct tcb_s *tcb);
#else #else
# define pthread_mutex_take(m,abs_timeout,i) pthread_sem_take(&(m)->sem,(abs_timeout),(i)) # define pthread_mutex_take(m,abs_timeout,i) pthread_sem_take(&(m)->sem,(abs_timeout))
# define pthread_mutex_trytake(m) pthread_sem_trytake(&(m)->sem) # define pthread_mutex_trytake(m) pthread_sem_trytake(&(m)->sem)
# define pthread_mutex_give(m) pthread_sem_give(&(m)->sem) # define pthread_mutex_give(m) pthread_sem_give(&(m)->sem)
#endif #endif

View File

@ -107,7 +107,7 @@ int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex)
* or if the thread is canceled (ECANCELED) * or if the thread is canceled (ECANCELED)
*/ */
status = pthread_sem_take(&cond->sem, NULL, false); status = pthread_sem_take(&cond->sem, NULL);
if (ret == OK) if (ret == OK)
{ {
/* Report the first failure that occurs */ /* Report the first failure that occurs */

View File

@ -52,40 +52,23 @@
* *
* Input Parameters: * Input Parameters:
* sem - The semaphore to lock or unlock * sem - The semaphore to lock or unlock
* intr - false: ignore EINTR errors when locking; true treat EINTR as
* other errors by returning the errno value
* *
* Returned Value: * Returned Value:
* 0 on success or an errno value on failure. * 0 on success or an errno value on failure.
* *
****************************************************************************/ ****************************************************************************/
int pthread_sem_take(FAR sem_t *sem, FAR const struct timespec *abs_timeout, int pthread_sem_take(FAR sem_t *sem, FAR const struct timespec *abs_timeout)
bool intr)
{ {
int ret; int ret;
if (intr) if (abs_timeout == NULL)
{ {
if (abs_timeout == NULL) ret = nxsem_wait_uninterruptible(sem);
{
ret = nxsem_wait(sem);
}
else
{
ret = nxsem_timedwait(sem, abs_timeout);
}
} }
else else
{ {
if (abs_timeout == NULL) ret = nxsem_timedwait_uninterruptible(sem, abs_timeout);
{
ret = nxsem_wait_uninterruptible(sem);
}
else
{
ret = nxsem_timedwait_uninterruptible(sem, abs_timeout);
}
} }
return -ret; return -ret;

View File

@ -166,7 +166,7 @@ int pthread_mutex_take(FAR struct pthread_mutex_s *mutex,
* returns zero on success and a positive errno value on failure. * returns zero on success and a positive errno value on failure.
*/ */
ret = pthread_sem_take(&mutex->sem, abs_timeout, intr); ret = pthread_sem_take(&mutex->sem, abs_timeout);
if (ret == OK) if (ret == OK)
{ {
/* Check if the holder of the mutex has terminated without /* Check if the holder of the mutex has terminated without