Introduce a global bool type
Subsystems (5)
PATCH v2 1/1 Introduce a global bool type
'bool' is defined in random places. This patch consolidates them into a single typedef, using _Bool introduced in C99.
---
Change since v1:
Move 'false' and 'true' to the common header file.
Need help from other arch maintainers to test it. I could only test powerpc.
arch/blackfin/include/asm/posix_types.h | 3 --- board/Marvell/include/core.h | 5 ----- board/bf533-stamp/video.h | 3 --- drivers/bios_emulator/atibios.c | 4 ---- drivers/mtd/nand/mxc_nand.c | 2 -- drivers/net/ne2000_base.h | 4 ---- drivers/usb/musb-new/linux-compat.h | 2 -- include/galileo/core.h | 5 ----- include/linux/types.h | 4 ++++ include/xyzModem.h | 8 -------- 10 files changed, 4 insertions(+), 36 deletions(-)
arch/blackfin/include/asm/posix_types.h +0 -3
@@ -61,9 +61,6 @@ typedef unsigned int __kernel_gid32_t;typedef unsigned short __kernel_old_uid_t ;typedef unsigned short __kernel_old_gid_t ; -#define BOOL_WAS_DEFINED -typedef enum { false =0 , true =1 }bool ; -#ifdef __GNUC__typedef long long __kernel_loff_t ;#endif
board/Marvell/include/core.h +0 -5
@@ -91,11 +91,6 @@ extern unsigned int INTERNAL_REG_BASE_ADDR;#define _1G 0x40000000#define _2G 0x80000000 -#ifndef BOOL_WAS_DEFINED -#define BOOL_WAS_DEFINED -typedef enum _bool {false,true}bool ; -#endif -/* Little to Big endian conversion macros */ #ifdef LE /* Little Endian */
board/bf533-stamp/video.h +0 -3
@@ -9,9 +9,6 @@#define YELLOW (0xD292D210)/* yellow pixel pattern */ #define WHITE (0xFE80FE80)/* white pixel pattern */ -#define true 1 -#define false 0 - typedef struct { unsigned int sav; unsigned int eav;
drivers/bios_emulator/atibios.c +0 -4
@@ -52,10 +52,6 @@/* Length of the BIOS image */ #define MAX_BIOSLEN (128 * 1024L) -/* Define some useful types and macros */ -#define true 1 -#define false 0 -/* Place to save PCI BAR's that we change and later restore */ static u32 saveROMBaseAddress;static u32 saveBaseAddress10;
drivers/mtd/nand/mxc_nand.c +0 -2
@@ -29,8 +29,6 @@#define DRIVER_NAME "mxc_nand" -typedef enum {false, true}bool ; -struct mxc_nand_host {struct mtd_info mtd;struct nand_chip *nand;
drivers/net/ne2000_base.h +0 -4
@@ -79,10 +79,6 @@ are GPL, so this is, of course, GPL.#ifndef __NE2000_BASE_H__#define __NE2000_BASE_H__ -#define bool int -#define false 0 -#define true 1 -/* * Debugging details *
drivers/usb/musb-new/linux-compat.h +0 -2
@@ -12,8 +12,6 @@#define __iomem#define __deprecated -typedef enum { false =0 , true =1 }bool ; -struct unused {};typedef struct unused unused_t ;
include/galileo/core.h +0 -5
@@ -110,11 +110,6 @@ extern unsigned int INTERNAL_REG_BASE_ADDR;#define _1G 0x40000000#define _2G 0x80000000 -#ifndef BOOL_WAS_DEFINED -#define BOOL_WAS_DEFINED -typedef enum _bool {false,true}bool ; -#endif -/* Little to Big endian conversion macros */ #ifdef LE /* Little Endian */
include/linux/types.h +4 -0
@@ -113,6 +113,10 @@ typedef __u64 u_int64_t;typedef __s64 int64_t ;#endif +typedef _Bool bool ; +#define false 0 +#define true 1 +#endif /* __KERNEL_STRICT_NAMES */ /*
include/xyzModem.h +0 -8
@@ -97,14 +97,6 @@ typedef struct { #endif } connection_info_t; -#ifndef BOOL_WAS_DEFINED -#define BOOL_WAS_DEFINED -typedef unsigned int bool ; -#endif - -#define false 0 -#define true 1 -#endif
Signature · 1 line
1.7.9.5
PATCH v2 1/1 Introduce a global bool type
Dear York Sun,
Quoted 7 lines · In message <[email protected]> you wrote:
'bool' is defined in random places. This patch consolidates them into a single typedef, using
_Boolintroduced in C99.Signed-off-by York Sun <[email protected]>---
Change since v1:
Move 'false' and 'true' to the common header file.
Please see M?ns Rullg?rd's comment about using stdbool.h instead.
Then please make sure that a sufficient number of tool chains as well as configurations using USE_PRIVATE_LIBGCC continue to work, i. e. in a first step verify that these are still compile-clean.
Thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The trouble with our times is that the future is not what it used to be. - Paul Valery
PATCH v2 1/1 Introduce a global bool type
Quoted 6 lines · Wolfgang Denk
Dear York Sun,
Quoted 3 lines · In message <[email protected]> you wrote:
'bool' is defined in random places. This patch consolidates them into a single typedef, using
_Boolintroduced in C99.
Quoted 7 lines
Quoted 4 lines
Signed-off-by York Sun <[email protected]>---
Change since v1:
Move 'false' and 'true' to the common header file.Please see M?ns Rullg?rd's comment about using
stdbool.hinstead.
Isn't stdbool.h more for backward compatability for user space programs, so only newer C99 aware programs can opt-in to the new data type? Linux for example doesn't use stdbool.h, it puts the definition of "bool" in types.h, and true/false in stddef.h. Since, like Linux, u-boot is a single codebase, all the data types can go in a common place and not have to worry about breaking old programs with new types.
Quoted 3 lines
Then please make sure that a sufficient number of tool chains as well as configurations using
USE_PRIVATE_LIBGCCcontinue to work, i. e. in a first step verify that these are still compile-clean.
If you cc me on newer versions of the patch I can help verify on tegra, which uses USE_PRIVATE_LIBGCC.
-Allen
Signature · 1 line
nvpublic
PATCH v2 1/1 Introduce a global bool type
In reply to York SunQuoted 10 lines · York Sun
'bool' is defined in random places. This patch consolidates them into a single typedef, using
_Boolintroduced in C99.Signed-off-by York Sun <[email protected]>---
Change since v1:
Move 'false' and 'true' to the common header file.Need help from other arch maintainers to test it. I could only test powerpc.
Thank you for taking this on, it's definately in need of cleanup.
There are also many duplicate definitions of the upper case variants (BOOL/TRUE/FALSE). Those should get fixed too.
include/linux/types.h typedef __u64 u_int64_t; · line 119
Quoted 4 lines
include/linux/types.h +4
-0+typedef _Bool bool ; +#define false 0 +#define true 1 +
Linux defines true/false as an enum type in stddef.h, since u-boot already has a copy of this Linux header, shouldn't it go in there?
-Allen
Signature · 1 line
nvpublic