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