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 "bsp.h" |
---|
25 | #include "stdio.h" |
---|
26 | #include "stdlib.h" |
---|
27 | #include "libcsupport.h" |
---|
28 | |
---|
29 | #define FOREVER 1 /* infinite loop */ |
---|
30 | |
---|
31 | #define directive_failed( dirstat, failmsg ) \ |
---|
32 | fatal_directive_status( dirstat, RTEMS_SUCCESSFUL, failmsg ) |
---|
33 | |
---|
34 | #define fatal_directive_status( stat, desired, msg ) \ |
---|
35 | { \ |
---|
36 | if ( (stat) != (desired) ) { \ |
---|
37 | printf( "\n%s FAILED -- expected (%d) got (%d)\n", \ |
---|
38 | (msg), (desired), (stat) ); \ |
---|
39 | exit( stat ); \ |
---|
40 | } \ |
---|
41 | } |
---|
42 | |
---|
43 | #define sprint_time(str,s1,tb,s2) \ |
---|
44 | sprintf( (str), "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ |
---|
45 | s1, (tb)->hour, (tb)->minute, (tb)->second, \ |
---|
46 | (tb)->month, (tb)->day, (tb)->year, s2 ); |
---|
47 | |
---|
48 | #define print_time(s1,tb,s2) \ |
---|
49 | printf( "%s%02d:%02d:%02d %02d/%02d/%04d%s", \ |
---|
50 | s1, (tb)->hour, (tb)->minute, (tb)->second, \ |
---|
51 | (tb)->month, (tb)->day, (tb)->year, s2 ); |
---|
52 | |
---|
53 | #define put_dot( c ) putchar( c ); fflush( stdout ) |
---|
54 | |
---|
55 | #define new_line puts( "" ) |
---|
56 | |
---|
57 | #define puts_nocr printf |
---|
58 | |
---|
59 | #define pause() \ |
---|
60 | do { \ |
---|
61 | char buffer[ 80 ]; \ |
---|
62 | printf( "<pause> " ); fflush( stdout ); \ |
---|
63 | gets( buffer ); \ |
---|
64 | puts( "" ); \ |
---|
65 | } while ( 0 ) |
---|
66 | |
---|
67 | #define pause_and_screen_number( _screen ) \ |
---|
68 | do { \ |
---|
69 | char buffer[ 80 ]; \ |
---|
70 | printf( "<pause - screen %d> ", (_screen) ); fflush( stdout ); \ |
---|
71 | gets( buffer ); \ |
---|
72 | puts( "" ); \ |
---|
73 | } while ( 0 ) |
---|
74 | |
---|
75 | #define put_name( name, crlf ) \ |
---|
76 | { rtems_unsigned32 c0, c1, c2, c3; \ |
---|
77 | c0 = (name >> 24) & 0xff; \ |
---|
78 | c1 = (name >> 16) & 0xff; \ |
---|
79 | c2 = (name >> 8) & 0xff; \ |
---|
80 | c3 = name & 0xff; \ |
---|
81 | putchar( (char)c0 ); \ |
---|
82 | if ( c1 ) putchar( (char)c1 ); \ |
---|
83 | if ( c2 ) putchar( (char)c2 ); \ |
---|
84 | if ( c3 ) putchar( (char)c3 ); \ |
---|
85 | if ( crlf ) \ |
---|
86 | putchar( '\n' ); \ |
---|
87 | } |
---|
88 | |
---|
89 | #define put_buffer( _buffer ) XYZ( _buffer ) |
---|
90 | |
---|
91 | #define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \ |
---|
92 | { (TB)->year = YR; \ |
---|
93 | (TB)->month = MON; \ |
---|
94 | (TB)->day = DAY; \ |
---|
95 | (TB)->hour = HR; \ |
---|
96 | (TB)->minute = MIN; \ |
---|
97 | (TB)->second = SEC; \ |
---|
98 | (TB)->ticks = TK; } |
---|
99 | |
---|
100 | #define task_number( tid ) \ |
---|
101 | ( rtems_get_index( tid ) - BSP_Configuration.number_of_initialization_tasks ) |
---|
102 | |
---|
103 | static inline rtems_unsigned32 get_ticks_per_second( void ) |
---|
104 | { |
---|
105 | rtems_interval ticks_per_second; |
---|
106 | (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second ); |
---|
107 | return ticks_per_second; |
---|
108 | } |
---|
109 | |
---|
110 | #define TICKS_PER_SECOND get_ticks_per_second() |
---|
111 | |
---|
112 | #ifdef __cplusplus |
---|
113 | } |
---|
114 | #endif |
---|
115 | |
---|
116 | #endif |
---|