|
1 /* |
|
2 * Copyright (c) 2001-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #if !defined(_EAP_ASSERT_H_) |
|
22 #define _EAP_ASSERT_H_ |
|
23 |
|
24 #include "eap_am_compiler_flags.h" |
|
25 |
|
26 #include "eap_tools.h" |
|
27 |
|
28 |
|
29 #if defined(_DEBUG) || defined(DEBUG) || defined(USE_EAP_ASSERTS) |
|
30 |
|
31 #if defined(__MARM__) || defined(__THUMB__) \ |
|
32 || defined(__ARMI__) || defined(__ARM4__) |
|
33 // Works only in ARM platform. |
|
34 #define EAP_SYSTEM_DEBUG_BREAK() User::Panic(_L("EAPOL"), KErrGeneral) |
|
35 #elif defined(__GNUC__) && defined(EAP_INTEL_PROCESSOR) |
|
36 // Works only in intel platform and gcc. |
|
37 #define EAP_SYSTEM_DEBUG_BREAK() __asm__( "int $0x03" : : ) |
|
38 #elif defined(__WINSCW__) |
|
39 // For RCVT compiler |
|
40 #define EAP_SYSTEM_DEBUG_BREAK() EAP_NULL_FUNCTION |
|
41 #elif defined(_WIN32) || defined(__WINS__) |
|
42 // Works only in intel platform and MSVC++. |
|
43 #define EAP_SYSTEM_DEBUG_BREAK() { __asm int 0x03 } |
|
44 #else |
|
45 #define EAP_SYSTEM_DEBUG_BREAK() EAP_NULL_FUNCTION |
|
46 #endif |
|
47 |
|
48 #define EAP_STATIC_ASSERT(_x) do { typedef int ai[(_x) ? 1 : 0]; } while(0) |
|
49 |
|
50 #else |
|
51 |
|
52 #define EAP_SYSTEM_DEBUG_BREAK() EAP_NULL_FUNCTION |
|
53 |
|
54 #define EAP_STATIC_ASSERT(_x) |
|
55 |
|
56 #endif |
|
57 |
|
58 |
|
59 |
|
60 #if !defined(USE_EAP_ASSERTS) |
|
61 |
|
62 #define EAP_ASSERT_TOOLS(am_tools, param) EAP_NULL_FUNCTION |
|
63 |
|
64 #define EAP_ASSERT(param) EAP_NULL_FUNCTION |
|
65 |
|
66 |
|
67 #define EAP_ASSERT_ALWAYS_TOOLS(am_tools, param) EAP_NULL_FUNCTION |
|
68 |
|
69 #define EAP_ASSERT_ALWAYS(param) EAP_NULL_FUNCTION |
|
70 |
|
71 |
|
72 #define EAP_ASSERT_ALWAYS_NO_TRACE(param) EAP_NULL_FUNCTION |
|
73 |
|
74 |
|
75 #define EAP_ASSERT_ANYWAY_TOOLS(am_tools) EAP_NULL_FUNCTION |
|
76 |
|
77 #define EAP_ASSERT_ANYWAY EAP_NULL_FUNCTION |
|
78 |
|
79 #else |
|
80 |
|
81 #if defined(__SYMBIAN32__) |
|
82 |
|
83 #if defined(_DEBUG) || defined(DEBUG) || defined(USE_EAP_ASSERTS) |
|
84 #define EAP_ASSERT_TOOLS(am_tools, param)\ |
|
85 if (!(param))\ |
|
86 {\ |
|
87 if ((am_tools) != 0) \ |
|
88 { \ |
|
89 (*(am_tools)).formatted_print(EAPL("ERROR: assertion failed " #param " %s:%d.\n"), __FILE__, __LINE__); \ |
|
90 } \ |
|
91 EAP_ASSERT_STACK_TRACE_TOOLS(am_tools, 0); \ |
|
92 EAP_SYSTEM_DEBUG_BREAK();\ |
|
93 }\ |
|
94 __ASSERT_ALWAYS((param), User::Panic(_L("EAPOL"), 1)) |
|
95 |
|
96 #define EAP_ASSERT(param)\ |
|
97 EAP_ASSERT_TOOLS(m_am_tools, param) |
|
98 |
|
99 #else |
|
100 #define EAP_ASSERT_TOOLS(am_tools, param) EAP_NULL_FUNCTION |
|
101 #define EAP_ASSERT(param) EAP_NULL_FUNCTION |
|
102 #endif |
|
103 |
|
104 |
|
105 #define EAP_ASSERT_ALWAYS_TOOLS(am_tools, param)\ |
|
106 if (!(param))\ |
|
107 {\ |
|
108 if ((am_tools) != 0) \ |
|
109 { \ |
|
110 (*(am_tools)).formatted_print(EAPL("ERROR: assertion failed " #param " %s:%d.\n"), __FILE__, __LINE__); \ |
|
111 } \ |
|
112 EAP_ASSERT_STACK_TRACE_TOOLS(am_tools, 0); \ |
|
113 EAP_SYSTEM_DEBUG_BREAK();\ |
|
114 }\ |
|
115 __ASSERT_ALWAYS((param), User::Panic(_L("EAPOL"), 1)) |
|
116 |
|
117 #define EAP_ASSERT_ALWAYS(param)\ |
|
118 EAP_ASSERT_ALWAYS_TOOLS(m_am_tools, param) |
|
119 |
|
120 |
|
121 #define EAP_ASSERT_ALWAYS_NO_TRACE(param) \ |
|
122 if (!(param)) \ |
|
123 { \ |
|
124 EAP_SYSTEM_DEBUG_BREAK();\ |
|
125 } \ |
|
126 __ASSERT_ALWAYS((param), User::Panic(_L("EAPOL"), 1)) |
|
127 |
|
128 |
|
129 #define EAP_ASSERT_ANYWAY_TOOLS(am_tools)\ |
|
130 if ((am_tools) != 0) \ |
|
131 { \ |
|
132 (*(am_tools)).formatted_print(EAPL("ERROR: assertion failed. %s:%d\n"), __FILE__, __LINE__); \ |
|
133 } \ |
|
134 EAP_ASSERT_STACK_TRACE_TOOLS(am_tools, 0); \ |
|
135 EAP_SYSTEM_DEBUG_BREAK();\ |
|
136 __ASSERT_ALWAYS(0, User::Panic(_L("EAPOL"), 1)) |
|
137 |
|
138 #define EAP_ASSERT_ANYWAY\ |
|
139 EAP_ASSERT_ANYWAY_TOOLS(m_am_tools) |
|
140 |
|
141 #elif defined(_WIN32) || defined(__GNUC__) || defined(__arm) |
|
142 |
|
143 #include <assert.h> |
|
144 |
|
145 #if defined(_DEBUG) || defined(DEBUG) || defined(USE_EAP_ASSERTS) |
|
146 #define EAP_ASSERT_TOOLS(am_tools, param) \ |
|
147 if (!(param)) \ |
|
148 { \ |
|
149 if ((am_tools) != 0) \ |
|
150 { \ |
|
151 (*(am_tools)).formatted_print(EAPL("ERROR: assertion failed " #param " %s:%d.\n"), __FILE__, __LINE__); \ |
|
152 } \ |
|
153 EAP_ASSERT_STACK_TRACE_TOOLS(am_tools, 0); \ |
|
154 EAP_SYSTEM_DEBUG_BREAK();\ |
|
155 } \ |
|
156 assert(param) |
|
157 |
|
158 #define EAP_ASSERT(param) \ |
|
159 EAP_ASSERT_TOOLS(m_am_tools, param) |
|
160 |
|
161 #else |
|
162 #define EAP_ASSERT_TOOLS(am_tools, param) EAP_NULL_FUNCTION |
|
163 #define EAP_ASSERT(param) EAP_NULL_FUNCTION |
|
164 #endif |
|
165 |
|
166 |
|
167 #define EAP_ASSERT_ALWAYS_TOOLS(am_tools, param) \ |
|
168 if (!(param)) \ |
|
169 { \ |
|
170 if ((am_tools) != 0) \ |
|
171 { \ |
|
172 (*(am_tools)).formatted_print(EAPL("ERROR: assertion failed " #param " %s:%d.\n"), __FILE__, __LINE__); \ |
|
173 } \ |
|
174 EAP_ASSERT_STACK_TRACE_TOOLS(am_tools, 0); \ |
|
175 EAP_SYSTEM_DEBUG_BREAK();\ |
|
176 } \ |
|
177 assert(param) |
|
178 |
|
179 #define EAP_ASSERT_ALWAYS(param) \ |
|
180 EAP_ASSERT_ALWAYS_TOOLS(m_am_tools, param) |
|
181 |
|
182 |
|
183 #define EAP_ASSERT_ALWAYS_NO_TRACE(param) \ |
|
184 if (!(param)) \ |
|
185 { \ |
|
186 EAP_SYSTEM_DEBUG_BREAK();\ |
|
187 } \ |
|
188 assert(param) |
|
189 |
|
190 |
|
191 #define EAP_ASSERT_ANYWAY_TOOLS(am_tools) \ |
|
192 if ((am_tools) != 0) \ |
|
193 { \ |
|
194 (*(am_tools)).formatted_print(EAPL("ERROR: assertion failed. %s:%d\n"), __FILE__, __LINE__); \ |
|
195 } \ |
|
196 EAP_ASSERT_STACK_TRACE_TOOLS(am_tools, 0); \ |
|
197 EAP_SYSTEM_DEBUG_BREAK();\ |
|
198 assert(0) |
|
199 |
|
200 #define EAP_ASSERT_ANYWAY \ |
|
201 EAP_ASSERT_ANYWAY_TOOLS(m_am_tools) |
|
202 |
|
203 #endif //#if defined(_WIN32) || defined(__GNUC__) |
|
204 |
|
205 #endif //#if !defined(USE_EAP_ASSERTS) |
|
206 |
|
207 #endif //#if !defined(_EAP_ASSERT_H_) |
|
208 |
|
209 |
|
210 |
|
211 // End. |