[U-Boot] [PATCH 2/7] types.h: define s8, s16, s32, s64, u8, u16, u32, u64 based on compiler info (MAD)

Masahiro Yamada yamada.m at jp.panasonic.com
Mon Dec 22 11:15:58 CET 2014


If CONFIG_USE_STDINT is defined, (u)int_{8,16,32,64}_t are provided
by <stdint.h>.  s{8,16,32,64}, u{8,16,32,64} must be consistent with them.

For example, some compilers define "uint32_t" as "unsigned long" and
some define it as "unsigned int".  "u32" should have the compatible type
with "uint32_t".
We cannot hard-code its definition when CONFIG_USE_STDINT is enabled.
If we want to use <stdint.h>, it must be consistent everywhere.

Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
Cc: Gabe Black <gabeblack at chromium.org>
Cc: Simon Glass <sjg at chromium.org>
Cc: Bill Richardson <wfrichar at google.com>
Cc: Tom Rini <trini at ti.com>
---

 arch/arc/include/asm/types.h        | 14 ++++++++++++++
 arch/arm/include/asm/types.h        | 16 ++++++++++++++++
 arch/avr32/include/asm/types.h      | 16 ++++++++++++++++
 arch/blackfin/include/asm/types.h   | 16 ++++++++++++++++
 arch/m68k/include/asm/types.h       | 16 ++++++++++++++++
 arch/microblaze/include/asm/types.h | 16 ++++++++++++++++
 arch/mips/include/asm/types.h       | 16 ++++++++++++++++
 arch/nds32/include/asm/types.h      | 16 ++++++++++++++++
 arch/nios2/include/asm/types.h      | 16 ++++++++++++++++
 arch/openrisc/include/asm/types.h   | 16 ++++++++++++++++
 arch/powerpc/include/asm/types.h    | 16 ++++++++++++++++
 arch/sandbox/include/asm/types.h    | 14 ++++++++++++++
 arch/sh/include/asm/types.h         | 16 ++++++++++++++++
 arch/sparc/include/asm/types.h      | 14 ++++++++++++++
 arch/x86/include/asm/types.h        | 14 ++++++++++++++
 15 files changed, 232 insertions(+)

diff --git a/arch/arc/include/asm/types.h b/arch/arc/include/asm/types.h
index 24eeb76..daa1f30 100644
--- a/arch/arc/include/asm/types.h
+++ b/arch/arc/include/asm/types.h
@@ -31,6 +31,19 @@ typedef unsigned long long __u64;
 /*
  * These aren't exported outside the kernel to avoid name space clashes
  */
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+#else
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -42,6 +55,7 @@ typedef unsigned int u32;
 
 typedef signed long long s64;
 typedef unsigned long long u64;
+#endif
 
 #define BITS_PER_LONG 32
 
diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/asm/types.h
index 2326420..4ab7e6b 100644
--- a/arch/arm/include/asm/types.h
+++ b/arch/arm/include/asm/types.h
@@ -27,6 +27,20 @@ __extension__ typedef unsigned long long __u64;
  */
 #ifdef __KERNEL__
 
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+#else
+
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -39,6 +53,8 @@ typedef unsigned int u32;
 typedef signed long long s64;
 typedef unsigned long long u64;
 
+#endif
+
 #ifdef	CONFIG_ARM64
 #define BITS_PER_LONG 64
 #else	/* CONFIG_ARM64 */
diff --git a/arch/avr32/include/asm/types.h b/arch/avr32/include/asm/types.h
index 65de677..fe355a2 100644
--- a/arch/avr32/include/asm/types.h
+++ b/arch/avr32/include/asm/types.h
@@ -39,6 +39,20 @@ __extension__ typedef unsigned long long __u64;
 
 #ifndef __ASSEMBLY__
 
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+#else
+
 typedef __signed__ char s8;
 typedef unsigned char u8;
 
@@ -51,6 +65,8 @@ typedef unsigned int u32;
 typedef __signed__ long long s64;
 typedef unsigned long long u64;
 
+#endif
+
 /* Dma addresses are 32-bits wide.  */
 
 typedef u32 dma_addr_t;
diff --git a/arch/blackfin/include/asm/types.h b/arch/blackfin/include/asm/types.h
index 92124f1..5ed8462 100644
--- a/arch/blackfin/include/asm/types.h
+++ b/arch/blackfin/include/asm/types.h
@@ -44,6 +44,20 @@ __extension__ typedef unsigned long long __u64;
  */
 #ifdef __KERNEL__
 
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+#else
+
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -56,6 +70,8 @@ typedef unsigned int u32;
 typedef signed long long s64;
 typedef unsigned long long u64;
 
+#endif
+
 #define BITS_PER_LONG 32
 
 /* Dma addresses are 32-bits wide. */
diff --git a/arch/m68k/include/asm/types.h b/arch/m68k/include/asm/types.h
index 3ffcab2..51bf08d 100644
--- a/arch/m68k/include/asm/types.h
+++ b/arch/m68k/include/asm/types.h
@@ -27,6 +27,20 @@ typedef struct {
 /*
  * These aren't exported outside the kernel to avoid name space clashes
  */
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+#else
+
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -39,6 +53,8 @@ typedef unsigned int u32;
 typedef signed long long s64;
 typedef unsigned long long u64;
 
+#endif
+
 #define BITS_PER_LONG 32
 
 /* DMA addresses are 32-bits wide */
diff --git a/arch/microblaze/include/asm/types.h b/arch/microblaze/include/asm/types.h
index 77094f6..343bf84 100644
--- a/arch/microblaze/include/asm/types.h
+++ b/arch/microblaze/include/asm/types.h
@@ -35,6 +35,20 @@ __extension__ typedef unsigned long long __u64;
  */
 #ifdef __KERNEL__
 
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+#else
+
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -47,6 +61,8 @@ typedef unsigned int u32;
 typedef signed long long s64;
 typedef unsigned long long u64;
 
+#endif
+
 #define BITS_PER_LONG 32
 
 /* Dma addresses are 32-bits wide.  */
diff --git a/arch/mips/include/asm/types.h b/arch/mips/include/asm/types.h
index aebafdb..9fc4a6d 100644
--- a/arch/mips/include/asm/types.h
+++ b/arch/mips/include/asm/types.h
@@ -46,6 +46,20 @@ typedef unsigned long long __u64;
 
 #ifndef __ASSEMBLY__
 
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+#else
+
 typedef __signed char s8;
 typedef unsigned char u8;
 
@@ -58,6 +72,8 @@ typedef unsigned int u32;
 typedef __signed__ long long s64;
 typedef unsigned long long u64;
 
+#endif
+
 #if (defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) \
     || defined(CONFIG_64BIT)
 typedef u64 dma_addr_t;
diff --git a/arch/nds32/include/asm/types.h b/arch/nds32/include/asm/types.h
index 2e8924f..e2c56d7 100644
--- a/arch/nds32/include/asm/types.h
+++ b/arch/nds32/include/asm/types.h
@@ -37,6 +37,20 @@ typedef unsigned long long __u64;
  */
 #ifdef __KERNEL__
 
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+#else
+
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -49,6 +63,8 @@ typedef unsigned int u32;
 typedef signed long long s64;
 typedef unsigned long long u64;
 
+#endif
+
 #define BITS_PER_LONG 32
 
 #include <stddef.h>
diff --git a/arch/nios2/include/asm/types.h b/arch/nios2/include/asm/types.h
index ea859c0..b3b25b3 100644
--- a/arch/nios2/include/asm/types.h
+++ b/arch/nios2/include/asm/types.h
@@ -35,6 +35,20 @@ __extension__ typedef unsigned long long __u64;
  */
 #ifdef __KERNEL__
 
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+#else
+
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -47,6 +61,8 @@ typedef unsigned int u32;
 typedef signed long long s64;
 typedef unsigned long long u64;
 
+#endif
+
 #define BITS_PER_LONG 32
 
 /* Dma addresses are 32-bits wide.  */
diff --git a/arch/openrisc/include/asm/types.h b/arch/openrisc/include/asm/types.h
index 1fe00bf..8a232bc 100644
--- a/arch/openrisc/include/asm/types.h
+++ b/arch/openrisc/include/asm/types.h
@@ -41,6 +41,20 @@ __extension__ typedef unsigned long long __u64;
  */
 #ifdef __KERNEL__
 
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+#else
+
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -53,6 +67,8 @@ typedef unsigned int u32;
 typedef signed long long s64;
 typedef unsigned long long u64;
 
+#endif
+
 #define BITS_PER_LONG 32
 
 /* Dma addresses are 32-bits wide.  */
diff --git a/arch/powerpc/include/asm/types.h b/arch/powerpc/include/asm/types.h
index b29ce79..cc76387 100644
--- a/arch/powerpc/include/asm/types.h
+++ b/arch/powerpc/include/asm/types.h
@@ -27,6 +27,20 @@ typedef struct {
 /*
  * These aren't exported outside the kernel to avoid name space clashes
  */
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+#else
+
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -39,6 +53,8 @@ typedef unsigned int u32;
 typedef signed long long s64;
 typedef unsigned long long u64;
 
+#endif
+
 #define BITS_PER_LONG 32
 
 #ifdef CONFIG_PHYS_64BIT
diff --git a/arch/sandbox/include/asm/types.h b/arch/sandbox/include/asm/types.h
index 42c09e2..a6a51b7 100644
--- a/arch/sandbox/include/asm/types.h
+++ b/arch/sandbox/include/asm/types.h
@@ -33,6 +33,18 @@ __extension__ typedef unsigned long long __u64;
  */
 #ifdef __KERNEL__
 
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+#else
+
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -42,6 +54,8 @@ typedef unsigned short u16;
 typedef signed int s32;
 typedef unsigned int u32;
 
+#endif
+
 #if !defined(CONFIG_USE_STDINT) || !defined(__INT64_TYPE__)
 typedef signed long long s64;
 typedef unsigned long long u64;
diff --git a/arch/sh/include/asm/types.h b/arch/sh/include/asm/types.h
index aed4a6e..7b005e4 100644
--- a/arch/sh/include/asm/types.h
+++ b/arch/sh/include/asm/types.h
@@ -35,6 +35,20 @@ __extension__ typedef unsigned long long __u64;
 
 #ifndef __ASSEMBLY__
 
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+
+#else
 
 typedef __signed__ char s8;
 typedef unsigned char u8;
@@ -48,6 +62,8 @@ typedef unsigned int u32;
 typedef __signed__ long long s64;
 typedef unsigned long long u64;
 
+#endif
+
 /* Dma addresses are 32-bits wide.  */
 
 typedef u32 dma_addr_t;
diff --git a/arch/sparc/include/asm/types.h b/arch/sparc/include/asm/types.h
index 72030b2..41c653a 100644
--- a/arch/sparc/include/asm/types.h
+++ b/arch/sparc/include/asm/types.h
@@ -34,6 +34,20 @@ typedef struct {
 /*
  * These aren't exported outside the kernel to avoid name space clashes
  */
+
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+typedef		__INT64_TYPE__	s64;
+typedef		__UINT64_TYPE__	u64;
+
 typedef signed char s8;
 typedef unsigned char u8;
 
diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h
index e272c90..ca773de 100644
--- a/arch/x86/include/asm/types.h
+++ b/arch/x86/include/asm/types.h
@@ -27,6 +27,18 @@ __extension__ typedef unsigned long long __u64;
  */
 #ifdef __KERNEL__
 
+#if defined(CONFIG_USE_STDINT)
+typedef		__INT8_TYPE__	s8;
+typedef		__UINT8_TYPE__	u8;
+
+typedef		__INT16_TYPE__	s16;
+typedef		__UINT16_TYPE__	u16;
+
+typedef		__INT32_TYPE__	s32;
+typedef		__UINT32_TYPE__	u32;
+
+#else
+
 typedef signed char s8;
 typedef unsigned char u8;
 
@@ -36,6 +48,8 @@ typedef unsigned short u16;
 typedef signed int s32;
 typedef unsigned int u32;
 
+#endif
+
 #if !defined(CONFIG_USE_STDINT) || !defined(__INT64_TYPE__)
 typedef signed long long s64;
 typedef unsigned long long u64;
-- 
1.9.1



More information about the U-Boot mailing list