summaryrefslogtreecommitdiff
path: root/include/rtdebug.h
diff options
context:
space:
mode:
authorHenson <[email protected]>2022-01-26 21:39:06 +0800
committerHenson <[email protected]>2022-01-26 21:39:06 +0800
commit500d26c2570bb3d905e38aed05fd9c9b324a8f6e (patch)
tree6b24159e6e081cfbe42963ee8f9a901538f90637 /include/rtdebug.h
parent9b44535740b7e1deda584e8c7397b40113fa43f0 (diff)
optimize code
Diffstat (limited to 'include/rtdebug.h')
-rw-r--r--include/rtdebug.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/include/rtdebug.h b/include/rtdebug.h
index 143f6c29d4..55d46171a2 100644
--- a/include/rtdebug.h
+++ b/include/rtdebug.h
@@ -116,25 +116,28 @@ while (0)
* 2) not in interrupt context.
* 3) scheduler is not locked.
*/
-#define RT_DEBUG_SCHEDULER_AVAILABLE \
+#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check) \
do \
{ \
- rt_base_t level; \
- level = rt_hw_interrupt_disable(); \
- if (rt_critical_level() != 0) \
+ if (need_check) \
{ \
- rt_kprintf("Function[%s]: scheduler is not available\n", \
- __FUNCTION__); \
- RT_ASSERT(0) \
+ rt_base_t level; \
+ level = rt_hw_interrupt_disable(); \
+ if (rt_critical_level() != 0) \
+ { \
+ rt_kprintf("Function[%s]: scheduler is not available\n", \
+ __FUNCTION__); \
+ RT_ASSERT(0) \
+ } \
+ RT_DEBUG_IN_THREAD_CONTEXT; \
+ rt_hw_interrupt_enable(level); \
} \
- RT_DEBUG_IN_THREAD_CONTEXT; \
- rt_hw_interrupt_enable(level); \
} \
while (0)
#else
#define RT_DEBUG_NOT_IN_INTERRUPT
#define RT_DEBUG_IN_THREAD_CONTEXT
-#define RT_DEBUG_SCHEDULER_AVAILABLE
+#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check)
#endif
#else /* RT_DEBUG */
@@ -143,7 +146,7 @@ while (0)
#define RT_DEBUG_LOG(type, message)
#define RT_DEBUG_NOT_IN_INTERRUPT
#define RT_DEBUG_IN_THREAD_CONTEXT
-#define RT_DEBUG_SCHEDULER_AVAILABLE
+#define RT_DEBUG_SCHEDULER_AVAILABLE(need_check)
#endif /* RT_DEBUG */