sched/pthread: Remove unused pthread_sem_xxx functions

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2024-07-05 21:22:18 +08:00
committed by Xiang Xiao
parent 015a45517e
commit a074a572af
7 changed files with 4 additions and 135 deletions
-1
View File
@@ -40,7 +40,6 @@ if(NOT CONFIG_DISABLE_PTHREAD)
pthread_condclockwait.c
pthread_sigmask.c
pthread_cancel.c
pthread_sem.c
pthread_completejoin.c
pthread_findjoininfo.c
pthread_release.c
+1 -1
View File
@@ -28,7 +28,7 @@ CSRCS += pthread_mutexinit.c pthread_mutexdestroy.c
CSRCS += pthread_mutextimedlock.c pthread_mutextrylock.c pthread_mutexunlock.c
CSRCS += pthread_condwait.c pthread_condsignal.c pthread_condbroadcast.c
CSRCS += pthread_condclockwait.c pthread_sigmask.c pthread_cancel.c
CSRCS += pthread_sem.c pthread_completejoin.c pthread_findjoininfo.c
CSRCS += pthread_completejoin.c pthread_findjoininfo.c
CSRCS += pthread_release.c pthread_setschedprio.c
CSRCS += pthread_barrierwait.c
-6
View File
@@ -107,12 +107,6 @@ int pthread_findjoininfo(FAR struct task_group_s *group, pid_t pid,
FAR struct task_join_s **join, bool create);
void pthread_release(FAR struct task_group_s *group);
int pthread_sem_take(FAR sem_t *sem, FAR const struct timespec *abs_timeout);
#ifdef CONFIG_PTHREAD_MUTEX_UNSAFE
int pthread_sem_trytake(FAR sem_t *sem);
#endif
int pthread_sem_give(FAR sem_t *sem);
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
int pthread_mutex_take(FAR struct pthread_mutex_s *mutex,
FAR const struct timespec *abs_timeout);
+1 -1
View File
@@ -90,7 +90,7 @@ int pthread_cond_broadcast(FAR pthread_cond_t *cond)
* Only the highest priority waiting thread will get to execute
*/
ret = pthread_sem_give(&cond->sem);
ret = -nxsem_post(&cond->sem);
/* Increment the semaphore count (as was done by the
* above post).
+1 -1
View File
@@ -93,7 +93,7 @@ int pthread_cond_signal(FAR pthread_cond_t *cond)
if (sval < 0)
{
sinfo("Signalling...\n");
ret = pthread_sem_give(&cond->sem);
ret = -nxsem_post(&cond->sem);
}
}
}
+1 -1
View File
@@ -97,7 +97,7 @@ int pthread_cond_wait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex)
* or if the thread is canceled (ECANCELED)
*/
status = pthread_sem_take(&cond->sem, NULL);
status = -nxsem_wait_uninterruptible(&cond->sem);
if (ret == OK)
{
/* Report the first failure that occurs */
-124
View File
@@ -1,124 +0,0 @@
/****************************************************************************
* sched/pthread/pthread_sem.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include <errno.h>
#include <nuttx/semaphore.h>
#include "pthread/pthread.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: pthread_sem_take, pthread_sem_trytake, and
* pthread_sem_give
*
* Description:
* Support managed access to the private data sets.
*
* REVISIT: These functions really do nothing more than match the return
* value of the semaphore functions (0 or -1 with errno set) to the
* return value of more pthread functions (0 or errno). A better solution
* would be to use an internal version of the semaphore functions that
* return the error value in the correct form.
*
* Input Parameters:
* sem - The semaphore to lock or unlock
*
* Returned Value:
* 0 on success or an errno value on failure.
*
****************************************************************************/
int pthread_sem_take(FAR sem_t *sem, FAR const struct timespec *abs_timeout)
{
int ret;
if (abs_timeout == NULL)
{
ret = nxsem_wait_uninterruptible(sem);
}
else
{
ret = nxsem_timedwait_uninterruptible(sem, abs_timeout);
}
return -ret;
}
#ifdef CONFIG_PTHREAD_MUTEX_UNSAFE
int pthread_sem_trytake(FAR sem_t *sem)
{
int ret = EINVAL;
/* Verify input parameters */
DEBUGASSERT(sem != NULL);
if (sem != NULL)
{
/* Try to take the semaphore */
int status = nxsem_trywait(sem);
ret = status < 0 ? -status : OK;
}
return ret;
}
#endif
int pthread_sem_give(FAR sem_t *sem)
{
int ret;
/* Verify input parameters */
DEBUGASSERT(sem != NULL);
if (sem != NULL)
{
/* Give the semaphore */
ret = nxsem_post(sem);
if (ret < 0)
{
return -ret;
}
return OK;
}
else
{
/* NULL semaphore pointer! */
return EINVAL;
}
}