1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2012. |
---|
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 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ |
---|
15 | |
---|
16 | #define TEST_NAME "05" |
---|
17 | #define TEST_STRING "User Signals" |
---|
18 | #define SIGNAL_ONE SIGUSR1 |
---|
19 | #define SIGNAL_TWO SIGUSR2 |
---|
20 | |
---|
21 | #include <pmacros.h> |
---|
22 | #include <signal.h> |
---|
23 | #include <errno.h> |
---|
24 | #include <errno.h> |
---|
25 | #include <rtems/posix/psignalimpl.h> |
---|
26 | |
---|
27 | /* forward declarations to avoid warnings */ |
---|
28 | void *POSIX_Init(void *argument); |
---|
29 | void Signal_handler(int signo, siginfo_t *info, void *arg); |
---|
30 | const char *signal_name(int signo); |
---|
31 | |
---|
32 | void Signal_handler( |
---|
33 | int signo, |
---|
34 | siginfo_t *info, |
---|
35 | void *arg |
---|
36 | ) |
---|
37 | { |
---|
38 | puts( "Signal handler hit" ); |
---|
39 | rtems_test_exit(0); |
---|
40 | } |
---|
41 | |
---|
42 | const char *signal_name(int signo) |
---|
43 | { |
---|
44 | if (signo == SIGUSR1) |
---|
45 | return "SIGUSR1"; |
---|
46 | if (signo == SIGUSR2) |
---|
47 | return "SIGUSR2"; |
---|
48 | if (signo == SIGRTMIN) |
---|
49 | return "SIGRTMIN"; |
---|
50 | if (signo == SIGRTMAX) |
---|
51 | return "SIGRTMAX"; |
---|
52 | return "unknown-signal"; |
---|
53 | } |
---|
54 | |
---|
55 | void *POSIX_Init( |
---|
56 | void *argument |
---|
57 | ) |
---|
58 | { |
---|
59 | struct sigaction act; |
---|
60 | siginfo_t info; |
---|
61 | bool bc; |
---|
62 | |
---|
63 | puts( "\n\n*** POSIX TEST SIGNAL " TEST_NAME " ***" ); |
---|
64 | |
---|
65 | act.sa_handler = NULL; |
---|
66 | act.sa_sigaction = Signal_handler; |
---|
67 | act.sa_flags = SA_SIGINFO; |
---|
68 | sigaction( SIGNAL_ONE, &act, NULL ); |
---|
69 | sigaction( SIGNAL_TWO, &act, NULL ); |
---|
70 | |
---|
71 | printf( |
---|
72 | "Init - _POSIX_signals_Clear_signals when signals pending but\n" |
---|
73 | "Init - not queued on SA_SIGINFO configured signal.\n" |
---|
74 | ); |
---|
75 | |
---|
76 | /* cheat and put signal directly in */ |
---|
77 | _POSIX_signals_Pending |= signo_to_mask( SIGUSR1 ); |
---|
78 | |
---|
79 | bc = _POSIX_signals_Clear_signals( |
---|
80 | _Thread_Get_executing()->API_Extensions[ THREAD_API_POSIX ], |
---|
81 | SIGNAL_ONE, |
---|
82 | &info, |
---|
83 | true, /* is_global */ |
---|
84 | false /* check_blocked */ |
---|
85 | ); |
---|
86 | rtems_test_assert( bc ); |
---|
87 | |
---|
88 | puts( "*** END OF POSIX TEST SIGNAL " TEST_NAME " ***" ); |
---|
89 | rtems_test_exit(0); |
---|
90 | |
---|
91 | return NULL; /* just so the compiler thinks we returned something */ |
---|
92 | } |
---|
93 | |
---|
94 | /* configuration information */ |
---|
95 | |
---|
96 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
97 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
98 | |
---|
99 | #define CONFIGURE_MAXIMUM_POSIX_THREADS 1 |
---|
100 | |
---|
101 | #define CONFIGURE_POSIX_INIT_THREAD_TABLE |
---|
102 | |
---|
103 | #define CONFIGURE_INIT |
---|
104 | #include <rtems/confdefs.h> |
---|