]> git.saurik.com Git - apple/xnu.git/blob - bsd/dev/random/YarrowCoreLib/src/assertverify.h
xnu-792.6.76.tar.gz
[apple/xnu.git] / bsd / dev / random / YarrowCoreLib / src / assertverify.h
1 /*
2 * Copyright (c) 1999, 2000-2001 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23 #ifndef ASSERT_VERIFY_H
24 #define ASSERT_VERIFY_H
25
26 /******************************************************************************
27 Written by: Jeffrey Richter
28 Notices: Copyright (c) 1995-1997 Jeffrey Richter
29 Purpose: Common header file containing handy macros and definitions used
30 throughout all the applications in the book.
31 ******************************************************************************/
32
33 /* These header functions were copied from the cmnhdr.h file that accompanies
34 Advanced Windows 3rd Edition by Jeffrey Richter */
35
36 //////////////////////////// Assert/Verify Macros /////////////////////////////
37
38 #if defined(macintosh) || defined(__APPLE__)
39 /* TBD */
40 #define chFAIL(szMSG)
41 #define chASSERTFAIL(file,line,expr)
42 #else
43 #define chFAIL(szMSG) { \
44 MessageBox(GetActiveWindow(), szMSG, \
45 __TEXT("Assertion Failed"), MB_OK | MB_ICONERROR); \
46 DebugBreak(); \
47 }
48
49 /* Put up an assertion failure message box. */
50 #define chASSERTFAIL(file,line,expr) { \
51 TCHAR sz[128]; \
52 wsprintf(sz, __TEXT("File %hs, line %d : %hs"), file, line, expr); \
53 chFAIL(sz); \
54 }
55
56 #endif /* macintosh */
57
58 /* Put up a message box if an assertion fails in a debug build. */
59 #ifdef _DEBUG
60 #define chASSERT(x) if (!(x)) chASSERTFAIL(__FILE__, __LINE__, #x)
61 #else
62 #define chASSERT(x)
63 #endif
64
65 /* Assert in debug builds, but don't remove the code in retail builds. */
66 #ifdef _DEBUG
67 #define chVERIFY(x) chASSERT(x)
68 #else
69 #define chVERIFY(x) (x)
70 #endif
71
72 #endif /* ASSERT_VERIFY_H */