/ basic-headers / AssertMacros.h
AssertMacros.h
   1  /*
   2   * Copyright (c) 2002-2008 by Apple Inc.. All rights reserved.
   3   *
   4   * @APPLE_LICENSE_HEADER_START@
   5   * 
   6   * This file contains Original Code and/or Modifications of Original Code
   7   * as defined in and that are subject to the Apple Public Source License
   8   * Version 2.0 (the 'License'). You may not use this file except in
   9   * compliance with the License. Please obtain a copy of the License at
  10   * http://www.opensource.apple.com/apsl/ and read it before using this
  11   * file.
  12   * 
  13   * The Original Code and all software distributed under the License are
  14   * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  15   * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  16   * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  17   * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  18   * Please see the License for the specific language governing rights and
  19   * limitations under the License.
  20   * 
  21   * @APPLE_LICENSE_HEADER_END@
  22   */
  23  
  24  
  25  /*
  26  	File:       AssertMacros.h
  27   
  28  	Contains:   This file defines structured error handling and assertion macros for
  29  				programming in C. Originally used in QuickDraw GX and later enhanced.
  30  				These macros are used throughout Apple's software.
  31  	
  32  				New code may not want to begin adopting these macros and instead use
  33  				existing language functionality.
  34  	
  35  				See "Living In an Exceptional World" by Sean Parent
  36  				(develop, The Apple Technical Journal, Issue 11, August/September 1992)
  37  				<http://developer.apple.com/dev/techsupport/develop/issue11toc.shtml> or
  38  				<http://www.mactech.com/articles/develop/issue_11/Parent_final.html>
  39  				for the methodology behind these error handling and assertion macros.
  40  	
  41  	Bugs?:      For bug reports, consult the following page on
  42  				the World Wide Web:
  43  
  44  	 http://developer.apple.com/bugreporter/ 
  45  */
  46  #ifndef __ASSERTMACROS__
  47  #define __ASSERTMACROS__
  48  
  49  /*
  50   *  Macro overview:
  51   *  
  52   *      check(assertion)
  53   *         In production builds, pre-processed away  
  54   *         In debug builds, if assertion evaluates to false, calls DEBUG_ASSERT_MESSAGE
  55   *  
  56   *      verify(assertion)
  57   *         In production builds, evaluates assertion and does nothing
  58   *         In debug builds, if assertion evaluates to false, calls DEBUG_ASSERT_MESSAGE
  59   *  
  60   *      require(assertion, exceptionLabel)
  61   *         In production builds, if the assertion expression evaluates to false, goto exceptionLabel
  62   *         In debug builds, if the assertion expression evaluates to false, calls DEBUG_ASSERT_MESSAGE
  63   *                          and jumps to exceptionLabel
  64   *  
  65   *      In addition the following suffixes are available:
  66   * 
  67   *         _noerr     Adds "!= 0" to assertion.  Useful for asserting and OSStatus or OSErr is noErr (zero)
  68   *         _action    Adds statement to be executued if assertion fails
  69   *         _quiet     Suppress call to DEBUG_ASSERT_MESSAGE
  70   *         _string    Allows you to add explanitory message to DEBUG_ASSERT_MESSAGE
  71   *  
  72   *        For instance, require_noerr_string(resultCode, label, msg) will do nothing if 
  73   *        resultCode is zero, otherwise it will call DEBUG_ASSERT_MESSAGE with msg
  74   *        and jump to label.
  75   *
  76   *  Configuration:
  77   *
  78   *      By default all macros generate "production code" (i.e non-debug).  If  
  79   *      DEBUG_ASSERT_PRODUCTION_CODE is defined to zero or DEBUG is defined to non-zero
  80   *      while this header is included, the macros will generated debug code.
  81   *
  82   *      If DEBUG_ASSERT_COMPONENT_NAME_STRING is defined, all debug messages will
  83   *      be prefixed with it.
  84   *
  85   *      By default, all messages write to stderr.  If you would like to write a custom
  86   *      error message formater, defined DEBUG_ASSERT_MESSAGE to your function name.
  87   *
  88   *      Each individual macro will only be defined if it is not already defined, so
  89   *      you can redefine their behavior singly by providing your own definition before
  90   *      this file is included.
  91   *
  92   *      If you define __ASSERTMACROS__ before this file is included, then nothing in
  93   *      this file will take effect.
  94   *
  95   *      Prior to Mac OS X 10.6 the macro names used in this file conflicted with some
  96   *      user code, including libraries in boost and the proposed C++ standards efforts,
  97   *      and there was no way for a client of this header to resolve this conflict. Because
  98   *      of this, most of the macros have been changed so that they are prefixed with 
  99   *      __ and contain at least one capital letter, which should alleviate the current
 100   *      and future conflicts.  However, to allow current sources to continue to compile,
 101   *      compatibility macros are defined at the end with the old names.  A tops script 
 102   *      at the end of this file will convert all of the old macro names used in a directory
 103   *      to the new names.  Clients are recommended to migrate over to these new macros as
 104   *      they update their sources because a future release of Mac OS X will remove the
 105   *      old macro definitions ( without the double-underscore prefix ).  Clients who
 106   *      want to compile without the old macro definitions can define the macro
 107   *      __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES to 0 before this file is
 108   *      included.
 109   */
 110  
 111  
 112  /*
 113   *  Before including this file, #define DEBUG_ASSERT_COMPONENT_NAME_STRING to
 114   *  a C-string containing the name of your client. This string will be passed to
 115   *  the DEBUG_ASSERT_MESSAGE macro for inclusion in any assertion messages.
 116   *
 117   *  If you do not define DEBUG_ASSERT_COMPONENT_NAME_STRING, the default
 118   *  DEBUG_ASSERT_COMPONENT_NAME_STRING value, an empty string, will be used by
 119   *  the assertion macros.
 120   */
 121  #ifndef DEBUG_ASSERT_COMPONENT_NAME_STRING
 122      #define DEBUG_ASSERT_COMPONENT_NAME_STRING ""
 123  #endif
 124  
 125  
 126  /*
 127   *  To activate the additional assertion code and messages for non-production builds,
 128   *  #define DEBUG_ASSERT_PRODUCTION_CODE to zero before including this file.
 129   *
 130   *  If you do not define DEBUG_ASSERT_PRODUCTION_CODE, the default value 1 will be used
 131   *  (production code = no assertion code and no messages).
 132   */
 133  #ifndef DEBUG_ASSERT_PRODUCTION_CODE
 134     #define DEBUG_ASSERT_PRODUCTION_CODE !DEBUG
 135  #endif
 136  
 137  
 138  /*
 139   *  DEBUG_ASSERT_MESSAGE(component, assertion, label, error, file, line, errorCode)
 140   *
 141   *  Summary:
 142   *    All assertion messages are routed through this macro. If you wish to use your
 143   *    own routine to display assertion messages, you can override DEBUG_ASSERT_MESSAGE
 144   *    by #defining DEBUG_ASSERT_MESSAGE before including this file.
 145   *
 146   *  Parameters:
 147   *
 148   *    componentNameString:
 149   *      A pointer to a string constant containing the name of the
 150   *      component this code is part of. This must be a string constant
 151   *      (and not a string variable or NULL) because the preprocessor
 152   *      concatenates it with other string constants.
 153   *
 154   *    assertionString:
 155   *      A pointer to a string constant containing the assertion.
 156   *      This must be a string constant (and not a string variable or
 157   *      NULL) because the Preprocessor concatenates it with other
 158   *      string constants.
 159   *    
 160   *    exceptionLabelString:
 161   *      A pointer to a string containing the exceptionLabel, or NULL.
 162   *    
 163   *    errorString:
 164   *      A pointer to the error string, or NULL. DEBUG_ASSERT_MESSAGE macros
 165   *      must not attempt to concatenate this string with constant
 166   *      character strings.
 167   *    
 168   *    fileName:
 169   *      A pointer to the fileName or pathname (generated by the
 170   *      preprocessor __FILE__ identifier), or NULL.
 171   *    
 172   *    lineNumber:
 173   *      The line number in the file (generated by the preprocessor
 174   *      __LINE__ identifier), or 0 (zero).
 175   *    
 176   *    errorCode:
 177   *      A value associated with the assertion, or 0.
 178   *
 179   *  Here is an example of a DEBUG_ASSERT_MESSAGE macro and a routine which displays
 180   *  assertion messsages:
 181   *
 182   *      #define DEBUG_ASSERT_COMPONENT_NAME_STRING "MyCoolProgram"
 183   *
 184   *      #define DEBUG_ASSERT_MESSAGE(componentNameString, assertionString,                           \
 185   *                                   exceptionLabelString, errorString, fileName, lineNumber, errorCode) \
 186   *              MyProgramDebugAssert(componentNameString, assertionString,                           \
 187   *                                   exceptionLabelString, errorString, fileName, lineNumber, errorCode)
 188   *
 189   *      static void
 190   *      MyProgramDebugAssert(const char *componentNameString, const char *assertionString, 
 191   *                           const char *exceptionLabelString, const char *errorString, 
 192   *                           const char *fileName, long lineNumber, int errorCode)
 193   *      {
 194   *          if ( (assertionString != NULL) && (*assertionString != '\0') )
 195   *              fprintf(stderr, "Assertion failed: %s: %s\n", componentNameString, assertionString);
 196   *          else
 197   *              fprintf(stderr, "Check failed: %s:\n", componentNameString);
 198   *          if ( exceptionLabelString != NULL )
 199   *              fprintf(stderr, "    %s\n", exceptionLabelString);
 200   *          if ( errorString != NULL )
 201   *              fprintf(stderr, "    %s\n", errorString);
 202   *          if ( fileName != NULL )
 203   *              fprintf(stderr, "    file: %s\n", fileName);
 204   *          if ( lineNumber != 0 )
 205   *              fprintf(stderr, "    line: %ld\n", lineNumber);
 206   *          if ( errorCode != 0 )
 207   *              fprintf(stderr, "    error: %d\n", errorCode);
 208   *      }
 209   *
 210   *  If you do not define DEBUG_ASSERT_MESSAGE, a simple printf to stderr will be used.
 211   */
 212  #ifndef DEBUG_ASSERT_MESSAGE
 213     #ifdef KERNEL
 214        #include <libkern/libkern.h>
 215        #define DEBUG_ASSERT_MESSAGE(name, assertion, label, message, file, line, value) \
 216                                    printf( "AssertMacros: %s, %s file: %s, line: %d\n", assertion, (message!=0) ? message : "", file, line);
 217     #else
 218        #include <stdio.h>
 219        #define DEBUG_ASSERT_MESSAGE(name, assertion, label, message, file, line, value) \
 220                                    fprintf(stderr, "AssertMacros: %s, %s file: %s, line: %d\n", assertion, (message!=0) ? message : "", file, line);
 221     #endif
 222  #endif
 223  
 224  
 225  
 226  
 227  
 228  /*
 229   *  __Debug_String(message)
 230   *
 231   *  Summary:
 232   *    Production builds: does nothing and produces no code.
 233   *
 234   *    Non-production builds: call DEBUG_ASSERT_MESSAGE.
 235   *
 236   *  Parameters:
 237   *
 238   *    message:
 239   *      The C string to display.
 240   *
 241   */
 242  #ifndef __Debug_String
 243  	#if DEBUG_ASSERT_PRODUCTION_CODE
 244  	   #define __Debug_String(message)
 245  	#else
 246  	   #define __Debug_String(message)                                             \
 247  		  do                                                                      \
 248  		  {                                                                       \
 249  			  DEBUG_ASSERT_MESSAGE(                                               \
 250  				  DEBUG_ASSERT_COMPONENT_NAME_STRING,                             \
 251  				  "",                                                             \
 252  				  0,                                                              \
 253  				  message,                                                        \
 254  				  __FILE__,                                                       \
 255  				  __LINE__,                                                       \
 256  				  0);                                                             \
 257  		  } while ( 0 )
 258  	#endif
 259  #endif
 260  
 261  /*
 262   *  __Check(assertion)
 263   *
 264   *  Summary:
 265   *    Production builds: does nothing and produces no code.
 266   *
 267   *    Non-production builds: if the assertion expression evaluates to false,
 268   *    call DEBUG_ASSERT_MESSAGE.
 269   *
 270   *  Parameters:
 271   *
 272   *    assertion:
 273   *      The assertion expression.
 274   */
 275  #ifndef __Check
 276  	#if DEBUG_ASSERT_PRODUCTION_CODE
 277  	   #define __Check(assertion)
 278  	#else
 279  	   #define __Check(assertion)                                                 \
 280  		  do                                                                      \
 281  		  {                                                                       \
 282  			  if ( __builtin_expect(!(assertion), 0) )                            \
 283  			  {                                                                   \
 284  				  DEBUG_ASSERT_MESSAGE(                                           \
 285  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 286  					  #assertion, 0, 0, __FILE__, __LINE__, 0 );                  \
 287  			  }                                                                   \
 288  		  } while ( 0 )
 289  	#endif
 290  #endif
 291  
 292  #ifndef __nCheck
 293  	#define __nCheck(assertion)  __Check(!(assertion))
 294  #endif
 295  
 296  /*
 297   *  __Check_String(assertion, message)
 298   *
 299   *  Summary:
 300   *    Production builds: does nothing and produces no code.
 301   *
 302   *    Non-production builds: if the assertion expression evaluates to false,
 303   *    call DEBUG_ASSERT_MESSAGE.
 304   *
 305   *  Parameters:
 306   *
 307   *    assertion:
 308   *      The assertion expression.
 309   *
 310   *    message:
 311   *      The C string to display.
 312   */
 313  #ifndef __Check_String
 314  	#if DEBUG_ASSERT_PRODUCTION_CODE
 315  	   #define __Check_String(assertion, message)
 316  	#else
 317  	   #define __Check_String(assertion, message)                                 \
 318  		  do                                                                      \
 319  		  {                                                                       \
 320  			  if ( __builtin_expect(!(assertion), 0) )                            \
 321  			  {                                                                   \
 322  				  DEBUG_ASSERT_MESSAGE(                                           \
 323  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 324  					  #assertion, 0, message, __FILE__, __LINE__, 0 );            \
 325  			  }                                                                   \
 326  		  } while ( 0 )
 327  	#endif
 328  #endif
 329  
 330  #ifndef __nCheck_String
 331  	#define __nCheck_String(assertion, message)  __Check_String(!(assertion), message)
 332  #endif
 333  
 334  /*
 335   *  __Check_noErr(errorCode)
 336   *
 337   *  Summary:
 338   *    Production builds: does nothing and produces no code.
 339   *
 340   *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
 341   *    call DEBUG_ASSERT_MESSAGE.
 342   *
 343   *  Parameters:
 344   *
 345   *    errorCode:
 346   *      The errorCode expression to compare with 0.
 347   */
 348  #ifndef __Check_noErr
 349  	#if DEBUG_ASSERT_PRODUCTION_CODE
 350  	   #define __Check_noErr(errorCode)
 351  	#else
 352  	   #define __Check_noErr(errorCode)                                           \
 353  		  do                                                                      \
 354  		  {                                                                       \
 355  			  long evalOnceErrorCode = (errorCode);                               \
 356  			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
 357  			  {                                                                   \
 358  				  DEBUG_ASSERT_MESSAGE(                                           \
 359  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 360  					  #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, evalOnceErrorCode ); \
 361  			  }                                                                   \
 362  		  } while ( 0 )
 363  	#endif
 364  #endif
 365  
 366  /*
 367   *  __Check_noErr_String(errorCode, message)
 368   *
 369   *  Summary:
 370   *    Production builds: check_noerr_string() does nothing and produces
 371   *    no code.
 372   *
 373   *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
 374   *    call DEBUG_ASSERT_MESSAGE.
 375   *
 376   *  Parameters:
 377   *
 378   *    errorCode:
 379   *      The errorCode expression to compare to 0.
 380   *
 381   *    message:
 382   *      The C string to display.
 383   */
 384  #ifndef __Check_noErr_String
 385  	#if DEBUG_ASSERT_PRODUCTION_CODE
 386  	   #define __Check_noErr_String(errorCode, message)
 387  	#else
 388  	   #define __Check_noErr_String(errorCode, message)                           \
 389  		  do                                                                      \
 390  		  {                                                                       \
 391  			  long evalOnceErrorCode = (errorCode);                               \
 392  			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
 393  			  {                                                                   \
 394  				  DEBUG_ASSERT_MESSAGE(                                           \
 395  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 396  					  #errorCode " == 0 ", 0, message, __FILE__, __LINE__, evalOnceErrorCode ); \
 397  			  }                                                                   \
 398  		  } while ( 0 )
 399  	#endif
 400  #endif
 401  
 402  /*
 403   *  __Verify(assertion)
 404   *
 405   *  Summary:
 406   *    Production builds: evaluate the assertion expression, but ignore
 407   *    the result.
 408   *
 409   *    Non-production builds: if the assertion expression evaluates to false,
 410   *    call DEBUG_ASSERT_MESSAGE.
 411   *
 412   *  Parameters:
 413   *
 414   *    assertion:
 415   *      The assertion expression.
 416   */
 417  #ifndef __Verify
 418  	#if DEBUG_ASSERT_PRODUCTION_CODE
 419  	   #define __Verify(assertion)                                                \
 420  		  do                                                                      \
 421  		  {                                                                       \
 422  			  if ( !(assertion) )                                                 \
 423  			  {                                                                   \
 424  			  }                                                                   \
 425  		  } while ( 0 )
 426  	#else
 427  	   #define __Verify(assertion)                                                \
 428  		  do                                                                      \
 429  		  {                                                                       \
 430  			  if ( __builtin_expect(!(assertion), 0) )                            \
 431  			  {                                                                   \
 432  				  DEBUG_ASSERT_MESSAGE(                                           \
 433  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 434  					  #assertion, 0, 0, __FILE__, __LINE__, 0 );                  \
 435  			  }                                                                   \
 436  		  } while ( 0 )
 437  	#endif
 438  #endif
 439  
 440  #ifndef __nVerify
 441  	#define __nVerify(assertion)	__Verify(!(assertion))
 442  #endif
 443  
 444  /*
 445   *  __Verify_String(assertion, message)
 446   *
 447   *  Summary:
 448   *    Production builds: evaluate the assertion expression, but ignore
 449   *    the result.
 450   *
 451   *    Non-production builds: if the assertion expression evaluates to false,
 452   *    call DEBUG_ASSERT_MESSAGE.
 453   *
 454   *  Parameters:
 455   *
 456   *    assertion:
 457   *      The assertion expression.
 458   *
 459   *    message:
 460   *      The C string to display.
 461   */
 462  #ifndef __Verify_String
 463  	#if DEBUG_ASSERT_PRODUCTION_CODE
 464  	   #define __Verify_String(assertion, message)                                \
 465  		  do                                                                      \
 466  		  {                                                                       \
 467  			  if ( !(assertion) )                                                 \
 468  			  {                                                                   \
 469  			  }                                                                   \
 470  		  } while ( 0 )
 471  	#else
 472  	   #define __Verify_String(assertion, message)                                \
 473  		  do                                                                      \
 474  		  {                                                                       \
 475  			  if ( __builtin_expect(!(assertion), 0) )                            \
 476  			  {                                                                   \
 477  				  DEBUG_ASSERT_MESSAGE(                                           \
 478  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 479  					  #assertion, 0, message, __FILE__, __LINE__, 0 );            \
 480  			  }                                                                   \
 481  		  } while ( 0 )
 482  	#endif
 483  #endif
 484  
 485  #ifndef __nVerify_String
 486  	#define __nVerify_String(assertion, message)  __Verify_String(!(assertion), message)
 487  #endif
 488  
 489  /*
 490   *  __Verify_noErr(errorCode)
 491   *
 492   *  Summary:
 493   *    Production builds: evaluate the errorCode expression, but ignore
 494   *    the result.
 495   *
 496   *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
 497   *    call DEBUG_ASSERT_MESSAGE.
 498   *
 499   *  Parameters:
 500   *
 501   *    errorCode:
 502   *      The expression to compare to 0.
 503   */
 504  #ifndef __Verify_noErr
 505  	#if DEBUG_ASSERT_PRODUCTION_CODE
 506  	   #define __Verify_noErr(errorCode)                                          \
 507  		  do                                                                      \
 508  		  {                                                                       \
 509  			  if ( 0 != (errorCode) )                                             \
 510  			  {                                                                   \
 511  			  }                                                                   \
 512  		  } while ( 0 )
 513  	#else
 514  	   #define __Verify_noErr(errorCode)                                          \
 515  		  do                                                                      \
 516  		  {                                                                       \
 517  			  long evalOnceErrorCode = (errorCode);                               \
 518  			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
 519  			  {                                                                   \
 520  				  DEBUG_ASSERT_MESSAGE(                                           \
 521  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 522  					  #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, evalOnceErrorCode ); \
 523  			  }                                                                   \
 524  		  } while ( 0 )
 525  	#endif
 526  #endif
 527  
 528  /*
 529   *  __Verify_noErr_String(errorCode, message)
 530   *
 531   *  Summary:
 532   *    Production builds: evaluate the errorCode expression, but ignore
 533   *    the result.
 534   *
 535   *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
 536   *    call DEBUG_ASSERT_MESSAGE.
 537   *
 538   *  Parameters:
 539   *
 540   *    errorCode:
 541   *      The expression to compare to 0.
 542   *
 543   *    message:
 544   *      The C string to display.
 545   */
 546  #ifndef __Verify_noErr_String
 547  	#if DEBUG_ASSERT_PRODUCTION_CODE
 548  	   #define __Verify_noErr_String(errorCode, message)                          \
 549  		  do                                                                      \
 550  		  {                                                                       \
 551  			  if ( 0 != (errorCode) )                                             \
 552  			  {                                                                   \
 553  			  }                                                                   \
 554  		  } while ( 0 )
 555  	#else
 556  	   #define __Verify_noErr_String(errorCode, message)                          \
 557  		  do                                                                      \
 558  		  {                                                                       \
 559  			  long evalOnceErrorCode = (errorCode);                               \
 560  			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
 561  			  {                                                                   \
 562  				  DEBUG_ASSERT_MESSAGE(                                           \
 563  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 564  					  #errorCode " == 0 ", 0, message, __FILE__, __LINE__, evalOnceErrorCode ); \
 565  			  }                                                                   \
 566  		  } while ( 0 )
 567  	#endif
 568  #endif
 569  
 570  /*
 571   *  __Verify_noErr_Action(errorCode, action)
 572   *
 573   *  Summary:
 574   *    Production builds: if the errorCode expression does not equal 0 (noErr),
 575   *    execute the action statement or compound statement (block).
 576   *
 577   *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
 578   *    call DEBUG_ASSERT_MESSAGE and then execute the action statement or compound
 579   *    statement (block).
 580   *
 581   *  Parameters:
 582   *
 583   *    errorCode:
 584   *      The expression to compare to 0.
 585   *
 586   *    action:
 587   *      The statement or compound statement (block).
 588   */
 589  #ifndef __Verify_noErr_Action
 590  	#if DEBUG_ASSERT_PRODUCTION_CODE
 591  	   #define __Verify_noErr_Action(errorCode, action)                          \
 592  		  if ( 0 != (errorCode) ) {                                              \
 593  			  action;                                                            \
 594  		  }                                                                      \
 595  		  else do {} while (0)
 596  	#else
 597  	   #define __Verify_noErr_Action(errorCode, action)                          \
 598                 do {                                                                   \
 599  		  long evalOnceErrorCode = (errorCode);                                  \
 600  		  if ( __builtin_expect(0 != evalOnceErrorCode, 0) ) {                   \
 601  			  DEBUG_ASSERT_MESSAGE(                                              \
 602  				  DEBUG_ASSERT_COMPONENT_NAME_STRING,                            \
 603  				  #errorCode " == 0 ", 0, 0, __FILE__, __LINE__, evalOnceErrorCode );            \
 604  			  action;                                                            \
 605  		  }                                                                      \
 606  	       } while (0)
 607  	#endif
 608  #endif
 609  
 610  /*
 611   *  __Verify_Action(assertion, action)
 612   *
 613   *  Summary:
 614   *    Production builds: if the assertion expression evaluates to false,
 615   *    then execute the action statement or compound statement (block).
 616   *
 617   *    Non-production builds: if the assertion expression evaluates to false,
 618   *    call DEBUG_ASSERT_MESSAGE and then execute the action statement or compound
 619   *    statement (block).
 620   *
 621   *  Parameters:
 622   *
 623   *    assertion:
 624   *      The assertion expression.
 625   *
 626   *    action:
 627   *      The statement or compound statement (block).
 628   */
 629  #ifndef __Verify_Action
 630  	#if DEBUG_ASSERT_PRODUCTION_CODE
 631  	   #define __Verify_Action(assertion, action)                                \
 632  		  if ( __builtin_expect(!(assertion), 0) ) {                             \
 633  			action;                                                              \
 634  		  }                                                                      \
 635  		  else do {} while (0)
 636  	#else
 637  	   #define __Verify_Action(assertion, action)                                \
 638  		  if ( __builtin_expect(!(assertion), 0) ) {                             \
 639  			  DEBUG_ASSERT_MESSAGE(                                              \
 640  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                        \
 641  					  #assertion, 0, 0, __FILE__, __LINE__, 0 );                 \
 642  			  action;                                                            \
 643  		  }                                                                      \
 644  		  else do {} while (0)
 645  	#endif
 646  #endif
 647  
 648  /*
 649   *  __Require(assertion, exceptionLabel)
 650   *
 651   *  Summary:
 652   *    Production builds: if the assertion expression evaluates to false,
 653   *    goto exceptionLabel.
 654   *
 655   *    Non-production builds: if the assertion expression evaluates to false,
 656   *    call DEBUG_ASSERT_MESSAGE and then goto exceptionLabel.
 657   *
 658   *  Parameters:
 659   *
 660   *    assertion:
 661   *      The assertion expression.
 662   *
 663   *    exceptionLabel:
 664   *      The label.
 665   */
 666  #ifndef __Require
 667  	#if DEBUG_ASSERT_PRODUCTION_CODE
 668  	   #define __Require(assertion, exceptionLabel)                               \
 669  		  do                                                                      \
 670  		  {                                                                       \
 671  			  if ( __builtin_expect(!(assertion), 0) )                            \
 672  			  {                                                                   \
 673  				  goto exceptionLabel;                                            \
 674  			  }                                                                   \
 675  		  } while ( 0 )
 676  	#else
 677  	   #define __Require(assertion, exceptionLabel)                               \
 678  		  do                                                                      \
 679  		  {                                                                       \
 680  			  if ( __builtin_expect(!(assertion), 0) ) {                          \
 681  				  DEBUG_ASSERT_MESSAGE(                                           \
 682  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 683  					  #assertion, #exceptionLabel, 0, __FILE__, __LINE__,  0);    \
 684  				  goto exceptionLabel;                                            \
 685  			  }                                                                   \
 686  		  } while ( 0 )
 687  	#endif
 688  #endif
 689  
 690  #ifndef __nRequire
 691  	#define __nRequire(assertion, exceptionLabel)  __Require(!(assertion), exceptionLabel)
 692  #endif
 693  
 694  /*
 695   *  __Require_Action(assertion, exceptionLabel, action)
 696   *
 697   *  Summary:
 698   *    Production builds: if the assertion expression evaluates to false,
 699   *    execute the action statement or compound statement (block) and then
 700   *    goto exceptionLabel.
 701   *
 702   *    Non-production builds: if the assertion expression evaluates to false,
 703   *    call DEBUG_ASSERT_MESSAGE, execute the action statement or compound
 704   *    statement (block), and then goto exceptionLabel.
 705   *
 706   *  Parameters:
 707   *
 708   *    assertion:
 709   *      The assertion expression.
 710   *
 711   *    exceptionLabel:
 712   *      The label.
 713   *
 714   *    action:
 715   *      The statement or compound statement (block).
 716   */
 717  #ifndef __Require_Action
 718  	#if DEBUG_ASSERT_PRODUCTION_CODE
 719  	   #define __Require_Action(assertion, exceptionLabel, action)                \
 720  		  do                                                                      \
 721  		  {                                                                       \
 722  			  if ( __builtin_expect(!(assertion), 0) )                            \
 723  			  {                                                                   \
 724  				  {                                                               \
 725  					  action;                                                     \
 726  				  }                                                               \
 727  				  goto exceptionLabel;                                            \
 728  			  }                                                                   \
 729  		  } while ( 0 )
 730  	#else
 731  	   #define __Require_Action(assertion, exceptionLabel, action)                \
 732  		  do                                                                      \
 733  		  {                                                                       \
 734  			  if ( __builtin_expect(!(assertion), 0) )                            \
 735  			  {                                                                   \
 736  				  DEBUG_ASSERT_MESSAGE(                                           \
 737  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 738  					  #assertion, #exceptionLabel, 0,   __FILE__, __LINE__, 0);   \
 739  				  {                                                               \
 740  					  action;                                                     \
 741  				  }                                                               \
 742  				  goto exceptionLabel;                                            \
 743  			  }                                                                   \
 744  		  } while ( 0 )
 745  	#endif
 746  #endif
 747  
 748  #ifndef __nRequire_Action
 749  	#define __nRequire_Action(assertion, exceptionLabel, action)                  \
 750  	__Require_Action(!(assertion), exceptionLabel, action)
 751  #endif
 752  
 753  /*
 754   *  __Require_Quiet(assertion, exceptionLabel)
 755   *
 756   *  Summary:
 757   *    If the assertion expression evaluates to false, goto exceptionLabel.
 758   *
 759   *  Parameters:
 760   *
 761   *    assertion:
 762   *      The assertion expression.
 763   *
 764   *    exceptionLabel:
 765   *      The label.
 766   */
 767  #ifndef __Require_Quiet
 768  	#define __Require_Quiet(assertion, exceptionLabel)                            \
 769  	  do                                                                          \
 770  	  {                                                                           \
 771  		  if ( __builtin_expect(!(assertion), 0) )                                \
 772  		  {                                                                       \
 773  			  goto exceptionLabel;                                                \
 774  		  }                                                                       \
 775  	  } while ( 0 )
 776  #endif
 777  
 778  #ifndef __nRequire_Quiet
 779  	#define __nRequire_Quiet(assertion, exceptionLabel)  __Require_Quiet(!(assertion), exceptionLabel)
 780  #endif
 781  
 782  /*
 783   *  __Require_Action_Quiet(assertion, exceptionLabel, action)
 784   *
 785   *  Summary:
 786   *    If the assertion expression evaluates to false, execute the action
 787   *    statement or compound statement (block), and goto exceptionLabel.
 788   *
 789   *  Parameters:
 790   *
 791   *    assertion:
 792   *      The assertion expression.
 793   *
 794   *    exceptionLabel:
 795   *      The label.
 796   *
 797   *    action:
 798   *      The statement or compound statement (block).
 799   */
 800  #ifndef __Require_Action_Quiet
 801  	#define __Require_Action_Quiet(assertion, exceptionLabel, action)             \
 802  	  do                                                                          \
 803  	  {                                                                           \
 804  		  if ( __builtin_expect(!(assertion), 0) )                                \
 805  		  {                                                                       \
 806  			  {                                                                   \
 807  				  action;                                                         \
 808  			  }                                                                   \
 809  			  goto exceptionLabel;                                                \
 810  		  }                                                                       \
 811  	  } while ( 0 )
 812  #endif
 813  
 814  #ifndef __nRequire_Action_Quiet
 815  	#define __nRequire_Action_Quiet(assertion, exceptionLabel, action)              \
 816  		__Require_Action_Quiet(!(assertion), exceptionLabel, action)
 817  #endif
 818  
 819  /*
 820   *  __Require_String(assertion, exceptionLabel, message)
 821   *
 822   *  Summary:
 823   *    Production builds: if the assertion expression evaluates to false,
 824   *    goto exceptionLabel.
 825   *
 826   *    Non-production builds: if the assertion expression evaluates to false,
 827   *    call DEBUG_ASSERT_MESSAGE, and then goto exceptionLabel.
 828   *
 829   *  Parameters:
 830   *
 831   *    assertion:
 832   *      The assertion expression.
 833   *
 834   *    exceptionLabel:
 835   *      The label.
 836   *
 837   *    message:
 838   *      The C string to display.
 839   */
 840  #ifndef __Require_String
 841  	#if DEBUG_ASSERT_PRODUCTION_CODE
 842  	   #define __Require_String(assertion, exceptionLabel, message)               \
 843  		  do                                                                      \
 844  		  {                                                                       \
 845  			  if ( __builtin_expect(!(assertion), 0) )                            \
 846  			  {                                                                   \
 847  				  goto exceptionLabel;                                            \
 848  			  }                                                                   \
 849  		  } while ( 0 )
 850  	#else
 851  	   #define __Require_String(assertion, exceptionLabel, message)               \
 852  		  do                                                                      \
 853  		  {                                                                       \
 854  			  if ( __builtin_expect(!(assertion), 0) )                            \
 855  			  {                                                                   \
 856  				  DEBUG_ASSERT_MESSAGE(                                           \
 857  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 858  					  #assertion, #exceptionLabel,  message,  __FILE__, __LINE__, 0); \
 859  				  goto exceptionLabel;                                            \
 860  			  }                                                                   \
 861  		  } while ( 0 )
 862  	#endif
 863  #endif
 864  
 865  #ifndef __nRequire_String
 866  	#define __nRequire_String(assertion, exceptionLabel, string)                  \
 867  		__Require_String(!(assertion), exceptionLabel, string)
 868  #endif
 869  
 870  /*
 871   *  __Require_Action_String(assertion, exceptionLabel, action, message)
 872   *
 873   *  Summary:
 874   *    Production builds: if the assertion expression evaluates to false,
 875   *    execute the action statement or compound statement (block), and then
 876   *    goto exceptionLabel.
 877   *
 878   *    Non-production builds: if the assertion expression evaluates to false,
 879   *    call DEBUG_ASSERT_MESSAGE, execute the action statement or compound
 880   *    statement (block), and then goto exceptionLabel.
 881   *
 882   *  Parameters:
 883   *
 884   *    assertion:
 885   *      The assertion expression.
 886   *
 887   *    exceptionLabel:
 888   *      The label.
 889   *
 890   *    action:
 891   *      The statement or compound statement (block).
 892   *
 893   *    message:
 894   *      The C string to display.
 895   */
 896  #ifndef __Require_Action_String
 897  	#if DEBUG_ASSERT_PRODUCTION_CODE
 898  	   #define __Require_Action_String(assertion, exceptionLabel, action, message)  \
 899  		  do                                                                      \
 900  		  {                                                                       \
 901  			  if ( __builtin_expect(!(assertion), 0) )                            \
 902  			  {                                                                   \
 903  				  {                                                               \
 904  					  action;                                                     \
 905  				  }                                                               \
 906  				  goto exceptionLabel;                                            \
 907  			  }                                                                   \
 908  		  } while ( 0 )
 909  	#else
 910  	   #define __Require_Action_String(assertion, exceptionLabel, action, message)  \
 911  		  do                                                                      \
 912  		  {                                                                       \
 913  			  if ( __builtin_expect(!(assertion), 0) )                            \
 914  			  {                                                                   \
 915  				  DEBUG_ASSERT_MESSAGE(                                           \
 916  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 917  					  #assertion, #exceptionLabel,  message,  __FILE__,  __LINE__, 0); \
 918  				  {                                                               \
 919  					  action;                                                     \
 920  				  }                                                               \
 921  				  goto exceptionLabel;                                            \
 922  			  }                                                                   \
 923  		  } while ( 0 )
 924  	#endif
 925  #endif
 926  
 927  #ifndef __nRequire_Action_String
 928  	#define __nRequire_Action_String(assertion, exceptionLabel, action, message)    \
 929  		__Require_Action_String(!(assertion), exceptionLabel, action, message)
 930  #endif
 931  
 932  /*
 933   *  __Require_noErr(errorCode, exceptionLabel)
 934   *
 935   *  Summary:
 936   *    Production builds: if the errorCode expression does not equal 0 (noErr),
 937   *    goto exceptionLabel.
 938   *
 939   *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
 940   *    call DEBUG_ASSERT_MESSAGE and then goto exceptionLabel.
 941   *
 942   *  Parameters:
 943   *
 944   *    errorCode:
 945   *      The expression to compare to 0.
 946   *
 947   *    exceptionLabel:
 948   *      The label.
 949   */
 950  #ifndef __Require_noErr
 951  	#if DEBUG_ASSERT_PRODUCTION_CODE
 952  	   #define __Require_noErr(errorCode, exceptionLabel)                         \
 953  		  do                                                                      \
 954  		  {                                                                       \
 955  			  if ( __builtin_expect(0 != (errorCode), 0) )                        \
 956  			  {                                                                   \
 957  				  goto exceptionLabel;                                            \
 958  			  }                                                                   \
 959  		  } while ( 0 )
 960  	#else
 961  	   #define __Require_noErr(errorCode, exceptionLabel)                         \
 962  		  do                                                                      \
 963  		  {                                                                       \
 964  			  long evalOnceErrorCode = (errorCode);                               \
 965  			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
 966  			  {                                                                   \
 967  				  DEBUG_ASSERT_MESSAGE(                                           \
 968  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
 969  					  #errorCode " == 0 ",  #exceptionLabel,  0,  __FILE__, __LINE__, evalOnceErrorCode); \
 970  				  goto exceptionLabel;                                            \
 971  			  }                                                                   \
 972  		  } while ( 0 )
 973  	#endif
 974  #endif
 975  
 976  /*
 977   *  __Require_noErr_Action(errorCode, exceptionLabel, action)
 978   *
 979   *  Summary:
 980   *    Production builds: if the errorCode expression does not equal 0 (noErr),
 981   *    execute the action statement or compound statement (block) and
 982   *    goto exceptionLabel.
 983   *
 984   *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
 985   *    call DEBUG_ASSERT_MESSAGE, execute the action statement or
 986   *    compound statement (block), and then goto exceptionLabel.
 987   *
 988   *  Parameters:
 989   *
 990   *    errorCode:
 991   *      The expression to compare to 0.
 992   *
 993   *    exceptionLabel:
 994   *      The label.
 995   *
 996   *    action:
 997   *      The statement or compound statement (block).
 998   */
 999  #ifndef __Require_noErr_Action
1000  	#if DEBUG_ASSERT_PRODUCTION_CODE
1001  	   #define __Require_noErr_Action(errorCode, exceptionLabel, action)          \
1002  		  do                                                                      \
1003  		  {                                                                       \
1004  			  if ( __builtin_expect(0 != (errorCode), 0) )                        \
1005  			  {                                                                   \
1006  				  {                                                               \
1007  					  action;                                                     \
1008  				  }                                                               \
1009  				  goto exceptionLabel;                                            \
1010  			  }                                                                   \
1011  		  } while ( 0 )
1012  	#else
1013  	   #define __Require_noErr_Action(errorCode, exceptionLabel, action)          \
1014  		  do                                                                      \
1015  		  {                                                                       \
1016  			  long evalOnceErrorCode = (errorCode);                               \
1017  			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
1018  			  {                                                                   \
1019  				  DEBUG_ASSERT_MESSAGE(                                           \
1020  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
1021  					  #errorCode " == 0 ", #exceptionLabel,  0,  __FILE__, __LINE__,  evalOnceErrorCode); \
1022  				  {                                                               \
1023  					  action;                                                     \
1024  				  }                                                               \
1025  				  goto exceptionLabel;                                            \
1026  			  }                                                                   \
1027  		  } while ( 0 )
1028  	#endif
1029  #endif
1030  
1031  /*
1032   *  __Require_noErr_Quiet(errorCode, exceptionLabel)
1033   *
1034   *  Summary:
1035   *    If the errorCode expression does not equal 0 (noErr),
1036   *    goto exceptionLabel.
1037   *
1038   *  Parameters:
1039   *
1040   *    errorCode:
1041   *      The expression to compare to 0.
1042   *
1043   *    exceptionLabel:
1044   *      The label.
1045   */
1046  #ifndef __Require_noErr_Quiet
1047  	#define __Require_noErr_Quiet(errorCode, exceptionLabel)                      \
1048  	  do                                                                          \
1049  	  {                                                                           \
1050  		  if ( __builtin_expect(0 != (errorCode), 0) )                            \
1051  		  {                                                                       \
1052  			  goto exceptionLabel;                                                \
1053  		  }                                                                       \
1054  	  } while ( 0 )
1055  #endif
1056  
1057  /*
1058   *  __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action)
1059   *
1060   *  Summary:
1061   *    If the errorCode expression does not equal 0 (noErr),
1062   *    execute the action statement or compound statement (block) and
1063   *    goto exceptionLabel.
1064   *
1065   *  Parameters:
1066   *
1067   *    errorCode:
1068   *      The expression to compare to 0.
1069   *
1070   *    exceptionLabel:
1071   *      The label.
1072   *
1073   *    action:
1074   *      The statement or compound statement (block).
1075   */
1076  #ifndef __Require_noErr_Action_Quiet
1077  	#define __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action)       \
1078  	  do                                                                          \
1079  	  {                                                                           \
1080  		  if ( __builtin_expect(0 != (errorCode), 0) )                            \
1081  		  {                                                                       \
1082  			  {                                                                   \
1083  				  action;                                                         \
1084  			  }                                                                   \
1085  			  goto exceptionLabel;                                                \
1086  		  }                                                                       \
1087  	  } while ( 0 )
1088  #endif
1089  
1090  /*
1091   *  __Require_noErr_String(errorCode, exceptionLabel, message)
1092   *
1093   *  Summary:
1094   *    Production builds: if the errorCode expression does not equal 0 (noErr),
1095   *    goto exceptionLabel.
1096   *
1097   *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
1098   *    call DEBUG_ASSERT_MESSAGE, and then goto exceptionLabel.
1099   *
1100   *  Parameters:
1101   *
1102   *    errorCode:
1103   *      The expression to compare to 0.
1104   *
1105   *    exceptionLabel:
1106   *      The label.
1107   *
1108   *    message:
1109   *      The C string to display.
1110   */
1111  #ifndef __Require_noErr_String
1112  	#if DEBUG_ASSERT_PRODUCTION_CODE
1113  	   #define __Require_noErr_String(errorCode, exceptionLabel, message)         \
1114  		  do                                                                      \
1115  		  {                                                                       \
1116  			  if ( __builtin_expect(0 != (errorCode), 0) )                        \
1117  			  {                                                                   \
1118  				  goto exceptionLabel;                                            \
1119  			  }                                                                   \
1120  		  } while ( 0 )
1121  	#else
1122  	   #define __Require_noErr_String(errorCode, exceptionLabel, message)         \
1123  		  do                                                                      \
1124  		  {                                                                       \
1125  			  long evalOnceErrorCode = (errorCode);                               \
1126  			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
1127  			  {                                                                   \
1128  				  DEBUG_ASSERT_MESSAGE(                                           \
1129  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
1130  					  #errorCode " == 0 ",  #exceptionLabel, message, __FILE__,  __LINE__,  evalOnceErrorCode); \
1131  				  goto exceptionLabel;                                            \
1132  			  }                                                                   \
1133  		  } while ( 0 )
1134  	#endif
1135  #endif
1136  
1137  /*
1138   *  __Require_noErr_Action_String(errorCode, exceptionLabel, action, message)
1139   *
1140   *  Summary:
1141   *    Production builds: if the errorCode expression does not equal 0 (noErr),
1142   *    execute the action statement or compound statement (block) and
1143   *    goto exceptionLabel.
1144   *
1145   *    Non-production builds: if the errorCode expression does not equal 0 (noErr),
1146   *    call DEBUG_ASSERT_MESSAGE, execute the action statement or compound
1147   *    statement (block), and then goto exceptionLabel.
1148   *
1149   *  Parameters:
1150   *
1151   *    errorCode:
1152   *      The expression to compare to 0.
1153   *
1154   *    exceptionLabel:
1155   *      The label.
1156   *
1157   *    action:
1158   *      The statement or compound statement (block).
1159   *
1160   *    message:
1161   *      The C string to display.
1162   */
1163  #ifndef __Require_noErr_Action_String
1164  	#if DEBUG_ASSERT_PRODUCTION_CODE
1165  	   #define __Require_noErr_Action_String(errorCode, exceptionLabel, action, message) \
1166  		  do                                                                      \
1167  		  {                                                                       \
1168  			  if ( __builtin_expect(0 != (errorCode), 0) )                        \
1169  			  {                                                                   \
1170  				  {                                                               \
1171  					  action;                                                     \
1172  				  }                                                               \
1173  				  goto exceptionLabel;                                            \
1174  			  }                                                                   \
1175  		  } while ( 0 )
1176  	#else
1177  	   #define __Require_noErr_Action_String(errorCode, exceptionLabel, action, message) \
1178  		  do                                                                      \
1179  		  {                                                                       \
1180  			  long evalOnceErrorCode = (errorCode);                               \
1181  			  if ( __builtin_expect(0 != evalOnceErrorCode, 0) )                  \
1182  			  {                                                                   \
1183  				  DEBUG_ASSERT_MESSAGE(                                           \
1184  					  DEBUG_ASSERT_COMPONENT_NAME_STRING,                         \
1185  					  #errorCode " == 0 ", #exceptionLabel, message, __FILE__, __LINE__, evalOnceErrorCode); \
1186  				  {                                                               \
1187  					  action;                                                     \
1188  				  }                                                               \
1189  				  goto exceptionLabel;                                            \
1190  			  }                                                                   \
1191  		  } while ( 0 )
1192  	#endif
1193  #endif
1194  
1195  /*
1196   *  __Check_Compile_Time(expr)
1197   *
1198   *  Summary:
1199   *    any build: if the expression is not true, generated a compile time error.
1200   *
1201   *  Parameters:
1202   *
1203   *    expr:
1204   *      The compile time expression that should evaluate to non-zero.
1205   *
1206   *  Discussion:
1207   *     This declares an array with a size that is determined by a compile-time expression.
1208   *     If false, it declares a negatively sized array, which generates a compile-time error.
1209   *
1210   * Examples:
1211   *     __Check_Compile_Time( sizeof( int ) == 4 );
1212   *     __Check_Compile_Time( offsetof( MyStruct, myField ) == 4 );
1213   *     __Check_Compile_Time( ( kMyBufferSize % 512 ) == 0 );
1214   *
1215   *  Note: This only works with compile-time expressions.
1216   *  Note: This only works in places where extern declarations are allowed (e.g. global scope).
1217   */
1218  #ifndef __Check_Compile_Time
1219      #ifdef __GNUC__ 
1220          #define __Check_Compile_Time( expr )    \
1221              extern int compile_time_assert_failed[ ( expr ) ? 1 : -1 ] __attribute__( ( unused ) )
1222      #else
1223          #define __Check_Compile_Time( expr )    \
1224              extern int compile_time_assert_failed[ ( expr ) ? 1 : -1 ]
1225      #endif
1226  #endif
1227  
1228  /*
1229   *	For time immemorial, Mac OS X has defined version of most of these macros without the __ prefix, which
1230   *	could collide with similarly named functions or macros in user code, including new functionality in
1231   *	Boost and the C++ standard library.
1232   *
1233   *	A future release of Mac OS X will no longer do this, and will require that clients move to the
1234   *  new macros as defined above.  However, in the interim both the new and old macros will work, unless
1235   *  clients define a macro __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES before this file is included
1236   *  in their compilations.  Clients who do not want the older macros defined can accomplish this by adding
1237   *    #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
1238   *  at the top of their sources, or my adding -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 to the
1239   *  gcc compilation options.
1240   *
1241   *  To aid users of these macros in converting their sources, the following tops script will convert usages
1242   *  of the old macros into the new equivalents.  To do so, in Terminal go into the directory containing the
1243   *  sources to be converted and run this command.
1244   *
1245      find . -name '*.[c|cc|cp|cpp|m|mm|h]' -print0 |  xargs -0 tops -verbose \
1246        replace "check(<b args>)" with "__Check(<args>)" \
1247        replace "check_noerr(<b args>)" with "__Check_noErr(<args>)" \
1248        replace "check_noerr_string(<b args>)" with "__Check_noErr_String(<args>)" \
1249        replace "check_string(<b args>)" with "__Check_String(<args>)" \
1250        replace "require(<b args>)" with "__Require(<args>)" \
1251        replace "require_action(<b args>)" with "__Require_Action(<args>)" \
1252        replace "require_action_string(<b args>)" with "__Require_Action_String(<args>)" \
1253        replace "require_noerr(<b args>)" with "__Require_noErr(<args>)" \
1254        replace "require_noerr_action(<b args>)" with "__Require_noErr_Action(<args>)" \
1255        replace "require_noerr_action_string(<b args>)" with "__Require_noErr_Action_String(<args>)" \
1256        replace "require_noerr_string(<b args>)" with "__Require_noErr_String(<args>)" \
1257        replace "require_string(<b args>)" with "__Require_String(<args>)" \
1258        replace "verify(<b args>)" with "__Verify(<args>)" \
1259        replace "verify_action(<b args>)" with "__Verify_Action(<args>)" \
1260        replace "verify_noerr(<b args>)" with "__Verify_noErr(<args>)" \
1261        replace "verify_noerr_action(<b args>)" with "__Verify_noErr_Action(<args>)" \
1262        replace "verify_noerr_string(<b args>)" with "__Verify_noErr_String(<args>)" \
1263        replace "verify_string(<b args>)" with "__Verify_String(<args>)" \
1264        replace "ncheck(<b args>)" with "__nCheck(<args>)" \
1265        replace "ncheck_string(<b args>)" with "__nCheck_String(<args>)" \
1266        replace "nrequire(<b args>)" with "__nRequire(<args>)" \
1267        replace "nrequire_action(<b args>)" with "__nRequire_Action(<args>)" \
1268        replace "nrequire_action_quiet(<b args>)" with "__nRequire_Action_Quiet(<args>)" \
1269        replace "nrequire_action_string(<b args>)" with "__nRequire_Action_String(<args>)" \
1270        replace "nrequire_quiet(<b args>)" with "__nRequire_Quiet(<args>)" \
1271        replace "nrequire_string(<b args>)" with "__nRequire_String(<args>)" \
1272        replace "nverify(<b args>)" with "__nVerify(<args>)" \
1273        replace "nverify_string(<b args>)" with "__nVerify_String(<args>)" \
1274        replace "require_action_quiet(<b args>)" with "__Require_Action_Quiet(<args>)" \
1275        replace "require_noerr_action_quiet(<b args>)" with "__Require_noErr_Action_Quiet(<args>)" \
1276        replace "require_noerr_quiet(<b args>)" with "__Require_noErr_Quiet(<args>)" \
1277        replace "require_quiet(<b args>)" with "__Require_Quiet(<args>)" \
1278        replace "check_compile_time(<b args>)" with "__Check_Compile_Time(<args>)" \
1279        replace "debug_string(<b args>)" with "__Debug_String(<args>)"
1280   *
1281   */
1282  
1283  #ifndef __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES
1284  	/* If we haven't set this yet, it defaults to on.  In the next release, this will default to off. */
1285  	#define	__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES	1
1286  #endif
1287  
1288  #if	__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES
1289  
1290  	#ifndef check
1291  	#define check(assertion)  __Check(assertion)
1292  	#endif
1293  
1294  	#ifndef check_noerr
1295  	#define check_noerr(errorCode)  __Check_noErr(errorCode)
1296  	#endif
1297  
1298  	#ifndef check_noerr_string
1299  		#define check_noerr_string(errorCode, message)  __Check_noErr_String(errorCode, message)
1300  	#endif
1301  
1302  	#ifndef check_string
1303  		#define check_string(assertion, message)  __Check_String(assertion, message)
1304  	#endif
1305  
1306  	#ifndef require
1307  		#define require(assertion, exceptionLabel)  __Require(assertion, exceptionLabel)
1308  	#endif
1309  
1310  	#ifndef require_action
1311  		#define require_action(assertion, exceptionLabel, action)  __Require_Action(assertion, exceptionLabel, action)
1312  	#endif
1313  
1314  	#ifndef require_action_string
1315  		#define require_action_string(assertion, exceptionLabel, action, message)  __Require_Action_String(assertion, exceptionLabel, action, message)
1316  	#endif
1317  
1318  	#ifndef require_noerr
1319  		#define require_noerr(errorCode, exceptionLabel)  __Require_noErr(errorCode, exceptionLabel)
1320  	#endif
1321  
1322  	#ifndef require_noerr_action
1323  		#define require_noerr_action(errorCode, exceptionLabel, action)  __Require_noErr_Action(errorCode, exceptionLabel, action)
1324  	#endif
1325  
1326  	#ifndef require_noerr_action_string
1327  		#define require_noerr_action_string(errorCode, exceptionLabel, action, message)  __Require_noErr_Action_String(errorCode, exceptionLabel, action, message)
1328  	#endif
1329  
1330  	#ifndef require_noerr_string
1331  		#define require_noerr_string(errorCode, exceptionLabel, message)  __Require_noErr_String(errorCode, exceptionLabel, message)
1332  	#endif
1333  
1334  	#ifndef require_string
1335  		#define require_string(assertion, exceptionLabel, message)  __Require_String(assertion, exceptionLabel, message)
1336  	#endif
1337  
1338  	#ifndef verify
1339  		#define verify(assertion) __Verify(assertion)
1340  	#endif
1341  
1342  	#ifndef verify_action
1343  		#define verify_action(assertion, action)  __Verify_Action(assertion, action)
1344  	#endif
1345  
1346  	#ifndef verify_noerr
1347  		#define verify_noerr(errorCode)  __Verify_noErr(errorCode)
1348  	#endif
1349  
1350  	#ifndef verify_noerr_action
1351  		#define verify_noerr_action(errorCode, action)  __Verify_noErr_Action(errorCode, action)
1352  	#endif
1353  
1354  	#ifndef verify_noerr_string
1355  		#define verify_noerr_string(errorCode, message)  __Verify_noErr_String(errorCode, message)
1356  	#endif
1357  
1358  	#ifndef verify_string
1359  		#define verify_string(assertion, message)  __Verify_String(assertion, message)
1360  	#endif
1361  
1362  	#ifndef ncheck
1363  		#define ncheck(assertion)  __nCheck(assertion)
1364  	#endif
1365  
1366  	#ifndef ncheck_string
1367  		#define ncheck_string(assertion, message)  __nCheck_String(assertion, message)
1368  	#endif
1369  
1370  	#ifndef nrequire
1371  		#define nrequire(assertion, exceptionLabel)  __nRequire(assertion, exceptionLabel)
1372  	#endif
1373  
1374  	#ifndef nrequire_action
1375  		#define nrequire_action(assertion, exceptionLabel, action)  __nRequire_Action(assertion, exceptionLabel, action)
1376  	#endif
1377  
1378  	#ifndef nrequire_action_quiet
1379  		#define nrequire_action_quiet(assertion, exceptionLabel, action)  __nRequire_Action_Quiet(assertion, exceptionLabel, action)
1380  	#endif
1381  
1382  	#ifndef nrequire_action_string
1383  		#define nrequire_action_string(assertion, exceptionLabel, action, message)  __nRequire_Action_String(assertion, exceptionLabel, action, message)
1384  	#endif
1385  
1386  	#ifndef nrequire_quiet
1387  		#define nrequire_quiet(assertion, exceptionLabel)  __nRequire_Quiet(assertion, exceptionLabel)
1388  	#endif
1389  
1390  	#ifndef nrequire_string
1391  		#define nrequire_string(assertion, exceptionLabel, string)  __nRequire_String(assertion, exceptionLabel, string)
1392  	#endif
1393  
1394  	#ifndef nverify
1395  		#define nverify(assertion)  __nVerify(assertion)
1396  	#endif
1397  
1398  	#ifndef nverify_string
1399  		#define nverify_string(assertion, message)  __nVerify_String(assertion, message)
1400  	#endif
1401  
1402  	#ifndef require_action_quiet
1403  		#define require_action_quiet(assertion, exceptionLabel, action)  __Require_Action_Quiet(assertion, exceptionLabel, action)
1404  	#endif
1405  
1406  	#ifndef require_noerr_action_quiet
1407  		#define require_noerr_action_quiet(errorCode, exceptionLabel, action)  __Require_noErr_Action_Quiet(errorCode, exceptionLabel, action)
1408  	#endif
1409  
1410  	#ifndef require_noerr_quiet
1411  		#define require_noerr_quiet(errorCode, exceptionLabel)  __Require_noErr_Quiet(errorCode, exceptionLabel)
1412  	#endif
1413  
1414  	#ifndef require_quiet
1415  		#define require_quiet(assertion, exceptionLabel)  __Require_Quiet(assertion, exceptionLabel)
1416  	#endif
1417  
1418  	#ifndef check_compile_time
1419  		#define check_compile_time( expr )  __Check_Compile_Time( expr )
1420  	#endif
1421  
1422  	#ifndef debug_string
1423  		#define debug_string(message)  __Debug_String(message)
1424  	#endif
1425  	
1426  #endif	/* ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES */
1427  
1428  
1429  #endif /* __ASSERTMACROS__ */