source: rtems/testsuites/psxtests/psxsignal05/init.c @ ae75429

4.115
Last change on this file since ae75429 was ae75429, checked in by Sebastian Huber <sebastian.huber@…>, on 08/06/13 at 14:10:26

PR766: Delete RTEMS_VIOLATE_KERNEL_VISIBILITY

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