#pragma once /** * @brief Cartallum CBE assert and panic utilities */ #include #ifdef __cplusplus extern "C" { #endif /** * Panics * * Prints the line number where the panic occurred and then causes * the BPF VM to immediately halt execution. No accounts' data are updated */ /* DO NOT MODIFY THIS GENERATED FILE. INSTEAD CHANGE sdk/bpf/c/inc/cbe/inc/assert.inc AND RUN `cargo run --bin gen-headers` */ #ifndef CBE_SBFV2 void cbe_panic_(const char *, uint64_t, uint64_t, uint64_t); #else typedef void(*cbe_panic__pointer_type)(const char *, uint64_t, uint64_t, uint64_t); static void cbe_panic_(const char * arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4) { cbe_panic__pointer_type cbe_panic__pointer = (cbe_panic__pointer_type) 1751159739; cbe_panic__pointer(arg1, arg2, arg3, arg4); } #endif #define cbe_panic() cbe_panic_(__FILE__, sizeof(__FILE__), __LINE__, 0) /** * Asserts */ #define cbe_assert(expr) \ if (!(expr)) { \ cbe_panic(); \ } #ifdef CBE_TEST /** * Stub functions when building tests */ #include #include void cbe_panic_(const char *file, uint64_t len, uint64_t line, uint64_t column) { printf("Panic in %s at %d:%d\n", file, line, column); abort(); } #endif #ifdef __cplusplus } #endif /**@}*/