xref: /freebsd/sys/contrib/ncsw/inc/error_ext.h (revision 273c26a3c3bea87a241d6879abd4f991db180bf0)
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 #define ERR_STRING(err)     #err
357 
358 #if (!(defined(DEBUG_ERRORS)) || (DEBUG_ERRORS == 0))
359 /* No debug/error/event messages at all */
360 #define DBG(_level, _vmsg)
361 
362 #define REPORT_ERROR(_level, _err, _vmsg)
363 
364 #define RETURN_ERROR(_level, _err, _vmsg) \
365         return ERROR_CODE(_err)
366 
367 #if (REPORT_EVENTS > 0)
368 
369 #define REPORT_EVENT(_ev, _appId, _flg, _vmsg) \
370     do { \
371         if (_ev##_LEVEL <= EVENT_DYNAMIC_LEVEL) { \
372             XX_EventById((uint32_t)(_ev), (t_Handle)(_appId), (uint16_t)(_flg), NO_MSG); \
373         } \
374     } while (0)
375 
376 #else
377 
378 #define REPORT_EVENT(_ev, _appId, _flg, _vmsg)
379 
380 #endif /* (REPORT_EVENTS > 0) */
381 
382 
383 #else /* DEBUG_ERRORS > 0 */
384 
385 extern const char *dbgLevelStrings[];
386 extern const char *errTypeStrings[];
387 extern const char *moduleStrings[];
388 #if (REPORT_EVENTS > 0)
389 extern const char *eventStrings[];
390 #endif /* (REPORT_EVENTS > 0) */
391 
392 
393 #if ((defined(DEBUG_USING_STATIC_LEVEL)) && (DEBUG_DYNAMIC_LEVEL < REPORT_LEVEL_WARNING))
394 /* No need for DBG macro - debug level is higher anyway */
395 #define DBG(_level, _vmsg)
396 #else
397 #define DBG(_level, _vmsg) \
398     do { \
399         if (REPORT_LEVEL_##_level <= DEBUG_DYNAMIC_LEVEL) { \
400             XX_Print("> %s (%s) " PRINT_FORMAT ": ", \
401                      dbgLevelStrings[REPORT_LEVEL_##_level - 1], \
402                      ERR_STRING(__ERR_MODULE__), \
403                      PRINT_FMT_PARAMS); \
404             XX_Print _vmsg; \
405             XX_Print("\r\n"); \
406         } \
407     } while (0)
408 #endif /* (defined(DEBUG_USING_STATIC_LEVEL) && (DEBUG_DYNAMIC_LEVEL < WARNING)) */
409 
410 
411 #define REPORT_ERROR(_level, _err, _vmsg) \
412     do { \
413         if (REPORT_LEVEL_##_level <= ERROR_DYNAMIC_LEVEL) { \
414             XX_Print("! %s %s Error " PRINT_FORMAT ": %s; ", \
415                      dbgLevelStrings[REPORT_LEVEL_##_level - 1], \
416                      ERR_STRING(__ERR_MODULE__), \
417                      PRINT_FMT_PARAMS, \
418                      errTypeStrings[(GET_ERROR_TYPE(_err) - E_OK - 1)]); \
419             XX_Print _vmsg; \
420             XX_Print("\r\n"); \
421         } \
422     } while (0)
423 
424 
425 #define RETURN_ERROR(_level, _err, _vmsg) \
426     do { \
427         REPORT_ERROR(_level, (_err), _vmsg); \
428         return ERROR_CODE(_err); \
429     } while (0)
430 
431 
432 #if (REPORT_EVENTS > 0)
433 
434 #define REPORT_EVENT(_ev, _appId, _flg, _vmsg) \
435     do { \
436         if (_ev##_LEVEL <= EVENT_DYNAMIC_LEVEL) { \
437             XX_Print("~ %s %s Event " PRINT_FORMAT ": %s (flags: 0x%04x); ", \
438                      dbgLevelStrings[_ev##_LEVEL - 1], \
439                      ERR_STRING(__ERR_MODULE__), \
440                      PRINT_FMT_PARAMS, \
441                      eventStrings[((_ev) - EV_NO_EVENT - 1)], \
442                      (uint16_t)(_flg)); \
443             XX_Print _vmsg; \
444             XX_Print("\r\n"); \
445             XX_EventById((uint32_t)(_ev), (t_Handle)(_appId), (uint16_t)(_flg), NO_MSG); \
446         } \
447     } while (0)
448 
449 #else /* not REPORT_EVENTS */
450 
451 #define REPORT_EVENT(_ev, _appId, _flg, _vmsg)
452 
453 #endif /* (REPORT_EVENTS > 0) */
454 
455 #endif /* (DEBUG_ERRORS > 0) */
456 
457 
458 /**************************************************************************//**
459  @Function      ASSERT_COND
460 
461  @Description   Assertion macro.
462 
463  @Param[in]     _cond - The condition being checked, in positive form;
464                         Failure of the condition triggers the assert.
465 *//***************************************************************************/
466 #ifdef DISABLE_ASSERTIONS
467 #define ASSERT_COND(_cond)
468 #else
469 #define ASSERT_COND(_cond) \
470     do { \
471         if (!(_cond)) { \
472             XX_Print("*** ASSERT_COND failed " PRINT_FORMAT "\r\n", \
473                     PRINT_FMT_PARAMS); \
474             XX_Exit(1); \
475         } \
476     } while (0)
477 #endif /* DISABLE_ASSERTIONS */
478 
479 
480 #ifdef DISABLE_INIT_PARAMETERS_CHECK
481 
482 #define CHECK_INIT_PARAMETERS(handle, f_check)
483 #define CHECK_INIT_PARAMETERS_RETURN_VALUE(handle, f_check, retval)
484 
485 #else
486 
487 #define CHECK_INIT_PARAMETERS(handle, f_check) \
488     do { \
489         t_Error err = f_check(handle); \
490         if (err != E_OK) { \
491             RETURN_ERROR(MAJOR, err, NO_MSG); \
492         } \
493     } while (0)
494 
495 #define CHECK_INIT_PARAMETERS_RETURN_VALUE(handle, f_check, retval) \
496     do { \
497         t_Error err = f_check(handle); \
498         if (err != E_OK) { \
499             REPORT_ERROR(MAJOR, err, NO_MSG); \
500             return (retval); \
501         } \
502     } while (0)
503 
504 #endif /* DISABLE_INIT_PARAMETERS_CHECK */
505 
506 #ifdef DISABLE_SANITY_CHECKS
507 
508 #define SANITY_CHECK_RETURN_ERROR(_cond, _err)
509 #define SANITY_CHECK_RETURN_VALUE(_cond, _err, retval)
510 #define SANITY_CHECK_RETURN(_cond, _err)
511 #define SANITY_CHECK_EXIT(_cond, _err)
512 
513 #else /* DISABLE_SANITY_CHECKS */
514 
515 #define SANITY_CHECK_RETURN_ERROR(_cond, _err) \
516     do { \
517         if (!(_cond)) { \
518             RETURN_ERROR(CRITICAL, (_err), NO_MSG); \
519         } \
520     } while (0)
521 
522 #define SANITY_CHECK_RETURN_VALUE(_cond, _err, retval) \
523     do { \
524         if (!(_cond)) { \
525             REPORT_ERROR(CRITICAL, (_err), NO_MSG); \
526             return (retval); \
527         } \
528     } while (0)
529 
530 #define SANITY_CHECK_RETURN(_cond, _err) \
531     do { \
532         if (!(_cond)) { \
533             REPORT_ERROR(CRITICAL, (_err), NO_MSG); \
534             return; \
535         } \
536     } while (0)
537 
538 #define SANITY_CHECK_EXIT(_cond, _err) \
539     do { \
540         if (!(_cond)) { \
541             REPORT_ERROR(CRITICAL, (_err), NO_MSG); \
542             XX_Exit(1); \
543         } \
544     } while (0)
545 
546 #endif /* DISABLE_SANITY_CHECKS */
547 
548 /** @} */ /* end of Debug/error Utils group */
549 
550 /** @} */ /* end of General Utils group */
551 
552 #endif /* __ERROR_EXT_H */
553 
554 
555