Skip to content

Commit

Permalink
Remove type casting to wdentry_t (sched/)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuuichiNakamura authored and patacongo committed Apr 7, 2020
1 parent 81b286d commit 3cc336d
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 58 deletions.
5 changes: 2 additions & 3 deletions sched/mqueue/mq_timedreceive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
5 changes: 2 additions & 3 deletions sched/mqueue/mq_timedsend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */

Expand Down
93 changes: 53 additions & 40 deletions sched/pthread/pthread_condtimedwait.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <nuttx/compiler.h>

#include <stdint.h>
#include <stdarg.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
Expand Down Expand Up @@ -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 */
}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions sched/semaphore/sem_tickwait.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
3 changes: 1 addition & 2 deletions sched/semaphore/sem_timedwait.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion sched/semaphore/sem_timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion sched/semaphore/semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
4 changes: 2 additions & 2 deletions sched/signal/sig_timedwait.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions sched/timer/timer_settime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 3cc336d

Please sign in to comment.