diff --git a/drivers/input/ajoystick.c b/drivers/input/ajoystick.c index ce8fea13007e0..4f37e89e280ab 100644 --- a/drivers/input/ajoystick.c +++ b/drivers/input/ajoystick.c @@ -84,9 +84,11 @@ struct ajoy_open_s /* Joystick event notification information */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS pid_t ao_pid; struct ajoy_notify_s ao_notify; struct sigwork_s ao_work; +#endif /* Poll event information */ @@ -173,8 +175,10 @@ static void ajoy_enable(FAR struct ajoy_upperhalf_s *priv) /* OR in the signal events */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS press |= opriv->ao_notify.an_press; release |= opriv->ao_notify.an_release; +#endif } /* Enable/disable button interrupts */ @@ -271,6 +275,7 @@ static void ajoy_sample(FAR struct ajoy_upperhalf_s *priv) /* Have any signal events occurred? */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS if ((press & opriv->ao_notify.an_press) != 0 || (release & opriv->ao_notify.an_release) != 0) { @@ -280,6 +285,7 @@ static void ajoy_sample(FAR struct ajoy_upperhalf_s *priv) nxsig_notification(opriv->ao_pid, &opriv->ao_notify.an_event, SI_QUEUE, &opriv->ao_work); } +#endif } priv->au_sample = sample; @@ -394,7 +400,9 @@ static int ajoy_close(FAR struct file *filep) /* Cancel any pending notification */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS nxsig_cancel_notification(&opriv->ao_work); +#endif /* And free the open structure */ @@ -545,6 +553,7 @@ static int ajoy_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * failure with the errno value set appropriately. */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS case AJOYIOC_REGISTER: { FAR struct ajoy_notify_s *notify = @@ -566,6 +575,7 @@ static int ajoy_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } } break; +#endif default: ierr("ERROR: Unrecognized command: %ld\n", cmd); diff --git a/drivers/input/button_upper.c b/drivers/input/button_upper.c index 6a871ff2c7b31..133758eb99ecc 100644 --- a/drivers/input/button_upper.c +++ b/drivers/input/button_upper.c @@ -85,9 +85,11 @@ struct btn_open_s /* Button event notification information */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS pid_t bo_pid; struct btn_notify_s bo_notify; struct sigwork_s bo_work; +#endif /* Poll event information */ @@ -297,6 +299,7 @@ static void btn_sample(wdparm_t arg) /* Have any signal events occurred? */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS if ((press & opriv->bo_notify.bn_press) != 0 || (release & opriv->bo_notify.bn_release) != 0) { @@ -306,6 +309,7 @@ static void btn_sample(wdparm_t arg) nxsig_notification(opriv->bo_pid, &opriv->bo_notify.bn_event, SI_QUEUE, &opriv->bo_work); } +#endif } priv->bu_sample = sample; diff --git a/drivers/input/djoystick.c b/drivers/input/djoystick.c index 1db52b2022b64..7b8d6781406dc 100644 --- a/drivers/input/djoystick.c +++ b/drivers/input/djoystick.c @@ -84,9 +84,11 @@ struct djoy_open_s /* Joystick event notification information */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS pid_t do_pid; struct djoy_notify_s do_notify; struct sigwork_s do_work; +#endif /* Poll event information */ @@ -172,9 +174,10 @@ static void djoy_enable(FAR struct djoy_upperhalf_s *priv) release |= opriv->do_pollevents.dp_release; /* OR in the signal events */ - +#ifndef CONFIG_DISABLE_ALL_SIGNALS press |= opriv->do_notify.dn_press; release |= opriv->do_notify.dn_release; +#endif } /* Enable/disable button interrupts */ @@ -271,6 +274,7 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv) /* Have any signal events occurred? */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS if ((press & opriv->do_notify.dn_press) != 0 || (release & opriv->do_notify.dn_release) != 0) { @@ -280,6 +284,7 @@ static void djoy_sample(FAR struct djoy_upperhalf_s *priv) nxsig_notification(opriv->do_pid, &opriv->do_notify.dn_event, SI_QUEUE, &opriv->do_work); } +#endif } priv->du_sample = sample; @@ -541,6 +546,7 @@ static int djoy_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * failure with the errno value set appropriately. */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS case DJOYIOC_REGISTER: { FAR struct djoy_notify_s *notify = @@ -562,6 +568,7 @@ static int djoy_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } } break; +#endif default: ierr("ERROR: Unrecognized command: %d\n", cmd); diff --git a/drivers/ioexpander/Kconfig b/drivers/ioexpander/Kconfig index 95133b576d658..1bd2cd89283c0 100644 --- a/drivers/ioexpander/Kconfig +++ b/drivers/ioexpander/Kconfig @@ -598,7 +598,7 @@ config DEV_GPIO_NPOLLWAITERS config DEV_GPIO_NSIGNALS int "Max number of signals" default 1 - depends on DEV_GPIO + depends on DEV_GPIO && !DISABLE_ALL_SIGNALS ---help--- The maximum number of signals that can be registered with the GPIO driver diff --git a/drivers/lcd/ft80x.c b/drivers/lcd/ft80x.c index 98a8efd7f01c6..495d987d9c8ae 100644 --- a/drivers/lcd/ft80x.c +++ b/drivers/lcd/ft80x.c @@ -258,6 +258,11 @@ static int ft80x_fade(FAR struct ft80x_dev_s *priv, static void ft80x_notify(FAR struct ft80x_dev_s *priv, enum ft80x_notify_e id, int value) { +#ifdef CONFIG_DISABLE_ALL_SIGNALS + UNUSED(priv); + UNUSED(id); + UNUSED(value); +#else FAR struct ft80x_eventinfo_s *info = &priv->notify[id]; /* Are notifications enabled for this event? */ @@ -271,6 +276,7 @@ static void ft80x_notify(FAR struct ft80x_dev_s *priv, info->event.sigev_value.sival_int = value; nxsig_notification(info->pid, &info->event, SI_QUEUE, &info->work); } +#endif } /**************************************************************************** @@ -997,6 +1003,7 @@ static int ft80x_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * Returns: None */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS case FT80X_IOC_EVENTNOTIFY: { FAR struct ft80x_notify_s *notify = @@ -1059,7 +1066,7 @@ static int ft80x_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } } break; - +#endif /* FT80X_IOC_FADE: * Description: Change the backlight intensity with a controllable * fade. diff --git a/drivers/lcd/ft80x.h b/drivers/lcd/ft80x.h index 681cdceda8d60..8725110191ae8 100644 --- a/drivers/lcd/ft80x.h +++ b/drivers/lcd/ft80x.h @@ -188,7 +188,9 @@ struct ft80x_dev_s /* Event notification support */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS struct ft80x_eventinfo_s notify[FT80X_INT_NEVENTS]; +#endif }; /**************************************************************************** diff --git a/drivers/modem/alt1250/CMakeLists.txt b/drivers/modem/alt1250/CMakeLists.txt index 443f02aa3fc56..6c01209a13b13 100644 --- a/drivers/modem/alt1250/CMakeLists.txt +++ b/drivers/modem/alt1250/CMakeLists.txt @@ -40,8 +40,11 @@ if(CONFIG_MODEM_ALT1250) altcom_errno.c altmdm.c altmdm_event.c - altmdm_spi.c - altmdm_timer.c) + altmdm_spi.c) + + if(NOT CONFIG_DISABLE_ALL_SIGNALS) + list(APPEND SRCS altmdm_timer.c) + endif() target_sources(drivers PRIVATE ${SRCS}) endif() diff --git a/drivers/modem/alt1250/Make.defs b/drivers/modem/alt1250/Make.defs index 26ce27f06f7e4..9c9cff8d912c9 100644 --- a/drivers/modem/alt1250/Make.defs +++ b/drivers/modem/alt1250/Make.defs @@ -42,7 +42,9 @@ CSRCS += altcom_errno.c CSRCS += altmdm.c CSRCS += altmdm_event.c CSRCS += altmdm_spi.c -CSRCS += altmdm_timer.c + ifneq ($(CONFIG_DISABLE_ALL_SIGNALS),y) + CSRCS += altmdm_timer.c + endif endif DEPPATH += --dep-path modem$(DELIM)alt1250 diff --git a/drivers/modem/alt1250/altmdm_timer.h b/drivers/modem/alt1250/altmdm_timer.h index 58f67d916bb3f..f7cc4412093d7 100644 --- a/drivers/modem/alt1250/altmdm_timer.h +++ b/drivers/modem/alt1250/altmdm_timer.h @@ -32,6 +32,7 @@ #include #include +#ifndef CONFIG_DISABLE_ALL_SIGNALS /**************************************************************************** * Public Function Prototypes ****************************************************************************/ @@ -109,5 +110,5 @@ int altmdm_timer_is_running(timer_t timerid); ****************************************************************************/ void altmdm_timer_stop(timer_t timerid); - +#endif /* !CONFIG_DISABLE_ALL_SIGNALS */ #endif /* __DEVICES_MODEM_ALT1250_ALTMDM_TIMER_H */ diff --git a/drivers/net/phy_notify.c b/drivers/net/phy_notify.c index 6276dddd2902c..6680b68b17f8f 100644 --- a/drivers/net/phy_notify.c +++ b/drivers/net/phy_notify.c @@ -226,12 +226,14 @@ static int phy_handler(int irq, FAR void *context, FAR void *arg) /* Signal the client that the PHY has something interesting to say to us */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS ret = nxsig_notification(client->pid, &client->event, SI_QUEUE, &client->work); if (ret < 0) { phyerr("ERROR: nxsig_notification failed: %d\n", ret); } +#endif return OK; } diff --git a/drivers/sensors/zerocross.c b/drivers/sensors/zerocross.c index 22b1fea2f0667..841b1d35f86ea 100644 --- a/drivers/sensors/zerocross.c +++ b/drivers/sensors/zerocross.c @@ -81,10 +81,11 @@ struct zc_open_s volatile bool do_closing; /* Zero cross event notification information */ - +#ifndef CONFIG_DISABLE_ALL_SIGNALS pid_t do_pid; struct sigevent do_event; struct sigwork_s do_work; +#endif }; /**************************************************************************** @@ -175,6 +176,7 @@ static void zerocross_interrupt(FAR const struct zc_lowerhalf_s *lower, /* Visit each opened reference and notify a zero cross event */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS for (opriv = priv->zu_open; opriv; opriv = opriv->do_flink) { /* Signal the waiter */ @@ -183,6 +185,7 @@ static void zerocross_interrupt(FAR const struct zc_lowerhalf_s *lower, nxsig_notification(opriv->do_pid, &opriv->do_event, SI_QUEUE, &opriv->do_work); } +#endif leave_critical_section(flags); } @@ -415,6 +418,7 @@ static int zc_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * failure with the errno value set appropriately. */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS case ZCIOC_REGISTER: { FAR struct sigevent *event = @@ -434,6 +438,7 @@ static int zc_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } } break; +#endif default: { diff --git a/drivers/timers/Kconfig b/drivers/timers/Kconfig index 2c796d10c50d4..14d3c2df34bdb 100644 --- a/drivers/timers/Kconfig +++ b/drivers/timers/Kconfig @@ -97,6 +97,7 @@ if CAPTURE config CAPTURE_NOTIFY bool "Capture Notification Support" default n + depends on !DISABLE_ALL_SIGNALS ---help--- Some hardware will support notification when a capture event occurs. If the hardware will support notification, then this @@ -239,6 +240,7 @@ endif # !RTC_DATETIME config RTC_ALARM bool "RTC Alarm Support" default n + depends on !DISABLE_ALL_SIGNALS ---help--- Enable if the RTC hardware supports setting of an alarm. A callback function will be executed when the alarm goes off. @@ -269,6 +271,7 @@ config RTC_ARCH config RTC_PERIODIC bool "RTC Periodic Interrupts" default n + depends on !DISABLE_ALL_SIGNALS ---help--- Add interrupt controls for RTCs that support periodic interrupts. diff --git a/drivers/timers/oneshot.c b/drivers/timers/oneshot.c index 4dc15c440a6f3..318221c019a2c 100644 --- a/drivers/timers/oneshot.c +++ b/drivers/timers/oneshot.c @@ -54,9 +54,11 @@ struct oneshot_dev_s /* Oneshot timer expiration notification information */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS struct sigevent od_event; /* Signal info */ struct sigwork_s od_work; /* Signal work */ pid_t od_pid; /* PID to be notified */ +#endif }; /**************************************************************************** @@ -70,8 +72,10 @@ static ssize_t oneshot_write(FAR struct file *filep, FAR const char *buffer, static int oneshot_ioctl(FAR struct file *filep, int cmd, unsigned long arg); +#ifndef CONFIG_DISABLE_ALL_SIGNALS static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower, FAR void *arg); +#endif /**************************************************************************** * Private Data @@ -95,6 +99,7 @@ static const struct file_operations g_oneshot_ops = * Name: oneshot_callback ****************************************************************************/ +#ifndef CONFIG_DISABLE_ALL_SIGNALS static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower, FAR void *arg) { @@ -107,6 +112,7 @@ static void oneshot_callback(FAR struct oneshot_lowerhalf_s *lower, nxsig_notification(priv->od_pid, &priv->od_event, SI_QUEUE, &priv->od_work); } +#endif /**************************************************************************** * Name: oneshot_read @@ -193,6 +199,7 @@ static int oneshot_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * Argument: A reference to struct oneshot_start_s */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS case OSIOC_START: { FAR struct oneshot_start_s *start; @@ -234,6 +241,7 @@ static int oneshot_ioctl(FAR struct file *filep, int cmd, unsigned long arg) nxsig_cancel_notification(&priv->od_work); } break; +#endif /* OSIOC_CURRENT - Get the current time * Argument: A reference to a struct timespec in @@ -311,8 +319,10 @@ int oneshot_register(FAR const char *devname, priv->od_lower = lower; +#ifndef CONFIG_DISABLE_ALL_SIGNALS lower->callback = oneshot_callback; lower->arg = priv; +#endif nxmutex_init(&priv->od_lock); diff --git a/drivers/timers/timer.c b/drivers/timers/timer.c index 10b0e1b325b39..c9bb4fc11fd7b 100644 --- a/drivers/timers/timer.c +++ b/drivers/timers/timer.c @@ -61,8 +61,10 @@ struct timer_upperhalf_s /* The contained signal info */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS struct timer_notify_s notify; struct sigwork_s work; +#endif /* The contained lower-half driver */ @@ -116,6 +118,7 @@ static const struct file_operations g_timerops = * ****************************************************************************/ +#ifndef CONFIG_DISABLE_ALL_SIGNALS static bool timer_notifier(FAR uint32_t *next_interval_us, FAR void *arg) { FAR struct timer_upperhalf_s *upper = (FAR struct timer_upperhalf_s *)arg; @@ -131,6 +134,7 @@ static bool timer_notifier(FAR uint32_t *next_interval_us, FAR void *arg) return notify->periodic; } +#endif /**************************************************************************** * Name: timer_open @@ -381,6 +385,7 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * Argument: signal information */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS case TCIOC_NOTIFICATION: { FAR struct timer_notify_s *notify = @@ -398,6 +403,7 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } } break; +#endif /* cmd: TCIOC_MAXTIMEOUT * Description: Get the maximum supported timeout value diff --git a/drivers/wireless/ieee802154/xbee/xbee_netdev.c b/drivers/wireless/ieee802154/xbee/xbee_netdev.c index 69fb6c619f0ba..3d37e2351c853 100644 --- a/drivers/wireless/ieee802154/xbee/xbee_netdev.c +++ b/drivers/wireless/ieee802154/xbee/xbee_netdev.c @@ -136,10 +136,12 @@ struct xbeenet_driver_s /* MAC Service notification information */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS bool xd_notify_registered; pid_t xd_notify_pid; struct sigevent xd_notify_event; struct sigwork_s xd_notify_work; +#endif }; /**************************************************************************** @@ -410,12 +412,14 @@ static int xbeenet_notify(FAR struct xbee_maccb_s *maccb, nxsem_post(&priv->xd_eventsem); } +#ifndef CONFIG_DISABLE_ALL_SIGNALS if (priv->xd_notify_registered) { priv->xd_notify_event.sigev_value.sival_int = primitive->type; nxsig_notification(priv->xd_notify_pid, &priv->xd_notify_event, SI_QUEUE, &priv->xd_notify_work); } +#endif nxmutex_unlock(&priv->xd_lock); return OK; @@ -940,6 +944,7 @@ static int xbeenet_ioctl(FAR struct net_driver_s *dev, int cmd, * appropriately. */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS case MAC802154IOC_NOTIFY_REGISTER: { /* Save the notification events */ @@ -950,6 +955,7 @@ static int xbeenet_ioctl(FAR struct net_driver_s *dev, int cmd, ret = OK; } break; +#endif case MAC802154IOC_GET_EVENT: { @@ -1293,7 +1299,10 @@ int xbee_netdev_register(XBEEHANDLE xbee) sq_init(&priv->primitive_queue); priv->xd_enableevents = false; + +#ifndef CONFIG_DISABLE_ALL_SIGNALS priv->xd_notify_registered = false; +#endif /* Initialize the XBee MAC callbacks */ diff --git a/fs/Kconfig b/fs/Kconfig index 4ac276b6b5d05..ac9202e49a8c9 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -45,7 +45,7 @@ config FS_AUTOMOUNTER_DEBUG config FS_AUTOMOUNTER_DRIVER bool "Auto-mounter driver" default n - depends on FS_AUTOMOUNTER + depends on FS_AUTOMOUNTER && !DISABLE_ALL_SIGNALS ---help--- Enabling this option will lead to registering of a character driver on FS_AUTOMOUNTER_VFS_PATH + mount point path for auto-mounter. diff --git a/fs/aio/Kconfig b/fs/aio/Kconfig index d3561a5ee02b9..fa09b9a38cc97 100644 --- a/fs/aio/Kconfig +++ b/fs/aio/Kconfig @@ -6,7 +6,7 @@ config FS_AIO bool "Asynchronous I/O support" default n - depends on SCHED_WORKQUEUE + depends on SCHED_WORKQUEUE && !DISABLE_ALL_SIGNALS ---help--- Enable support for asynchronous I/O. This selection enables the interfaces declared in include/aio.h. diff --git a/libs/libc/pthread/CMakeLists.txt b/libs/libc/pthread/CMakeLists.txt index 4032cdecf56bd..96ff96e8225f0 100644 --- a/libs/libc/pthread/CMakeLists.txt +++ b/libs/libc/pthread/CMakeLists.txt @@ -76,7 +76,6 @@ if(NOT CONFIG_DISABLE_PTHREAD) pthread_create.c pthread_equal.c pthread_exit.c - pthread_kill.c pthread_setname_np.c pthread_getname_np.c pthread_get_stackaddr_np.c @@ -132,6 +131,10 @@ if(NOT CONFIG_DISABLE_PTHREAD) list(APPEND SRCS pthread_spinlock.c) endif() + if(NOT CONFIG_DISABLE_ALL_SIGNALS) + list(APPEND SRCS pthread_kill.c) + endif() + if(NOT CONFIG_TLS_NCLEANUP EQUAL 0) list(APPEND SRCS pthread_cleanup.c) endif() diff --git a/libs/libc/pthread/Make.defs b/libs/libc/pthread/Make.defs index b043230e23bf3..14a4200d0c875 100644 --- a/libs/libc/pthread/Make.defs +++ b/libs/libc/pthread/Make.defs @@ -47,7 +47,7 @@ CSRCS += pthread_condattr_getpshared.c pthread_condattr_setpshared.c CSRCS += pthread_condattr_setclock.c pthread_condattr_getclock.c CSRCS += pthread_condinit.c pthread_conddestroy.c pthread_condtimedwait.c CSRCS += pthread_equal.c pthread_condbroadcast.c pthread_condclockwait.c pthread_condsignal.c -CSRCS += pthread_condwait.c pthread_create.c pthread_exit.c pthread_kill.c +CSRCS += pthread_condwait.c pthread_create.c pthread_exit.c CSRCS += pthread_setname_np.c pthread_getname_np.c CSRCS += pthread_get_stackaddr_np.c pthread_get_stacksize_np.c CSRCS += pthread_mutexattr_init.c pthread_mutexattr_destroy.c @@ -69,6 +69,10 @@ CSRCS += pthread_testcancel.c pthread_getcpuclockid.c CSRCS += pthread_self.c pthread_gettid_np.c CSRCS += pthread_concurrency.c +ifneq ($(CONFIG_DISABLE_ALL_SIGNALS),y) +CSRCS += pthread_kill.c +endif + ifeq ($(CONFIG_SMP),y) CSRCS += pthread_attr_getaffinity.c pthread_attr_setaffinity.c endif diff --git a/libs/libc/pthread/pthread_mutex_destroy.c b/libs/libc/pthread/pthread_mutex_destroy.c index 8bfb6cf1686e6..6cbc7c306b688 100644 --- a/libs/libc/pthread/pthread_mutex_destroy.c +++ b/libs/libc/pthread/pthread_mutex_destroy.c @@ -90,6 +90,7 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex) * nxsched_get_tcb() does. */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS if (pthread_kill(pid, 0) != 0) { /* The thread associated with the PID no longer exists */ @@ -121,6 +122,7 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex) } } else +#endif { ret = EBUSY; } diff --git a/sched/signal/CMakeLists.txt b/sched/signal/CMakeLists.txt index 9db325fec5ed7..a9595309737d7 100644 --- a/sched/signal/CMakeLists.txt +++ b/sched/signal/CMakeLists.txt @@ -20,24 +20,25 @@ # # ############################################################################## +set(SRCS sig_nanosleep.c sig_usleep.c sig_sleep.c sig_clockwait.c) + if(NOT CONFIG_DISABLE_ALL_SIGNALS) - set(SRCS - sig_procmask.c - sig_suspend.c - sig_kill.c - sig_tgkill.c - sig_queue.c - sig_waitinfo.c - sig_timedwait.c - sig_lowest.c - sig_notification.c - sig_dispatch.c - sig_pause.c - sig_nanosleep.c - sig_usleep.c - sig_sleep.c - sig_ppoll.c - sig_pselect.c) + list( + APPEND + SRCS + sig_procmask.c + sig_suspend.c + sig_kill.c + sig_tgkill.c + sig_queue.c + sig_waitinfo.c + sig_timedwait.c + sig_lowest.c + sig_notification.c + sig_dispatch.c + sig_pause.c + sig_ppoll.c + sig_pselect.c) endif() if(CONFIG_ENABLE_ALL_SIGNALS) diff --git a/sched/signal/Make.defs b/sched/signal/Make.defs index b70ac2a8246f3..e1099a4ebc114 100644 --- a/sched/signal/Make.defs +++ b/sched/signal/Make.defs @@ -19,11 +19,14 @@ # under the License. # ############################################################################ + +CSRCS += sig_nanosleep.c sig_sleep.c sig_usleep.c sig_clockwait.c + ifneq ($(CONFIG_DISABLE_ALL_SIGNALS),y) -CSRCS += sig_dispatch.c sig_kill.c sig_lowest.c sig_nanosleep.c +CSRCS += sig_dispatch.c sig_kill.c sig_lowest.c CSRCS += sig_notification.c sig_pause.c sig_ppoll.c sig_procmask.c -CSRCS += sig_pselect.c sig_queue.c sig_sleep.c sig_suspend.c sig_tgkill.c -CSRCS += sig_timedwait.c sig_usleep.c sig_waitinfo.c +CSRCS += sig_pselect.c sig_queue.c sig_suspend.c sig_tgkill.c +CSRCS += sig_timedwait.c sig_waitinfo.c endif ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y) diff --git a/sched/signal/sig_clockwait.c b/sched/signal/sig_clockwait.c new file mode 100644 index 0000000000000..8d295be946874 --- /dev/null +++ b/sched/signal/sig_clockwait.c @@ -0,0 +1,297 @@ +/**************************************************************************** + * sched/signal/sig_clockwait.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "sched/sched.h" +#include "signal/signal.h" +#include "clock/clock.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxsig_timeout + * + * Description: + * A timeout elapsed while waiting for signals to be queued. + * + * Assumptions: + * This function executes in the context of the timer interrupt handler. + * Local interrupts are assumed to be disabled on entry. + * + ****************************************************************************/ + +static void nxsig_timeout(wdparm_t arg) +{ + FAR struct tcb_s *wtcb = (FAR struct tcb_s *)(uintptr_t)arg; + + irqstate_t flags; + + /* We must be in a critical section in order to call up_switch_context() + * below. + */ + + flags = enter_critical_section(); + + /* There may be a race condition -- make sure the task is + * still waiting for a signal + */ + + if (wtcb->task_state == TSTATE_WAIT_SIG) + { + nxsig_wait_irq(wtcb, SIG_WAIT_TIMEOUT, SI_TIMER, ETIMEDOUT); + } + + leave_critical_section(flags); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxsig_wait_irq + * + * Description: + * An error event has occurred and the signal wait must be terminated with + * an error. + * + ****************************************************************************/ + +void nxsig_wait_irq(FAR struct tcb_s *wtcb, uint8_t signo, + uint8_t code, int errcode) +{ + FAR struct tcb_s *rtcb = this_task(); + +#ifdef CONFIG_DISABLE_ALL_SIGNALS + UNUSED(signo); + UNUSED(code); + UNUSED(errcode); +#else + if (wtcb->sigunbinfo != NULL) + { + wtcb->sigunbinfo->si_signo = signo; + wtcb->sigunbinfo->si_code = code; + wtcb->sigunbinfo->si_errno = errcode; + wtcb->sigunbinfo->si_value.sival_int = 0; +# ifdef CONFIG_SCHED_HAVE_PARENT + wtcb->sigunbinfo->si_pid = 0; /* Not applicable */ + wtcb->sigunbinfo->si_status = OK; +# endif + } +#endif + + /* Remove the task from waiting list */ + + dq_rem((FAR dq_entry_t *)wtcb, list_waitingforsignal()); + + /* Add the task to ready-to-run task list, and + * perform the context switch if one is needed + */ + + if (nxsched_add_readytorun(wtcb)) + { + up_switch_context(this_task(), rtcb); + } +} + +/**************************************************************************** + * Name: nxsig_clockwait + * + * Description: + * This function selects the pending signal set specified by the argument + * set. If multiple signals are pending in set, it will remove and return + * the lowest numbered one. If no signals in set are pending at the time + * of the call, the calling process will be suspended until one of the + * signals in set becomes pending, OR until the process is interrupted by + * an unblocked signal, OR until the time interval specified by timeout + * (if any), has expired. If timeout is NULL, then the timeout interval + * is forever. + * + * 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 stored in the + * si_code member. The content of si_value is only meaningful if the + * signal was generated by sigqueue() (or nxsig_queue). + * + * This is an internal OS interface. It is functionally equivalent to + * sigtimedwait() except that: + * + * - It is not a cancellation point, and + * - It does not modify the errno value. + * + * Input Parameters: + * clockid - The ID of the clock to be used to measure the timeout. + * flags - Open flags. TIMER_ABSTIME is the only supported flag. + * rqtp - The amount of time to be suspended from execution. + * rmtp - If the rmtp argument is non-NULL, the timespec structure + * referenced by it is updated to contain the amount of time + * remaining in the interval (the requested time minus the time + * actually slept) + * + * Returned Value: + * This is an internal OS interface and should not be used by applications. + * A negated errno value is returned on failure. + * + * EAGAIN - wait time is zero. + * EINTR - The wait was interrupted by an unblocked, caught signal. + * + * Notes: + * This function should be called with critical section set. + * + ****************************************************************************/ + +int nxsig_clockwait(int clockid, int flags, + FAR const struct timespec *rqtp, + FAR struct timespec *rmtp) +{ + FAR struct tcb_s *rtcb; + irqstate_t iflags; + clock_t expect = 0u; + clock_t stop = 0u; + + if (rqtp && (rqtp->tv_nsec < 0 || rqtp->tv_nsec >= 1000000000)) + { + return -EINVAL; + } + + /* If rqtp is zero, yield CPU and return + * Notice: The behavior of sleep(0) is not defined in POSIX, so there are + * different implementations: + * 1. In Linux, nanosleep(0) will call schedule() to yield CPU: + * https://elixir.bootlin.com/linux/latest/source/kernel/time/ + * hrtimer.c#L2038 + * 2. In BSD, nanosleep(0) will return immediately: + * https://github.com/freebsd/freebsd-src/blob/ + * 475fa89800086718bd9249fd4dc3f862549f1f78/crypto/openssh/ + * openbsd-compat/bsd-misc.c#L243 + */ + + if (rqtp && rqtp->tv_sec == 0 && rqtp->tv_nsec == 0) + { + sched_yield(); + return -EAGAIN; + } + +#ifdef CONFIG_CANCELLATION_POINTS + /* nxsig_clockwait() is not a cancellation point, but it may be called + * from a cancellation point. So if a cancellation is pending, we + * must exit immediately without waiting. + */ + + if (check_cancellation_point()) + { + /* If there is a pending cancellation, then do not perform + * the wait. Exit now with ECANCELED. + */ + + return -ECANCELED; + } +#endif + + iflags = enter_critical_section(); + rtcb = this_task(); + + if (rqtp) + { + /* Start the watchdog timer */ + + if ((flags & TIMER_ABSTIME) == 0) + { + expect = clock_delay2abstick(clock_time2ticks(rqtp)); + } + else if (clockid == CLOCK_REALTIME) + { +#ifdef CONFIG_CLOCK_TIMEKEEPING + clock_t delay; + + clock_abstime2ticks(CLOCK_REALTIME, rqtp, &delay); + expect = clock_delay2abstick(delay); +#else + clock_realtime2absticks(rqtp, &expect); +#endif + } + else + { + expect = clock_time2ticks(rqtp); + } + + wd_start_abstick(&rtcb->waitdog, expect, + nxsig_timeout, (uintptr_t)rtcb); + } + + /* Remove the tcb task from the ready-to-run list. */ + + nxsched_remove_self(rtcb); + + /* Add the task to the specified blocked task list */ + + rtcb->task_state = TSTATE_WAIT_SIG; + dq_addlast((FAR dq_entry_t *)rtcb, list_waitingforsignal()); + + /* Now, perform the context switch if one is needed */ + + up_switch_context(this_task(), rtcb); + + /* We no longer need the watchdog */ + + if (rqtp) + { + stop = clock_systime_ticks(); + } + + leave_critical_section(iflags); + + if (rqtp && rmtp && expect) + { + clock_ticks2time(rmtp, + clock_compare(stop, expect) ? expect - stop : 0); + } + + return 0; +} diff --git a/sched/signal/sig_timedwait.c b/sched/signal/sig_timedwait.c index d3f63506694b4..e6024702be392 100644 --- a/sched/signal/sig_timedwait.c +++ b/sched/signal/sig_timedwait.c @@ -55,241 +55,10 @@ * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: nxsig_timeout - * - * Description: - * A timeout elapsed while waiting for signals to be queued. - * - * Assumptions: - * This function executes in the context of the timer interrupt handler. - * Local interrupts are assumed to be disabled on entry. - * - ****************************************************************************/ - -static void nxsig_timeout(wdparm_t arg) -{ - FAR struct tcb_s *wtcb = (FAR struct tcb_s *)(uintptr_t)arg; - - irqstate_t flags; - - /* We must be in a critical section in order to call up_switch_context() - * below. - */ - - flags = enter_critical_section(); - - /* There may be a race condition -- make sure the task is - * still waiting for a signal - */ - - if (wtcb->task_state == TSTATE_WAIT_SIG) - { - nxsig_wait_irq(wtcb, SIG_WAIT_TIMEOUT, SI_TIMER, ETIMEDOUT); - } - - leave_critical_section(flags); -} - /**************************************************************************** * Public Functions ****************************************************************************/ -/**************************************************************************** - * Name: nxsig_wait_irq - * - * Description: - * An error event has occurred and the signal wait must be terminated with - * an error. - * - ****************************************************************************/ - -void nxsig_wait_irq(FAR struct tcb_s *wtcb, uint8_t signo, - uint8_t code, int errcode) -{ - FAR struct tcb_s *rtcb = this_task(); - - if (wtcb->sigunbinfo != NULL) - { - wtcb->sigunbinfo->si_signo = signo; - wtcb->sigunbinfo->si_code = code; - wtcb->sigunbinfo->si_errno = errcode; - wtcb->sigunbinfo->si_value.sival_int = 0; -#ifdef CONFIG_SCHED_HAVE_PARENT - wtcb->sigunbinfo->si_pid = 0; /* Not applicable */ - wtcb->sigunbinfo->si_status = OK; -#endif - } - - /* Remove the task from waiting list */ - - dq_rem((FAR dq_entry_t *)wtcb, list_waitingforsignal()); - - /* Add the task to ready-to-run task list, and - * perform the context switch if one is needed - */ - - if (nxsched_add_readytorun(wtcb)) - { - up_switch_context(this_task(), rtcb); - } -} - -/**************************************************************************** - * Name: nxsig_clockwait - * - * Description: - * This function selects the pending signal set specified by the argument - * set. If multiple signals are pending in set, it will remove and return - * the lowest numbered one. If no signals in set are pending at the time - * of the call, the calling process will be suspended until one of the - * signals in set becomes pending, OR until the process is interrupted by - * an unblocked signal, OR until the time interval specified by timeout - * (if any), has expired. If timeout is NULL, then the timeout interval - * is forever. - * - * 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 stored in the - * si_code member. The content of si_value is only meaningful if the - * signal was generated by sigqueue() (or nxsig_queue). - * - * This is an internal OS interface. It is functionally equivalent to - * sigtimedwait() except that: - * - * - It is not a cancellation point, and - * - It does not modify the errno value. - * - * Input Parameters: - * clockid - The ID of the clock to be used to measure the timeout. - * flags - Open flags. TIMER_ABSTIME is the only supported flag. - * rqtp - The amount of time to be suspended from execution. - * rmtp - If the rmtp argument is non-NULL, the timespec structure - * referenced by it is updated to contain the amount of time - * remaining in the interval (the requested time minus the time - * actually slept) - * - * Returned Value: - * This is an internal OS interface and should not be used by applications. - * A negated errno value is returned on failure. - * - * EAGAIN - wait time is zero. - * EINTR - The wait was interrupted by an unblocked, caught signal. - * - * Notes: - * This function should be called with critical section set. - * - ****************************************************************************/ - -int nxsig_clockwait(int clockid, int flags, - FAR const struct timespec *rqtp, - FAR struct timespec *rmtp) -{ - FAR struct tcb_s *rtcb; - irqstate_t iflags; - clock_t expect = 0u; - clock_t stop = 0u; - - if (rqtp && (rqtp->tv_nsec < 0 || rqtp->tv_nsec >= 1000000000)) - { - return -EINVAL; - } - - /* If rqtp is zero, yield CPU and return - * Notice: The behavior of sleep(0) is not defined in POSIX, so there are - * different implementations: - * 1. In Linux, nanosleep(0) will call schedule() to yield CPU: - * https://elixir.bootlin.com/linux/latest/source/kernel/time/ - * hrtimer.c#L2038 - * 2. In BSD, nanosleep(0) will return immediately: - * https://github.com/freebsd/freebsd-src/blob/ - * 475fa89800086718bd9249fd4dc3f862549f1f78/crypto/openssh/ - * openbsd-compat/bsd-misc.c#L243 - */ - - if (rqtp && rqtp->tv_sec == 0 && rqtp->tv_nsec == 0) - { - sched_yield(); - return -EAGAIN; - } - -#ifdef CONFIG_CANCELLATION_POINTS - /* nxsig_clockwait() is not a cancellation point, but it may be called - * from a cancellation point. So if a cancellation is pending, we - * must exit immediately without waiting. - */ - - if (check_cancellation_point()) - { - /* If there is a pending cancellation, then do not perform - * the wait. Exit now with ECANCELED. - */ - - return -ECANCELED; - } -#endif - - iflags = enter_critical_section(); - rtcb = this_task(); - - if (rqtp) - { - /* Start the watchdog timer */ - - if ((flags & TIMER_ABSTIME) == 0) - { - expect = clock_delay2abstick(clock_time2ticks(rqtp)); - } - else if (clockid == CLOCK_REALTIME) - { -#ifdef CONFIG_CLOCK_TIMEKEEPING - clock_t delay; - - clock_abstime2ticks(CLOCK_REALTIME, rqtp, &delay); - expect = clock_delay2abstick(delay); -#else - clock_realtime2absticks(rqtp, &expect); -#endif - } - else - { - expect = clock_time2ticks(rqtp); - } - - wd_start_abstick(&rtcb->waitdog, expect, - nxsig_timeout, (uintptr_t)rtcb); - } - - /* Remove the tcb task from the ready-to-run list. */ - - nxsched_remove_self(rtcb); - - /* Add the task to the specified blocked task list */ - - rtcb->task_state = TSTATE_WAIT_SIG; - dq_addlast((FAR dq_entry_t *)rtcb, list_waitingforsignal()); - - /* Now, perform the context switch if one is needed */ - - up_switch_context(this_task(), rtcb); - - /* We no longer need the watchdog */ - - if (rqtp) - { - stop = clock_systime_ticks(); - } - - leave_critical_section(iflags); - - if (rqtp && rmtp && expect) - { - clock_ticks2time(rmtp, - clock_compare(stop, expect) ? expect - stop : 0); - } - - return 0; -} - /**************************************************************************** * Name: nxsig_timedwait * diff --git a/wireless/ieee802154/mac802154_device.c b/wireless/ieee802154/mac802154_device.c index 5658023e9c5b2..0806607e2e318 100644 --- a/wireless/ieee802154/mac802154_device.c +++ b/wireless/ieee802154/mac802154_device.c @@ -110,10 +110,12 @@ struct mac802154_chardevice_s /* MAC Service notification information */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS bool md_notify_registered; pid_t md_notify_pid; struct sigevent md_notify_event; struct sigwork_s md_notify_work; +#endif }; /**************************************************************************** @@ -575,6 +577,7 @@ static int mac802154dev_ioctl(FAR struct file *filep, int cmd, * failure with the errno value set appropriately. */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS case MAC802154IOC_NOTIFY_REGISTER: { /* Save the notification events */ @@ -586,6 +589,7 @@ static int mac802154dev_ioctl(FAR struct file *filep, int cmd, ret = OK; } break; +#endif case MAC802154IOC_GET_EVENT: { @@ -721,12 +725,14 @@ static int mac802154dev_notify(FAR struct mac802154_maccb_s *maccb, nxsem_post(&dev->geteventsem); } +#ifndef CONFIG_DISABLE_ALL_SIGNALS if (dev->md_notify_registered) { dev->md_notify_event.sigev_value.sival_int = primitive->type; nxsig_notification(dev->md_notify_pid, &dev->md_notify_event, SI_QUEUE, &dev->md_notify_work); } +#endif nxmutex_unlock(&dev->md_lock); return OK; diff --git a/wireless/ieee802154/mac802154_netdev.c b/wireless/ieee802154/mac802154_netdev.c index beb2a6dd334a5..7777fcd408d96 100644 --- a/wireless/ieee802154/mac802154_netdev.c +++ b/wireless/ieee802154/mac802154_netdev.c @@ -147,10 +147,12 @@ struct macnet_driver_s /* MAC Service notification information */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS bool md_notify_registered; pid_t md_notify_pid; struct sigevent md_notify_event; struct sigwork_s md_notify_work; +#endif #ifdef CONFIG_NET_6LOWPAN struct sixlowpan_reassbuf_s md_iobuffer; @@ -378,12 +380,14 @@ static int macnet_notify(FAR struct mac802154_maccb_s *maccb, nxsem_post(&priv->md_eventsem); } +#ifndef CONFIG_DISABLE_ALL_SIGNALS if (priv->md_notify_registered) { priv->md_notify_event.sigev_value.sival_int = primitive->type; nxsig_notification(priv->md_notify_pid, &priv->md_notify_event, SI_QUEUE, &priv->md_notify_work); } +#endif nxmutex_unlock(&priv->md_lock); return OK; @@ -933,6 +937,7 @@ static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd, * errno value set appropriately. */ +#ifndef CONFIG_DISABLE_ALL_SIGNALS case MAC802154IOC_NOTIFY_REGISTER: { /* Save the notification events */ @@ -943,6 +948,7 @@ static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd, ret = OK; } break; +#endif case MAC802154IOC_GET_EVENT: {