You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/10/12 18:47:50 UTC
(nuttx) branch master updated: sched/pthread: Remove unused pthread_sem_xxx functions
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new a074a572af sched/pthread: Remove unused pthread_sem_xxx functions
a074a572af is described below
commit a074a572af4d10a07878db7c61ecffe238f87368
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Jul 5 21:22:18 2024 +0800
sched/pthread: Remove unused pthread_sem_xxx functions
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
sched/pthread/CMakeLists.txt | 1 -
sched/pthread/Make.defs | 2 +-
sched/pthread/pthread.h | 6 --
sched/pthread/pthread_condbroadcast.c | 2 +-
sched/pthread/pthread_condsignal.c | 2 +-
sched/pthread/pthread_condwait.c | 2 +-
sched/pthread/pthread_sem.c | 124 ----------------------------------
7 files changed, 4 insertions(+), 135 deletions(-)
diff --git a/sched/pthread/CMakeLists.txt b/sched/pthread/CMakeLists.txt
index 50418ddff1..da24530c83 100644
--- a/sched/pthread/CMakeLists.txt
+++ b/sched/pthread/CMakeLists.txt
@@ -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
diff --git a/sched/pthread/Make.defs b/sched/pthread/Make.defs
index c44e9a02a6..209f11ef95 100644
--- a/sched/pthread/Make.defs
+++ b/sched/pthread/Make.defs
@@ -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
diff --git a/sched/pthread/pthread.h b/sched/pthread/pthread.h
index f99c25b94b..d6c3bd76ad 100644
--- a/sched/pthread/pthread.h
+++ b/sched/pthread/pthread.h
@@ -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);
diff --git a/sched/pthread/pthread_condbroadcast.c b/sched/pthread/pthread_condbroadcast.c
index 9912771647..599bd976c2 100644
--- a/sched/pthread/pthread_condbroadcast.c
+++ b/sched/pthread/pthread_condbroadcast.c
@@ -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).
diff --git a/sched/pthread/pthread_condsignal.c b/sched/pthread/pthread_condsignal.c
index eed49a73f4..fb9453b712 100644
--- a/sched/pthread/pthread_condsignal.c
+++ b/sched/pthread/pthread_condsignal.c
@@ -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);
}
}
}
diff --git a/sched/pthread/pthread_condwait.c b/sched/pthread/pthread_condwait.c
index 2820c95137..fbc914897c 100644
--- a/sched/pthread/pthread_condwait.c
+++ b/sched/pthread/pthread_condwait.c
@@ -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 */
diff --git a/sched/pthread/pthread_sem.c b/sched/pthread/pthread_sem.c
deleted file mode 100644
index cea0e6bfe0..0000000000
--- a/sched/pthread/pthread_sem.c
+++ /dev/null
@@ -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;
- }
-}