summaryrefslogtreecommitdiff
path: root/include/rtdebug.h
diff options
context:
space:
mode:
author[email protected] <[email protected]>2011-06-14 23:59:42 +0000
committer[email protected] <[email protected]>2011-06-14 23:59:42 +0000
commitee68988518f8aa2b7cdafc2bcfe0abe6ad7df385 (patch)
treec673b27eee805e37c3c138e4e1d4c3596f985c9b /include/rtdebug.h
parent99dc4465a66d757b1a94220b513d30e647861b4c (diff)
change the RT_DEBUG_NOT_REENT to RT_DEBUG_NOT_IN_INTERRUPT.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1503 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'include/rtdebug.h')
-rw-r--r--include/rtdebug.h40
1 files changed, 11 insertions, 29 deletions
diff --git a/include/rtdebug.h b/include/rtdebug.h
index 7a743f4d60..d7874b0770 100644
--- a/include/rtdebug.h
+++ b/include/rtdebug.h
@@ -39,9 +39,9 @@
#define RT_DEBUG_IPC 0
#endif
-/* Turn on this to enable reentrance check */
-#ifndef RT_DEBUG_REENT_CHK
-#define RT_DEBUG_REENT_CHK 1
+/* Turn on this to enable context check */
+#ifndef RT_DEBUG_CONTEXT_CHECK
+#define RT_DEBUG_CONTEXT_CHECK 1
#endif
#define RT_DEBUG_LOG(type,message) do{ if(type) rt_kprintf message;}while(0)
@@ -50,39 +50,21 @@
rt_kprintf("(%s) assert failed at %s:%d \n", \
#EX, __FUNCTION__, __LINE__); while (dummy==0);}
-/* Reentrance check */
-/* counter */
-extern rt_uint8_t rt_debug_reent_cnt;
-
-#define RT_DEBUG_REENT_IN if(RT_DEBUG_REENT_CHK){\
- rt_base_t level;\
- level = rt_hw_interrupt_disable();\
- rt_debug_reent_cnt++;\
- rt_hw_interrupt_enable(level);}
-
-#define RT_DEBUG_REENT_OUT if(RT_DEBUG_REENT_CHK){\
- rt_base_t level;\
- level = rt_hw_interrupt_disable();\
- rt_debug_reent_cnt--;\
- rt_hw_interrupt_enable(level);}
-
-/* Mark those non-reentrant functions with this macro */
-#define RT_DEBUG_NOT_REENT if(RT_DEBUG_REENT_CHK){\
+/* Macro to check current context */
+#if RT_DEBUG_CONTEXT_CHECK
+#define RT_DEBUG_NOT_IN_INTERRUPT do {\
rt_base_t level;\
level = rt_hw_interrupt_disable();\
- if(rt_debug_reent_cnt != 0){\
- rt_kprintf("Non-reentrant function used in critical area!\n");\
+ if(rt_interrupt_get_nest() != 0){\
+ rt_kprintf("Function[%s] shall not used in ISR\n", __FUNCTION__);\
RT_ASSERT(0)}\
- rt_hw_interrupt_enable(level);}
-
-
+ rt_hw_interrupt_enable(level);} while (0)
+#endif
#else /* RT_DEBUG */
#define RT_ASSERT(EX)
#define RT_DEBUG_LOG(type,message)
-#define RT_DEBUG_REENT_IN
-#define RT_DEBUG_REENT_OUT
-#define RT_DEBUG_NOT_REENT
+#define RT_DEBUG_NOT_IN_INTERRUPT
#endif /* RT_DEBUG */