lkml.org 
[lkml]   [2012]   [Feb]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] kernel.h: Include <linux/bug.h> to avoid build breakage with ARRAY_SIZE()
Date
Building imx_v6_v7_defconfig generated the following build error:

arch/arm/mach-imx/cpu_op-mx51.c: In function 'mx51_get_cpu_op':
arch/arm/mach-imx/cpu_op-mx51.c:27: error: implicit declaration of function 'BUILD_BUG_ON_ZERO'

commit 6f863554 (kernel.h: doesn't explicitly use bug.h, so don't include it.)
has removed asm/debug.h from linux/kernel.h.

Quoting Russell King (http://www.spinics.net/lists/arm-kernel/msg161916.html)

"linux/kernel.h _does_ use bug stuff - in ARRAY_SIZE().

ARRAY_SIZE() uses __must_be_array(), which is defined in linux/compiler-gcc.h,
which is obtained via linux/compiler.h and linux/linkage.h.

linux/compiler-gcc.h defines __must_be_array() to be:
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))

and BUILD_BUG_ON_ZERO used to be in linux/kernel.h but got moved to
linux/bug.h.

Hence why people are seeing build breakage with ARRAY_SIZE()."

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
include/linux/kernel.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index ed9f92e..9c0a86b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -21,6 +21,7 @@
#include <linux/typecheck.h>
#include <linux/printk.h>
#include <linux/dynamic_debug.h>
+#include <linux/bug.h>
#include <asm/byteorder.h>

#define USHRT_MAX ((u16)(~0U))
--
1.7.1



\
 
 \ /
  Last update: 2012-02-28 14:45    [W:0.120 / U:0.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site