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 dcc75048be Revert "system: pthread_barrierwait should be moved to 
kernel space"
dcc75048be is described below

commit dcc75048beecea7ddeaa807a9c13115c8d03280c
Author: hujun5 <huj...@xiaomi.com>
AuthorDate: Fri Nov 15 14:58:41 2024 +0800

    Revert "system: pthread_barrierwait should be moved to kernel space"
    
    reason:
    new implementation does not requires the use of enter_critical_section,
    so the source code needs to be moved to user space
    
    This reverts commit d189a86a35482fc20951031e2b9bcb39929deef9.
---
 include/sys/syscall_lookup.h                       |  1 -
 libs/libc/pthread/CMakeLists.txt                   |  1 +
 libs/libc/pthread/Make.defs                        |  2 +-
 {sched => libs/libc}/pthread/pthread_barrierwait.c | 15 +++++++++++++--
 sched/pthread/CMakeLists.txt                       |  3 +--
 sched/pthread/Make.defs                            |  1 -
 syscall/syscall.csv                                |  1 -
 7 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/include/sys/syscall_lookup.h b/include/sys/syscall_lookup.h
index 5bef5e5d1c..8a4f281b06 100644
--- a/include/sys/syscall_lookup.h
+++ b/include/sys/syscall_lookup.h
@@ -310,7 +310,6 @@ SYSCALL_LOOKUP(munmap,                     2)
 /* The following are defined if pthreads are enabled */
 
 #ifndef CONFIG_DISABLE_PTHREAD
-  SYSCALL_LOOKUP(pthread_barrier_wait,     1)
   SYSCALL_LOOKUP(pthread_cancel,           1)
   SYSCALL_LOOKUP(pthread_cond_broadcast,   1)
   SYSCALL_LOOKUP(pthread_cond_signal,      1)
diff --git a/libs/libc/pthread/CMakeLists.txt b/libs/libc/pthread/CMakeLists.txt
index 0c9ef8d836..fd46897e70 100644
--- a/libs/libc/pthread/CMakeLists.txt
+++ b/libs/libc/pthread/CMakeLists.txt
@@ -57,6 +57,7 @@ if(NOT CONFIG_DISABLE_PTHREAD)
     pthread_barrierattr_setpshared.c
     pthread_barrierinit.c
     pthread_barrierdestroy.c
+    pthread_barrierwait.c
     pthread_condattr_init.c
     pthread_condattr_destroy.c
     pthread_condattr_getpshared.c
diff --git a/libs/libc/pthread/Make.defs b/libs/libc/pthread/Make.defs
index fa69fd39ba..69c6ce4f4a 100644
--- a/libs/libc/pthread/Make.defs
+++ b/libs/libc/pthread/Make.defs
@@ -40,7 +40,7 @@ CSRCS += pthread_attr_setschedparam.c 
pthread_attr_getschedparam.c
 CSRCS += pthread_attr_setscope.c pthread_attr_getscope.c
 CSRCS += pthread_barrierattr_init.c pthread_barrierattr_destroy.c
 CSRCS += pthread_barrierattr_getpshared.c pthread_barrierattr_setpshared.c
-CSRCS += pthread_barrierinit.c pthread_barrierdestroy.c
+CSRCS += pthread_barrierinit.c pthread_barrierdestroy.c pthread_barrierwait.c
 CSRCS += pthread_condattr_init.c pthread_condattr_destroy.c
 CSRCS += pthread_condattr_getpshared.c pthread_condattr_setpshared.c
 CSRCS += pthread_condattr_setclock.c pthread_condattr_getclock.c
diff --git a/sched/pthread/pthread_barrierwait.c 
b/libs/libc/pthread/pthread_barrierwait.c
similarity index 93%
rename from sched/pthread/pthread_barrierwait.c
rename to libs/libc/pthread/pthread_barrierwait.c
index 0cbf4901e9..ef6d6278e4 100644
--- a/sched/pthread/pthread_barrierwait.c
+++ b/libs/libc/pthread/pthread_barrierwait.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * sched/pthread/pthread_barrierwait.c
+ * libs/libc/pthread/pthread_barrierwait.c
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -112,5 +112,16 @@ int pthread_barrier_wait(FAR pthread_barrier_t *barrier)
 
   nxmutex_unlock(&barrier->mutex);
 
-  return -nxsem_wait_uninterruptible(&barrier->sem);
+  while (sem_wait(&barrier->sem) != OK)
+    {
+      /* If the thread is awakened by a signal, just continue to wait */
+
+      int errornumber = get_errno();
+      if (errornumber != EINTR)
+        {
+          return errornumber;
+        }
+    }
+
+  return OK;
 }
diff --git a/sched/pthread/CMakeLists.txt b/sched/pthread/CMakeLists.txt
index da24530c83..2ccf5d358f 100644
--- a/sched/pthread/CMakeLists.txt
+++ b/sched/pthread/CMakeLists.txt
@@ -43,8 +43,7 @@ if(NOT CONFIG_DISABLE_PTHREAD)
       pthread_completejoin.c
       pthread_findjoininfo.c
       pthread_release.c
-      pthread_setschedprio.c
-      pthread_barrierwait.c)
+      pthread_setschedprio.c)
 
   if(NOT CONFIG_PTHREAD_MUTEX_UNSAFE)
     list(APPEND SRCS pthread_mutex.c pthread_mutexconsistent.c
diff --git a/sched/pthread/Make.defs b/sched/pthread/Make.defs
index 209f11ef95..bff1a88da1 100644
--- a/sched/pthread/Make.defs
+++ b/sched/pthread/Make.defs
@@ -30,7 +30,6 @@ CSRCS += pthread_condwait.c pthread_condsignal.c 
pthread_condbroadcast.c
 CSRCS += pthread_condclockwait.c pthread_sigmask.c pthread_cancel.c
 CSRCS += pthread_completejoin.c pthread_findjoininfo.c
 CSRCS += pthread_release.c pthread_setschedprio.c
-CSRCS += pthread_barrierwait.c
 
 ifneq ($(CONFIG_PTHREAD_MUTEX_UNSAFE),y)
 CSRCS += pthread_mutex.c pthread_mutexconsistent.c pthread_mutexinconsistent.c
diff --git a/syscall/syscall.csv b/syscall/syscall.csv
index f883a50c87..959f7d9545 100644
--- a/syscall/syscall.csv
+++ b/syscall/syscall.csv
@@ -105,7 +105,6 @@
 "prctl","sys/prctl.h","","int","int","...","uintptr_t","uintptr_t"
 "pread","unistd.h","","ssize_t","int","FAR void *","size_t","off_t"
 "pselect","sys/select.h","","int","int","FAR fd_set *","FAR fd_set *","FAR 
fd_set *","FAR const struct timespec *","FAR const sigset_t *"
-"pthread_barrier_wait","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR
 pthread_barrier_t *"
 
"pthread_cancel","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","pthread_t"
 
"pthread_cond_broadcast","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR
 pthread_cond_t *"
 
"pthread_cond_clockwait","pthread.h","!defined(CONFIG_DISABLE_PTHREAD)","int","FAR
 pthread_cond_t *","FAR pthread_mutex_t *","clockid_t","FAR const struct 
timespec *"

Reply via email to