]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/ncsw/inc/error_ext.h
Merge bmake-20160512
[FreeBSD/FreeBSD.git] / sys / contrib / ncsw / inc / error_ext.h
1 /* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above copyright
9  *       notice, this list of conditions and the following disclaimer in the
10  *       documentation and/or other materials provided with the distribution.
11  *     * Neither the name of Freescale Semiconductor nor the
12  *       names of its contributors may be used to endorse or promote products
13  *       derived from this software without specific prior written permission.
14  *
15  *
16  * ALTERNATIVELY, this software may be distributed under the terms of the
17  * GNU General Public License ("GPL") as published by the Free Software
18  * Foundation, either version 2 of that License or (at your option) any
19  * later version.
20  *
21  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 /**
34  @File          error_ext.h
35
36  @Description   Error definitions.
37 *//***************************************************************************/
38
39 #ifndef __ERROR_EXT_H
40 #define __ERROR_EXT_H
41
42 #include "std_ext.h"
43 #include "xx_ext.h"
44 #include "core_ext.h"
45
46 /**************************************************************************//**
47  @Group         gen_id  General Drivers Utilities
48
49  @Description   External routines.
50
51  @{
52 *//***************************************************************************/
53
54 /**************************************************************************//**
55  @Group         gen_error_id  Errors, Events and Debug
56
57  @Description   External routines.
58
59  @{
60 *//***************************************************************************/
61
62 /******************************************************************************
63 The scheme below provides the bits description for error codes:
64
65  0    1    2    3    4    5    6    7    8    9    10   11   12   13   14   15
66 |       Reserved (should be zero)      |              Module ID               |
67
68  16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31
69 |                               Error Type                                    |
70 ******************************************************************************/
71
72 #define ERROR_CODE(_err)            ((((uint32_t)_err) & 0x0000FFFF) | __ERR_MODULE__)
73
74 #define GET_ERROR_TYPE(_errcode)    ((_errcode) & 0x0000FFFF)
75                                 /**< Extract module code from error code (#t_Error) */
76
77 #define GET_ERROR_MODULE(_errcode)  ((_errcode) & 0x00FF0000)
78                                 /**< Extract error type (#e_ErrorType) from
79                                      error code (#t_Error) */
80
81
82 /**************************************************************************//**
83  @Description    Error Type Enumeration
84 *//***************************************************************************/
85 typedef enum e_ErrorType    /*   Comments / Associated Message Strings                      */
86 {                           /* ------------------------------------------------------------ */
87     E_OK = 0                /*   Never use "RETURN_ERROR" with E_OK; Use "return E_OK;"     */
88
89     /* Invalid Function Calls */
90     ,E_INVALID_STATE        /**< The operation is not allowed in current module state.      */
91                             /*   String: none.                                              */
92     ,E_INVALID_OPERATION    /**< The operation/command is invalid (unrecognized).           */
93                             /*   String: none.                                              */
94     ,E_NOT_SUPPORTED        /**< The function is not supported or not implemented.          */
95                             /*   String: none.                                              */
96     ,E_NO_DEVICE            /**< The associated device is not initialized.                  */
97                             /*   String: none.                                              */
98
99     /* Invalid Parameters */
100     ,E_INVALID_HANDLE       /**< Invalid handle of module or object.                        */
101                             /*   String: none, unless the function takes in more than one
102                                  handle (in this case add the handle description)           */
103     ,E_INVALID_ID           /**< Invalid module ID (usually enumeration or index).          */
104                             /*   String: none, unless the function takes in more than one
105                                  ID (in this case add the ID description)                   */
106     ,E_NULL_POINTER         /**< Unexpected NULL pointer.                                   */
107                             /*   String: pointer description.                               */
108     ,E_INVALID_VALUE        /**< Invalid value.                                             */
109                             /*   Use for non-enumeration parameters, and
110                                  only when other error types are not suitable.
111                                  String: parameter description + "(should be <attribute>)",
112                                  e.g: "Maximum Rx buffer length (should be divisible by 8)",
113                                       "Channel number (should be even)".                    */
114     ,E_INVALID_SELECTION    /**< Invalid selection or mode.                                 */
115                             /*   Use for enumeration values, only when other error types
116                                  are not suitable.
117                                  String: parameter description.                             */
118     ,E_INVALID_COMM_MODE    /**< Invalid communication mode.                                */
119                             /*   String: none, unless the function takes in more than one
120                                  communication mode indications (in this case add
121                                  parameter description).                                    */
122     ,E_INVALID_BYTE_ORDER   /**< Invalid byte order.                                        */
123                             /*   String: none, unless the function takes in more than one
124                                  byte order indications (in this case add parameter
125                                  description).                                              */
126     ,E_INVALID_MEMORY_TYPE  /**< Invalid memory type.                                       */
127                             /*   String: none, unless the function takes in more than one
128                                  memory types (in this case add memory description,
129                                  e.g: "Data memory", "Buffer descriptors memory").          */
130     ,E_INVALID_INTR_QUEUE   /**< Invalid interrupt queue.                                   */
131                             /*   String: none, unless the function takes in more than one
132                                  interrupt queues (in this case add queue description,
133                                  e.g: "Rx interrupt queue", "Tx interrupt queue").          */
134     ,E_INVALID_PRIORITY     /**< Invalid priority.                                          */
135                             /*   String: none, unless the function takes in more than one
136                                  priority (in this case add priority description).          */
137     ,E_INVALID_CLOCK        /**< Invalid clock.                                             */
138                             /*   String: none, unless the function takes in more than one
139                                  clocks (in this case add clock description,
140                                  e.g: "Rx clock", "Tx clock").                              */
141     ,E_INVALID_RATE         /**< Invalid rate value.                                        */
142                             /*   String: none, unless the function takes in more than one
143                                  rate values (in this case add rate description).           */
144     ,E_INVALID_ADDRESS      /**< Invalid address.                                           */
145                             /*   String: description of the specific violation.             */
146     ,E_INVALID_BUS          /**< Invalid bus type.                                          */
147                             /*   String: none, unless the function takes in more than one
148                                  bus parameters (in this case add bus description).         */
149     ,E_BUS_CONFLICT         /**< Bus (or memory) type conflicts with another setting.       */
150                             /*   String: description of the conflicting buses/memories.     */
151     ,E_CONFLICT             /**< Some setting conflicts with another setting.               */
152                             /*   String: description of the conflicting settings.           */
153     ,E_NOT_ALIGNED          /**< Non-aligned address.                                       */
154                             /*   String: parameter description + "(should be %d-bytes aligned)",
155                                  e.g: "Rx data buffer (should be 32-bytes aligned)".        */
156     ,E_NOT_IN_RANGE         /**< Parameter value is out of range.                           */
157                             /*   Don't use this error for enumeration parameters.
158                                  String: parameter description + "(should be %d-%d)",
159                                  e.g: "Number of pad characters (should be 0-15)".          */
160
161     /* Frame/Buffer Errors */
162     ,E_INVALID_FRAME        /**< Invalid frame object (NULL handle or missing buffers).     */
163                             /*   String: none.                                              */
164     ,E_EMPTY_FRAME          /**< Frame object is empty (has no buffers).                    */
165                             /*   String: none.                                              */
166     ,E_EMPTY_BUFFER         /**< Buffer object is empty (no data, or zero data length).     */
167                             /*   String: none.                                              */
168
169     /* Resource Errors */
170     ,E_NO_MEMORY            /**< External memory allocation failed.                         */
171                             /*   String: description of item for which allocation failed.   */
172     ,E_NOT_FOUND            /**< Requested resource or item was not found.                  */
173                             /*   Use only when the resource/item is uniquely identified.
174                                  String: none, unless the operation is not the main goal
175                                  of the function (in this case add item description).       */
176     ,E_NOT_AVAILABLE        /**< Resource is unavailable.                                   */
177                             /*   String: none, unless the operation is not the main goal
178                                  of the function (in this case add resource description).   */
179     ,E_ALREADY_EXISTS       /**< Requested resource or item already exists.                 */
180                             /*   Use when resource duplication or sharing are not allowed.
181                                  String: none, unless the operation is not the main goal
182                                  of the function (in this case add item description).       */
183     ,E_FULL                 /**< Resource is full.                                          */
184                             /*   String: none, unless the operation is not the main goal
185                                  of the function (in this case add resource description).   */
186     ,E_EMPTY                /**< Resource is empty.                                         */
187                             /*   String: none, unless the operation is not the main goal
188                                  of the function (in this case add resource description).   */
189     ,E_BUSY                 /**< Resource or module is busy.                                */
190                             /*   String: none, unless the operation is not the main goal
191                                  of the function (in this case add resource description).   */
192     ,E_ALREADY_FREE         /**< Specified resource or item is already free or deleted.     */
193                             /*   String: none, unless the operation is not the main goal
194                                  of the function (in this case add item description).       */
195
196     /* Read/Write Access Errors */
197     ,E_READ_FAILED          /**< Read access failed on memory/device.                       */
198                             /*   String: none, or device name.                              */
199     ,E_WRITE_FAILED         /**< Write access failed on memory/device.                      */
200                             /*   String: none, or device name.                              */
201
202     /* Send/Receive Failures */
203     ,E_SEND_FAILED          /**< Send operation failed on device.                           */
204                             /*   String: none, or device name.                              */
205     ,E_RECEIVE_FAILED       /**< Receive operation failed on device.                        */
206                             /*   String: none, or device name.                              */
207
208     /* Operation time-out */
209     ,E_TIMEOUT              /**< The operation timed out.                                   */
210                             /*   String: none.                                              */
211
212     ,E_DUMMY_LAST           /* NEVER USED */
213
214 } e_ErrorType;
215
216
217 /**************************************************************************//**
218  @Description    Event Type Enumeration
219 *//***************************************************************************/
220 typedef enum e_Event        /*   Comments / Associated Flags and Message Strings            */
221 {                           /* ------------------------------------------------------------ */
222     EV_NO_EVENT = 0         /**< No event; Never used.                                      */
223
224     ,EV_RX_DISCARD          /**< Received packet discarded (by the driver, and only for
225                                  complete packets);
226                                  Flags: error flags in case of error, zero otherwise.       */
227                             /*   String: reason for discard, e.g: "Error in frame",
228                                  "Disordered frame", "Incomplete frame", "No frame object". */
229     ,EV_RX_ERROR            /**< Receive error (by hardware/firmware);
230                                  Flags: usually status flags from the buffer descriptor.    */
231                             /*   String: none.                                              */
232     ,EV_TX_ERROR            /**< Transmit error (by hardware/firmware);
233                                  Flags: usually status flags from the buffer descriptor.    */
234                             /*   String: none.                                              */
235     ,EV_NO_BUFFERS          /**< System ran out of buffer objects;
236                                  Flags: zero.                                               */
237                             /*   String: none.                                              */
238     ,EV_NO_MB_FRAMES        /**< System ran out of multi-buffer frame objects;
239                                  Flags: zero.                                               */
240                             /*   String: none.                                              */
241     ,EV_NO_SB_FRAMES        /**< System ran out of single-buffer frame objects;
242                                  Flags: zero.                                               */
243                             /*   String: none.                                              */
244     ,EV_TX_QUEUE_FULL       /**< Transmit queue is full;
245                                  Flags: zero.                                               */
246                             /*   String: none.                                              */
247     ,EV_RX_QUEUE_FULL       /**< Receive queue is full;
248                                  Flags: zero.                                               */
249                             /*   String: none.                                              */
250     ,EV_INTR_QUEUE_FULL     /**< Interrupt queue overflow;
251                                  Flags: zero.                                               */
252                             /*   String: none.                                              */
253     ,EV_NO_DATA_BUFFER      /**< Data buffer allocation (from higher layer) failed;
254                                  Flags: zero.                                               */
255                             /*   String: none.                                              */
256     ,EV_OBJ_POOL_EMPTY      /**< Objects pool is empty;
257                                  Flags: zero.                                               */
258                             /*   String: object description (name).                         */
259     ,EV_BUS_ERROR           /**< Illegal access on bus;
260                                  Flags: the address (if available) or bus identifier        */
261                             /*   String: bus/address/module description.                    */
262     ,EV_PTP_TXTS_QUEUE_FULL /**< PTP Tx timestamps queue is full;
263                                  Flags: zero.                                               */
264                             /*   String: none.                                              */
265     ,EV_PTP_RXTS_QUEUE_FULL /**< PTP Rx timestamps queue is full;
266                                  Flags: zero.                                               */
267                             /*   String: none.                                              */
268     ,EV_DUMMY_LAST
269
270 } e_Event;
271
272
273 /**************************************************************************//**
274  @Collection    Debug Levels for Errors and Events
275
276                 The level description refers to errors only.
277                 For events, classification is done by the user.
278
279                 The TRACE, INFO and WARNING levels are allowed only when using
280                 the DBG macro, and are not allowed when using the error macros
281                 (RETURN_ERROR or REPORT_ERROR).
282  @{
283 *//***************************************************************************/
284 #define REPORT_LEVEL_CRITICAL   1       /**< Crasher: Incorrect flow, NULL pointers/handles. */
285 #define REPORT_LEVEL_MAJOR      2       /**< Cannot proceed: Invalid operation, parameters or
286                                              configuration. */
287 #define REPORT_LEVEL_MINOR      3       /**< Recoverable problem: a repeating call with the same
288                                              parameters may be successful. */
289 #define REPORT_LEVEL_WARNING    4       /**< Something is not exactly right, yet it is not an error. */
290 #define REPORT_LEVEL_INFO       5       /**< Messages which may be of interest to user/programmer. */
291 #define REPORT_LEVEL_TRACE      6       /**< Program flow messages. */
292
293 #define EVENT_DISABLED          0xFF    /**< Disabled event (not reported at all) */
294
295 /* @} */
296
297
298
299 #define NO_MSG      ("")
300
301 #ifndef DEBUG_GLOBAL_LEVEL
302 #define DEBUG_GLOBAL_LEVEL  REPORT_LEVEL_WARNING
303 #endif /* DEBUG_GLOBAL_LEVEL */
304
305 #ifndef ERROR_GLOBAL_LEVEL
306 #define ERROR_GLOBAL_LEVEL  DEBUG_GLOBAL_LEVEL
307 #endif /* ERROR_GLOBAL_LEVEL */
308
309 #ifndef EVENT_GLOBAL_LEVEL
310 #define EVENT_GLOBAL_LEVEL  REPORT_LEVEL_MINOR
311 #endif /* EVENT_GLOBAL_LEVEL */
312
313 #ifdef EVENT_LOCAL_LEVEL
314 #define EVENT_DYNAMIC_LEVEL EVENT_LOCAL_LEVEL
315 #else
316 #define EVENT_DYNAMIC_LEVEL EVENT_GLOBAL_LEVEL
317 #endif /* EVENT_LOCAL_LEVEL */
318
319
320 #ifndef DEBUG_DYNAMIC_LEVEL
321 #define DEBUG_USING_STATIC_LEVEL
322
323 #ifdef DEBUG_STATIC_LEVEL
324 #define DEBUG_DYNAMIC_LEVEL DEBUG_STATIC_LEVEL
325 #else
326 #define DEBUG_DYNAMIC_LEVEL DEBUG_GLOBAL_LEVEL
327 #endif /* DEBUG_STATIC_LEVEL */
328
329 #else /* DEBUG_DYNAMIC_LEVEL */
330 #ifdef DEBUG_STATIC_LEVEL
331 #error "Please use either DEBUG_STATIC_LEVEL or DEBUG_DYNAMIC_LEVEL (not both)"
332 #else
333 int DEBUG_DYNAMIC_LEVEL = DEBUG_GLOBAL_LEVEL;
334 #endif /* DEBUG_STATIC_LEVEL */
335 #endif /* !DEBUG_DYNAMIC_LEVEL */
336
337
338 #ifndef ERROR_DYNAMIC_LEVEL
339
340 #ifdef ERROR_STATIC_LEVEL
341 #define ERROR_DYNAMIC_LEVEL ERROR_STATIC_LEVEL
342 #else
343 #define ERROR_DYNAMIC_LEVEL ERROR_GLOBAL_LEVEL
344 #endif /* ERROR_STATIC_LEVEL */
345
346 #else /* ERROR_DYNAMIC_LEVEL */
347 #ifdef ERROR_STATIC_LEVEL
348 #error "Please use either ERROR_STATIC_LEVEL or ERROR_DYNAMIC_LEVEL (not both)"
349 #else
350 int ERROR_DYNAMIC_LEVEL = ERROR_GLOBAL_LEVEL;
351 #endif /* ERROR_STATIC_LEVEL */
352 #endif /* !ERROR_DYNAMIC_LEVEL */
353
354 #define PRINT_FORMAT        "[CPU%02d, %s:%d %s]"
355 #define PRINT_FMT_PARAMS    CORE_GetId(), __FILE__, __LINE__, __FUNCTION__
356
357 #if (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0))
358 /* No debug/error/event messages at all */
359 #define DBG(_level, _vmsg)
360
361 #define REPORT_ERROR(_level, _err, _vmsg)
362
363 #define RETURN_ERROR(_level, _err, _vmsg) \
364         return ERROR_CODE(_err)
365
366 #if (REPORT_EVENTS > 0)
367
368 #define REPORT_EVENT(_ev, _appId, _flg, _vmsg) \
369     do { \
370         if (_ev##_LEVEL <= EVENT_DYNAMIC_LEVEL) { \
371             XX_EventById((uint32_t)(_ev), (t_Handle)(_appId), (uint16_t)(_flg), NO_MSG); \
372         } \
373     } while (0)
374
375 #else
376
377 #define REPORT_EVENT(_ev, _appId, _flg, _vmsg)
378
379 #endif /* (REPORT_EVENTS > 0) */
380
381
382 #else /* DEBUG_ERRORS > 0 */
383
384 extern const char *dbgLevelStrings[];
385 extern const char *errTypeStrings[];
386 extern const char *moduleStrings[];
387 #if (REPORT_EVENTS > 0)
388 extern const char *eventStrings[];
389 #endif /* (REPORT_EVENTS > 0) */
390
391
392 #if ((defined(DEBUG_USING_STATIC_LEVEL)) && (DEBUG_DYNAMIC_LEVEL < REPORT_LEVEL_WARNING))
393 /* No need for DBG macro - debug level is higher anyway */
394 #define DBG(_level, _vmsg)
395 #else
396 #define DBG(_level, _vmsg) \
397     do { \
398         if (REPORT_LEVEL_##_level <= DEBUG_DYNAMIC_LEVEL) { \
399             XX_Print("> %s (%s) " PRINT_FORMAT ": ", \
400                      dbgLevelStrings[REPORT_LEVEL_##_level - 1], \
401                      moduleStrings[__ERR_MODULE__ >> 16], \
402                      PRINT_FMT_PARAMS); \
403             XX_Print _vmsg; \
404             XX_Print("\r\n"); \
405         } \
406     } while (0)
407 #endif /* (defined(DEBUG_USING_STATIC_LEVEL) && (DEBUG_DYNAMIC_LEVEL < WARNING)) */
408
409
410 #define REPORT_ERROR(_level, _err, _vmsg) \
411     do { \
412         if (REPORT_LEVEL_##_level <= ERROR_DYNAMIC_LEVEL) { \
413             XX_Print("! %s %s Error " PRINT_FORMAT ": %s; ", \
414                      dbgLevelStrings[REPORT_LEVEL_##_level - 1], \
415                      moduleStrings[__ERR_MODULE__ >> 16], \
416                      PRINT_FMT_PARAMS, \
417                      errTypeStrings[(GET_ERROR_TYPE(_err) - E_OK - 1)]); \
418             XX_Print _vmsg; \
419             XX_Print("\r\n"); \
420         } \
421     } while (0)
422
423
424 #define RETURN_ERROR(_level, _err, _vmsg) \
425     do { \
426         REPORT_ERROR(_level, (_err), _vmsg); \
427         return ERROR_CODE(_err); \
428     } while (0)
429
430
431 #if (REPORT_EVENTS > 0)
432
433 #define REPORT_EVENT(_ev, _appId, _flg, _vmsg) \
434     do { \
435         if (_ev##_LEVEL <= EVENT_DYNAMIC_LEVEL) { \
436             XX_Print("~ %s %s Event " PRINT_FORMAT ": %s (flags: 0x%04x); ", \
437                      dbgLevelStrings[_ev##_LEVEL - 1], \
438                      moduleStrings[__ERR_MODULE__ >> 16], \
439                      PRINT_FMT_PARAMS, \
440                      eventStrings[((_ev) - EV_NO_EVENT - 1)], \
441                      (uint16_t)(_flg)); \
442             XX_Print _vmsg; \
443             XX_Print("\r\n"); \
444             XX_EventById((uint32_t)(_ev), (t_Handle)(_appId), (uint16_t)(_flg), NO_MSG); \
445         } \
446     } while (0)
447
448 #else /* not REPORT_EVENTS */
449
450 #define REPORT_EVENT(_ev, _appId, _flg, _vmsg)
451
452 #endif /* (REPORT_EVENTS > 0) */
453
454 #endif /* (DEBUG_ERRORS > 0) */
455
456
457 /**************************************************************************//**
458  @Function      ASSERT_COND
459
460  @Description   Assertion macro.
461
462  @Param[in]     _cond - The condition being checked, in positive form;
463                         Failure of the condition triggers the assert.
464 *//***************************************************************************/
465 #ifdef DISABLE_ASSERTIONS
466 #define ASSERT_COND(_cond)
467 #else
468 #define ASSERT_COND(_cond) \
469     do { \
470         if (!(_cond)) { \
471             XX_Print("*** ASSERT_COND failed " PRINT_FORMAT "\r\n", \
472                     PRINT_FMT_PARAMS); \
473             XX_Exit(1); \
474         } \
475     } while (0)
476 #endif /* DISABLE_ASSERTIONS */
477
478
479 #ifdef DISABLE_INIT_PARAMETERS_CHECK
480
481 #define CHECK_INIT_PARAMETERS(handle, f_check)
482 #define CHECK_INIT_PARAMETERS_RETURN_VALUE(handle, f_check, retval)
483
484 #else
485
486 #define CHECK_INIT_PARAMETERS(handle, f_check) \
487     do { \
488         t_Error err = f_check(handle); \
489         if (err != E_OK) { \
490             RETURN_ERROR(MAJOR, err, NO_MSG); \
491         } \
492     } while (0)
493
494 #define CHECK_INIT_PARAMETERS_RETURN_VALUE(handle, f_check, retval) \
495     do { \
496         t_Error err = f_check(handle); \
497         if (err != E_OK) { \
498             REPORT_ERROR(MAJOR, err, NO_MSG); \
499             return (retval); \
500         } \
501     } while (0)
502
503 #endif /* DISABLE_INIT_PARAMETERS_CHECK */
504
505 #ifdef DISABLE_SANITY_CHECKS
506
507 #define SANITY_CHECK_RETURN_ERROR(_cond, _err)
508 #define SANITY_CHECK_RETURN_VALUE(_cond, _err, retval)
509 #define SANITY_CHECK_RETURN(_cond, _err)
510 #define SANITY_CHECK_EXIT(_cond, _err)
511
512 #else /* DISABLE_SANITY_CHECKS */
513
514 #define SANITY_CHECK_RETURN_ERROR(_cond, _err) \
515     do { \
516         if (!(_cond)) { \
517             RETURN_ERROR(CRITICAL, (_err), NO_MSG); \
518         } \
519     } while (0)
520
521 #define SANITY_CHECK_RETURN_VALUE(_cond, _err, retval) \
522     do { \
523         if (!(_cond)) { \
524             REPORT_ERROR(CRITICAL, (_err), NO_MSG); \
525             return (retval); \
526         } \
527     } while (0)
528
529 #define SANITY_CHECK_RETURN(_cond, _err) \
530     do { \
531         if (!(_cond)) { \
532             REPORT_ERROR(CRITICAL, (_err), NO_MSG); \
533             return; \
534         } \
535     } while (0)
536
537 #define SANITY_CHECK_EXIT(_cond, _err) \
538     do { \
539         if (!(_cond)) { \
540             REPORT_ERROR(CRITICAL, (_err), NO_MSG); \
541             XX_Exit(1); \
542         } \
543     } while (0)
544
545 #endif /* DISABLE_SANITY_CHECKS */
546
547 /** @} */ /* end of Debug/error Utils group */
548
549 /** @} */ /* end of General Utils group */
550
551 #endif /* __ERROR_EXT_H */
552
553