source: rtems/testsuites/psxtests/psxualarm/init.c @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
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 CONFIGURE_INIT
15#include "system.h"
16#include <signal.h>
17#include <unistd.h>
18#include <errno.h>
19typedef void (*sighandler_t)(int);
20sighandler_t signal(int signum, sighandler_t handler);
21extern void _POSIX_signals_Abnormal_termination_handler( int signo );
22
23volatile int Signal_occurred;
24volatile int Signal_count;
25
26void Signal_handler(
27  int signo
28)
29{
30  Signal_count++;
31  printf(
32    "Signal: %d caught by 0x%" PRIxpthread_t " (%d)\n",
33    signo,
34    pthread_self(),
35    Signal_count
36  );
37  Signal_occurred = 1;
38}
39
40rtems_timer_service_routine Signal_duringISR_TSR(
41  rtems_id  ignored_id,
42  void     *ignored_address
43)
44{
45  int               status;
46
47  status = kill( getpid(), SIGUSR1 );
48  rtems_test_assert( status == 0 );
49}
50
51
52void *POSIX_Init(
53  void *argument
54)
55{
56  int               status;
57  useconds_t        result;
58  struct sigaction  act;
59  sigset_t          mask;
60
61  puts( "\n\n*** POSIX TEST UALARM ***" );
62
63  /* set the time of day, and print our buffer in multiple ways */
64
65  set_time( TM_FRIDAY, TM_MAY, 24, 96, 11, 5, 0 );
66
67  /* get id of this thread */
68
69  Init_id = pthread_self();
70  printf( "Init's ID is 0x%08" PRIxpthread_t "\n", Init_id );
71
72  Signal_occurred = 0;
73  Signal_count = 0;
74
75  /* Validate ualarm is ignored if signal not caught */
76  act.sa_handler = Signal_handler;
77  act.sa_flags   = 0;
78  sigaction( SIGALRM, &act, NULL );
79  puts( "Init: ualarm in 1 us" );
80  sleep(3);
81  result = ualarm(1,0);
82  rtems_test_assert( result == 0 );
83 
84  status = sleep(10);
85  rtems_test_assert( status == 0 );
86
87  /* unblock Signal and see if it happened */
88  status = sigemptyset( &mask );
89  rtems_test_assert( !status );
90  status = sigaddset( &mask, SIGALRM );
91  rtems_test_assert( !status );
92  puts( "Init: Unblock SIGALRM" );
93  status = sigprocmask( SIG_UNBLOCK, &mask, NULL );
94  rtems_test_assert( !status );
95  status = sleep(10);
96
97  /* stop ularm */
98  puts( "Init: clear ualarm with 0,0" );
99  result = ualarm(0,0);
100  status = sleep(10);
101
102  puts( "*** END OF POSIX TEST UALARM ***" );
103  rtems_test_exit(0);
104
105  return NULL; /* just so the compiler thinks we returned something */
106}
Note: See TracBrowser for help on using the repository browser.