38 #ifndef included_error_h 39 #define included_error_h 48 #ifdef CLIB_LINUX_KERNEL 49 #include <linux/errno.h> 59 #define clib_warning(format,args...) \ 60 _clib_error (CLIB_ERROR_WARNING, clib_error_function, __LINE__, format, ## args) 62 #define clib_error(format,args...) \ 63 _clib_error (CLIB_ERROR_FATAL, clib_error_function, __LINE__, format, ## args) 65 #define clib_unix_error(format,args...) \ 66 _clib_error (CLIB_ERROR_FATAL | CLIB_ERROR_ERRNO_VALID, clib_error_function, __LINE__, format, ## args) 68 #define clib_unix_warning(format,args...) \ 69 _clib_error (CLIB_ERROR_WARNING | CLIB_ERROR_ERRNO_VALID, clib_error_function, __LINE__, format, ## args) 72 #define clib_panic(format,args...) \ 73 _clib_error (CLIB_ERROR_ABORT, (char *) clib_error_function, __LINE__, format, ## args) 88 #define clib_error_get_code(err) ((err) ? (err)->code : 0) 89 #define clib_error_set_code(err, c) \ 97 #define clib_error_free(e) e = clib_error_free_vector(e) 106 #define clib_error_return_code(e,code,flags,args...) \ 107 _clib_error_return((e),(code),(flags),(char *)clib_error_function,args) 109 #define clib_error_create(args...) \ 110 clib_error_return_code(0,0,0,args) 112 #define clib_error_return(e,args...) \ 113 clib_error_return_code(e,0,0,args) 115 #define clib_error_return_unix(e,args...) \ 116 clib_error_return_code(e,errno,CLIB_ERROR_ERRNO_VALID,args) 118 #define clib_error_return_fatal(e,args...) \ 119 clib_error_return_code(e,0,CLIB_ERROR_FATAL,args) 121 #define clib_error_return_unix_fatal(e,args...) \ 122 clib_error_return_code(e,errno,CLIB_ERROR_ERRNO_VALID|CLIB_ERROR_FATAL,args) 126 #define clib_error_report(e) do { (e) = _clib_error_report (e); } while (0) 143 #define IF_ERROR_IS_FATAL_RETURN_ELSE_FREE(e) \ 147 if (unix_error_is_fatal (clib_error_get_code (e))) \ 150 clib_error_free (e); \ 154 #define ERROR_RETURN_IF(x) \ 156 clib_error_t * _error_return_if = (x); \ 157 if (_error_return_if) \ 158 return clib_error_return (_error_return_if, 0); \ 161 #define ERROR_ASSERT(truth) \ 163 clib_error_t * _error_assert = 0; \ 164 if (CLIB_DEBUG > 0 && ! (truth)) \ 166 _error_assert = clib_error_return_fatal \ 167 (0, "%s:%d (%s) assertion `%s' fails", \ 170 clib_error_function, \ 177 #define CLIB_ERROR_ASSERT(truth) \ 179 clib_error_t * _error_assert = 0; \ 183 clib_error_return_fatal \ 184 (0, "%s:%d (%s) assertion `%s' fails", \ 187 clib_error_function, \
u8 * format_clib_error(u8 *s, va_list *va)
void clib_error_handler_func_t(void *arg, u8 *msg, int msg_len)
void * clib_error_free_vector(clib_error_t *errors)
always_inline word unix_error_is_fatal(word error)
void clib_error_register_handler(clib_error_handler_func_t func, void *arg)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".