Remove type casting to wdentry_t (sched/)

This commit is contained in:
Nakamura, Yuuichi 2020-03-13 15:44:16 +09:00 committed by patacongo
parent 81b286d375
commit 3cc336dddd
9 changed files with 71 additions and 62 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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, ...)
{
pid_t pid = (pid_t)arg1;
int signo;
va_list ap;
/* Retrieve the variadic argument */
va_start(ap, arg1);
signo = (int)va_arg(ap, wdparm_t);
va_end(ap);
#ifdef HAVE_GROUP_MEMBERS
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_t)pid);
if (tcb)
{
/* Create the siginfo structure */
FAR struct tcb_s *tcb;
siginfo_t info;
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;
#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.
/* 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.
*/
nxsig_tcbdispatch(tcb, &info);
/* 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;
#ifdef CONFIG_SCHED_HAVE_PARENT
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.
*/
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

View File

@ -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 */

View File

@ -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.

View File

@ -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;

View File

@ -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 */

View File

@ -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,

View File

@ -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)
{