[PATCH 13/19] include: <asm-generic/bug.h>: implement ASSERT()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ASSERT() is a statement commonly used by other projects. This patch adds
an implementation for it.

It is normally compiled away and can be enabled with
CONFIG_BUG_ON_DATA_CORRUPTION.

While ASSERT() is usually written in lowercase letters, use uppercase
letters for barebox as we have a function hook in the reset controller
core that uses lowercase letters.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 include/asm-generic/bug.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 5d0a458eae..18a1b419ff 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -62,4 +62,9 @@
 	unlikely(__ret_warn_once);			\
 })
 
+#define ASSERT(expr)  do {				\
+	if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION))	\
+		BUG_ON(!(expr));			\
+} while (0)
+
 #endif
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux