Changeset 4b960e5 in rtems


Ignore:
Timestamp:
Nov 16, 1999, 4:21:00 PM (20 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
90378e4
Parents:
72d4b1d9
Message:

Added code to the macros which checked directive status to also
check that the _Thread_Dispatch_disable_level is set to the
proper value (0 99% of the time). This automatic check significantly
reduces the chance of mismatching disable/enable dispatch pairs
while doing internal RTEMS work.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/tests/support/include/tmacros.h

    r72d4b1d9 r4b960e5  
    2626#include <stdio.h>
    2727#include <stdlib.h>
     28#include <assert.h>
    2829
    2930#define FOREVER 1                  /* infinite loop */
     
    3637#endif
    3738
    38 #define directive_failed( dirstat, failmsg )  \
    39     fatal_directive_status( dirstat, RTEMS_SUCCESSFUL, failmsg )
     39#define check_dispatch_disable_level( _expect ) \
     40  do { \
     41    extern volatile rtems_unsigned32 _Thread_Dispatch_disable_level; \
     42    if ( _Thread_Dispatch_disable_level != (_expect) ) { \
     43      printf( "\n_Thread_Dispatch_disable_level is (%d) not %d\n", \
     44              _Thread_Dispatch_disable_level, (_expect) ); \
     45      fflush(stdout); \
     46      exit( 1 ); \
     47    } \
     48  } while ( 0 )
    4049
    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#define directive_failed( _dirstat, _failmsg )  \
     51 fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
    5052
    51 #define sprint_time(str,s1,tb,s2) \
     53#define directive_failed_with_level( _dirstat, _failmsg, _level )  \
     54 fatal_directive_status_with_level( \
     55      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
     56
     57#define fatal_directive_status( _stat, _desired, _msg ) \
     58  fatal_directive_status_with_level( _stat, _desired, _msg, 0 )
     59
     60#define fatal_directive_status_with_level( _stat, _desired, _msg, _level ) \
     61  do { \
     62    check_dispatch_disable_level( _level ); \
     63    if ( (_stat) != (_desired) ) { \
     64      printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
     65              (_msg), (_desired), (_stat) ); \
     66      fflush(stdout); \
     67      exit( _stat ); \
     68    } \
     69  } while ( 0 )
     70
     71#define sprint_time(_str, _s1, _tb, _s2) \
    5272  do { \
    5373    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 ); \
     74       _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
     75       (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
    5676  } while ( 0 )
    5777
    58 #define print_time(s1,tb,s2) \
     78#define print_time(_s1, _tb, _s2) \
    5979  do { \
    6080    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 ); \
     81       _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
     82       (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
    6383    fflush(stdout); \
    6484  } while ( 0 )
    6585
    66 #define put_dot( c ) putchar( c ); fflush( stdout )
     86#define put_dot( _c ) \
     87  do { \
     88    putchar( _c ); \
     89    fflush( stdout ); \
     90  } while ( 0 )
    6791
    6892#define new_line  puts( "" )
  • testsuites/support/include/tmacros.h

    r72d4b1d9 r4b960e5  
    2626#include <stdio.h>
    2727#include <stdlib.h>
     28#include <assert.h>
    2829
    2930#define FOREVER 1                  /* infinite loop */
     
    3637#endif
    3738
    38 #define directive_failed( dirstat, failmsg )  \
    39     fatal_directive_status( dirstat, RTEMS_SUCCESSFUL, failmsg )
     39#define check_dispatch_disable_level( _expect ) \
     40  do { \
     41    extern volatile rtems_unsigned32 _Thread_Dispatch_disable_level; \
     42    if ( _Thread_Dispatch_disable_level != (_expect) ) { \
     43      printf( "\n_Thread_Dispatch_disable_level is (%d) not %d\n", \
     44              _Thread_Dispatch_disable_level, (_expect) ); \
     45      fflush(stdout); \
     46      exit( 1 ); \
     47    } \
     48  } while ( 0 )
    4049
    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#define directive_failed( _dirstat, _failmsg )  \
     51 fatal_directive_status( _dirstat, RTEMS_SUCCESSFUL, _failmsg )
    5052
    51 #define sprint_time(str,s1,tb,s2) \
     53#define directive_failed_with_level( _dirstat, _failmsg, _level )  \
     54 fatal_directive_status_with_level( \
     55      _dirstat, RTEMS_SUCCESSFUL, _failmsg, _level )
     56
     57#define fatal_directive_status( _stat, _desired, _msg ) \
     58  fatal_directive_status_with_level( _stat, _desired, _msg, 0 )
     59
     60#define fatal_directive_status_with_level( _stat, _desired, _msg, _level ) \
     61  do { \
     62    check_dispatch_disable_level( _level ); \
     63    if ( (_stat) != (_desired) ) { \
     64      printf( "\n%s FAILED -- expected (%d) got (%d)\n", \
     65              (_msg), (_desired), (_stat) ); \
     66      fflush(stdout); \
     67      exit( _stat ); \
     68    } \
     69  } while ( 0 )
     70
     71#define sprint_time(_str, _s1, _tb, _s2) \
    5272  do { \
    5373    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 ); \
     74       _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
     75       (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
    5676  } while ( 0 )
    5777
    58 #define print_time(s1,tb,s2) \
     78#define print_time(_s1, _tb, _s2) \
    5979  do { \
    6080    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 ); \
     81       _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
     82       (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
    6383    fflush(stdout); \
    6484  } while ( 0 )
    6585
    66 #define put_dot( c ) putchar( c ); fflush( stdout )
     86#define put_dot( _c ) \
     87  do { \
     88    putchar( _c ); \
     89    fflush( stdout ); \
     90  } while ( 0 )
    6791
    6892#define new_line  puts( "" )
Note: See TracChangeset for help on using the changeset viewer.