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