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) 89 #define clib_error_get_code(err) ((err) ? (err)->code : 0) 90 #define clib_error_set_code(err, c) \ 98 #define clib_error_free(e) e = clib_error_free_vector(e) 103 char *where,
char *fmt, ...);
105 #define clib_error_return_code(e,code,flags,args...) \ 106 _clib_error_return((e),(code),(flags),(char *)clib_error_function,args) 108 #define clib_error_create(args...) \ 109 clib_error_return_code(0,0,0,args) 111 #define clib_error_return(e,args...) \ 112 clib_error_return_code(e,0,0,args) 114 #define clib_error_return_unix(e,args...) \ 115 clib_error_return_code(e,errno,CLIB_ERROR_ERRNO_VALID,args) 117 #define clib_error_return_fatal(e,args...) \ 118 clib_error_return_code(e,0,CLIB_ERROR_FATAL,args) 120 #define clib_error_return_unix_fatal(e,args...) \ 121 clib_error_return_code(e,errno,CLIB_ERROR_ERRNO_VALID|CLIB_ERROR_FATAL,args) 125 #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, \ 198 #ifndef _Static_assert 199 #define _Static_assert(x,y)
u8 * format_clib_error(u8 *s, va_list *va)
static word unix_error_is_fatal(word error)
void clib_error_handler_func_t(void *arg, u8 *msg, int msg_len)
void * clib_error_free_vector(clib_error_t *errors)
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".