2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2014-08-08 20:44:44 +02:00
|
|
|
* sched/signal/signal.h
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2024-09-11 13:45:11 +02:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* 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
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-08 16:33:58 +01:00
|
|
|
* 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.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2014-08-08 20:44:44 +02:00
|
|
|
#ifndef __SCHED_SIGNAL_SIGNAL_H
|
|
|
|
#define __SCHED_SIGNAL_SIGNAL_H
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Included Files
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-02-27 22:17:21 +01:00
|
|
|
#include <nuttx/compiler.h>
|
2009-12-14 20:30:18 +01:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2018-08-27 19:40:09 +02:00
|
|
|
#include <stdbool.h>
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <sched.h>
|
2009-12-14 20:30:18 +01:00
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <nuttx/kmalloc.h>
|
2022-09-25 17:08:38 +02:00
|
|
|
#include <nuttx/queue.h>
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2015-04-08 14:47:36 +02:00
|
|
|
* Pre-processor Definitions
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The following definition determines the number of signal structures to
|
|
|
|
* allocate in a block
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
2020-08-04 05:58:41 +02:00
|
|
|
#define NUM_PENDING_ACTIONS 4
|
|
|
|
#define NUM_SIGNALS_PENDING 4
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Type Definitions
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2018-09-09 16:32:37 +02:00
|
|
|
/* This enumeration identifies the type of signal data allocation */
|
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
enum sigalloc_e
|
|
|
|
{
|
|
|
|
SIG_ALLOC_FIXED = 0, /* pre-allocated; never freed */
|
|
|
|
SIG_ALLOC_DYN, /* dynamically allocated; free when unused */
|
|
|
|
SIG_ALLOC_IRQ /* Preallocated, reserved for interrupt handling */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* The following defines the sigaction queue entry */
|
|
|
|
|
|
|
|
struct sigactq
|
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR struct sigactq *flink; /* Forward link */
|
|
|
|
struct sigaction act; /* Sigaction data */
|
2009-12-14 19:39:29 +01:00
|
|
|
uint8_t signo; /* Signal associated with action */
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
|
|
|
typedef struct sigactq sigactq_t;
|
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
/* The following defines the queue structure within each TCB to hold pending
|
|
|
|
* signals received by the task. These are signals that cannot be processed
|
|
|
|
* because: (1) the task is not waiting for them, or (2) the task has no
|
|
|
|
* action associated with the signal.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct sigpendq
|
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR struct sigpendq *flink; /* Forward link */
|
|
|
|
siginfo_t info; /* Signal information */
|
2009-12-14 19:39:29 +01:00
|
|
|
uint8_t type; /* (Used to manage allocations) */
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
|
|
|
typedef struct sigpendq sigpendq_t;
|
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
/* The following defines the queue structure within each TCB to hold queued
|
|
|
|
* signal actions that need action by the task
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct sigq_s
|
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR struct sigq_s *flink; /* Forward link */
|
2007-02-18 00:21:28 +01:00
|
|
|
union
|
|
|
|
{
|
2007-02-21 03:19:19 +01:00
|
|
|
void (*sighandler)(int signo, siginfo_t *info, void *context);
|
2007-02-18 00:21:28 +01:00
|
|
|
} action; /* Signal action */
|
2007-02-27 22:17:21 +01:00
|
|
|
sigset_t mask; /* Additional signals to mask while the
|
2012-07-14 21:30:31 +02:00
|
|
|
* the signal-catching function executes */
|
2007-02-27 22:17:21 +01:00
|
|
|
siginfo_t info; /* Signal information */
|
2009-12-14 19:39:29 +01:00
|
|
|
uint8_t type; /* (Used to manage allocations) */
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
|
|
|
typedef struct sigq_s sigq_t;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2015-10-03 00:30:35 +02:00
|
|
|
* Public Data
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigfreeaction data structure is a list of available signal action
|
|
|
|
* structures.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigfreeaction;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingaction data structure is a list of available pending
|
|
|
|
* signal action structures.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingaction;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingirqaction is a list of available pending signal actions
|
|
|
|
* that are reserved for use by interrupt handlers.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingirqaction;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingsignal data structure is a list of available pending
|
|
|
|
* signal structures.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingsignal;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingirqsignal data structure is a list of available pending
|
|
|
|
* signal structures that are reserved for use by interrupt handlers.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingirqsignal;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Function Prototypes
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* Internal signal-related interfaces ***************************************/
|
2020-08-04 05:58:41 +02:00
|
|
|
|
2013-10-01 20:10:09 +02:00
|
|
|
/* Forward references */
|
|
|
|
|
|
|
|
struct task_group_s;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-12-05 17:37:55 +01:00
|
|
|
/* sig_initializee.c */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2022-08-16 06:20:39 +02:00
|
|
|
void nxsig_initialize(void);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* sig_action.c */
|
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
void nxsig_release_action(FAR sigactq_t *sigact);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2018-08-27 19:40:09 +02:00
|
|
|
/* sig_default.c */
|
|
|
|
|
|
|
|
#ifdef CONFIG_SIG_DEFAULT
|
|
|
|
bool nxsig_isdefault(FAR struct tcb_s *tcb, int signo);
|
2018-08-28 20:39:03 +02:00
|
|
|
bool nxsig_iscatchable(int signo);
|
2018-08-27 23:37:43 +02:00
|
|
|
_sa_handler_t nxsig_default(FAR struct tcb_s *tcb, int signo,
|
2018-08-27 21:13:23 +02:00
|
|
|
bool defaction);
|
2018-08-27 19:40:09 +02:00
|
|
|
int nxsig_default_initialize(FAR struct tcb_s *tcb);
|
|
|
|
#endif
|
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/* sig_dispatch.c */
|
|
|
|
|
2020-08-04 05:58:41 +02:00
|
|
|
int nxsig_tcbdispatch(FAR struct tcb_s *stcb,
|
|
|
|
FAR siginfo_t *info);
|
2024-09-19 04:43:59 +02:00
|
|
|
int nxsig_dispatch(pid_t pid, FAR siginfo_t *info,
|
|
|
|
bool thread);
|
2013-02-05 20:50:37 +01:00
|
|
|
|
|
|
|
/* sig_cleanup.c */
|
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
void nxsig_cleanup(FAR struct tcb_s *stcb);
|
|
|
|
void nxsig_release(FAR struct task_group_s *group);
|
2013-02-05 20:50:37 +01:00
|
|
|
|
2017-10-12 16:55:19 +02:00
|
|
|
/* sig_timedwait.c */
|
|
|
|
|
|
|
|
#ifdef CONFIG_CANCELLATION_POINTS
|
|
|
|
void nxsig_wait_irq(FAR struct tcb_s *wtcb, int errcode);
|
|
|
|
#endif
|
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
/* In files of the same name */
|
|
|
|
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
FAR sigq_t *nxsig_alloc_pendingsigaction(void);
|
|
|
|
void nxsig_deliver(FAR struct tcb_s *stcb);
|
2020-08-04 05:58:41 +02:00
|
|
|
FAR sigactq_t *nxsig_find_action(FAR struct task_group_s *group,
|
|
|
|
int signo);
|
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_
This is analogous to similar renaming that was done previously for semaphores.
Squashed commit of the following:
sched/signal: Fix a few compile warnings introduced by naming changes.
sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix.
sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces.
sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-05 21:25:25 +02:00
|
|
|
int nxsig_lowest(FAR sigset_t *set);
|
|
|
|
void nxsig_release_pendingsigaction(FAR sigq_t *sigq);
|
|
|
|
void nxsig_release_pendingsignal(FAR sigpendq_t *sigpend);
|
2020-08-04 05:58:41 +02:00
|
|
|
FAR sigpendq_t *nxsig_remove_pendingsignal(FAR struct tcb_s *stcb,
|
|
|
|
int signo);
|
2018-11-08 14:39:37 +01:00
|
|
|
bool nxsig_unmask_pendingsignal(void);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2014-08-08 20:44:44 +02:00
|
|
|
#endif /* __SCHED_SIGNAL_SIGNAL_H */
|