source: examples-v2/testmacros.h @ b5a5384b

4.11examples-v2-4-10-branch
Last change on this file since b5a5384b was 3083373, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 6, 2009 at 8:25:58 PM

Initial import of reorganized examples.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*  testmacros.h
2 *
3 *  This include file contains some commonly used test macros.
4 *
5 *  COPYRIGHT (c) 1989-2007.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#ifndef __TEST_MACROS_h
16#define __TEST_MACROS_h
17
18/*
19 *  Handy macros and static inline functions
20 */
21
22/*
23 *  Macro to hide the ugliness of printing the time.
24 */
25
26#define print_time(_s1, _tb, _s2) \
27  do { \
28    printf( "%s%02d:%02d:%02d   %02d/%02d/%04d%s", \
29       _s1, (int) (_tb)->hour, (int) (_tb)->minute, (int) (_tb)->second, \
30       (int) (_tb)->month, (int) (_tb)->day, (int) (_tb)->year, _s2 ); \
31    fflush(stdout); \
32  } while ( 0 )
33
34/*
35 *  Macro to print an task name that is composed of ASCII characters.
36 *
37 */
38
39#define put_name( _name, _crlf ) \
40  do { \
41    uint32_t c0, c1, c2, c3; \
42    \
43    c0 = ((_name) >> 24) & 0xff; \
44    c1 = ((_name) >> 16) & 0xff; \
45    c2 = ((_name) >> 8) & 0xff; \
46    c3 = (_name) & 0xff; \
47    putchar( (char)c0 ); \
48    if ( c1 ) putchar( (char)c1 ); \
49    if ( c2 ) putchar( (char)c2 ); \
50    if ( c3 ) putchar( (char)c3 ); \
51    if ( (_crlf) ) \
52      putchar( '\n' ); \
53  } while (0)
54
55/*
56 *  static inline routine to make obtaining ticks per second easier.
57 */
58
59static inline uint32_t get_ticks_per_second( void )
60{
61  rtems_interval ticks_per_second;
62  (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second );  return ticks_per_second;
63}
64
65
66/*
67 *  This allows us to view the "Test_task" instantiations as a set
68 *  of numbered tasks by eliminating the number of application
69 *  tasks created.
70 *
71 *  In reality, this is too complex for the purposes of this
72 *  example.  It would have been easier to pass a task argument. :)
73 *  But it shows how rtems_id's can sometimes be used.
74 */
75
76#define task_number( tid ) \
77  ( rtems_object_id_get_index( tid ) - \
78     rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks )
79
80#endif
81/* end of include file */
Note: See TracBrowser for help on using the repository browser.