1 | /* tmacros.h |
---|
2 | * |
---|
3 | * This include file contains macros which are useful in the RTEMS |
---|
4 | * test suites. |
---|
5 | * |
---|
6 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * All rights assigned to U.S. Government, 1994. |
---|
9 | * |
---|
10 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
11 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
12 | * notice must appear in all copies of this file and its derivatives. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef __TMACROS_h |
---|
18 | #define __TMACROS_h |
---|
19 | |
---|
20 | #ifdef __cplusplus |
---|
21 | extern "C" { |
---|
22 | #endif |
---|
23 | |
---|
24 | #include <rtems.h> |
---|
25 | #include <bsp.h> |
---|
26 | |
---|
27 | #include <stdio.h> |
---|
28 | #include <stdlib.h> |
---|
29 | #include <libcsupport.h> |
---|
30 | |
---|
31 | #define FOREVER 1 /* infinite loop */ |
---|
32 | |
---|
33 | #ifdef TEST_INIT |
---|
34 | #define TEST_EXTERN |
---|
35 | #define CONFIGURE_INIT |
---|
36 | #else |
---|
37 | #define TEST_EXTERN extern |
---|
38 | #endif |
---|
39 | |
---|
40 | #define directive_failed( dirstat, failmsg ) \ |
---|
41 | fatal_directive_status( dirstat, RTEMS_SUCCESSFUL, failmsg ) |
---|
42 | |
---|
43 | #define fatal_directive_status( stat, desired, msg ) \ |
---|
44 | { \ |
---|
45 | if ( (stat) != (desired) ) { \ |
---|
46 | printf( "\n%s FAILED -- expected (%d) got (%d)\n", \ |
---|
47 | (msg), (desired), (stat) ); \ |
---|
48 | exit( stat ); \ |
---|
49 | } \ |
---|
50 | } |
---|
51 | |
---|
52 | #define sprint_time(str,s1,tb,s2) \ |
---|
53 | sprintf( (str), "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ |
---|
54 | s1, (tb)->hour, (tb)->minute, (tb)->second, \ |
---|
55 | (tb)->month, (tb)->day, (tb)->year, s2 ); |
---|
56 | |
---|
57 | #define print_time(s1,tb,s2) \ |
---|
58 | printf( "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ |
---|
59 | s1, (tb)->hour, (tb)->minute, (tb)->second, \ |
---|
60 | (tb)->month, (tb)->day, (tb)->year, s2 ); |
---|
61 | |
---|
62 | #define put_dot( c ) putchar( c ); fflush( stdout ) |
---|
63 | |
---|
64 | #define new_line puts( "" ) |
---|
65 | |
---|
66 | #define puts_nocr printf |
---|
67 | |
---|
68 | #define pause() \ |
---|
69 | do { \ |
---|
70 | char buffer[ 80 ]; \ |
---|
71 | printf( "<pause>" ); fflush( stdout ); \ |
---|
72 | gets( buffer ); \ |
---|
73 | puts( "" ); \ |
---|
74 | } while ( 0 ) |
---|
75 | |
---|
76 | #define pause_and_screen_number( _screen ) \ |
---|
77 | do { \ |
---|
78 | char buffer[ 80 ]; \ |
---|
79 | printf( "<pause - screen %d>", (_screen) ); fflush( stdout ); \ |
---|
80 | gets( buffer ); \ |
---|
81 | puts( "" ); \ |
---|
82 | } while ( 0 ) |
---|
83 | |
---|
84 | #define put_name( name, crlf ) \ |
---|
85 | { rtems_unsigned32 c0, c1, c2, c3; \ |
---|
86 | c0 = (name >> 24) & 0xff; \ |
---|
87 | c1 = (name >> 16) & 0xff; \ |
---|
88 | c2 = (name >> 8) & 0xff; \ |
---|
89 | c3 = name & 0xff; \ |
---|
90 | putchar( (char)c0 ); \ |
---|
91 | if ( c1 ) putchar( (char)c1 ); \ |
---|
92 | if ( c2 ) putchar( (char)c2 ); \ |
---|
93 | if ( c3 ) putchar( (char)c3 ); \ |
---|
94 | if ( crlf ) \ |
---|
95 | putchar( '\n' ); \ |
---|
96 | } |
---|
97 | |
---|
98 | #define put_buffer( _buffer ) XYZ( _buffer ) |
---|
99 | |
---|
100 | #define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \ |
---|
101 | { (TB)->year = YR; \ |
---|
102 | (TB)->month = MON; \ |
---|
103 | (TB)->day = DAY; \ |
---|
104 | (TB)->hour = HR; \ |
---|
105 | (TB)->minute = MIN; \ |
---|
106 | (TB)->second = SEC; \ |
---|
107 | (TB)->ticks = TK; } |
---|
108 | |
---|
109 | #define task_number( tid ) \ |
---|
110 | ( rtems_get_index( tid ) - BSP_Configuration.number_of_initialization_tasks ) |
---|
111 | |
---|
112 | static inline rtems_unsigned32 get_ticks_per_second( void ) |
---|
113 | { |
---|
114 | rtems_interval ticks_per_second; |
---|
115 | (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second ); |
---|
116 | return ticks_per_second; |
---|
117 | } |
---|
118 | |
---|
119 | #define TICKS_PER_SECOND get_ticks_per_second() |
---|
120 | |
---|
121 | #ifdef __cplusplus |
---|
122 | } |
---|
123 | #endif |
---|
124 | |
---|
125 | #endif |
---|