3 * This include file contains macros which are useful in the RTEMS
6 * COPYRIGHT (c) 1989-1999.
7 * On-Line Applications Research Corporation (OAR).
9 * The license and distribution terms for this file may be
10 * found in the file LICENSE in this distribution or at
11 * http://www.OARcorp.com/rtems/license.html.
13 * tmacros.h,v 1.25 2002/08/02 00:51:52 joel Exp
23 #include <bsp.h> /* includes <rtems.h> */
29 #include <rtems/error.h>
31 #define FOREVER 1 /* infinite loop */
36 #define TEST_EXTERN extern
39 #include "buffer_test_io.h"
42 * Check that that the dispatch disable level is proper for the
43 * mode/state of the test. Normally it should be 0 when in task space.
46 #define check_dispatch_disable_level( _expect ) \
48 extern volatile rtems_unsigned32 _Thread_Dispatch_disable_level; \
49 if ( (_expect) != -1 && _Thread_Dispatch_disable_level != (_expect) ) { \
50 printf( "\n_Thread_Dispatch_disable_level is (%d) not %d\n", \
51 _Thread_Dispatch_disable_level, (_expect) ); \
53 rtems_test_exit( 1 ); \
58 * These macros properly report errors within the Classic API
61 #define directive_failed( _dirstat, _failmsg ) \
62 fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
64 #define directive_failed_with_level( _dirstat, _failmsg, _level ) \
65 fatal_directive_status_with_level( \
66 _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
68 #define fatal_directive_status( _stat, _desired, _msg ) \
69 fatal_directive_status_with_level( _stat, _desired, _msg, 0 )
71 #define fatal_directive_check_status_only( _stat, _desired, _msg ) \
73 if ( (_stat) != (_desired) ) { \
74 printf( "\n%s FAILED -- expected (%s) got (%s)\n", \
75 (_msg), rtems_status_text(_desired), rtems_status_text(_stat) ); \
77 rtems_test_exit( _stat ); \
81 #define fatal_directive_status_with_level( _stat, _desired, _msg, _level ) \
83 check_dispatch_disable_level( _level ); \
84 fatal_directive_check_status_only( _stat, _desired, _msg ); \
88 * These macros properly report errors from the POSIX API
91 #define posix_service_failed( _dirstat, _failmsg ) \
92 fatal_posix_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
94 #define posix_service_failed_with_level( _dirstat, _failmsg, _level ) \
95 fatal_posix_service_status_with_level( \
96 _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
98 #define fatal_posix_service_status( _stat, _desired, _msg ) \
99 fatal_posix_service_status_with_level( _stat, _desired, _msg, 0 )
101 #define fatal_posix_service_status_with_level( _stat, _desired, _msg, _level ) \
103 check_dispatch_disable_level( _level ); \
104 if ( (_stat) != (_desired) ) { \
105 printf( "\n%s FAILED -- expected (%d - %s) got (%d - %s)\n", \
106 (_msg), _desired, strerror(_desired), _stat, strerror(_stat) ); \
107 printf( "\n FAILED -- errno (%d - %s)\n", \
108 errno, strerror(errno) ); \
110 rtems_test_exit( _stat ); \
115 * Generic integer version of the error reporting
118 #define int_service_failed( _dirstat, _failmsg ) \
119 fatal_int_service_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
121 #define int_service_failed_with_level( _dirstat, _failmsg, _level ) \
122 fatal_int_service_status_with_level( \
123 _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
125 #define fatal_int_service_status( _stat, _desired, _msg ) \
126 fatal_int_service_status_with_level( _stat, _desired, _msg, 0 )
128 #define fatal_int_service_status_with_level( _stat, _desired, _msg, _level ) \
130 check_dispatch_disable_level( _level ); \
131 if ( (_stat) != (_desired) ) { \
132 printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
133 (_msg), (_desired), (_stat) ); \
135 rtems_test_exit( _stat ); \
140 * Print the time: modificata per swarm da Poletti Francesco per risolvere il
141 * problema di stampa degli interi
144 #define print_time(_s1, _tb, _s2) \
146 myprint( "%s%02d:%02d:%02d %02d/%02d/%0d%s", \
147 _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
148 (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
153 #define sprint_time(_str, _s1, _tb, _s2) \
155 sprintf( (str), "%s%02d:%02d:%02d %02d/%02d/%04d%s", \
156 _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
157 (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
160 #define put_dot( _c ) \
166 #define new_line puts( "" )
168 #define puts_nocr printf
170 #ifdef RTEMS_TEST_NO_PAUSE
171 #define rtems_test_pause() \
173 printf( "<pause>\n" ); \
177 #define rtems_test_pause_and_screen_number( _screen ) \
179 printf( "<pause - screen %d>\n", (_screen) ); \
183 #define rtems_test_pause() \
186 printf( "<pause>" ); \
192 #define rtems_test_pause_and_screen_number( _screen ) \
195 printf( "<pause - screen %d>", (_screen) ); \
202 #define put_name( _name, _crlf ) \
203 do { char buf[6];int i=1;\
204 rtems_unsigned32 c0, c1, c2, c3; \
206 c0 = ((_name) >> 24) & 0xff; \
207 c1 = ((_name) >> 16) & 0xff; \
208 c2 = ((_name) >> 8) & 0xff; \
209 c3 = (_name) & 0xff; \
211 if ( c1 ) {buf[i]=(char)c1; i++;} ; \
212 if ( c2 ) {buf[i]=(char)c2; i++;}; \
213 if ( c3 ) {buf[i]=(char)c3; i++;}; \
214 if ( (_crlf) ) {buf[i]='\n'; i++;}\
220 #define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \
225 (TB)->minute = MIN; \
226 (TB)->second = SEC; \
230 #define task_number( tid ) \
231 ( rtems_get_index( tid ) - \
232 rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks )
234 static inline rtems_unsigned32 get_ticks_per_second( void )
236 rtems_interval ticks_per_second;
237 (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second );
238 return ticks_per_second;
241 #define TICKS_PER_SECOND get_ticks_per_second()