Commit Graph

58 Commits

Author SHA1 Message Date
ligd 76e77ff184 assert: add header files to resolve compile failed
error: 'NULL' undecleard

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-12 09:29:37 +08:00
yinshengkai 2fe33f551c assert: change the do-while of assert to a conditional expression
According to the standard definition, assert should return a void expression
https://pubs.opengroup.org/onlinepubs/007904875/basedefs/assert.h.html

This patch involves two changes:

If you define the NDEBUG macro, assert does not use any parameters and directly returns a void expression.
assert should return a void expression and cannot use do-while statements.
If the following code , a compilation error will occur.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-11 00:51:20 +08:00
Alin Jerpelea cd2fcf5252 include: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-10-04 08:18:42 +08:00
YAMAMOTO Takashi 92a2e22c6c Restore ASSERT/VERIFY semantics
This partly fixes esp32-devkitc:knsh.
2024-09-09 15:25:04 +08:00
chao an f12c88d287 assert: check COMPILE_TIME_ASSERT before define
check COMPILE_TIME_ASSERT before define

Signed-off-by: chao an <anchao@lixiang.com>
2024-08-20 02:42:35 +08:00
guoshichao 64176214a0 assert: add compile_assert macro
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2024-08-19 22:16:04 +08:00
yinshengkai f25a506f91 include: When defining NDEBUG, assert will implement alignment standards
As defined by the C standard, if NDEBUG is defined, assert should do nothing but be simply defined as:

  #define assert(ignore) ((void)0)

Reference link:
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/assert.h.html

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-05-17 10:18:16 -03:00
Tiago Medicci Serrano 2b18917a6b Revert "assert/panic: disable panic message to save the code size"
This reverts commit 9b1c451f2f.
2024-03-13 09:44:51 +08:00
chao an 9b1c451f2f assert/panic: disable panic message to save the code size
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 <anchao@lixiang.com>
2024-02-27 10:33:43 -03:00
Masayuki Ishikawa 1a11479831 Revert "assert: change the do-while of assert to a conditional expression"
This reverts commit 23aba6c2a1.
2024-02-21 21:29:48 -08:00
Masayuki Ishikawa e6ca27ac2f Revert "assert: When defining NDEBUG, do not use macro parameters"
This reverts commit 3b6e7c1927.
2024-02-21 21:29:48 -08:00
yinshengkai 3b6e7c1927 assert: When defining NDEBUG, do not use macro parameters
The implementation of assert in linux is as follows:
define assert(expr)        (__ASSERT_VOID_CAST (0))

After defining NDEBUG in sqlite, some variables will be undefined,
and referencing variables in assert will cause compilation errors.

sqlite3.c:28729:23: error: ‘mutexIsInit’ undeclared (first use in this function)
28729 |   assert( GLOBAL(int, mutexIsInit) );

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-02-21 13:28:20 -03:00
yinshengkai 23aba6c2a1 assert: change the do-while of assert to a conditional expression
According to the standard definition, assert should return a void expression
https://pubs.opengroup.org/onlinepubs/007904875/basedefs/assert.h.html

This patch involves two changes:

If you define the NDEBUG macro, assert does not use any parameters and directly returns a void expression.
assert should return a void expression and cannot use do-while statements.
If the following code , a compilation error will occur.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-02-21 13:28:20 -03:00
chao an fc80c70205 assert: rename __ASSERT to __ASSERT__ to avoid conflict
The definition of __ASSERT has special define in some OS and librarys,
rename to __ASSERT__ to avoid conflict

Signed-off-by: chao an <anchao@xiaomi.com>
2023-10-26 16:21:02 +08:00
chao an a521fd7b82 debug/assert: decouple configuration of show file name feature
add new config CONFIG_ASSERTIONS_FILENAME to library call assert(3) to decouple with CONFIG_DEBUG_ASSERTIONS

| Function         |CONFIG                            | Show filename/line |
| ---              | ---                              | ---                |
|assert(), ASSERT()|CONFIG_ASSERTIONS_FILENAME=y      | Yes                |
|assert(), ASSERT()|CONFIG_ASSERTIONS_FILENAME=n      | No                 |
|DEBUGASSERT()     |CONFIG_DEBUG_ASSERTIONS_FILENAME=y| Yes                |
|DEBUGASSERT()     |CONFIG_DEBUG_ASSERTIONS_FILENAME=n| No                 |

Signed-off-by: chao an <anchao@xiaomi.com>
2023-10-20 02:22:48 +08:00
zhangyuan21 bfab486611 assert: add panic notifier data for notify more information
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-08-03 03:17:22 -07:00
dongjiuzhu1 6ff4826492 nuttx/bits.h: support GENMASK and GENMASK_ULL
Ref to https://github.com/torvalds/linux/blob/master/include/linux/bits.h

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-07-29 16:41:31 -03:00
chao an 3ce2796175 assert: disable function/line print if DEBUG_ASSERTIONS_FILENAME disabled
Test on sim/nsh:
(CONFIG_DEBUG_ASSERTIONS=y CONFIG_DEFAULT_SMALL=y)
   text	   data	    bss	    dec	    hex	filename
 423626	  27152	   4128	 454906	  6f0fa	nuttx     /* before */
 417010	  27152	   4128	 448290	  6d722	nuttx     /* after */
  -6616

Signed-off-by: chao an <anchao@xiaomi.com>
2023-06-12 13:36:08 +08:00
zhangyuan21 884be2bdb9 assert: Distinguish between assert and exception
CURRENT_REGS may change during assert handling, so pass
in the 'regs' parameter at the entry point of _assert.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-05-03 14:49:32 +08:00
Xiang Xiao c9b917bcee assert.h: Replace NULL with 0 to avoid including stddef.h
Fix error: 'NULL' undeclared if user include assert.h only

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-24 13:13:43 -06:00
yinshengkai 926bfe5818 include/assert: fix nxstyle
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-21 12:09:45 -03:00
yinshengkai 216483f96b include/compiler: replace likely to predict_true
likely is defined repeatedly in an external library

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-03-21 12:09:45 -03:00
yinshengkai cb594a4c9c include: add branch prediction for assert
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-02-23 22:35:33 +08:00
Xiang Xiao 65a04c66a2 libc: Define _assert/__assert to avoid 3rd libary redefine them
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-06 15:04:30 +01:00
chao an dff2192c75 misc/assert: remove const string from assert expression
Signed-off-by: chao an <anchao@xiaomi.com>
2023-02-02 15:08:47 +08:00
anjiahao 8a80c6ab28 assert:add a Kconfig option to limit binfile size
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-02-02 01:58:43 +08:00
Xiang Xiao 43e7b13697 assert: Log the assertion expression in case of fail
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-24 15:00:19 -03:00
Ville Juven 172b209f2d sched/assert: Re-implement assert() into user space
_assert is a kernel procedure, entered via system call to make the core
dump in privileged mode.

Running exit() from this context is not OK as it runs the registered
exit functions and flushes streams, which must not be done
from privileged mode as it is a security hole.

Thus, implement assert() into user space (again) and remove the exit()
call from the kernel procedure.
2022-12-22 21:07:47 +08:00
wangbowen6 913c7148e5 assert: static_assert is not support in c standard C89,C99.
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
2022-04-21 23:11:21 +08:00
Xiang Xiao 0dd844d89b assert.h: Don't use UNUSED macro since it's very easy happen conflict
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-02 09:01:36 +01:00
ligd 3cfc6761ff xtensa: fix lack of float register save & resotre
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-01-11 12:17:09 +01:00
Petro Karashchenko 09948a6bbb include/assert.h: remove dependency on stdint.h
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-10 19:55:51 +01:00
Alin Jerpelea b0ddc6e2c5 include: Omni Hoverboards: update licenses to Apache
Gregory Nutt has submitted the SGA
Omni Hoverboards has submitted the SGA
Paul Alexander Patience  has submitted the ICLA

as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-09-28 04:37:38 -07:00
Xiang Xiao 5f3a98b5a8 libc/assert: Reference the expression in all case
to avoid the warning "defined but not used"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I55b7c092d0f2e5882fc1784987657c10cdf2d90b
2021-04-03 21:00:41 +01:00
Xiang Xiao d6827cab60 arch: up_assert shouldn't call exit directly
since exit will be only callable from userspace and change
the 1st argument from "const uint8_t *" to "const char *"

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I86487d57210ab63109148232da71dbc4d60a563b
2020-07-19 01:21:36 +01:00
Paul A. Patience 983ccf1b0a assert: Don't define static_assert in C++ 2016-06-21 07:17:29 -04:00
Gregory Nutt d1a62f1d24 Add a comment 2016-06-20 14:26:13 -06:00
Paul A. Patience a96c7492ad assert: Define static_assert 2016-06-20 10:29:41 -04:00
Paul A. Patience f995f3c7bf assert: Simplify 2016-06-12 08:18:30 -04:00
Gregory Nutt c211ce8be1 DEBUGASSERT() is not enabled with CONFIG_DEBUG_ASSERTIONS, not CONFIG_DEBUG 2016-06-11 12:49:21 -06:00
Gregory Nutt d84dbbc455 Add a comment to assert.h 2016-06-08 09:59:11 -06:00
Paul A. Patience 79a157cc9d assert: Check if NDEBUG is defined 2016-06-08 11:07:24 -04:00
Gregory Nutt df4e24ddeb include/assert.h: Wrap definitions of assertion macros in do while. Suggested by orbitalfox 2015-04-22 07:35:35 -06:00
Gregory Nutt d11050e978 Add support for the UG-2843HHSWEG04 OLED and for the SAM4L Xplained Pro OLED module that uses that OLED. 2013-06-23 14:39:56 -06:00
Gregory Nutt 0d1cf112cf Changes to remove some warning sduring compilation for ZKit-arm-1769 Board. 2013-05-02 06:28:59 -06:00
Gregory Nutt 86b815373a Remove up_assert_code 2013-04-25 15:19:59 -06:00
patacongo 14298ad8b8 Fixe to kernel build and syscalls.
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5738 42af7a65-404d-4744-a932-0658087f49c3
2013-03-13 17:32:37 +00:00
patacongo 1b94639432 Misc clean; mark assertions as non-returning; allow toolchain prefix to be overriden from make command line
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5591 42af7a65-404d-4744-a932-0658087f49c3
2013-01-31 23:29:34 +00:00
patacongo 435dbaacd8 Add configurable application entry point
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5070 42af7a65-404d-4744-a932-0658087f49c3
2012-08-30 20:13:50 +00:00
patacongo f13f49939e Add interface to enabled/disable debug output
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4386 42af7a65-404d-4744-a932-0658087f49c3
2012-02-12 23:54:26 +00:00