mirror of
https://github.com/apache/nuttx.git
synced 2026-06-03 22:20:31 +08:00
Squashed commit of the following:
Replace all calls to sigqueue() in the OS proper with calls to nxsig_queue() to avoid accessing the errno variable.
sched/signal: Add nxsig_queue() which is functionally equivalent to sigqueue() except that it does not modify the errno variable.
This commit is contained in:
@@ -58,9 +58,10 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
|
#include <nuttx/random.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/input/ajoystick.h>
|
#include <nuttx/input/ajoystick.h>
|
||||||
#include <nuttx/random.h>
|
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
@@ -376,10 +377,12 @@ static void ajoy_sample(FAR struct ajoy_upperhalf_s *priv)
|
|||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
union sigval value;
|
union sigval value;
|
||||||
value.sival_int = (int)sample;
|
value.sival_int = (int)sample;
|
||||||
(void)sigqueue(opriv->ao_pid, opriv->ao_notify.an_signo, value);
|
|
||||||
|
(void)nxsig_queue(opriv->ao_pid, opriv->ao_notify.an_signo,
|
||||||
|
value);
|
||||||
#else
|
#else
|
||||||
(void)sigqueue(opriv->ao_pid, opriv->ao_notify.dn.signo,
|
(void)nxsig_queue(opriv->ao_pid, opriv->ao_notify.dn.signo,
|
||||||
(FAR void *)sample);
|
(FAR void *)sample);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -54,9 +54,10 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
|
#include <nuttx/random.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/input/buttons.h>
|
#include <nuttx/input/buttons.h>
|
||||||
#include <nuttx/random.h>
|
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
@@ -358,10 +359,11 @@ static void btn_sample(FAR struct btn_upperhalf_s *priv)
|
|||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
union sigval value;
|
union sigval value;
|
||||||
value.sival_int = (int)sample;
|
value.sival_int = (int)sample;
|
||||||
(void)sigqueue(opriv->bo_pid, opriv->bo_notify.bn_signo, value);
|
(void)nxsig_queue(opriv->bo_pid, opriv->bo_notify.bn_signo,
|
||||||
|
value);
|
||||||
#else
|
#else
|
||||||
(void)sigqueue(opriv->bo_pid, opriv->bo_notify.dn.signo,
|
(void)nxsig_queue(opriv->bo_pid, opriv->bo_notify.dn.signo,
|
||||||
(FAR void *)sample);
|
(FAR void *)sample);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -58,9 +58,10 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
|
#include <nuttx/random.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/input/djoystick.h>
|
#include <nuttx/input/djoystick.h>
|
||||||
#include <nuttx/random.h>
|
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
|
||||||
@@ -376,10 +377,11 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv)
|
|||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
union sigval value;
|
union sigval value;
|
||||||
value.sival_int = (int)sample;
|
value.sival_int = (int)sample;
|
||||||
(void)sigqueue(opriv->do_pid, opriv->do_notify.dn_signo, value);
|
(void)nxsig_queue(opriv->do_pid, opriv->do_notify.dn_signo,
|
||||||
|
value);
|
||||||
#else
|
#else
|
||||||
(void)sigqueue(opriv->do_pid, opriv->do_notify.dn.signo,
|
(void)nxsig_queue(opriv->do_pid, opriv->do_notify.dn.signo,
|
||||||
(FAR void *)sample);
|
(FAR void *)sample);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/net/phy.h>
|
#include <nuttx/net/phy.h>
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_PHY_INTERRUPT
|
#ifdef CONFIG_ARCH_PHY_INTERRUPT
|
||||||
@@ -251,18 +252,14 @@ static int phy_handler(int irq, FAR void *context, FAR void *arg)
|
|||||||
|
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
value.sival_ptr = client->arg;
|
value.sival_ptr = client->arg;
|
||||||
ret = sigqueue(client->pid, client->signo, value);
|
ret = nxsig_queue(client->pid, client->signo, value);
|
||||||
#else
|
#else
|
||||||
ret = sigqueue(client->pid, client->signo, client->arg);
|
ret = nxsig_queue(client->pid, client->signo, client->arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
int errcode = errno;
|
nerr("ERROR: nxsig_queue failed: %d\n", ret);
|
||||||
DEBUGASSERT(errcode > 0);
|
|
||||||
|
|
||||||
nerr("ERROR: sigqueue failed: %d\n", errcode);
|
|
||||||
UNUSED(errcode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
+19
-16
@@ -52,8 +52,9 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/fs/fs.h>
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/sensors/zerocross.h>
|
#include <nuttx/sensors/zerocross.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
@@ -206,23 +207,23 @@ static void zerocross_interrupt(FAR const struct zc_lowerhalf_s *lower,
|
|||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
union sigval value;
|
union sigval value;
|
||||||
value.sival_int = (int)sample;
|
value.sival_int = (int)sample;
|
||||||
(void)sigqueue(opriv->do_pid, opriv->do_notify.zc_signo, value);
|
(void)nxsig_queue(opriv->do_pid, opriv->do_notify.zc_signo, value);
|
||||||
#else
|
#else
|
||||||
(void)sigqueue(opriv->do_pid, opriv->do_notify.zc_signo,
|
(void)nxsig_queue(opriv->do_pid, opriv->do_notify.zc_signo,
|
||||||
(FAR void *)sample);
|
(FAR void *)sample);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: zc_open
|
* Name: zc_open
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This function is called whenever the PWM device is opened.
|
* This function is called whenever the PWM device is opened.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int zc_open(FAR struct file *filep)
|
static int zc_open(FAR struct file *filep)
|
||||||
{
|
{
|
||||||
@@ -271,13 +272,13 @@ errout_with_sem:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: zc_close
|
* Name: zc_close
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This function is called when the PWM device is closed.
|
* This function is called when the PWM device is closed.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int zc_close(FAR struct file *filep)
|
static int zc_close(FAR struct file *filep)
|
||||||
{
|
{
|
||||||
@@ -366,43 +367,45 @@ errout_with_exclsem:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: zc_read
|
* Name: zc_read
|
||||||
*
|
*
|
||||||
* Description:O
|
* Description:O
|
||||||
* A dummy read method. This is provided only to satsify the VFS layer.
|
* A dummy read method. This is provided only to satsify the VFS layer.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t zc_read(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
static ssize_t zc_read(FAR struct file *filep, FAR char *buffer,
|
||||||
|
size_t buflen)
|
||||||
{
|
{
|
||||||
/* Return zero -- usually meaning end-of-file */
|
/* Return zero -- usually meaning end-of-file */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: zc_write
|
* Name: zc_write
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A dummy write method. This is provided only to satsify the VFS layer.
|
* A dummy write method. This is provided only to satsify the VFS layer.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static ssize_t zc_write(FAR struct file *filep, FAR const char *buffer, size_t buflen)
|
static ssize_t zc_write(FAR struct file *filep, FAR const char *buffer,
|
||||||
|
size_t buflen)
|
||||||
{
|
{
|
||||||
/* Return a failure */
|
/* Return a failure */
|
||||||
|
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* Name: zc_ioctl
|
* Name: zc_ioctl
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* The standard ioctl method. This is where ALL of the PWM work is done.
|
* The standard ioctl method. This is where ALL of the PWM work is done.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int zc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
static int zc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/timers/oneshot.h>
|
#include <nuttx/timers/oneshot.h>
|
||||||
|
|
||||||
@@ -139,9 +140,9 @@ static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower,
|
|||||||
|
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
value.sival_ptr = priv->od_arg;
|
value.sival_ptr = priv->od_arg;
|
||||||
(void)sigqueue(priv->od_pid, priv->od_signo, value);
|
(void)nxsig_queue(priv->od_pid, priv->od_signo, value);
|
||||||
#else
|
#else
|
||||||
(void)sigqueue(priv->od_pid, priv->od_signo, priv->od_arg);
|
(void)nxsig_queue(priv->od_pid, priv->od_signo, priv->od_arg);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/timers/rtc.c
|
* drivers/timers/rtc.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/timers/rtc.h>
|
#include <nuttx/timers/rtc.h>
|
||||||
|
|
||||||
@@ -188,11 +189,11 @@ static void rtc_alarm_callback(FAR void *priv, int alarmid)
|
|||||||
/* Yes.. signal the alarm expriration */
|
/* Yes.. signal the alarm expriration */
|
||||||
|
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
(void)sigqueue(alarminfo->pid, alarminfo->signo,
|
(void)nxsig_queue(alarminfo->pid, alarminfo->signo,
|
||||||
alarminfo->sigvalue);
|
alarminfo->sigvalue);
|
||||||
#else
|
#else
|
||||||
(void)sigqueue(alarminfo->pid, alarminfo->signo,
|
(void)nxsig_queue(alarminfo->pid, alarminfo->signo,
|
||||||
alarminfo->sigvalue->sival_ptr);
|
alarminfo->sigvalue->sival_ptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/timers/timer.c
|
* drivers/timers/timer.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2014, 2016-2017 Gregory Nutt. All rights reserved.
|
||||||
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
* Authors: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Bob Doiron
|
* Bob Doiron
|
||||||
*
|
*
|
||||||
@@ -51,9 +51,10 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/fs/fs.h>
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/timers/timer.h>
|
#include <nuttx/timers/timer.h>
|
||||||
|
|
||||||
#ifdef CONFIG_TIMER
|
#ifdef CONFIG_TIMER
|
||||||
@@ -138,9 +139,9 @@ static bool timer_notifier(FAR uint32_t *next_interval_us, FAR void *arg)
|
|||||||
|
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
value.sival_ptr = upper->arg;
|
value.sival_ptr = upper->arg;
|
||||||
(void)sigqueue(upper->pid, upper->signo, value);
|
(void)nxsig_queue(upper->pid, upper->signo, value);
|
||||||
#else
|
#else
|
||||||
(void)sigqueue(upper->pid, upper->signo, upper->arg);
|
(void)nxsig_queue(upper->pid, upper->signo, upper->arg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/wqueue.h>
|
#include <nuttx/wqueue.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/mm/iob.h>
|
#include <nuttx/mm/iob.h>
|
||||||
#include <nuttx/net/arp.h>
|
#include <nuttx/net/arp.h>
|
||||||
#include <nuttx/net/netdev.h>
|
#include <nuttx/net/netdev.h>
|
||||||
@@ -494,10 +495,11 @@ static void xbeenet_notify(FAR struct xbee_maccb_s *maccb,
|
|||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
union sigval value;
|
union sigval value;
|
||||||
value.sival_int = (int)notif->notiftype;
|
value.sival_int = (int)notif->notiftype;
|
||||||
(void)sigqueue(priv->xd_notify_pid, priv->xd_notify_signo, value);
|
(void)nxsig_queue(priv->xd_notify_pid, priv->xd_notify_signo,
|
||||||
|
value);
|
||||||
#else
|
#else
|
||||||
(void)sigqueue(priv->xd_notify_pid, priv->xd_notify_signo,
|
(void)nxsig_queue(priv->xd_notify_pid, priv->xd_notify_signo,
|
||||||
(FAR void *)notif->notiftype);
|
(FAR void *)notif->notiftype);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+15
-14
@@ -47,6 +47,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/signal.h>
|
||||||
|
|
||||||
#include "aio/aio.h"
|
#include "aio/aio.h"
|
||||||
|
|
||||||
#ifdef CONFIG_FS_AIO
|
#ifdef CONFIG_FS_AIO
|
||||||
@@ -80,7 +82,6 @@ int aio_signal(pid_t pid, FAR struct aiocb *aiocbp)
|
|||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
union sigval value;
|
union sigval value;
|
||||||
#endif
|
#endif
|
||||||
int errcode;
|
|
||||||
int status;
|
int status;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -93,17 +94,15 @@ int aio_signal(pid_t pid, FAR struct aiocb *aiocbp)
|
|||||||
if (aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL)
|
if (aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
status = sigqueue(pid, aiocbp->aio_sigevent.sigev_signo,
|
ret = nxsig_queue(pid, aiocbp->aio_sigevent.sigev_signo,
|
||||||
aiocbp->aio_sigevent.sigev_value);
|
aiocbp->aio_sigevent.sigev_value);
|
||||||
#else
|
#else
|
||||||
status = sigqueue(pid, aiocbp->aio_sigevent.sigev_sign,
|
ret = nxsig_queue(pid, aiocbp->aio_sigevent.sigev_sign,
|
||||||
aiocbp->aio_sigevent.sigev_value.sival_ptr);
|
aiocbp->aio_sigevent.sigev_value.sival_ptr);
|
||||||
#endif
|
#endif
|
||||||
if (status < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
errcode = get_errno();
|
ferr("ERROR: nxsig_queue #1 failed: %d\n", ret);
|
||||||
ferr("ERROR: sigqueue #1 failed: %d\n", errcode);
|
|
||||||
ret = ERROR;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,22 +125,24 @@ int aio_signal(pid_t pid, FAR struct aiocb *aiocbp)
|
|||||||
|
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
value.sival_ptr = aiocbp;
|
value.sival_ptr = aiocbp;
|
||||||
status = sigqueue(pid, SIGPOLL, value);
|
status = nxsig_queue(pid, SIGPOLL, value);
|
||||||
#else
|
#else
|
||||||
status = sigqueue(pid, SIGPOLL, aiocbp);
|
status = nxsig_queue(pid, SIGPOLL, aiocbp);
|
||||||
#endif
|
#endif
|
||||||
if (status && ret == OK)
|
if (status < 0)
|
||||||
{
|
{
|
||||||
errcode = get_errno();
|
ferr("ERROR: nxsig_queue #2 failed: %d\n", status);
|
||||||
ferr("ERROR: sigqueue #2 failed: %d\n", errcode);
|
if (ret >= OK)
|
||||||
ret = ERROR;
|
{
|
||||||
|
ret = status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure that errno is set correctly on return */
|
/* Make sure that errno is set correctly on return */
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
set_errno(errcode);
|
set_errno(-ret);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,47 @@
|
|||||||
|
|
||||||
struct timespec; /* Forward reference */
|
struct timespec; /* Forward reference */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: nxsig_queue
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function sends the signal specified by signo with the signal
|
||||||
|
* parameter value to the process specified by pid.
|
||||||
|
*
|
||||||
|
* If the receiving process has the signal blocked via the sigprocmask,
|
||||||
|
* the signal will pend until it is unmasked. Only one pending signal (per
|
||||||
|
* signo) is retained. This is consistent with POSIX which states, "If
|
||||||
|
* a subsequent occurrence of a pending signal is generated, it is
|
||||||
|
* implementation defined as to whether the signal is delivered more than
|
||||||
|
* once.
|
||||||
|
*
|
||||||
|
* This is an internal OS interface. It is functionally equivalent to
|
||||||
|
* sigqueue() except that it does not modify the errno value.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* pid - Process ID of task to receive signal
|
||||||
|
* signo - Signal number
|
||||||
|
* value - Value to pass to task with signal
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* This is an internal OS interface and should not be used by applications.
|
||||||
|
* It follows the NuttX internal error return policy: Zero (OK) is
|
||||||
|
* returned on success. A negated errno value is returned on failure.
|
||||||
|
*
|
||||||
|
* EGAIN - The limit of signals which may be queued has been reached.
|
||||||
|
* EINVAL - sig was invalid.
|
||||||
|
* EPERM - The process does not have permission to send the
|
||||||
|
* signal to the receiving process.
|
||||||
|
* ESRCH - No process has a PID matching pid.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
|
int nxsig_queue (int pid, int signo, union sigval value);
|
||||||
|
#else
|
||||||
|
int nxsig_queue(int pid, int signo, void *sival_ptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxsig_kill
|
* Name: nxsig_kill
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/cancelpt.h>
|
#include <nuttx/cancelpt.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
@@ -88,10 +89,10 @@ static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
|
|||||||
FAR struct tcb_s *tcb;
|
FAR struct tcb_s *tcb;
|
||||||
siginfo_t info;
|
siginfo_t info;
|
||||||
|
|
||||||
/* The logic below if equivalent to sigqueue(), but uses nxsig_tcbdispatch()
|
/* The logic below if equivalent to nxsig_queue(), but uses
|
||||||
* instead of nxsig_dispatch(). This avoids the group signal deliver logic
|
* nxsig_tcbdispatch() instead of nxsig_dispatch(). This avoids the group
|
||||||
* and assures, instead, that the signal is delivered specifically to this
|
* signal deliver logic and assures, instead, that the signal is delivered
|
||||||
* thread that is known to be waiting on the signal.
|
* 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
|
/* Get the waiting TCB. sched_gettcb() might return NULL if the task has
|
||||||
@@ -123,7 +124,7 @@ static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
|
|||||||
#else /* HAVE_GROUP_MEMBERS */
|
#else /* HAVE_GROUP_MEMBERS */
|
||||||
|
|
||||||
/* Things are a little easier if there are not group members. We can just
|
/* Things are a little easier if there are not group members. We can just
|
||||||
* use sigqueue().
|
* use nxsig_queue().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
@@ -132,9 +133,9 @@ static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
|
|||||||
/* Send the specified signal to the specified task. */
|
/* Send the specified signal to the specified task. */
|
||||||
|
|
||||||
value.sival_ptr = NULL;
|
value.sival_ptr = NULL;
|
||||||
(void)sigqueue((int)pid, (int)signo, value);
|
(void)nxsig_queue((int)pid, (int)signo, value);
|
||||||
#else
|
#else
|
||||||
(void)sigqueue((int)pid, (int)signo, NULL);
|
(void)nxsig_queue((int)pid, (int)signo, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* HAVE_GROUP_MEMBERS */
|
#endif /* HAVE_GROUP_MEMBERS */
|
||||||
|
|||||||
@@ -45,6 +45,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/signal.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "signal/signal.h"
|
#include "signal/signal.h"
|
||||||
|
|
||||||
@@ -56,10 +58,11 @@
|
|||||||
* Name: nxsig_mqnotempty
|
* Name: nxsig_mqnotempty
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This function is equivalent to sigqueue(), but supports the messaging
|
* This function is equivalent to nxsig_queue(), but supports the
|
||||||
* system's requirement to signal a task when a message queue becomes
|
* messaging system's requirement to signal a task when a message queue
|
||||||
* non-empty. It is identical to sigqueue(), except that it sets the
|
* becomes non-empty. It is identical to nxsig_queue(), except that it
|
||||||
* si_code field in the siginfo structure to SI_MESGQ rather than SI_QUEUE.
|
* sets the si_code field in the siginfo structure to SI_MESGQ rather than
|
||||||
|
* SI_QUEUE.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|||||||
+75
-28
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* sched/signal/sig_queue.c
|
* sched/signal/sig_queue.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2013, 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -45,6 +45,8 @@
|
|||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/signal.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "signal/signal.h"
|
#include "signal/signal.h"
|
||||||
|
|
||||||
@@ -53,7 +55,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: sigqueue
|
* Name: nxsig_queue
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This function sends the signal specified by signo with the signal
|
* This function sends the signal specified by signo with the signal
|
||||||
@@ -64,7 +66,10 @@
|
|||||||
* signo) is retained. This is consistent with POSIX which states, "If
|
* signo) is retained. This is consistent with POSIX which states, "If
|
||||||
* a subsequent occurrence of a pending signal is generated, it is
|
* a subsequent occurrence of a pending signal is generated, it is
|
||||||
* implementation defined as to whether the signal is delivered more than
|
* implementation defined as to whether the signal is delivered more than
|
||||||
* once."
|
* once.
|
||||||
|
*
|
||||||
|
* This is an internal OS interface. It is functionally equivalent to
|
||||||
|
* sigqueue() except that it does not modify the errno value.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* pid - Process ID of task to receive signal
|
* pid - Process ID of task to receive signal
|
||||||
@@ -72,23 +77,22 @@
|
|||||||
* value - Value to pass to task with signal
|
* value - Value to pass to task with signal
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* On success (at least one signal was sent), zero is returned. On
|
* This is an internal OS interface and should not be used by applications.
|
||||||
* error, -1 is returned, and errno is set appropriately:
|
* It follows the NuttX internal error return policy: Zero (OK) is
|
||||||
|
* returned on success. A negated errno value is returned on failure.
|
||||||
*
|
*
|
||||||
* EGAIN The limit of signals which may be queued has been reached.
|
* EGAIN - The limit of signals which may be queued has been reached.
|
||||||
* EINVAL sig was invalid.
|
* EINVAL - sig was invalid.
|
||||||
* EPERM The process does not have permission to send the
|
* EPERM - The process does not have permission to send the
|
||||||
* signal to the receiving process.
|
* signal to the receiving process.
|
||||||
* ESRCH No process has a PID matching pid.
|
* ESRCH - No process has a PID matching pid.
|
||||||
*
|
|
||||||
* Assumptions:
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
int sigqueue (int pid, int signo, union sigval value)
|
int nxsig_queue (int pid, int signo, union sigval value)
|
||||||
#else
|
#else
|
||||||
int sigqueue(int pid, int signo, void *sival_ptr)
|
int nxsig_queue(int pid, int signo, void *sival_ptr)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SCHED_HAVE_PARENT
|
#ifdef CONFIG_SCHED_HAVE_PARENT
|
||||||
@@ -107,8 +111,7 @@ int sigqueue(int pid, int signo, void *sival_ptr)
|
|||||||
|
|
||||||
if (!GOOD_SIGNO(signo))
|
if (!GOOD_SIGNO(signo))
|
||||||
{
|
{
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto errout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the siginfo structure */
|
/* Create the siginfo structure */
|
||||||
@@ -132,17 +135,61 @@ int sigqueue(int pid, int signo, void *sival_ptr)
|
|||||||
ret = nxsig_dispatch(pid, &info);
|
ret = nxsig_dispatch(pid, &info);
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
|
|
||||||
/* Check for errors */
|
return ret;
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
|
|
||||||
errout:
|
|
||||||
set_errno(-ret);
|
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: sigqueue
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* This function sends the signal specified by signo with the signal
|
||||||
|
* parameter value to the process specified by pid.
|
||||||
|
*
|
||||||
|
* If the receiving process has the signal blocked via the sigprocmask,
|
||||||
|
* the signal will pend until it is unmasked. Only one pending signal (per
|
||||||
|
* signo) is retained. This is consistent with POSIX which states, "If
|
||||||
|
* a subsequent occurrence of a pending signal is generated, it is
|
||||||
|
* implementation defined as to whether the signal is delivered more than
|
||||||
|
* once."
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* pid - Process ID of task to receive signal
|
||||||
|
* signo - Signal number
|
||||||
|
* value - Value to pass to task with signal
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* On success (at least one signal was sent), zero (OK) is returned. On
|
||||||
|
* any failure, -1 (ERROR) is returned and errno varaible is set
|
||||||
|
* appropriately:
|
||||||
|
*
|
||||||
|
* EGAIN - The limit of signals which may be queued has been reached.
|
||||||
|
* EINVAL - sig was invalid.
|
||||||
|
* EPERM - The process does not have permission to send the
|
||||||
|
* signal to the receiving process.
|
||||||
|
* ESRCH - No process has a PID matching pid.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
|
int sigqueue (int pid, int signo, union sigval value)
|
||||||
|
#else
|
||||||
|
int sigqueue(int pid, int signo, void *sival_ptr)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Let nxsig_queue() do all of the real work */
|
||||||
|
|
||||||
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
|
ret = nxsig_queue(pid, signo, value);
|
||||||
|
#else
|
||||||
|
ret = nxsig_queue(pid, signo, sival_ptr);
|
||||||
|
#endif
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
set_errno(-ret);
|
||||||
|
ret = ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ static void nxsig_timeout(int argc, wdparm_t itcb)
|
|||||||
* If the info argument is non-NULL, the selected signal number is stored
|
* If the info argument is non-NULL, the selected signal number is stored
|
||||||
* in the si_signo member and the cause of the signal is store din the
|
* in the si_signo member and the cause of the signal is store din the
|
||||||
* si_code member. The content of si_value is only meaningful if the
|
* si_code member. The content of si_value is only meaningful if the
|
||||||
* signal was generated by sigqueue().
|
* signal was generated by sigqueue() (or nxsig_queue).
|
||||||
*
|
*
|
||||||
* This is an internal OS interface. It is functionally equivalent to
|
* This is an internal OS interface. It is functionally equivalent to
|
||||||
* sigtimedwait() except that:
|
* sigtimedwait() except that:
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ static void timer_timeout(int argc, wdparm_t itimer);
|
|||||||
* Name: timer_signotify
|
* Name: timer_signotify
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* This function basically reimplements sigqueue() so that the si_code can
|
* This function basically reimplements nxsig_queue() so that the si_code
|
||||||
* be correctly set to SI_TIMER
|
* can be correctly set to SI_TIMER
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* timer - A reference to the POSIX timer that just timed out
|
* timer - A reference to the POSIX timer that just timed out
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/mm/iob.h>
|
#include <nuttx/mm/iob.h>
|
||||||
|
|
||||||
#include <nuttx/wireless/ieee802154/ieee802154_device.h>
|
#include <nuttx/wireless/ieee802154/ieee802154_device.h>
|
||||||
@@ -792,10 +792,11 @@ static void mac802154dev_notify(FAR struct mac802154_maccb_s *maccb,
|
|||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
union sigval value;
|
union sigval value;
|
||||||
value.sival_int = (int)notif->notiftype;
|
value.sival_int = (int)notif->notiftype;
|
||||||
(void)sigqueue(dev->md_notify_pid, dev->md_notify_signo, value);
|
(void)nxsig_queue(dev->md_notify_pid, dev->md_notify_signo,
|
||||||
|
value);
|
||||||
#else
|
#else
|
||||||
(void)sigqueue(dev->md_notify_pid, dev->md_notify_signo,
|
(void)nxsig_queue(dev->md_notify_pid, dev->md_notify_signo,
|
||||||
(FAR void *)notif->notiftype);
|
(FAR void *)notif->notiftype);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
|
#include <nuttx/signal.h>
|
||||||
#include <nuttx/wdog.h>
|
#include <nuttx/wdog.h>
|
||||||
#include <nuttx/wqueue.h>
|
#include <nuttx/wqueue.h>
|
||||||
#include <nuttx/mm/iob.h>
|
#include <nuttx/mm/iob.h>
|
||||||
@@ -493,10 +494,11 @@ static void macnet_notify(FAR struct mac802154_maccb_s *maccb,
|
|||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
union sigval value;
|
union sigval value;
|
||||||
value.sival_int = (int)notif->notiftype;
|
value.sival_int = (int)notif->notiftype;
|
||||||
(void)sigqueue(priv->md_notify_pid, priv->md_notify_signo, value);
|
(void)nxsig_queue(priv->md_notify_pid, priv->md_notify_signo,
|
||||||
|
value);
|
||||||
#else
|
#else
|
||||||
(void)sigqueue(priv->md_notify_pid, priv->md_notify_signo,
|
(void)nxsig_queue(priv->md_notify_pid, priv->md_notify_signo,
|
||||||
(FAR void *)notif->notiftype);
|
(FAR void *)notif->notiftype);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user