Skip to content

Commit

Permalink
assert/panic: disable panic message to save the code size
Browse files Browse the repository at this point in the history
Requirement of nuttx as a minimum scheduler os.

Test build on Cortex-R52, fvp-armv8r-aarch32/nsh

Disable CONFIG_DEBUG_ASSERTIONS and without this change:
$ size nuttx
   text	   data	    bss	    dec	    hex	filename
  19484	    104	   1092	  20680	   50c8	nuttx

Disable CONFIG_DEBUG_ASSERTIONS and with this change:
$ size nuttx
   text	   data	    bss	    dec	    hex	filename
  17604	     80	    848	  18532	   4864	nuttx

Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao authored and acassis committed Feb 27, 2024
1 parent 4123615 commit 9b1c451
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions include/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@
# define __ASSERT_LINE__ 0
#endif

#define PANIC() __assert(__ASSERT_FILE__, __ASSERT_LINE__, "panic")
#define PANIC_WITH_REGS(msg, regs) _assert(__ASSERT_FILE__, \
__ASSERT_LINE__, msg, regs)

#define __ASSERT__(f, file, line, _f) \
do \
{ \
Expand All @@ -101,13 +97,18 @@
#endif

#ifdef CONFIG_DEBUG_ASSERTIONS
# define PANIC() __assert(__ASSERT_FILE__, __ASSERT_LINE__, "panic")
# define PANIC_WITH_REGS(msg, regs) _assert(__ASSERT_FILE__, \
__ASSERT_LINE__, msg, regs)
# define DEBUGPANIC() __assert(__DEBUG_ASSERT_FILE__, __DEBUG_ASSERT_LINE__, "panic")
# define DEBUGASSERT(f) _ASSERT(f, __DEBUG_ASSERT_FILE__, __DEBUG_ASSERT_LINE__)
# define DEBUGVERIFY(f) _VERIFY(f, __DEBUG_ASSERT_FILE__, __DEBUG_ASSERT_LINE__)
#else
# define DEBUGPANIC()
# define DEBUGASSERT(f) ((void)(1 || (f)))
# define DEBUGVERIFY(f) ((void)(f))
# define PANIC() do { } while (1)
# define PANIC_WITH_REGS(msg, regs) PANIC()
#endif

/* The C standard states that if NDEBUG is defined, assert will do nothing.
Expand Down

0 comments on commit 9b1c451

Please sign in to comment.