[kservice]add hook for RT_ASSERT

This commit is contained in:
armink
2015-06-11 10:59:25 +08:00
parent a51f6afa41
commit 892eac2cce
3 changed files with 25 additions and 2 deletions
+7 -2
View File
@@ -84,8 +84,13 @@ while (0)
if (!(EX)) \
{ \
volatile char dummy = 0; \
rt_kprintf("(%s) assert failed at %s:%d \n", #EX, __FUNCTION__, __LINE__);\
while (dummy == 0); \
if (rt_assert_hook == RT_NULL) \
{ \
rt_kprintf("(%s) assert failed at %s:%d \n", #EX, __FUNCTION__, __LINE__);\
while (dummy == 0); \
} else { \
rt_assert_hook(#EX, __FUNCTION__, __LINE__); \
} \
}
/* Macro to check current context */
+5
View File
@@ -515,6 +515,11 @@ rt_uint32_t rt_strcasecmp(const char *a, const char *b);
void rt_show_version(void);
#ifdef RT_DEBUG
extern void (*rt_assert_hook)(const char* ex, const char* func, rt_size_t line);
void rt_assert_set_hook(void (*hook)(const char* ex, const char* func, rt_size_t line));
#endif /* RT_DEBUG */
/*@}*/
#ifdef __cplusplus