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, \ 82 #if defined(__clang__) 83 #define STATIC_ASSERT(truth,...) 85 #define STATIC_ASSERT(truth,...) _Static_assert(truth, __VA_ARGS__) 88 #define STATIC_ASSERT_SIZEOF(d, s) \ 89 STATIC_ASSERT (sizeof (d) == s, "Size of " #d " must be " # s " bytes") 91 #define STATIC_ASSERT_SIZEOF_ELT(d, e, s) \ 92 STATIC_ASSERT (sizeof (((d *)0)->e) == s, "Size of " #d "." #e " must be " # s " bytes") 94 #define STATIC_ASSERT_OFFSET_OF(s, e, o) \ 95 STATIC_ASSERT (STRUCT_OFFSET_OF(s,e) == o, "Offset of " #s "." #e " must be " # o) 97 #define STATIC_ASSERT_FITS_IN(s, e, o) \ 98 STATIC_ASSERT (STRUCT_OFFSET_OF(s,e) <= (o - sizeof(((s *)0)->e)), \ 99 #s "." #e " does not fit into " # o " bytes") 102 #define ASSERT_AND_PANIC(truth) \ 104 if (CLIB_ASSERT_ENABLE && ! (truth)) \
unsigned char function_name[]