From 3747bdbb2bb83a3bb2e7bd823856de4f4908f711 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 6 Aug 2018 20:47:39 +0900 Subject: [PATCH] arch: types.h: factor out fixed width typedefs to int-ll64.h All architectures have the same definition for s8/16/32/64 and u8/16/32/64. Factor out the duplicated code into . BTW, Linux unified the kernel space definition into int-ll64.h a few years ago as you see in Linux commit 0c79a8e29b5f ("asm/types.h: Remove include/asm-generic/int-l64.h"). Signed-off-by: Masahiro Yamada --- arch/arc/include/asm/types.h | 36 ++-------------------- arch/arm/include/asm/types.h | 33 ++------------------ arch/m68k/include/asm/types.h | 30 ++---------------- arch/microblaze/include/asm/types.h | 33 ++------------------ arch/mips/include/asm/types.h | 36 ++-------------------- arch/nds32/include/asm/types.h | 33 ++------------------ arch/powerpc/include/asm/types.h | 30 ++---------------- arch/riscv/include/asm/types.h | 33 ++------------------ arch/sandbox/include/asm/types.h | 33 ++------------------ arch/sh/include/asm/types.h | 34 ++------------------- arch/x86/include/asm/types.h | 33 ++------------------ arch/xtensa/include/asm/types.h | 33 ++------------------ include/asm-generic/int-ll64.h | 47 +++++++++++++++++++++++++++++ include/asm-generic/types.h | 9 ++++++ 14 files changed, 80 insertions(+), 373 deletions(-) create mode 100644 include/asm-generic/int-ll64.h create mode 100644 include/asm-generic/types.h diff --git a/arch/arc/include/asm/types.h b/arch/arc/include/asm/types.h index 3e37781677..f31dcdf28e 100644 --- a/arch/arc/include/asm/types.h +++ b/arch/arc/include/asm/types.h @@ -6,41 +6,9 @@ #ifndef __ASM_ARC_TYPES_H #define __ASM_ARC_TYPES_H -typedef unsigned short umode_t; - -/* - * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the - * header files exported to user space - */ - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; +#include -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64; -typedef unsigned long long __u64; -#endif - -/* - * These aren't exported outside the kernel to avoid name space clashes - */ -typedef signed char s8; -typedef unsigned char u8; - -typedef signed short s16; -typedef unsigned short u16; - -typedef signed int s32; -typedef unsigned int u32; - -typedef signed long long s64; -typedef unsigned long long u64; +typedef unsigned short umode_t; #define BITS_PER_LONG 32 diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/asm/types.h index 9af7353f08..900b2619a4 100644 --- a/arch/arm/include/asm/types.h +++ b/arch/arm/include/asm/types.h @@ -1,44 +1,15 @@ #ifndef __ASM_ARM_TYPES_H #define __ASM_ARM_TYPES_H -typedef unsigned short umode_t; - -/* - * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the - * header files exported to user space - */ - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; +#include -#if defined(__GNUC__) -__extension__ typedef __signed__ long long __s64; -__extension__ typedef unsigned long long __u64; -#endif +typedef unsigned short umode_t; /* * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ -typedef signed char s8; -typedef unsigned char u8; - -typedef signed short s16; -typedef unsigned short u16; - -typedef signed int s32; -typedef unsigned int u32; - -typedef signed long long s64; -typedef unsigned long long u64; - #ifdef CONFIG_ARM64 #define BITS_PER_LONG 64 #else /* CONFIG_ARM64 */ diff --git a/arch/m68k/include/asm/types.h b/arch/m68k/include/asm/types.h index 3ffcab20df..5d39b97b67 100644 --- a/arch/m68k/include/asm/types.h +++ b/arch/m68k/include/asm/types.h @@ -1,43 +1,17 @@ #ifndef _M68K_TYPES_H #define _M68K_TYPES_H +#include + #ifndef __ASSEMBLY__ typedef unsigned short umode_t; -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#if defined(__GNUC__) -__extension__ typedef __signed__ long long __s64; -__extension__ typedef unsigned long long __u64; -#endif - typedef struct { __u32 u[4]; } __attribute__((aligned(16))) vector128; #ifdef __KERNEL__ -/* - * These aren't exported outside the kernel to avoid name space clashes - */ -typedef signed char s8; -typedef unsigned char u8; - -typedef signed short s16; -typedef unsigned short u16; - -typedef signed int s32; -typedef unsigned int u32; - -typedef signed long long s64; -typedef unsigned long long u64; #define BITS_PER_LONG 32 diff --git a/arch/microblaze/include/asm/types.h b/arch/microblaze/include/asm/types.h index 77094f62d6..056a3133fb 100644 --- a/arch/microblaze/include/asm/types.h +++ b/arch/microblaze/include/asm/types.h @@ -1,6 +1,8 @@ #ifndef _ASM_TYPES_H #define _ASM_TYPES_H +#include + /* * This file is never included by application software unless * explicitly requested (e.g., via linux/types.h) in which case the @@ -11,42 +13,11 @@ typedef unsigned short umode_t; -/* - * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the - * header files exported to user space - */ - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#if defined(__GNUC__) -__extension__ typedef __signed__ long long __s64; -__extension__ typedef unsigned long long __u64; -#endif - /* * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ -typedef signed char s8; -typedef unsigned char u8; - -typedef signed short s16; -typedef unsigned short u16; - -typedef signed int s32; -typedef unsigned int u32; - -typedef signed long long s64; -typedef unsigned long long u64; - #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 7032862a29..925d7ef023 100644 --- a/arch/mips/include/asm/types.h +++ b/arch/mips/include/asm/types.h @@ -6,32 +6,12 @@ #ifndef _ASM_TYPES_H #define _ASM_TYPES_H +#include + #ifndef __ASSEMBLY__ typedef unsigned short umode_t; -/* - * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the - * header files exported to user space - */ - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#if defined(__GNUC__) -__extension__ typedef __signed__ long long __s64; -__extension__ typedef unsigned long long __u64; -#else -typedef __signed__ long long __s64; -typedef unsigned long long __u64; -#endif - #endif /* __ASSEMBLY__ */ /* @@ -43,18 +23,6 @@ typedef unsigned long long __u64; #ifndef __ASSEMBLY__ -typedef __signed char s8; -typedef unsigned char u8; - -typedef __signed short s16; -typedef unsigned short u16; - -typedef __signed int s32; -typedef unsigned int u32; - -typedef __signed__ long long s64; -typedef unsigned long long u64; - #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 2e8924f76a..d2444da9b6 100644 --- a/arch/nds32/include/asm/types.h +++ b/arch/nds32/include/asm/types.h @@ -11,44 +11,15 @@ #ifndef __ASM_NDS_TYPES_H #define __ASM_NDS_TYPES_H -typedef unsigned short umode_t; - -/* - * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the - * header files exported to user space - */ - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; +#include -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64; -typedef unsigned long long __u64; -#endif +typedef unsigned short umode_t; /* * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ -typedef signed char s8; -typedef unsigned char u8; - -typedef signed short s16; -typedef unsigned short u16; - -typedef signed int s32; -typedef unsigned int u32; - -typedef signed long long s64; -typedef unsigned long long u64; - #define BITS_PER_LONG 32 #include diff --git a/arch/powerpc/include/asm/types.h b/arch/powerpc/include/asm/types.h index b29ce792f7..cc8d123b8f 100644 --- a/arch/powerpc/include/asm/types.h +++ b/arch/powerpc/include/asm/types.h @@ -1,43 +1,17 @@ #ifndef _PPC_TYPES_H #define _PPC_TYPES_H +#include + #ifndef __ASSEMBLY__ typedef unsigned short umode_t; -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#if defined(__GNUC__) -__extension__ typedef __signed__ long long __s64; -__extension__ typedef unsigned long long __u64; -#endif - typedef struct { __u32 u[4]; } __attribute__((aligned(16))) vector128; #ifdef __KERNEL__ -/* - * These aren't exported outside the kernel to avoid name space clashes - */ -typedef signed char s8; -typedef unsigned char u8; - -typedef signed short s16; -typedef unsigned short u16; - -typedef signed int s32; -typedef unsigned int u32; - -typedef signed long long s64; -typedef unsigned long long u64; #define BITS_PER_LONG 32 diff --git a/arch/riscv/include/asm/types.h b/arch/riscv/include/asm/types.h index 9797206e5e..bd8627196d 100644 --- a/arch/riscv/include/asm/types.h +++ b/arch/riscv/include/asm/types.h @@ -12,44 +12,15 @@ #ifndef __ASM_RISCV_TYPES_H #define __ASM_RISCV_TYPES_H -typedef unsigned short umode_t; - -/* - * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the - * header files exported to user space - */ - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; +#include -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64; -typedef unsigned long long __u64; -#endif +typedef unsigned short umode_t; /* * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ -typedef signed char s8; -typedef unsigned char u8; - -typedef signed short s16; -typedef unsigned short u16; - -typedef signed int s32; -typedef unsigned int u32; - -typedef signed long long s64; -typedef unsigned long long u64; - #define BITS_PER_LONG 32 #include diff --git a/arch/sandbox/include/asm/types.h b/arch/sandbox/include/asm/types.h index 79c85aa5f6..7cd56b4147 100644 --- a/arch/sandbox/include/asm/types.h +++ b/arch/sandbox/include/asm/types.h @@ -6,44 +6,15 @@ #ifndef __ASM_SANDBOX_TYPES_H #define __ASM_SANDBOX_TYPES_H -typedef unsigned short umode_t; - -/* - * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the - * header files exported to user space - */ - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; +#include -#if defined(__GNUC__) -__extension__ typedef __signed__ long long __s64; -__extension__ typedef unsigned long long __u64; -#endif +typedef unsigned short umode_t; /* * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ -typedef signed char s8; -typedef unsigned char u8; - -typedef signed short s16; -typedef unsigned short u16; - -typedef signed int s32; -typedef unsigned int u32; - -typedef signed long long s64; -typedef unsigned long long u64; - /* * Number of bits in a C 'long' on this architecture. */ diff --git a/arch/sh/include/asm/types.h b/arch/sh/include/asm/types.h index aed4a6eb57..c5ddbbd26b 100644 --- a/arch/sh/include/asm/types.h +++ b/arch/sh/include/asm/types.h @@ -1,29 +1,12 @@ #ifndef __ASM_SH_TYPES_H #define __ASM_SH_TYPES_H +#include + #ifndef __ASSEMBLY__ typedef unsigned short umode_t; -/* - * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the - * header files exported to user space - */ - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#if defined(__GNUC__) -__extension__ typedef __signed__ long long __s64; -__extension__ typedef unsigned long long __u64; -#endif - #endif /* __ASSEMBLY__ */ /* @@ -35,19 +18,6 @@ __extension__ typedef unsigned long long __u64; #ifndef __ASSEMBLY__ - -typedef __signed__ char s8; -typedef unsigned char u8; - -typedef __signed__ short s16; -typedef unsigned short u16; - -typedef __signed__ int s32; -typedef unsigned int u32; - -typedef __signed__ long long s64; -typedef unsigned long long u64; - /* Dma addresses are 32-bits wide. */ typedef u32 dma_addr_t; diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h index 7649c2bb0c..ba50001560 100644 --- a/arch/x86/include/asm/types.h +++ b/arch/x86/include/asm/types.h @@ -1,44 +1,15 @@ #ifndef __ASM_I386_TYPES_H #define __ASM_I386_TYPES_H -typedef unsigned short umode_t; - -/* - * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the - * header files exported to user space - */ - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; - -typedef __signed__ int __s32; -typedef unsigned int __u32; +#include -#if defined(__GNUC__) -__extension__ typedef __signed__ long long __s64; -__extension__ typedef unsigned long long __u64; -#endif +typedef unsigned short umode_t; /* * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ -typedef signed char s8; -typedef unsigned char u8; - -typedef signed short s16; -typedef unsigned short u16; - -typedef signed int s32; -typedef unsigned int u32; - -typedef signed long long s64; -typedef unsigned long long u64; - #if CONFIG_IS_ENABLED(X86_64) #define BITS_PER_LONG 64 #else diff --git a/arch/xtensa/include/asm/types.h b/arch/xtensa/include/asm/types.h index bae1a480ee..2c5b5433cc 100644 --- a/arch/xtensa/include/asm/types.h +++ b/arch/xtensa/include/asm/types.h @@ -6,44 +6,15 @@ #ifndef _XTENSA_TYPES_H #define _XTENSA_TYPES_H -typedef unsigned short umode_t; - -/* - * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the - * header files exported to user space - */ - -typedef __signed__ char __s8; -typedef unsigned char __u8; - -typedef __signed__ short __s16; -typedef unsigned short __u16; +#include -typedef __signed__ int __s32; -typedef unsigned int __u32; - -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -typedef __signed__ long long __s64; -typedef unsigned long long __u64; -#endif +typedef unsigned short umode_t; /* * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ -typedef signed char s8; -typedef unsigned char u8; - -typedef signed short s16; -typedef unsigned short u16; - -typedef signed int s32; -typedef unsigned int u32; - -typedef signed long long s64; -typedef unsigned long long u64; - #define BITS_PER_LONG 32 /* Dma addresses are 32-bits wide */ diff --git a/include/asm-generic/int-ll64.h b/include/asm-generic/int-ll64.h new file mode 100644 index 0000000000..7451718a61 --- /dev/null +++ b/include/asm-generic/int-ll64.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * asm-generic/int-ll64.h + * + * Integer declarations for architectures which use "long long" + * for 64-bit types. + */ + +#ifndef _ASM_GENERIC_INT_LL64_H +#define _ASM_GENERIC_INT_LL64_H + +#ifndef __ASSEMBLY__ +/* + * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the + * header files exported to user space + */ + +typedef __signed__ char __s8; +typedef unsigned char __u8; + +typedef __signed__ short __s16; +typedef unsigned short __u16; + +typedef __signed__ int __s32; +typedef unsigned int __u32; + +#ifdef __GNUC__ +__extension__ typedef __signed__ long long __s64; +__extension__ typedef unsigned long long __u64; +#else +typedef __signed__ long long __s64; +typedef unsigned long long __u64; +#endif + +typedef __s8 s8; +typedef __u8 u8; +typedef __s16 s16; +typedef __u16 u16; +typedef __s32 s32; +typedef __u32 u32; +typedef __s64 s64; +typedef __u64 u64; + +#endif /* __ASSEMBLY__ */ + + +#endif /* _ASM_GENERIC_INT_LL64_H */ diff --git a/include/asm-generic/types.h b/include/asm-generic/types.h new file mode 100644 index 0000000000..7c076c56ce --- /dev/null +++ b/include/asm-generic/types.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_GENERIC_TYPES_H +#define _ASM_GENERIC_TYPES_H +/* + * int-ll64 is used everywhere now. + */ +#include + +#endif /* _ASM_GENERIC_TYPES_H */ -- 2.39.5