1/*
2  File: DebugSupport.h
3
4  Contains:
5
6  Version: 1.0.0
7
8  Copyright: Copyright (c) 2007 by Apple Inc., All Rights Reserved.
9
10Disclaimer:IMPORTANT:  This Apple software is supplied to you by Apple Inc.
11("Apple") in consideration of your agreement to the following terms, and your use,
12installation, modification or redistribution of this Apple software constitutes acceptance
13of these terms.  If you do not agree with these terms, please do not use, install, modify or
14redistribute this Apple software.
15
16In consideration of your agreement to abide by the following terms, and subject
17to these terms, Apple grants you a personal, non-exclusive license, under Apple's
18copyrights in this original Apple software (the "Apple Software"), to use, reproduce,
19modify and redistribute the Apple Software, with or without modifications, in source and/or
20binary forms; provided that if you redistribute the Apple Software in its entirety
21and without modifications, you must retain this notice and the following text
22and disclaimers in all such redistributions of the Apple Software.  Neither the
23name, trademarks, service marks or logos of Apple Inc. may be used to
24endorse or promote products derived from the Apple Software without specific prior
25written permission from Apple.  Except as expressly stated in this notice, no
26other rights or licenses, express or implied, are granted by Apple herein,
27including but not limited to any patent rights that may be infringed by your derivative
28works or by other works in which the Apple Software may be incorporated.
29
30The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO WARRANTIES,
31EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
32MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE
33OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE
34BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
35NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
36OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
37REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
38AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT
39LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40*/
41
42
43#ifndef __DEBUG_SUPPORT_H__
44#define __DEBUG_SUPPORT_H__
45
46
47#if KERNEL
48#include <IOKit/IOLib.h>
49#else
50#include <IOKit/IOKitLib.h>
51#endif
52
53
54#ifndef DEBUG_ASSERT_COMPONENT_NAME_STRING
55	#define DEBUG_ASSERT_COMPONENT_NAME_STRING "AppleSCSIEmulator"
56#endif
57
58#if KERNEL
59
60#ifdef __cplusplus
61extern "C" {
62#endif
63
64/* AppleSCSIEmulatorDebugAssert prototype*/
65void
66AppleSCSIEmulatorDebugAssert (
67						const char * componentNameString,
68						const char * assertionString,
69						const char * exceptionLabelString,
70						const char * errorString,
71						const char * fileName,
72						long lineNumber,
73						int errorCode );
74
75#ifdef __cplusplus
76}
77#endif
78
79
80#define DEBUG_ASSERT_MESSAGE( componentNameString, 					\
81	assertionString, 												\
82	exceptionLabelString, 											\
83	errorString, 													\
84	fileName, 														\
85	lineNumber, 													\
86	error ) 														\
87	AppleSCSIEmulatorDebugAssert( componentNameString,				\
88	assertionString, 												\
89	exceptionLabelString, 											\
90	errorString, 													\
91	fileName, 														\
92	lineNumber, 													\
93	error )
94
95
96#endif	/* KERNEL */
97
98
99#include </usr/include/AssertMacros.h>
100
101
102#define require_success( errorCode, exceptionLabel ) \
103	require( kIOReturnSuccess == (errorCode), exceptionLabel )
104
105#define require_success_action( errorCode, exceptionLabel, action ) \
106	require_action( kIOReturnSuccess == (errorCode), exceptionLabel, action )
107
108#define require_success_quiet( errorCode, exceptionLabel ) \
109	require_quiet( kIOReturnSuccess == (errorCode), exceptionLabel )
110
111#define require_success_action_quiet( errorCode, exceptionLabel, action ) \
112	require_action_quiet( kIOReturnSuccess == (errorCode), exceptionLabel, action )
113
114#define require_success_string( errorCode, exceptionLabel, message ) \
115	require_string( kIOReturnSuccess == (errorCode), exceptionLabel, message )
116
117#define require_success_action_string( errorCode, exceptionLabel, action, message ) \
118	require_action_string( kIOReturnSuccess == (errorCode), exceptionLabel, action, message )
119
120
121#define require_nonzero( obj, exceptionLabel ) \
122	require( ( 0 != obj ), exceptionLabel )
123
124#define require_nonzero_action( obj, exceptionLabel, action ) \
125	require_action( ( 0 != obj ), exceptionLabel, action )
126
127#define require_nonzero_quiet( obj, exceptionLabel ) \
128	require_quiet( ( 0 != obj ), exceptionLabel )
129
130#define require_nonzero_action_quiet( obj, exceptionLabel, action ) \
131	require_action_quiet( ( 0 != obj ), exceptionLabel, action )
132
133#define require_nonzero_string( obj, exceptionLabel, message ) \
134	require_string( ( 0 != obj ), exceptionLabel, message )
135
136#define require_nonzero_action_string( obj, exceptionLabel, action, message ) \
137	require_action_string( ( 0 != obj ), exceptionLabel, action, message )
138
139
140#endif	/* __DEBUG_SUPPORT_H__ */
141