]> git.saurik.com Git - apple/xnu.git/blob - bsd/dev/random/YarrowCoreLib/src/assertverify.h
02905deb078ec2ff6f8736f89aab95df5f13c294
[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 * 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 #ifndef ASSERT_VERIFY_H
25 #define ASSERT_VERIFY_H
26
27 /******************************************************************************
28 Written by: Jeffrey Richter
29 Notices: Copyright (c) 1995-1997 Jeffrey Richter
30 Purpose: Common header file containing handy macros and definitions used
31 throughout all the applications in the book.
32 ******************************************************************************/
33
34 /* These header functions were copied from the cmnhdr.h file that accompanies
35 Advanced Windows 3rd Edition by Jeffrey Richter */
36
37 //////////////////////////// Assert/Verify Macros /////////////////////////////
38
39 #if defined(macintosh) || defined(__APPLE__)
40 /* TBD */
41 #define chFAIL(szMSG)
42 #define chASSERTFAIL(file,line,expr)
43 #else
44 #define chFAIL(szMSG) { \
45 MessageBox(GetActiveWindow(), szMSG, \
46 __TEXT("Assertion Failed"), MB_OK | MB_ICONERROR); \
47 DebugBreak(); \
48 }
49
50 /* Put up an assertion failure message box. */
51 #define chASSERTFAIL(file,line,expr) { \
52 TCHAR sz[128]; \
53 wsprintf(sz, __TEXT("File %hs, line %d : %hs"), file, line, expr); \
54 chFAIL(sz); \
55 }
56
57 #endif /* macintosh */
58
59 /* Put up a message box if an assertion fails in a debug build. */
60 #ifdef _DEBUG
61 #define chASSERT(x) if (!(x)) chASSERTFAIL(__FILE__, __LINE__, #x)
62 #else
63 #define chASSERT(x)
64 #endif
65
66 /* Assert in debug builds, but don't remove the code in retail builds. */
67 #ifdef _DEBUG
68 #define chVERIFY(x) chASSERT(x)
69 #else
70 #define chVERIFY(x) (x)
71 #endif
72
73 #endif /* ASSERT_VERIFY_H */