source: rtems/c/src/tests/support/include/tmacros.h @ 2a3d1fd

4.104.114.84.95
Last change on this file since 2a3d1fd was 2a3d1fd, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 29, 1997 at 12:31:56 AM

Made stopping for the pause an option which can be configured in the
targopts.h file.

  • Property mode set to 100644
File size: 3.4 KB
Line 
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
21extern "C" {
22#endif
23
24#include <bsp.h>    /* includes <rtems.h> */
25
26#include <stdio.h>
27#include <stdlib.h>
28
29#define FOREVER 1                  /* infinite loop */
30
31#ifdef TEST_INIT
32#define TEST_EXTERN
33#define CONFIGURE_INIT
34#else
35#define TEST_EXTERN extern
36#endif
37
38#define directive_failed( dirstat, failmsg )  \
39    fatal_directive_status( dirstat, RTEMS_SUCCESSFUL, failmsg )
40
41#define fatal_directive_status( stat, desired, msg ) \
42     do { \
43       if ( (stat) != (desired) ) { \
44         printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
45                 (msg), (desired), (stat) ); \
46         fflush(stdout); \
47         exit( stat ); \
48       } \
49     } while ( 0 )
50
51#define sprint_time(str,s1,tb,s2) \
52  do { \
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  } while ( 0 )
57
58#define print_time(s1,tb,s2) \
59  do { \
60    printf( "%s%02d:%02d:%02d   %02d/%02d/%04d%s", \
61       s1, (tb)->hour, (tb)->minute, (tb)->second, \
62       (tb)->month, (tb)->day, (tb)->year, s2 ); \
63    fflush(stdout); \
64  } while ( 0 )
65
66#define put_dot( c ) putchar( c ); fflush( stdout )
67
68#define new_line  puts( "" )
69
70#define puts_nocr printf
71
72#ifdef RTEMS_TEST_NO_PAUSE
73#define rtems_test_pause() \
74    do { \
75      printf( "<pause>\n" ); fflush( stdout ); \
76  } while ( 0 )
77
78#define rtems_test_pause_and_screen_number( _screen ) \
79  do { \
80    printf( "<pause - screen %d>\n", (_screen) ); fflush( stdout ); \
81  } while ( 0 )
82#else
83#define rtems_test_pause() \
84  do { \
85    char buffer[ 80 ]; \
86    printf( "<pause>" ); fflush( stdout ); \
87    gets( buffer ); \
88    puts( "" ); \
89  } while ( 0 )
90
91#define rtems_test_pause_and_screen_number( _screen ) \
92  do { \
93    char buffer[ 80 ]; \
94    printf( "<pause - screen %d>", (_screen) ); fflush( stdout ); \
95    gets( buffer ); \
96    puts( "" ); \
97  } while ( 0 )
98#endif
99
100#define put_name( name, crlf ) \
101{ rtems_unsigned32 c0, c1, c2, c3; \
102  c0 = (name >> 24) & 0xff; \
103  c1 = (name >> 16) & 0xff; \
104  c2 = (name >> 8) & 0xff; \
105  c3 = name & 0xff; \
106  putchar( (char)c0 ); \
107  if ( c1 ) putchar( (char)c1 ); \
108  if ( c2 ) putchar( (char)c2 ); \
109  if ( c3 ) putchar( (char)c3 ); \
110  if ( crlf ) \
111    putchar( '\n' ); \
112}
113
114#define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \
115  { (TB)->year   = YR;  \
116    (TB)->month  = MON; \
117    (TB)->day    = DAY; \
118    (TB)->hour   = HR;  \
119    (TB)->minute = MIN; \
120    (TB)->second = SEC; \
121    (TB)->ticks  = TK; }
122
123#define task_number( tid ) \
124  ( rtems_get_index( tid ) - \
125     BSP_Configuration.RTEMS_api_configuration->number_of_initialization_tasks )
126
127static inline rtems_unsigned32 get_ticks_per_second( void )
128{
129  rtems_interval ticks_per_second;
130  (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second );
131  return ticks_per_second;
132}
133
134#define TICKS_PER_SECOND get_ticks_per_second()
135
136#ifdef __cplusplus
137}
138#endif
139
140#endif
Note: See TracBrowser for help on using the repository browser.