统一断言接口
This commit is contained in:
parent
078da19f55
commit
0b6f3ce698
|
@ -194,8 +194,6 @@ public:
|
|||
// 将集合元素复制到数组中
|
||||
virtual void CopyTo(T* arr)
|
||||
{
|
||||
assert_ptr(arr);
|
||||
|
||||
if(!_Count) return;
|
||||
|
||||
Node* node;
|
||||
|
|
16
Core/_Core.h
16
Core/_Core.h
|
@ -5,28 +5,20 @@
|
|||
|
||||
extern "C"
|
||||
{
|
||||
#if defined(DEBUG) || defined(MSGDEBUG)
|
||||
|
||||
#define debug_printf printf
|
||||
|
||||
#if defined(DEBUG)
|
||||
#define debug_printf printf
|
||||
#else
|
||||
|
||||
#define debug_printf(format, ...)
|
||||
|
||||
#define debug_printf(format, ...)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(DEBUG) && defined(USE_FULL_ASSERT)
|
||||
|
||||
//#define assert_ptr(expr) (assert_ptr_(expr) ? (void)0 : assert_failed2("ptr==nullptr", (const char*)__FILE__, __LINE__))
|
||||
//bool assert_ptr_(const void* p);
|
||||
#if defined(DEBUG)
|
||||
|
||||
void assert_failed2(const char* msg, const char* file, unsigned int line);
|
||||
#define assert(expr, msg) ((expr) ? (void)0 : assert_failed2(msg, (const char*)__FILE__, __LINE__))
|
||||
|
||||
#else
|
||||
|
||||
#define assert_ptr(expr) ((void)0)
|
||||
#define assert(expr, msg) ((void)0)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -669,8 +669,6 @@ void ShowStatusTask(void* param)
|
|||
|
||||
void AutoOpenTask(void* param)
|
||||
{
|
||||
assert_ptr(param);
|
||||
|
||||
auto nrf = (NRF24L01*)param;
|
||||
nrf->Open();
|
||||
}
|
||||
|
@ -1057,8 +1055,6 @@ void NRF24L01::ShowStatus()
|
|||
|
||||
void NRF24L01::ReceiveTask(void* param)
|
||||
{
|
||||
assert_ptr(param);
|
||||
|
||||
auto nrf = (NRF24L01*)param;
|
||||
// 需要判断锁,如果有别的线程正在读写,则定时器无条件退出。
|
||||
if(nrf->Opened) nrf->OnIRQ();
|
||||
|
|
25
Kernel/Sys.h
25
Kernel/Sys.h
|
@ -17,39 +17,25 @@
|
|||
#include "Core\Dictionary.h"
|
||||
#include "Core\Delegate.h"
|
||||
|
||||
/* 引脚定义 */
|
||||
//#include "Platform\Pin.h"
|
||||
|
||||
// 强迫内联
|
||||
#define _force_inline __attribute__( ( always_inline ) ) __INLINE
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#if defined(DEBUG) || defined(MSGDEBUG)
|
||||
|
||||
#define debug_printf printf
|
||||
|
||||
#if defined(DEBUG)
|
||||
#define debug_printf printf
|
||||
#else
|
||||
|
||||
#define debug_printf(format, ...)
|
||||
|
||||
#define debug_printf(format, ...)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_FULL_ASSERT
|
||||
|
||||
// 验证确保对象不为空,并且在有效的内存范围内
|
||||
//extern void assert_failed(uint8_t* file, uint32_t line);
|
||||
|
||||
//#define assert_ptr(expr) (assert_ptr_(expr) ? (void)0 : assert_failed2("ptr==nullptr", (const char*)__FILE__, __LINE__))
|
||||
//bool assert_ptr_(const void* p);
|
||||
#ifdef DEBUG
|
||||
|
||||
void assert_failed2(cstring msg, cstring file, unsigned int line);
|
||||
#define assert(expr, msg) ((expr) ? (void)0 : assert_failed2(msg, (const char*)__FILE__, __LINE__))
|
||||
|
||||
#else
|
||||
|
||||
#define assert_ptr(expr) ((void)0)
|
||||
#define assert(expr, msg) ((void)0)
|
||||
|
||||
#endif
|
||||
|
@ -65,9 +51,6 @@ struct HandlerRemap
|
|||
extern struct HandlerRemap StrBoot;
|
||||
#endif
|
||||
|
||||
// 判定指针是否在ROM区
|
||||
#define IN_ROM_SECTION(p) ( (int)p < 0x20000000 )
|
||||
|
||||
class SystemConfig;
|
||||
|
||||
// 系统类
|
||||
|
|
|
@ -140,7 +140,12 @@ void operator delete[](void* p) noexcept
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_FULL_ASSERT
|
||||
void assert_failed(uint8_t* file, unsigned int line)
|
||||
{
|
||||
debug_printf("Assert Failed! Line %d, %s\r\n", line, file);
|
||||
|
||||
TInterrupt::Halt();
|
||||
}
|
||||
|
||||
void assert_failed2(cstring msg, cstring file, unsigned int line)
|
||||
{
|
||||
|
@ -148,7 +153,6 @@ void assert_failed2(cstring msg, cstring file, unsigned int line)
|
|||
|
||||
TInterrupt::Halt();
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
#include "Sys.h"
|
||||
|
||||
#include "Platform\stm32.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// 仅用于调试使用的一些函数实现,RTM不需要
|
||||
|
||||
#if DEBUG
|
||||
|
||||
extern uint __heap_base;
|
||||
extern uint __heap_limit;
|
||||
extern uint __Vectors;
|
||||
extern uint __Vectors_End;
|
||||
extern uint __Vectors_Size;
|
||||
|
||||
#ifdef USE_FULL_ASSERT
|
||||
|
||||
void assert_failed(uint8_t* file, unsigned int line)
|
||||
{
|
||||
debug_printf("Assert Failed! Line %d, %s\r\n", line, file);
|
||||
|
||||
TInterrupt::Halt();
|
||||
}
|
||||
|
||||
/*bool assert_ptr_(const void* p)
|
||||
{
|
||||
if((uint)p < FLASH_BASE)
|
||||
{
|
||||
debug_printf("ptr:0x%08x < FLASH_BASE:0x%08x\r\n", p, FLASH_BASE);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint ramEnd = SRAM_BASE + (Sys.RAMSize << 10);
|
||||
if(Sys.RAMSize > 0 && (uint)p >= ramEnd)
|
||||
{
|
||||
debug_printf("ptr:0x%08x >= SRAM_END:0x%08x\r\n", p, ramEnd);
|
||||
return false;
|
||||
}
|
||||
|
||||
// F4有64k的CCM内存
|
||||
#if defined(STM32F4)
|
||||
if((uint)p >= 0x10000000 && (uint)p < 0x10010000) return true;
|
||||
#endif
|
||||
|
||||
uint flashEnd = FLASH_BASE + (Sys.FlashSize << 10);
|
||||
if(Sys.FlashSize > 0 && (uint)p >= flashEnd && (uint)p < SRAM_BASE)
|
||||
{
|
||||
debug_printf("ptr:0x%08x >= FLASH_END:0x%08x\r\n", p, flashEnd);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 不支持静态全局对象
|
||||
//if(p <= (void*)&__heap_base) return false;
|
||||
|
||||
return true;
|
||||
}*/
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue