source: rtems/cpukit/posix/src/psignalclearsignals.c @ 8f6b7b51

4.104.115
Last change on this file since 8f6b7b51 was 21de9dc, checked in by Joel Sherrill <joel.sherrill@…>, on 08/05/09 at 19:09:21

2009-08-05 Joel Sherrill <joel.sherrill@…>

  • posix/src/psignalclearsignals.c: Add comments.
  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2007.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <errno.h>
17#include <pthread.h>
18#include <signal.h>
19
20#include <rtems/system.h>
21#include <rtems/score/isr.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/tqdata.h>
24#include <rtems/score/wkspace.h>
25#include <rtems/seterr.h>
26#include <rtems/posix/threadsup.h>
27#include <rtems/posix/psignal.h>
28#include <rtems/posix/pthread.h>
29#include <rtems/posix/time.h>
30#include <stdio.h>
31
32/*PAGE
33 *
34 *  _POSIX_signals_Clear_signals
35 */
36
37bool _POSIX_signals_Clear_signals(
38  POSIX_API_Control  *api,
39  int                 signo,
40  siginfo_t          *info,
41  bool                is_global,
42  bool                check_blocked
43)
44{
45  sigset_t                    mask;
46  sigset_t                    signals_blocked;
47  ISR_Level                   level;
48  bool                        do_callout;
49  POSIX_signals_Siginfo_node *psiginfo;
50
51  mask = signo_to_mask( signo );
52
53  do_callout = false;
54
55  /* set blocked signals based on if checking for them, SIGNAL_ALL_MASK
56   * insures that no signals are blocked and all are checked.
57   */
58
59  if ( check_blocked )
60    signals_blocked = ~api->signals_blocked;
61  else
62    signals_blocked = SIGNAL_ALL_MASK;
63
64  /* XXX is this right for siginfo type signals? */
65  /* XXX are we sure they can be cleared the same way? */
66
67  _ISR_Disable( level );
68    if ( is_global ) {
69       if ( mask & (_POSIX_signals_Pending & signals_blocked) ) {
70         if ( _POSIX_signals_Vectors[ signo ].sa_flags == SA_SIGINFO ) {
71           psiginfo = (POSIX_signals_Siginfo_node *)
72             _Chain_Get_unprotected( &_POSIX_signals_Siginfo[ signo ] );
73           _POSIX_signals_Clear_process_signals( signo );
74           /*
75            *  It may be impossible to get here with an empty chain
76            *  BUT until that is proven we need to be defensive and
77            *  protect against it.
78            */
79           if ( psiginfo ) {
80             *info = psiginfo->Info;
81             _Chain_Append_unprotected(
82               &_POSIX_signals_Inactive_siginfo,
83               &psiginfo->Node
84             );
85           } else
86             do_callout = false;
87         }
88         _POSIX_signals_Clear_process_signals( signo );
89         do_callout = true;
90       }
91    } else {
92      if ( mask & (api->signals_pending & signals_blocked) ) {
93        api->signals_pending &= ~mask;
94        do_callout = true;
95      }
96    }
97  _ISR_Enable( level );
98  return do_callout;
99}
Note: See TracBrowser for help on using the repository browser.