//              COPYRIGHT T.R.BARBOUR 1995. All rights reserved.
//              =============================================== 
                                                                
#ifndef BUGLEVS_H_
   #error "buglevs.h" not included - "xchecks.h"
#endif

#ifndef PRINTBUG_H_
   #include "printbug.h"
#endif

#ifdef XCHECKS_H_
   #undef XCHECKS_H_
   #undef dbprc
   #undef dbprc2
   #undef dbprc3
   #undef prec0
   #undef prec
   #undef prec2
   #undef dbchk
   #undef dbchk2
   #undef dbchk3
   #undef check0
   #undef check
   #undef check2
#endif

#if __DEBUG == 0
   #undef __DEBUG
   #define __DEBUG 99
#endif

#define XCHECKS_H_
#if __DEBUG >= PRECONDITIONS
   #define dbprc(stmt) stmt
   #define dbprc2(part1,part2) part1,part2
   #define dbprc3(part1,part2,part3) part1,part2,part3
   #define prec0(p)                                                         \
      ( (p) ? (void)0 : (void) ( ERR << "Precondition violated: " #p        \
                                     << halt                           ) )
   #define prec(x,p)                                                         \
      ( (p) ? (void)0 : (void) ( ERR << "Precondition violated: " #p        \
                                     << ", " << PRS(x) << halt         ) )
   #define prec2(x,y,p)                                                      \
      ( (p) ? (void)0 : (void) ( ERR << "Precondition violated: " #p       \
                                      << ", " << PRS(x)                     \
                                      << ", " << PRS(y) << halt       ) )  
#else
   #define dbprc(stmt)
   #define dbprc2(part1,part2)
   #define dbprc3(part1,part2,part3)
   #define prec0(p) ((void)0)
   #define prec(x,p) ((void)0)
   #define prec2(x,y,p) ((void)0)
#endif

#if __DEBUG >= INTERNALCHECKS
   #define dbchk(stmt) stmt
   #define dbchk2(part1,part2) part1,part2
   #define dbchk3(part1,part2,part3) part1,part2,part3
   #define check0(p)                                                      \
      ( (p) ? (void)0 : (void) ( ERR << "Check failed: " #p                  \
                                      << halt                ) )  
   #define check(x,p)                                                      \
      ( (p) ? (void)0 : (void) ( ERR << "Check failed: " #p                  \
                                      << ", " << PRS(x) << halt ) )  
   #define check2(x,y,p)                                                   \
      ( (p) ? (void)0 : (void) ( ERR << "Check failed: " #p                \
                                      << ", " << PRS(x)                       \
                                      << ", " << PRS(y) << halt ) )   
#else
   #define dbchk(stmt)
   #define dbchk2(part1,part2)
   #define dbchk3(part1,part2,part3)
   #define check0(p) ((void)0)
   #define check(x,p) ((void)0)
   #define check2(x,y,p) ((void)0)
#endif
