You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/04/07 12:23:25 UTC

[incubator-nuttx] 01/05: Remove type casting to wdentry_t (sched/)

This is an automated email from the ASF dual-hosted git repository.

gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 3cc336dddd48e17ae15a457807eb89fdcdc906ab
Author: Nakamura, Yuuichi <Yu...@sony.com>
AuthorDate: Fri Mar 13 15:44:16 2020 +0900

    Remove type casting to wdentry_t (sched/)
---
 sched/mqueue/mq_timedreceive.c        |  5 +-
 sched/mqueue/mq_timedsend.c           |  5 +-
 sched/pthread/pthread_condtimedwait.c | 93 ++++++++++++++++++++---------------
 sched/semaphore/sem_tickwait.c        |  3 +-
 sched/semaphore/sem_timedwait.c       |  3 +-
 sched/semaphore/sem_timeout.c         |  2 +-
 sched/semaphore/semaphore.h           |  2 +-
 sched/signal/sig_timedwait.c          |  4 +-
 sched/timer/timer_settime.c           |  8 +--
 9 files changed, 67 insertions(+), 58 deletions(-)

diff --git a/sched/mqueue/mq_timedreceive.c b/sched/mqueue/mq_timedreceive.c
index 8500472..a7dbcf5 100644
--- a/sched/mqueue/mq_timedreceive.c
+++ b/sched/mqueue/mq_timedreceive.c
@@ -64,7 +64,7 @@
  *
  ****************************************************************************/
 
-static void nxmq_rcvtimeout(int argc, wdparm_t pid)
+static void nxmq_rcvtimeout(int argc, wdparm_t pid, ...)
 {
   FAR struct tcb_s *wtcb;
   irqstate_t flags;
@@ -224,8 +224,7 @@ ssize_t nxmq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen,
 
       /* Start the watchdog */
 
-      wd_start(rtcb->waitdog, ticks, (wdentry_t)nxmq_rcvtimeout,
-               1, getpid());
+      wd_start(rtcb->waitdog, ticks, nxmq_rcvtimeout, 1, getpid());
     }
 
   /* Get the message from the message queue */
diff --git a/sched/mqueue/mq_timedsend.c b/sched/mqueue/mq_timedsend.c
index 7a46d5d..821a066 100644
--- a/sched/mqueue/mq_timedsend.c
+++ b/sched/mqueue/mq_timedsend.c
@@ -63,7 +63,7 @@
  *
  ****************************************************************************/
 
-static void nxmq_sndtimeout(int argc, wdparm_t pid)
+static void nxmq_sndtimeout(int argc, wdparm_t pid, ...)
 {
   FAR struct tcb_s *wtcb;
   irqstate_t flags;
@@ -256,8 +256,7 @@ int nxmq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen,
 
   /* Start the watchdog and begin the wait for MQ not full */
 
-  wd_start(rtcb->waitdog, ticks, (wdentry_t)nxmq_sndtimeout,
-           1, getpid());
+  wd_start(rtcb->waitdog, ticks, nxmq_sndtimeout, 1, getpid());
 
   /* And wait for the message queue to be non-empty */
 
diff --git a/sched/pthread/pthread_condtimedwait.c b/sched/pthread/pthread_condtimedwait.c
index 2bc81bd..6f14009 100644
--- a/sched/pthread/pthread_condtimedwait.c
+++ b/sched/pthread/pthread_condtimedwait.c
@@ -26,6 +26,7 @@
 #include <nuttx/compiler.h>
 
 #include <stdint.h>
+#include <stdarg.h>
 #include <unistd.h>
 #include <pthread.h>
 #include <signal.h>
@@ -67,61 +68,73 @@
  *
  ****************************************************************************/
 
-static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
+static void pthread_condtimedout(int argc, wdparm_t arg1, ...)
 {
-#ifdef HAVE_GROUP_MEMBERS
+  pid_t pid = (pid_t)arg1;
+  int signo;
+  va_list ap;
 
-  FAR struct tcb_s *tcb;
-  siginfo_t info;
+  /* Retrieve the variadic argument */
 
-  /* The logic below if equivalent to nxsig_queue(), but uses
-   * nxsig_tcbdispatch() instead of nxsig_dispatch().  This avoids the group
-   * signal deliver logic and assures, instead, that the signal is delivered
-   * specifically to this thread that is known to be waiting on the signal.
-   */
+  va_start(ap, arg1);
+  signo = (int)va_arg(ap, wdparm_t);
+  va_end(ap);
 
-  /* Get the waiting TCB.  sched_gettcb() might return NULL if the task has
-   * exited for some reason.
-   */
-
-  tcb = sched_gettcb((pid_t)pid);
-  if (tcb)
+#ifdef HAVE_GROUP_MEMBERS
     {
-      /* Create the siginfo structure */
+      FAR struct tcb_s *tcb;
+      siginfo_t info;
+
+      /* The logic below if equivalent to nxsig_queue(), but uses
+       * nxsig_tcbdispatch() instead of nxsig_dispatch().  This avoids the
+       * group signal deliver logic and assures, instead, that the signal is
+       * delivered specifically to this thread that is known to be waiting on
+       * the signal.
+       */
+
+      /* Get the waiting TCB.  sched_gettcb() might return NULL if the task
+       * has exited for some reason.
+       */
+
+      tcb = sched_gettcb(pid);
+      if (tcb)
+        {
+          /* Create the siginfo structure */
 
-      info.si_signo           = signo;
-      info.si_code            = SI_QUEUE;
-      info.si_errno           = ETIMEDOUT;
-      info.si_value.sival_ptr = NULL;
+          info.si_signo           = signo;
+          info.si_code            = SI_QUEUE;
+          info.si_errno           = ETIMEDOUT;
+          info.si_value.sival_ptr = NULL;
 #ifdef CONFIG_SCHED_HAVE_PARENT
-      info.si_pid             = (pid_t)pid;
-      info.si_status          = OK;
+          info.si_pid             = pid;
+          info.si_status          = OK;
 #endif
 
-      /* Process the receipt of the signal.  The scheduler is not locked as
-       * is normally the case when this function is called because we are in
-       * a watchdog timer interrupt handler.
-       */
+          /* Process the receipt of the signal.  The scheduler is not locked
+           * as is normally the case when this function is called because we
+           * are in a watchdog timer interrupt handler.
+           */
 
-      nxsig_tcbdispatch(tcb, &info);
+          nxsig_tcbdispatch(tcb, &info);
+        }
     }
-
 #else /* HAVE_GROUP_MEMBERS */
-
-  /* Things are a little easier if there are not group members.  We can just
-   * use nxsig_queue().
-   */
+    {
+      /* Things are a little easier if there are not group members.  We can
+       *  just use nxsig_queue().
+       */
 
 #ifdef CONFIG_CAN_PASS_STRUCTS
-  union sigval value;
+      union sigval value;
 
-  /* Send the specified signal to the specified task. */
+      /* Send the specified signal to the specified task. */
 
-  value.sival_ptr = NULL;
-  nxsig_queue((int)pid, (int)signo, value);
+      value.sival_ptr = NULL;
+      nxsig_queue((int)pid, signo, value);
 #else
-  nxsig_queue((int)pid, (int)signo, NULL);
+      nxsig_queue((int)pid, signo, NULL);
 #endif
+    }
 
 #endif /* HAVE_GROUP_MEMBERS */
 }
@@ -276,9 +289,9 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond,
                       /* Start the watchdog */
 
                       wd_start(rtcb->waitdog, ticks,
-                               (wdentry_t)pthread_condtimedout,
-                               2, (uint32_t)mypid,
-                               (uint32_t)SIGCONDTIMEDOUT);
+                               pthread_condtimedout,
+                               2, (wdparm_t)mypid,
+                               (wdparm_t)SIGCONDTIMEDOUT);
 
                       /* Take the condition semaphore.  Do not restore
                        * interrupts until we return from the wait.  This is
diff --git a/sched/semaphore/sem_tickwait.c b/sched/semaphore/sem_tickwait.c
index e41c038..0bbfbf0 100644
--- a/sched/semaphore/sem_tickwait.c
+++ b/sched/semaphore/sem_tickwait.c
@@ -132,8 +132,7 @@ int nxsem_tickwait(FAR sem_t *sem, clock_t start, uint32_t delay)
 
   /* Start the watchdog with interrupts still disabled */
 
-  wd_start(rtcb->waitdog, delay, (wdentry_t)nxsem_timeout,
-           1, getpid());
+  wd_start(rtcb->waitdog, delay, nxsem_timeout, 1, getpid());
 
   /* Now perform the blocking wait */
 
diff --git a/sched/semaphore/sem_timedwait.c b/sched/semaphore/sem_timedwait.c
index e12d074..da7294f 100644
--- a/sched/semaphore/sem_timedwait.c
+++ b/sched/semaphore/sem_timedwait.c
@@ -175,8 +175,7 @@ int nxsem_timedwait(FAR sem_t *sem, FAR const struct timespec *abstime)
 
   /* Start the watchdog */
 
-  wd_start(rtcb->waitdog, ticks, (wdentry_t)nxsem_timeout,
-           1, getpid());
+  wd_start(rtcb->waitdog, ticks, nxsem_timeout, 1, getpid());
 
   /* Now perform the blocking wait.  If nxsem_wait() fails, the
    * negated errno value will be returned below.
diff --git a/sched/semaphore/sem_timeout.c b/sched/semaphore/sem_timeout.c
index b0cca95..b248ae9 100644
--- a/sched/semaphore/sem_timeout.c
+++ b/sched/semaphore/sem_timeout.c
@@ -71,7 +71,7 @@
  *
  ****************************************************************************/
 
-void nxsem_timeout(int argc, wdparm_t pid)
+void nxsem_timeout(int argc, wdparm_t pid, ...)
 {
   FAR struct tcb_s *wtcb;
   irqstate_t flags;
diff --git a/sched/semaphore/semaphore.h b/sched/semaphore/semaphore.h
index 7008db8..77cf8a8 100644
--- a/sched/semaphore/semaphore.h
+++ b/sched/semaphore/semaphore.h
@@ -75,7 +75,7 @@ void nxsem_wait_irq(FAR struct tcb_s *wtcb, int errcode);
 
 /* Handle semaphore timer expiration */
 
-void nxsem_timeout(int argc, wdparm_t pid);
+void nxsem_timeout(int argc, wdparm_t pid, ...);
 
 /* Recover semaphore resources with a task or thread is destroyed  */
 
diff --git a/sched/signal/sig_timedwait.c b/sched/signal/sig_timedwait.c
index 4ccc5e9..ad75792 100644
--- a/sched/signal/sig_timedwait.c
+++ b/sched/signal/sig_timedwait.c
@@ -87,7 +87,7 @@
  *
  ****************************************************************************/
 
-static void nxsig_timeout(int argc, wdparm_t itcb)
+static void nxsig_timeout(int argc, wdparm_t itcb, ...)
 {
 #ifdef CONFIG_SMP
   irqstate_t flags;
@@ -358,7 +358,7 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info,
               /* Start the watchdog */
 
               wd_start(rtcb->waitdog, waitticks,
-                       (wdentry_t)nxsig_timeout, 1, wdparm.pvarg);
+                       nxsig_timeout, 1, wdparm.pvarg);
 
               /* Now wait for either the signal or the watchdog, but
                * first, make sure this is not the idle task,
diff --git a/sched/timer/timer_settime.c b/sched/timer/timer_settime.c
index 33c8bce..92201d7 100644
--- a/sched/timer/timer_settime.c
+++ b/sched/timer/timer_settime.c
@@ -43,7 +43,7 @@
 static inline void timer_signotify(FAR struct posix_timer_s *timer);
 static inline void timer_restart(FAR struct posix_timer_s *timer,
                                  wdparm_t itimer);
-static void timer_timeout(int argc, wdparm_t itimer);
+static void timer_timeout(int argc, wdparm_t itimer, ...);
 
 /****************************************************************************
  * Private Functions
@@ -99,7 +99,7 @@ static inline void timer_restart(FAR struct posix_timer_s *timer,
     {
       timer->pt_last = timer->pt_delay;
       wd_start(timer->pt_wdog, timer->pt_delay,
-               (wdentry_t)timer_timeout, 1, itimer);
+               timer_timeout, 1, itimer);
     }
 }
 
@@ -123,7 +123,7 @@ static inline void timer_restart(FAR struct posix_timer_s *timer,
  *
  ****************************************************************************/
 
-static void timer_timeout(int argc, wdparm_t itimer)
+static void timer_timeout(int argc, wdparm_t itimer, ...)
 {
 #ifndef CONFIG_CAN_PASS_STRUCTS
   /* On many small machines, pointers are encoded and cannot be simply cast
@@ -355,7 +355,7 @@ int timer_settime(timer_t timerid, int flags,
        */
 
       timer->pt_last = delay;
-      ret = wd_start(timer->pt_wdog, delay, (wdentry_t)timer_timeout,
+      ret = wd_start(timer->pt_wdog, delay, timer_timeout,
                      1, (wdparm_t)timer);
       if (ret < 0)
         {