source: rtems/testsuites/support/include/tmacros.h @ c64e4ed4

4.104.114.84.95
Last change on this file since c64e4ed4 was c64e4ed4, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 15, 1996 at 9:50:28 PM

updates from Tony Bennett for PA and UNIX ports

  • Property mode set to 100644
File size: 3.1 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#define pause() \
73  do { \
74    char buffer[ 80 ]; \
75    printf( "<pause>" ); fflush( stdout ); \
76    gets( buffer ); \
77    puts( "" ); \
78  } while ( 0 )
79
80#define pause_and_screen_number( _screen ) \
81  do { \
82    char buffer[ 80 ]; \
83    printf( "<pause - screen %d>", (_screen) ); fflush( stdout ); \
84    gets( buffer ); \
85    puts( "" ); \
86  } while ( 0 )
87
88#define put_name( name, crlf ) \
89{ rtems_unsigned32 c0, c1, c2, c3; \
90  c0 = (name >> 24) & 0xff; \
91  c1 = (name >> 16) & 0xff; \
92  c2 = (name >> 8) & 0xff; \
93  c3 = name & 0xff; \
94  putchar( (char)c0 ); \
95  if ( c1 ) putchar( (char)c1 ); \
96  if ( c2 ) putchar( (char)c2 ); \
97  if ( c3 ) putchar( (char)c3 ); \
98  if ( crlf ) \
99    putchar( '\n' ); \
100}
101
102#define build_time( TB, MON, DAY, YR, HR, MIN, SEC, TK ) \
103  { (TB)->year   = YR;  \
104    (TB)->month  = MON; \
105    (TB)->day    = DAY; \
106    (TB)->hour   = HR;  \
107    (TB)->minute = MIN; \
108    (TB)->second = SEC; \
109    (TB)->ticks  = TK; }
110
111#define task_number( tid ) \
112  ( rtems_get_index( tid ) - BSP_Configuration.number_of_initialization_tasks )
113
114static inline rtems_unsigned32 get_ticks_per_second( void )
115{
116  rtems_interval ticks_per_second;
117  (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second );
118  return ticks_per_second;
119}
120
121#define TICKS_PER_SECOND get_ticks_per_second()
122
123#ifdef __cplusplus
124}
125#endif
126
127#endif
Note: See TracBrowser for help on using the repository browser.