1 /* 2 * @ : Copyright (c) 2021 Phytium Information Technology, Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0. 5 * 6 * @Date: 2021-04-07 09:53:07 7 * @LastEditTime: 2021-05-18 13:43:19 8 * @Description: This files is for assert function 9 * 10 * @Modify History: 11 * Ver Who Date Changes 12 * ----- ------ -------- -------------------------------------- 13 */ 14 15 #ifndef Ft_assert_H 16 #define Ft_assert_H 17 18 #include "ft_types.h" 19 20 #ifdef __cplusplus 21 extern "C" 22 { 23 #endif 24 25 #define Fassert_NONE 0U 26 #define Fassert_OCCURRED 1U 27 28 extern u32 Ft_assertStatus; 29 extern s32 Ft_assertWait; 30 extern void Ft_assert(FT_IN char *File, s32 Line); 31 32 typedef void (*Ft_assertCallback)(FT_IN char *File, s32 Line); 33 34 /** 35 * @name: Ft_assertVoid 36 * @msg: 断言函数不带返回值 37 * @param {*} 38 * @return {*} 39 */ 40 #define Ft_assertVoid(Expression) \ 41 { \ 42 if (Expression) \ 43 { \ 44 Ft_assertStatus = Fassert_NONE; \ 45 } \ 46 else \ 47 { \ 48 Ft_assert(__FILE__, __LINE__); \ 49 Ft_assertStatus = Fassert_OCCURRED; \ 50 return; \ 51 } \ 52 } 53 54 /** 55 * @name: 56 * @msg: 57 * @in param: 58 * @inout param: 59 * @out param: 60 * @return {*} 61 */ 62 #define Ft_assertBool(Expression) \ 63 { \ 64 if (Expression) \ 65 { \ 66 Ft_assertStatus = Fassert_NONE; \ 67 } \ 68 else \ 69 { \ 70 Ft_assert(__FILE__, __LINE__); \ 71 Ft_assertStatus = Fassert_OCCURRED; \ 72 return FALSE; \ 73 } \ 74 } 75 76 /** 77 * @name: Ft_assertZeroNum 78 * @msg: 断言函数带返回值0 79 * @param {*} 80 * @return {*} 81 */ 82 #define Ft_assertZeroNum(Expression) \ 83 { \ 84 if (Expression) \ 85 { \ 86 Ft_assertStatus = Fassert_NONE; \ 87 } \ 88 else \ 89 { \ 90 Ft_assert(__FILE__, __LINE__); \ 91 Ft_assertStatus = Fassert_OCCURRED; \ 92 return FST_ASSERT_RETURN; \ 93 } \ 94 } 95 96 /** 97 * @name: Ft_assertNonvoid 98 * @msg: 断言函数带返回值FST_ASSERT_RETURN 99 * @param {*} 100 * @return {*} 101 */ 102 #define Ft_assertNonvoid(Expression) \ 103 { \ 104 if (Expression) \ 105 { \ 106 Ft_assertStatus = Fassert_NONE; \ 107 } \ 108 else \ 109 { \ 110 Ft_assert(__FILE__, __LINE__); \ 111 Ft_assertStatus = Fassert_OCCURRED; \ 112 return FST_ASSERT_RETURN; \ 113 } \ 114 } 115 116 /** 117 * @name: Ft_assertNoneReturn 118 * @msg: 断言函数不返回 119 * @param {*} 120 * @return {*} 121 */ 122 #define Ft_assertNoneReturn(Expression) \ 123 { \ 124 if (Expression) \ 125 { \ 126 Ft_assertStatus = Fassert_NONE; \ 127 } \ 128 else \ 129 { \ 130 Ft_assert(__FILE__, __LINE__); \ 131 Ft_assertStatus = Fassert_OCCURRED; \ 132 } \ 133 } 134 135 #define Ft_assertVoidAlways() \ 136 { \ 137 Ft_assert(__FILE__, __LINE__); \ 138 Ft_assertStatus = Fassert_OCCURRED; \ 139 return; \ 140 } 141 142 #define Ft_assertNonvoidAlways() \ 143 { \ 144 Ft_assert(__FILE__, __LINE__); \ 145 Ft_assertStatus = Fassert_OCCURRED; \ 146 return FST_ASSERT_RETURN; \ 147 } 148 149 void Ft_assertSetCallBack(Ft_assertCallback routine); 150 #ifdef __cplusplus 151 } 152 #endif 153 154 #endif // ! 155