/* * @file hv_vos_Assert.h * @brief Header file of vos Assert. * * @verbatim * ============================================================================== * ##### How to use ##### * ============================================================================== * (+) Use () * * @endverbatim * @author HiView SoC Software Team * @version 1.0.0 * @date 2023-03-01 */ #ifndef _HV_VOS_ASSERT_H #define _HV_VOS_ASSERT_H #include "hv_vos_Types.h" VOS_EXTERN_C_BEGIN #define HV_MSG_NOT_IMPL "not implemented" #define HV_MSG_NOT_READY "not ready" #define HV_MSG_INV_ARG "invalid argument" #define HV_MSG_OUT_OF_MEMORY "out of memory" #define HV_MSG_OUT_OF_BOUNDS "out of bounds" /// assert report routine void Hv_Vos_Assert_Report(const char *condition, int line, const char *function, const char *message); /// HS portable assertion /// @param cond logical condition #define HV_ASSERT(cond) HV_ASSERT_IMPL((cond), __LINE__, __FUNCTION__, NULL) /// simple way to assert HV_RESULT #define HV_ASSERT_RESULT(result) HV_ASSERT(result >= 0) /// HS portable assertion implementation #define HV_ASSERT_IMPL(cond, line, function, msg) \ do { \ if (!(cond)) { \ Hv_Vos_Assert_Report(#cond, line, function, msg); \ } \ } while (0) /// assert for arguement checking #define HV_ASSERT_CHK_ARG(cond) \ HV_ASSERT_IMPL((cond), __LINE__, __FUNCTION__, HV_MSG_INV_ARG) /// assert for not implemented function #define HV_ASSERT_NOT_IMPL() \ HV_ASSERT_IMPL(0, __LINE__, __FUNCTION__, HV_MSG_NOT_IMPL) #define HV_ASSERT_OUT_OF_MEMORY() \ HV_ASSERT_IMPL(0, __LINE__, __FUNCTION__, HV_MSG_OUT_OF_MEMORY) /** @} */ VOS_EXTERN_C_END #endif