Skip to contentSkip to conversation

bug.h: move BUILD_BUG_* defines to include/linux/bug.h

PATCH New Masahiro Yamada 2 participants 2 messages Jan 24, 2016 – Jan 25, 2016

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bug.h: move BUILD_BUG_* defines to include/linux/bug.h

BUILD_BUG_* macros have been defined in several headers. It would be nice to collect them in include/linux/bug.h like Linux.

This commit is cherry-picking useful macros from include/linux/bug.h of Linux 4.4.

I did not import BUILD_BUG_ON_MSG() because it would not work if it is used with include/common.h in U-Boot. I'd like to postpone it until the root cause (the "error()" macro in include/common.h causes the name conflict with "__attribute__((error()))") is fixed.

---

Changes in v2:
- Add more detailed git-log. (no change in code diff)

 arch/arm/mach-tegra/ap.c                    |  1 +
 common/cmd_dtt.c                            |  1 +
 drivers/gpio/gpio-uclass.c                  |  1 +
 drivers/mtd/ubi/build.c                     |  1 +
 drivers/net/fsl-mc/mc.c                     |  1 +
 drivers/pinctrl/uniphier/pinctrl-uniphier.h |  4 +--
 drivers/usb/dwc3/gadget.c                   |  1 +
 drivers/usb/dwc3/linux-compat.h             |  2 --
 fs/ubifs/replay.c                           |  1 +
 fs/ubifs/super.c                            |  1 +
 include/common.h                            |  3 --
 include/linux/bug.h                         | 55 +++++++++++++++++++++++++++++
 12 files changed, 64 insertions(+), 8 deletions(-)
 create mode 100644 include/linux/bug.h
arch/arm/mach-tegra/ap.c +1 -0
index b4229f4..a4fa00c 100644
@@ -8,6 +8,7 @@
 /* Tegra AP (Application Processor) code */
 
 #include <common.h>
+#include <linux/bug.h>
 #include <asm/io.h>
 #include <asm/arch/gp_padctrl.h>
 #include <asm/arch/mc.h>
common/cmd_dtt.c +1 -0
index f2e750f..dd427a3 100644
@@ -12,6 +12,7 @@
 #include <dtt.h>
 #include <i2c.h>
 #include <tmu.h>
+#include <linux/bug.h>
 
 #if defined CONFIG_DTT_SENSORS
 static unsigned long sensor_initialized;
drivers/gpio/gpio-uclass.c +1 -0
index 3ed4d89..d603b55 100644
@@ -10,6 +10,7 @@
 #include <fdtdec.h>
 #include <malloc.h>
 #include <asm/gpio.h>
+#include <linux/bug.h>
 #include <linux/ctype.h>
 
 DECLARE_GLOBAL_DATA_PTR;
drivers/mtd/ubi/build.c +1 -0
index f484e62..baf4e2d 100644
@@ -30,6 +30,7 @@
 #include <linux/slab.h>
 #include <linux/major.h>
 #else
+#include <linux/bug.h>
 #include <linux/log2.h>
 #endif
 #include <linux/err.h>
drivers/net/fsl-mc/mc.c +1 -0
index bac4610..4b9b372 100644
@@ -5,6 +5,7 @@
  */
 #include <common.h>
 #include <errno.h>
+#include <linux/bug.h>
 #include <asm/io.h>
 #include <libfdt.h>
 #include <fdt_support.h>
drivers/pinctrl/uniphier/pinctrl-uniphier.h +1 -3
index 7eaec6a..6bdebf2 100644
@@ -7,9 +7,7 @@
 #ifndef __PINCTRL_UNIPHIER_H__
 #define __PINCTRL_UNIPHIER_H__
 
-/* TODO: move this to include/linux/bug.h */
-#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
-
+#include <linux/bug.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 
drivers/usb/dwc3/gadget.c +1 -0
index 8ff949d..25ccc01 100644
@@ -18,6 +18,7 @@
 #include <malloc.h>
 #include <asm/dma-mapping.h>
 #include <usb/lin_gadget_compat.h>
+#include <linux/bug.h>
 #include <linux/list.h>
 
 #include <linux/usb/ch9.h>
drivers/usb/dwc3/linux-compat.h +0 -2
index 6c9c279..9e944a3 100644
@@ -17,8 +17,6 @@
 #define dev_WARN(dev, format, arg...)	debug(format, ##arg)
 #define WARN_ON_ONCE(val)		debug("Error %d\n", val)
 
-#define BUILD_BUG_ON_NOT_POWER_OF_2(n)
-
 static inline size_t strlcat(char *dest, const char *src, size_t n)
 {
 	strcat(dest, src);
fs/ubifs/replay.c +1 -0
index d0fcd83..176125e 100644
@@ -26,6 +26,7 @@
 #include <linux/err.h>
 #endif
 #include "ubifs.h"
+#include <linux/bug.h>
 #include <linux/list_sort.h>
 
 /**
fs/ubifs/super.c +1 -0
index abe861a..dcf3a47 100644
@@ -31,6 +31,7 @@
 #include <common.h>
 #include <malloc.h>
 #include <memalign.h>
+#include <linux/bug.h>
 #include <linux/log2.h>
 #include <linux/stat.h>
 #include <linux/err.h>
include/common.h +0 -3
index 7bed0cc..1563d64 100644
@@ -146,9 +146,6 @@ void __assert_fail(const char *assertion, const char *file, unsigned line,
 #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
 #endif /* BUG */
 
-/* Force a compilation error if condition is true */
-#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
-
 typedef void (interrupt_handler_t)(void *);
 
 #include <asm/u-boot.h> /* boot information for Linux kernel */
include/linux/bug.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/1 bug.h: move BUILD_BUG_* defines to include/linux/bug.h

Quoted 6 lines · Masahiro Yamada

BUILD_BUG_* macros have been defined in several headers. It would be nice to collect them in include/linux/bug.h like Linux.

This commit is cherry-picking useful macros from include/linux/bug.h of Linux 4.4.

Quoted 7 lines

I did not import BUILD_BUG_ON_MSG() because it would not work if it is used with include/common.h in U-Boot. I'd like to postpone it until the root cause (the "error()" macro in include/common.h causes the name conflict with "__attribute__((error()))") is fixed.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160125/aa5313f4/attachment.sig>