43 #ifdef CLIB_LINUX_KERNEL 44 #include <linux/unistd.h> 45 #include <linux/kernel.h> 54 #ifdef CLIB_STANDALONE 55 #include <vppinfra/standalone_stdio.h> 101 for (i = 0; i <
vec_len (handlers); i++)
102 handlers[i].func (handlers[i].arg, msg, vec_len (msg));
105 if (vec_len (handlers) == 0)
106 os_puts (msg, vec_len (msg), 1);
112 _clib_error (
int how_to_die,
122 msg =
format (msg,
"%wd:", line_number);
132 msg =
format (msg,
": %s (errno %d)", strerror (errno), errno);
157 word errno_save = errno;
206 where =
format (where,
"from ");
209 s =
format (s,
"%v: ", where);
214 if ((
vec_end (errors) - 1) != e)
246 return error_return (0,
"x is odd %d", x);
252 return error_return (0,
"x is even %d", x);
264 return error_return (e, 0);
268 error_handler (
void *arg,
char *msg,
int msg_len)
270 write (2, msg, msg_len);
274 main (
int argc,
char *argv[])
278 register_error_handler (error_handler, 0);
vl_api_wireguard_peer_flags_t flags
void os_puts(u8 *string, uword length, uword is_error)
Optimized string handling code, including c11-compliant "safe C library" variants.
__clib_export void * clib_error_free_vector(clib_error_t *errors)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static u8 * dispatch_message(u8 *msg)
description fragment has unexpected format
__clib_export void clib_error_register_handler(clib_error_handler_func_t func, void *arg)
#define vec_end(v)
End (last data address) of vector.
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
clib_error_handler_func_t * func
void clib_error_handler_func_t(void *arg, u8 *msg, int msg_len)
unsigned char function_name[]
static void error_exit(int code)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
int main(int argc, char **argv)
#define clib_error_free(e)
#define vec_foreach(var, vec)
Vector iterator.
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
static void debugger(void)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".