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 | |
---|
37 | bool _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 this is not right for siginfo type signals yet */ |
---|
65 | /* XXX since they can't 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 | if ( _Chain_Is_empty( &_POSIX_signals_Siginfo[ signo ] ) ) |
---|
74 | _POSIX_signals_Clear_process_signals( mask ); |
---|
75 | if ( psiginfo ) { |
---|
76 | *info = psiginfo->Info; |
---|
77 | _Chain_Append_unprotected( |
---|
78 | &_POSIX_signals_Inactive_siginfo, |
---|
79 | &psiginfo->Node |
---|
80 | ); |
---|
81 | } else |
---|
82 | do_callout = false; |
---|
83 | } else |
---|
84 | _POSIX_signals_Clear_process_signals( mask ); |
---|
85 | do_callout = true; |
---|
86 | } |
---|
87 | } else { |
---|
88 | if ( mask & (api->signals_pending & signals_blocked) ) { |
---|
89 | api->signals_pending &= ~mask; |
---|
90 | do_callout = true; |
---|
91 | } |
---|
92 | } |
---|
93 | _ISR_Enable( level ); |
---|
94 | return do_callout; |
---|
95 | } |
---|