38 #ifndef included_error_bootstrap_h 39 #define included_error_bootstrap_h 56 #define clib_error_function ((char *) __FUNCTION__) 58 #ifndef CLIB_ASSERT_ENABLE 59 #define CLIB_ASSERT_ENABLE (CLIB_DEBUG > 0) 65 extern void _clib_error (
int code,
69 #define ASSERT(truth) \ 71 if (CLIB_ASSERT_ENABLE && ! (truth)) \ 73 _clib_error (CLIB_ERROR_ABORT, 0, 0, \ 74 "%s:%d (%s) assertion `%s' fails", \ 77 clib_error_function, \ 89 #define ALWAYS_ASSERT(truth) \ 91 if (PREDICT_FALSE(!(truth))) \ 93 _clib_error (CLIB_ERROR_ABORT, 0, 0, \ 94 "%s:%d (%s) assertion `%s' fails", \ 97 clib_error_function, \ 102 #define ALWAYS_ASSERT(truth) \ 104 if (PREDICT_FALSE(!(truth))) \ 111 #if defined(__clang__) 112 #define STATIC_ASSERT(truth,...) 114 #define STATIC_ASSERT(truth,...) _Static_assert(truth, __VA_ARGS__) 117 #define STATIC_ASSERT_SIZEOF(d, s) \ 118 STATIC_ASSERT (sizeof (d) == s, "Size of " #d " must be " # s " bytes") 120 #define STATIC_ASSERT_SIZEOF_ELT(d, e, s) \ 121 STATIC_ASSERT (sizeof (((d *)0)->e) == s, "Size of " #d "." #e " must be " # s " bytes") 123 #define STATIC_ASSERT_OFFSET_OF(s, e, o) \ 124 STATIC_ASSERT (STRUCT_OFFSET_OF(s,e) == o, "Offset of " #s "." #e " must be " # o) 126 #define STATIC_ASSERT_FITS_IN(s, e, o) \ 127 STATIC_ASSERT (STRUCT_OFFSET_OF(s,e) <= (o - sizeof(((s *)0)->e)), \ 128 #s "." #e " does not fit into " # o " bytes") 131 #define ASSERT_AND_PANIC(truth) \ 133 if (CLIB_ASSERT_ENABLE && ! (truth)) \
unsigned char function_name[]