1 /* 2 * Copyright 2018 Rockchip Electronics Co. LTD 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 * author: martin.cheng@rock-chips.com 17 * date: 20180704 18 */ 19 20 #ifndef INCLUDE_RT_BASE_RT_DEBUG_H_ 21 #define INCLUDE_RT_BASE_RT_DEBUG_H_ 22 23 #include <assert.h> 24 #include "rt_log.h" // NOLINT 25 26 #define RT_ABORT_DBG 1 27 #define RT_DEBUG 1 28 29 #define RT_ABORT() do { \ 30 if (RT_ABORT_DBG) { \ 31 abort(); \ 32 } \ 33 } while (0) 34 35 #if RT_DEBUG 36 #define RT_ASSERT(cond) do { \ 37 if (!(cond)) { \ 38 RT_LOGE("Assertion %s failed at %s:%d\n", \ 39 #cond, __FUNCTION__, __LINE__); \ 40 RT_ABORT(); \ 41 } \ 42 } while (0) 43 44 #define RT_ASSERT_IF(cond, fmt, ...) static_cast<void>(0) 45 #define RT_DEBUGFAIL(messge) 46 #define RT_ASSERT_RESULT(cond) if (cond) {} do {} while (false) 47 #else 48 #define RT_ASSERT(cond) 49 #define RT_ASSERT_IF(cond, fmt, ...) 50 #define RT_DEBUGFAIL(message) 51 #define RT_ASSERT_RESULT(cond) 52 #endif 53 54 #endif // INCLUDE_RT_BASE_RT_DEBUG_H_ 55