Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:12

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  * 
0006  * @brief POSIX Signals Support
0007  *
0008  * This include file defines internal information about POSIX signals.
0009  */
0010 
0011 /*
0012  *  COPYRIGHT (c) 1989-2013.
0013  *  On-Line Applications Research Corporation (OAR).
0014  *
0015  * Redistribution and use in source and binary forms, with or without
0016  * modification, are permitted provided that the following conditions
0017  * are met:
0018  * 1. Redistributions of source code must retain the above copyright
0019  *    notice, this list of conditions and the following disclaimer.
0020  * 2. Redistributions in binary form must reproduce the above copyright
0021  *    notice, this list of conditions and the following disclaimer in the
0022  *    documentation and/or other materials provided with the distribution.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0027  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0028  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0029  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0030  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0031  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0032  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0033  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0034  * POSSIBILITY OF SUCH DAMAGE.
0035  */
0036 
0037 #ifndef _RTEMS_POSIX_PSIGNALIMPL_H
0038 #define _RTEMS_POSIX_PSIGNALIMPL_H
0039 
0040 /**
0041  * @defgroup POSIX_SIGNALS POSIX Signals Support
0042  *
0043  * @ingroup POSIXAPI
0044  *
0045  * @brief Internal Information about POSIX Signals
0046  * 
0047  */
0048 /**@{**/
0049 
0050 #include <rtems/posix/psignal.h>
0051 #include <rtems/posix/pthread.h>
0052 #include <rtems/posix/sigset.h>
0053 #include <rtems/score/isrlock.h>
0054 #include <rtems/score/percpu.h>
0055 #include <rtems/score/threadqimpl.h>
0056 
0057 #define POSIX_SIGNALS_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
0058 
0059 #define _States_Is_interruptible_signal( _states ) \
0060   ( ((_states) & \
0061     (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL)) == \
0062       (STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL))
0063 
0064 #define SIGACTION_TERMINATE \
0065   { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Abnormal_termination_handler} }
0066 #define SIGACTION_IGNORE \
0067   { 0, SIGNAL_ALL_MASK, {SIG_IGN} }
0068 #define SIGACTION_STOP \
0069   { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Stop_handler} }
0070 #define SIGACTION_CONTINUE \
0071   { 0, SIGNAL_ALL_MASK, {_POSIX_signals_Continue_handler} }
0072 
0073 #define SIG_ARRAY_MAX  (SIGRTMAX + 1)
0074 
0075 /*
0076  *  Variables
0077  */
0078 
0079 extern sigset_t  _POSIX_signals_Pending;
0080 
0081 extern const struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ];
0082 
0083 extern struct sigaction _POSIX_signals_Vectors[ SIG_ARRAY_MAX ];
0084 
0085 extern Thread_queue_Control _POSIX_signals_Wait_queue;
0086 
0087 extern Chain_Control _POSIX_signals_Inactive_siginfo;
0088 
0089 extern Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
0090 
0091 /*
0092  *  Internal routines
0093  */
0094 
0095 static inline void _POSIX_signals_Acquire(
0096   Thread_queue_Context *queue_context
0097 )
0098 {
0099   _Thread_queue_Acquire( &_POSIX_signals_Wait_queue, queue_context );
0100 }
0101 
0102 static inline void _POSIX_signals_Release(
0103   Thread_queue_Context *queue_context
0104 )
0105 {
0106   _Thread_queue_Release( &_POSIX_signals_Wait_queue, queue_context );
0107 }
0108 
0109 /**
0110  * @brief Unlock POSIX signals thread.
0111  */
0112 bool _POSIX_signals_Unblock_thread(
0113   Thread_Control  *the_thread,
0114   int              signo,
0115   siginfo_t       *info
0116 );
0117 
0118 /**
0119  * @brief Clear POSIX signals.
0120  */
0121 bool _POSIX_signals_Clear_signals(
0122   POSIX_API_Control  *api,
0123   int                 signo,
0124   siginfo_t          *info,
0125   bool                is_global,
0126   bool                check_blocked,
0127   bool                do_signals_acquire_release
0128 );
0129 
0130 int _POSIX_signals_Send(
0131   pid_t               pid,
0132   int                 sig,
0133   const union sigval *value
0134 );
0135 
0136 /**
0137  *  @brief Set POSIX process signals.
0138  */
0139 void _POSIX_signals_Set_process_signals(
0140   sigset_t   mask
0141 );
0142 
0143 void _POSIX_signals_Clear_process_signals(
0144   int        signo
0145 );
0146 
0147 /*
0148  *  Default signal handlers
0149  */
0150 
0151 #define _POSIX_signals_Stop_handler NULL
0152 #define _POSIX_signals_Continue_handler NULL
0153 
0154 void _POSIX_signals_Abnormal_termination_handler( int signo );
0155 
0156 /** @} */
0157 
0158 #endif
0159 /* end of file */