diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html index 1fe1a96720..aaf32db579 100644 --- a/Documentation/NuttxPortingGuide.html +++ b/Documentation/NuttxPortingGuide.html @@ -2147,7 +2147,7 @@ The specific environmental definitions are unique for each board but should incl

4.2.13 up_assert()

Function Prototype:
- void up_assert(FAR const uint8_t *filename, int linenum); + void up_assert(FAR const char *filename, int linenum);

Description. diff --git a/arch/arm/src/arm/arm_assert.c b/arch/arm/src/arm/arm_assert.c index f34f47c61d..71e1512aa0 100644 --- a/arch/arm/src/arm/arm_assert.c +++ b/arch/arm/src/arm/arm_assert.c @@ -283,8 +283,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -313,7 +312,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -325,7 +323,7 @@ static void _up_assert(int errorcode) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -355,5 +353,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(arm_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/arm/src/armv6-m/arm_assert.c b/arch/arm/src/armv6-m/arm_assert.c index c8bd7d3686..bbc1e41356 100644 --- a/arch/arm/src/armv6-m/arm_assert.c +++ b/arch/arm/src/armv6-m/arm_assert.c @@ -340,8 +340,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -370,7 +369,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -382,7 +380,7 @@ static void _up_assert(int errorcode) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -412,5 +410,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(arm_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/arm/src/armv7-a/arm_assert.c b/arch/arm/src/armv7-a/arm_assert.c index b4cb872dae..3e5e48acd6 100644 --- a/arch/arm/src/armv7-a/arm_assert.c +++ b/arch/arm/src/armv7-a/arm_assert.c @@ -353,8 +353,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -394,7 +393,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -406,7 +404,7 @@ static void _up_assert(int errorcode) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -446,5 +444,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(arm_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/arm/src/armv7-m/arm_assert.c b/arch/arm/src/armv7-m/arm_assert.c index 41b69c2a88..aae1da418b 100644 --- a/arch/arm/src/armv7-m/arm_assert.c +++ b/arch/arm/src/armv7-m/arm_assert.c @@ -347,8 +347,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -383,7 +382,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -395,7 +393,7 @@ static void _up_assert(int errorcode) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -435,5 +433,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(arm_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/arm/src/armv7-r/arm_assert.c b/arch/arm/src/armv7-r/arm_assert.c index f4791b8810..ae4c71947a 100644 --- a/arch/arm/src/armv7-r/arm_assert.c +++ b/arch/arm/src/armv7-r/arm_assert.c @@ -333,8 +333,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -363,7 +362,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -375,7 +373,7 @@ static void _up_assert(int errorcode) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -405,5 +403,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(arm_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/arm/src/armv8-m/arm_assert.c b/arch/arm/src/armv8-m/arm_assert.c index 6e9b63317e..4477964914 100644 --- a/arch/arm/src/armv8-m/arm_assert.c +++ b/arch/arm/src/armv8-m/arm_assert.c @@ -347,8 +347,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -383,7 +382,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -395,7 +393,7 @@ static void _up_assert(int errorcode) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -435,5 +433,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(arm_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/avr/src/common/up_assert.c b/arch/avr/src/common/up_assert.c index c5c21eaab6..91dd03de3c 100644 --- a/arch/avr/src/common/up_assert.c +++ b/arch/avr/src/common/up_assert.c @@ -79,8 +79,7 @@ * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -109,7 +108,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -145,7 +143,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -181,5 +179,5 @@ void up_assert(const uint8_t *filename, int lineno) usbtrace_enumerate(assert_tracecallback, NULL); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/hc/src/m9s12/m9s12_assert.c b/arch/hc/src/m9s12/m9s12_assert.c index 390c1e0291..487031c194 100644 --- a/arch/hc/src/m9s12/m9s12_assert.c +++ b/arch/hc/src/m9s12/m9s12_assert.c @@ -285,8 +285,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -315,7 +314,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -327,7 +325,7 @@ static void _up_assert(int errorcode) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -357,5 +355,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(hc_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/mips/src/mips32/mips_assert.c b/arch/mips/src/mips32/mips_assert.c index 754eb1021a..f0d8e67a21 100644 --- a/arch/mips/src/mips32/mips_assert.c +++ b/arch/mips/src/mips32/mips_assert.c @@ -78,8 +78,7 @@ * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -108,7 +107,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -144,7 +142,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -180,5 +178,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(mips_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/misoc/src/lm32/lm32_assert.c b/arch/misoc/src/lm32/lm32_assert.c index 36d0b0747e..73c377b394 100644 --- a/arch/misoc/src/lm32/lm32_assert.c +++ b/arch/misoc/src/lm32/lm32_assert.c @@ -78,8 +78,7 @@ * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -113,7 +112,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -149,7 +147,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -185,5 +183,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(misoc_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/misoc/src/minerva/minerva_assert.c b/arch/misoc/src/minerva/minerva_assert.c index fe47be2e17..5931618291 100644 --- a/arch/misoc/src/minerva/minerva_assert.c +++ b/arch/misoc/src/minerva/minerva_assert.c @@ -78,8 +78,7 @@ * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -113,7 +112,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -149,7 +147,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t * filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -184,5 +182,5 @@ void up_assert(const uint8_t * filename, int lineno) board_crashdump(misoc_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/or1k/src/common/up_assert.c b/arch/or1k/src/common/up_assert.c index 53aa77c83d..d7abb50804 100644 --- a/arch/or1k/src/common/up_assert.c +++ b/arch/or1k/src/common/up_assert.c @@ -340,8 +340,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -370,7 +369,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -382,7 +380,7 @@ static void _up_assert(int errorcode) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -412,5 +410,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(or1k_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/renesas/src/common/up_assert.c b/arch/renesas/src/common/up_assert.c index fd7086c1b1..5fa078e036 100644 --- a/arch/renesas/src/common/up_assert.c +++ b/arch/renesas/src/common/up_assert.c @@ -79,8 +79,7 @@ * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -108,7 +107,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -144,7 +142,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -180,5 +178,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(renesas_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/risc-v/src/rv32im/riscv_assert.c b/arch/risc-v/src/rv32im/riscv_assert.c index 84004809d1..bcf85b3d58 100644 --- a/arch/risc-v/src/rv32im/riscv_assert.c +++ b/arch/risc-v/src/rv32im/riscv_assert.c @@ -278,8 +278,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -308,7 +307,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -344,7 +342,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -384,5 +382,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(riscv_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/risc-v/src/rv64gc/riscv_assert.c b/arch/risc-v/src/rv64gc/riscv_assert.c index 61376b5a60..b23db6219f 100644 --- a/arch/risc-v/src/rv64gc/riscv_assert.c +++ b/arch/risc-v/src/rv64gc/riscv_assert.c @@ -287,8 +287,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -323,7 +322,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -359,7 +357,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -415,5 +413,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(riscv_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/sim/src/sim/up_head.c b/arch/sim/src/sim/up_head.c index 000fef940b..ec45563e89 100644 --- a/arch/sim/src/sim/up_head.c +++ b/arch/sim/src/sim/up_head.c @@ -108,7 +108,7 @@ int main(int argc, char **argv, char **envp) * ****************************************************************************/ -void up_assert(const uint8_t *filename, int line) +void up_assert(const char *filename, int line) { /* Show the location of the failed assertion */ diff --git a/arch/x86/src/common/up_assert.c b/arch/x86/src/common/up_assert.c index f27d07577d..7dcb30ffc0 100644 --- a/arch/x86/src/common/up_assert.c +++ b/arch/x86/src/common/up_assert.c @@ -246,8 +246,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -276,7 +275,6 @@ static void _up_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -288,7 +286,7 @@ static void _up_assert(int errorcode) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -318,5 +316,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(x86_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/x86_64/src/common/up_assert.c b/arch/x86_64/src/common/up_assert.c index 50737f82d4..b092a27e21 100644 --- a/arch/x86_64/src/common/up_assert.c +++ b/arch/x86_64/src/common/up_assert.c @@ -52,6 +52,10 @@ # undef CONFIG_ARCH_USBDUMP #endif +#ifndef CONFIG_BOARD_RESET_ON_ASSERT +# define CONFIG_BOARD_RESET_ON_ASSERT 0 +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -208,8 +212,7 @@ static void up_dumpstate(void) * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) noreturn_function; -static void _up_assert(int errorcode) +static void _up_assert(void) { /* Are we in an interrupt handler or the idle task? */ @@ -218,6 +221,9 @@ static void _up_assert(int errorcode) (void)up_irq_save(); for (; ; ) { +#if CONFIG_BOARD_RESET_ON_ASSERT >= 1 + board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); +#endif #ifdef CONFIG_ARCH_LEDS board_autoled_on(LED_PANIC); up_mdelay(250); @@ -228,7 +234,11 @@ static void _up_assert(int errorcode) } else { - exit(errorcode); + /* Assertions in other contexts only cause the thread to exit */ + +#if CONFIG_BOARD_RESET_ON_ASSERT >= 2 + board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); +#endif } } @@ -240,7 +250,7 @@ static void _up_assert(int errorcode) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = this_task(); @@ -262,5 +272,5 @@ void up_assert(const uint8_t *filename, int lineno) board_crashdump(x64_getsp(), this_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/xtensa/src/common/xtensa_assert.c b/arch/xtensa/src/common/xtensa_assert.c index 5cce6ec7ef..0c5d4fefec 100644 --- a/arch/xtensa/src/common/xtensa_assert.c +++ b/arch/xtensa/src/common/xtensa_assert.c @@ -101,8 +101,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) * Name: xtensa_assert ****************************************************************************/ -static void xtensa_assert(int errorcode) noreturn_function; -static void xtensa_assert(int errorcode) +static void xtensa_assert(void) { /* Dump the processor state */ @@ -151,7 +150,6 @@ static void xtensa_assert(int errorcode) #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -163,7 +161,7 @@ static void xtensa_assert(int errorcode) * Name: up_assert ****************************************************************************/ -void up_assert(const uint8_t *filename, int lineno) +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -183,7 +181,7 @@ void up_assert(const uint8_t *filename, int lineno) filename, lineno); #endif - xtensa_assert(EXIT_FAILURE); + xtensa_assert(); } /**************************************************************************** @@ -229,7 +227,7 @@ void xtensa_panic(int xptcode, uint32_t *regs) #endif CURRENT_REGS = regs; - xtensa_assert(EXIT_FAILURE); /* Should not return */ + xtensa_assert(); /* Should not return */ for (; ; ); } @@ -334,6 +332,6 @@ void xtensa_user_panic(int exccause, uint32_t *regs) #endif CURRENT_REGS = regs; - xtensa_assert(EXIT_FAILURE); /* Should not return */ + xtensa_assert(); /* Should not return */ for (; ; ); } diff --git a/arch/z16/src/common/z16_assert.c b/arch/z16/src/common/z16_assert.c index 39d428b11e..9273f0b5cd 100644 --- a/arch/z16/src/common/z16_assert.c +++ b/arch/z16/src/common/z16_assert.c @@ -63,7 +63,7 @@ * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) /* noreturn_function */ +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -92,7 +92,6 @@ static void _up_assert(int errorcode) /* noreturn_function */ #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -128,11 +127,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg) * Name: up_assert ****************************************************************************/ -#ifdef CONFIG_HAVE_FILENAME -void up_assert(const uint8_t *filename, int lineno) -#else -void up_assert(void) -#endif +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -144,20 +139,12 @@ void up_assert(void) syslog_flush(); -#ifdef CONFIG_HAVE_FILENAME #if CONFIG_TASK_NAME_SIZE > 0 _alert("Assertion failed at file:%s line: %d task: %s\n", filename, lineno, rtcb->name); #else _alert("Assertion failed at file:%s line: %d\n", filename, lineno); -#endif -#else -#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) - _alert("Assertion failed: task: %s\n", rtcb->name); -#else - _alert("Assertion failed\n"); -#endif #endif z16_registerdump(); @@ -177,5 +164,5 @@ void up_assert(void) board_crashdump(z16_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/arch/z80/src/common/z80_assert.c b/arch/z80/src/common/z80_assert.c index 87ebbcb9af..c55ef1f53f 100644 --- a/arch/z80/src/common/z80_assert.c +++ b/arch/z80/src/common/z80_assert.c @@ -62,7 +62,7 @@ * Name: _up_assert ****************************************************************************/ -static void _up_assert(int errorcode) /* noreturn_function */ +static void _up_assert(void) { /* Flush any buffered SYSLOG data */ @@ -91,7 +91,6 @@ static void _up_assert(int errorcode) /* noreturn_function */ #if CONFIG_BOARD_RESET_ON_ASSERT >= 2 board_reset(CONFIG_BOARD_ASSERT_RESET_VALUE); #endif - exit(errorcode); } } @@ -127,11 +126,7 @@ static int assert_tracecallback(struct usbtrace_s *trace, void *arg) * Name: up_assert ****************************************************************************/ -#ifdef CONFIG_HAVE_FILENAME -void up_assert(const uint8_t *filename, int lineno) -#else -void up_assert(void) -#endif +void up_assert(const char *filename, int lineno) { #if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG_ALERT) struct tcb_s *rtcb = running_task(); @@ -143,20 +138,12 @@ void up_assert(void) syslog_flush(); -#ifdef CONFIG_HAVE_FILENAME #if CONFIG_TASK_NAME_SIZE > 0 _alert("Assertion failed at file:%s line: %d task: %s\n", filename, lineno, rtcb->name); #else _alert("Assertion failed at file:%s line: %d\n", filename, lineno); -#endif -#else -#if CONFIG_TASK_NAME_SIZE > 0 - _alert("Assertion failed: task: %s\n", rtcb->name); -#else - _alert("Assertion failed\n"); -#endif #endif REGISTER_DUMP(); @@ -178,5 +165,5 @@ void up_assert(void) board_crashdump(z80_getsp(), running_task(), filename, lineno); #endif - _up_assert(EXIT_FAILURE); + _up_assert(); } diff --git a/include/assert.h b/include/assert.h index 88254f6494..8d96e874b4 100644 --- a/include/assert.h +++ b/include/assert.h @@ -1,7 +1,8 @@ /**************************************************************************** * include/assert.h * - * Copyright (C) 2007-2009, 2011-2013, 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2013, 2015-2016 Gregory Nutt. + * All rights reserved. * Author: Gregory Nutt * * Copyright (C) 2016 Omni Hoverboards Inc. All rights reserved. @@ -60,9 +61,9 @@ #undef DEBUGVERIFY /* Like VERIFY, but only if CONFIG_DEBUG_ASSERTIONS is defined */ #ifdef CONFIG_HAVE_FILENAME -# define PANIC() up_assert((const uint8_t *)__FILE__, (int)__LINE__) +# define PANIC() _assert(__FILE__, __LINE__) #else -# define PANIC() up_assert() +# define PANIC() _assert("unknown", 0) #endif #define ASSERT(f) do { if (!(f)) PANIC(); } while (0) @@ -117,11 +118,7 @@ extern "C" * Public Function Prototypes ****************************************************************************/ -#ifdef CONFIG_HAVE_FILENAME -void up_assert(FAR const uint8_t *filename, int linenum) noreturn_function; -#else -void up_assert(void) noreturn_function; -#endif +void _assert(FAR const char *filename, int linenum) noreturn_function; #undef EXTERN #ifdef __cplusplus diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 8ef1fde4c6..e28a217f2f 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -475,7 +475,7 @@ void up_exit() noreturn_function; * ****************************************************************************/ -/* Prototype is in assert.h */ +void up_assert(FAR const char *filename, int linenum); /**************************************************************************** * Name: up_schedule_sigaction diff --git a/include/nuttx/irq.h b/include/nuttx/irq.h index e33815fb48..6e9e2a8dc3 100644 --- a/include/nuttx/irq.h +++ b/include/nuttx/irq.h @@ -48,6 +48,10 @@ # include #endif +/* Now include architecture-specific types */ + +#include + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -118,10 +122,6 @@ typedef uint32_t irq_mapped_t; typedef CODE int (*xcpt_t)(int irq, FAR void *context, FAR void *arg); #endif /* __ASSEMBLY__ */ -/* Now include architecture-specific types */ - -#include - /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/libs/libc/Makefile b/libs/libc/Makefile index c1c0fd09ad..89d4856f55 100644 --- a/libs/libc/Makefile +++ b/libs/libc/Makefile @@ -21,6 +21,7 @@ include $(TOPDIR)/Make.defs include aio/Make.defs +include assert/Make.defs include audio/Make.defs include builtin/Make.defs include dirent/Make.defs diff --git a/libs/libc/assert/Make.defs b/libs/libc/assert/Make.defs new file mode 100644 index 0000000000..d355f17ba0 --- /dev/null +++ b/libs/libc/assert/Make.defs @@ -0,0 +1,26 @@ +############################################################################ +# libs/libc/assert/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +CSRCS += lib_assert.c + +# Add the assert directory to the build + +DEPPATH += --dep-path assert +VPATH += :assert diff --git a/libs/libc/assert/lib_assert.c b/libs/libc/assert/lib_assert.c new file mode 100644 index 0000000000..fa3e18e2b3 --- /dev/null +++ b/libs/libc/assert/lib_assert.c @@ -0,0 +1,38 @@ +/**************************************************************************** + * libs/libc/assert/lib_assert.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void _assert(FAR const char *filename, int linenum) +{ + up_assert(filename, linenum); + exit(EXIT_FAILURE); +} diff --git a/syscall/syscall.csv b/syscall/syscall.csv index d9ba87880c..931eca9d69 100644 --- a/syscall/syscall.csv +++ b/syscall/syscall.csv @@ -178,7 +178,7 @@ "uname","sys/utsname.h","","int","FAR struct utsname *" "unlink","unistd.h","!defined(CONFIG_DISABLE_MOUNTPOINT)","int","FAR const char *" "unsetenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","int","FAR const char *" -"up_assert","assert.h","","void","FAR const uint8_t *","int" +"up_assert","nuttx/arch.h","","void","FAR const char *","int" "vfork","unistd.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_ARCH_HAVE_VFORK)","pid_t" "wait","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","pid_t","FAR int *" "waitid","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","int","idtype_t","id_t"," FAR siginfo_t *","int"