From patchwork Tue Nov 19 04:22:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 292258 X-Patchwork-Delegate: wd@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 81DEC2C00AA for ; Tue, 19 Nov 2013 15:23:44 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0B06A4B351; Tue, 19 Nov 2013 05:23:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l0IXImj2jhFz; Tue, 19 Nov 2013 05:23:42 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 435AB4B33E; Tue, 19 Nov 2013 05:23:38 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 882524B336 for ; Tue, 19 Nov 2013 05:23:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4DMUGEjux2pB for ; Tue, 19 Nov 2013 05:23:26 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp.mei.co.jp (smtp.mei.co.jp [133.183.100.20]) by theia.denx.de (Postfix) with ESMTP id 6EA9D4B321 for ; Tue, 19 Nov 2013 05:23:19 +0100 (CET) Received: from mail-gw.jp.panasonic.com ([157.8.1.157]) by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile13) with ESMTP id rAJ4N27C001133; Tue, 19 Nov 2013 13:23:02 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili11) with ESMTP id rAJ4N2R16640; Tue, 19 Nov 2013 13:23:02 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi14) id rAJ4N2NE016181; Tue, 19 Nov 2013 13:23:02 +0900 Received: from poodle by lomi14.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id rAJ4N1xd016155; Tue, 19 Nov 2013 13:23:01 +0900 Received: from beagle.diag.org (beagle.diag.org [10.184.179.16]) by poodle (Postfix) with ESMTP id AB8CF2740043; Tue, 19 Nov 2013 13:23:01 +0900 (JST) From: Masahiro Yamada To: u-boot@lists.denx.de Date: Tue, 19 Nov 2013 13:22:57 +0900 Message-Id: <1384834977-10536-1-git-send-email-yamada.m@jp.panasonic.com> X-Mailer: git-send-email 1.8.3.2 Cc: Tom Rini , Sonic Zhang Subject: [U-Boot] [PATCH v2] include: define bool type in the same way as Linux X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Before this commit, U-Boot included in order to define bool, true and false. The header of gcc generally defines them as macros as follows: #define bool _Bool #define true 1 #define false 0 But this gave a bad imapct on common/cmd_test.c, which implements "true" and "false" commands: U_BOOT_CMD( true, CONFIG_SYS_MAXARGS, 1, do_true, "do nothing, successfully", NULL ); In order to work around this problem, common/cmd_test.c defined _STDBOOL_H at the top in order to avoid including . But this caused another problem: build error on Blackfin boards. arch/blackfin/include/asm/blackfin_local.h uses bool type here: extern bool bfin_os_log_check(void); This commit changes header files to define bool, true and false in the same way as Linux Kernel does. This change also resolves the build error of common/cmd_test.c on Blackfin boards. Signed-off-by: Masahiro Yamada --- For example, when I try to compile bct-brettl2 board, I got an error like follows at compiling common/cmd_test.c. bfin-uclinux-gcc -g -Os -ffixed-P3 -fomit-frame-pointer -mno-fdpic -ffunction-sections -fdata-sections -mcpu=bf536-0.3 -D__KERNEL__ -I/home/yamada/u-boot/include -I/home/yamada/u-boot/arch/blackfin/include -fno-builtin -ffreestanding -nostdinc -isystem /opt/gcc-4.6.3-nolibc/bfin-uclinux/bin/../lib/gcc/bfin-uclinux/4.6.3/include -pipe -DCONFIG_BLACKFIN -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -o cmd_test.o cmd_test.c -c In file included from /home/yamada/u-boot/arch/blackfin/include/asm/blackfin.h:13:0, from /home/yamada/u-boot/include/common.h:92, from cmd_test.c:17: /home/yamada/u-boot/arch/blackfin/include/asm/blackfin_local.h:54:1: error: unknown type name 'bool' make[2]: *** [cmd_test.o] Error 1 make[2]: Leaving directory `/home/yamada/u-boot/common' make[1]: *** [common/built-in.o] Error 2 make[1]: Leaving directory `/home/yamada/u-boot' make: *** [bct-brettl2] Error 2 I think this patch will not break the other boards. I did build test for all target boards. I did run-time test only on sandbox. I confirmed that "true" and "false" commonds worked. Changes in v2: - Change subject and commit log because it turned out the error is __not__ the compiler issue. - Delete the tweak in common/cmd_test.c because we will not include arch/arm/cpu/armv7/mx6/soc.c | 1 - common/cmd_test.c | 9 --------- include/galileo/core.h | 2 +- include/linux/stddef.h | 5 +++++ include/linux/types.h | 3 ++- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c index a390296..54ef447 100644 --- a/arch/arm/cpu/armv7/mx6/soc.c +++ b/arch/arm/cpu/armv7/mx6/soc.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include diff --git a/common/cmd_test.c b/common/cmd_test.c index bacc368..76b62c4 100644 --- a/common/cmd_test.c +++ b/common/cmd_test.c @@ -5,15 +5,6 @@ * SPDX-License-Identifier: GPL-2.0+ */ -/* - * Define _STDBOOL_H here to avoid macro expansion of true and false. - * If the future code requires macro true or false, remove this define - * and undef true and false before U_BOOT_CMD. This define and comment - * shall be removed if change to U_BOOT_CMD is made to take string - * instead of stringifying it. - */ -#define _STDBOOL_H - #include #include diff --git a/include/galileo/core.h b/include/galileo/core.h index 95013fa..2d1b2ed 100644 --- a/include/galileo/core.h +++ b/include/galileo/core.h @@ -14,7 +14,7 @@ space). The macros take care of Big/Little endian conversions. /* includes */ #include "gt64260R.h" -#include +#include extern unsigned int INTERNAL_REG_BASE_ADDR; diff --git a/include/linux/stddef.h b/include/linux/stddef.h index c540f61..5893ec9 100644 --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -12,6 +12,11 @@ #include #endif +enum { + false = 0, + true = 1 +}; + #ifndef __CHECKER__ #undef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) diff --git a/include/linux/types.h b/include/linux/types.h index 9aebc4e..157e1ae 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -3,7 +3,6 @@ #include #include -#include #ifndef __KERNEL_STRICT_NAMES @@ -18,6 +17,8 @@ typedef __kernel_daddr_t daddr_t; typedef __kernel_key_t key_t; typedef __kernel_suseconds_t suseconds_t; +typedef _Bool bool; + #ifdef __KERNEL__ typedef __kernel_uid32_t uid_t; typedef __kernel_gid32_t gid_t;