Skip to contentSkip to conversation

x86: headers - include linux/types.h instead of asm/types.h

PATCH In review Cyrill Gorcunov 3 participants 10 messages Jan 13, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: headers - include linux/types.h instead of asm/types.h

Impact: cleanup

'make headers_check' warns that linux/types.h is preferred over asm/types.h. So be it.

CC Jaswinder Singh Rajput <[email protected]>
CC Sam Ravnborg <[email protected]>
CC Harvey Harrison <[email protected]>

---

 arch/x86/include/asm/e820.h       |    2 ++
 arch/x86/include/asm/kvm.h        |    2 +-
 arch/x86/include/asm/mce.h        |    2 +-
 arch/x86/include/asm/mtrr.h       |    1 +
 arch/x86/include/asm/ptrace-abi.h |    2 +-
 arch/x86/include/asm/sigcontext.h |    2 +-
 arch/x86/include/asm/swab.h       |    2 +-
 7 files changed, 8 insertions(+), 5 deletions(-)
arch/x86/include/asm/e820.h +2 -0
Index: linux-2.6.git/arch/x86/include/asm/e820.h
===================================================================
@@ -1,5 +1,6 @@
 #ifndef _ASM_X86_E820_H
 #define _ASM_X86_E820_H
+
 #define E820MAP	0x2d0		/* our map */
 #define E820MAX	128		/* number of entries in E820MAP */
 
@@ -49,6 +50,7 @@
 #define E820_RESERVED_KERN        128
 
 #ifndef __ASSEMBLY__
+#include <linux/types.h>
 struct e820entry {
 	__u64 addr;	/* start of memory segment */
 	__u64 size;	/* size of memory segment */
arch/x86/include/asm/kvm.h +1 -1
Index: linux-2.6.git/arch/x86/include/asm/kvm.h
===================================================================
@@ -6,7 +6,7 @@
  *
  */
 
-#include <asm/types.h>
+#include <linux/types.h>
 #include <linux/ioctl.h>
 
 /* Architectural interrupt line count. */
arch/x86/include/asm/mce.h +1 -1
Index: linux-2.6.git/arch/x86/include/asm/mce.h
===================================================================
@@ -4,7 +4,7 @@
 #ifdef __x86_64__
 
 #include <asm/ioctls.h>
-#include <asm/types.h>
+#include <linux/types.h>
 
 /*
  * Machine Check support for x86
arch/x86/include/asm/mtrr.h +1 -0
Index: linux-2.6.git/arch/x86/include/asm/mtrr.h
===================================================================
@@ -23,6 +23,7 @@
 #ifndef _ASM_X86_MTRR_H
 #define _ASM_X86_MTRR_H
 
+#include <linux/types.h>
 #include <linux/ioctl.h>
 #include <linux/errno.h>
 
arch/x86/include/asm/ptrace-abi.h +1 -1
Index: linux-2.6.git/arch/x86/include/asm/ptrace-abi.h
===================================================================
@@ -83,7 +83,7 @@
 #ifdef CONFIG_X86_PTRACE_BTS
 
 #ifndef __ASSEMBLY__
-#include <asm/types.h>
+#include <linux/types.h>
 
 /* configuration/status structure used in PTRACE_BTS_CONFIG and
    PTRACE_BTS_STATUS commands.
arch/x86/include/asm/sigcontext.h +1 -1
Index: linux-2.6.git/arch/x86/include/asm/sigcontext.h
===================================================================
@@ -2,7 +2,7 @@
 #define _ASM_X86_SIGCONTEXT_H
 
 #include <linux/compiler.h>
-#include <asm/types.h>
+#include <linux/types.h>
 
 #define FP_XSTATE_MAGIC1	0x46505853U
 #define FP_XSTATE_MAGIC2	0x46505845U
arch/x86/include/asm/swab.h +1 -1
Index: linux-2.6.git/arch/x86/include/asm/swab.h
===================================================================
@@ -1,7 +1,7 @@
 #ifndef _ASM_X86_SWAB_H
 #define _ASM_X86_SWAB_H
 
-#include <asm/types.h>
+#include <linux/types.h>
 #include <linux/compiler.h>
 
 static inline __attribute_const__ __u32 __arch_swab32(__u32 val)
#1 lore raw

[Cyrill Gorcunov - Tue, Jan 13, 2009 at 03:09:05PM +0300]

| Impact: cleanup
| 
| 'make headers_check' warns that linux/types.h is
| preferred over asm/types.h. So be it.
| 
| Signed-off-by: Cyrill Gorcunov <[email protected]>
| CC: Jaswinder Singh Rajput <[email protected]>
| CC: Sam Ravnborg <[email protected]>
| CC: Harvey Harrison <[email protected]>
| ---
| 
|  arch/x86/include/asm/e820.h       |    2 ++
|  arch/x86/include/asm/kvm.h        |    2 +-
|  arch/x86/include/asm/mce.h        |    2 +-
|  arch/x86/include/asm/mtrr.h       |    1 +
|  arch/x86/include/asm/ptrace-abi.h |    2 +-
|  arch/x86/include/asm/sigcontext.h |    2 +-
|  arch/x86/include/asm/swab.h       |    2 +-
|  7 files changed, 8 insertions(+), 5 deletions(-)
|

...

well... on the other hand I'm not sure if it's really a good idea to include linux/types.h where we need only __u[8,16] and so on definitions.

Ingo, don't apply this patch please -- have to check for other ways.

- Cyrill -

#2 lore raw
Quoted 21 lines · Cyrill Gorcunov

[Cyrill Gorcunov - Tue, Jan 13, 2009 at 03:09:05PM +0300]

| Impact: cleanup
| 
| 'make headers_check' warns that linux/types.h is
| preferred over asm/types.h. So be it.
| 
| Signed-off-by: Cyrill Gorcunov <[email protected]>
| CC: Jaswinder Singh Rajput <[email protected]>
| CC: Sam Ravnborg <[email protected]>
| CC: Harvey Harrison <[email protected]>
| ---
| 
|  arch/x86/include/asm/e820.h       |    2 ++
|  arch/x86/include/asm/kvm.h        |    2 +-
|  arch/x86/include/asm/mce.h        |    2 +-
|  arch/x86/include/asm/mtrr.h       |    1 +
|  arch/x86/include/asm/ptrace-abi.h |    2 +-
|  arch/x86/include/asm/sigcontext.h |    2 +-
|  arch/x86/include/asm/swab.h       |    2 +-
|  7 files changed, 8 insertions(+), 5 deletions(-)
|
Quoted 5 lines

...

well... on the other hand I'm not sure if it's really a good idea to include linux/types.h where we need only __u[8,16] and so on definitions.

Well, linux/types.h is supposed to be a 'lightweight', 'core data types only' kind of header file, so including it is not wrong per se.

Sam, is there some other preferred way perhaps to resolve these?

Ingo

#8 lore raw
In reply to Cyrill Gorcunov
Quoted 21 lines · Cyrill Gorcunov

[Cyrill Gorcunov - Tue, Jan 13, 2009 at 03:09:05PM +0300]

| Impact: cleanup
|
| 'make headers_check' warns that linux/types.h is
| preferred over asm/types.h. So be it.
|
| Signed-off-by: Cyrill Gorcunov <[email protected]>
| CC: Jaswinder Singh Rajput <[email protected]>
| CC: Sam Ravnborg <[email protected]>
| CC: Harvey Harrison <[email protected]>
| ---
|
|  arch/x86/include/asm/e820.h       |    2 ++
|  arch/x86/include/asm/kvm.h        |    2 +-
|  arch/x86/include/asm/mce.h        |    2 +-
|  arch/x86/include/asm/mtrr.h       |    1 +
|  arch/x86/include/asm/ptrace-abi.h |    2 +-
|  arch/x86/include/asm/sigcontext.h |    2 +-
|  arch/x86/include/asm/swab.h       |    2 +-
|  7 files changed, 8 insertions(+), 5 deletions(-)
|
Quoted 9 lines

...

well... on the other hand I'm not sure if it's really a good idea to include linux/types.h where we need only __u[8,16] and so on definitions.

Ingo, don't apply this patch please -- have to check for other ways.

I am attaching usr/include/linux/types.h for your reference which includes all these definations for userspace.

Thanks
--
JSR

#ifndef _LINUX_TYPES_H
#define _LINUX_TYPES_H

#include <linux/posix_types.h>
#include <asm/types.h>

#ifndef __KERNEL_STRICT_NAMES

typedef __u32 __kernel_dev_t;

typedef __kernel_fd_set fd_set;
typedef __kernel_dev_t dev_t;
typedef __kernel_ino_t ino_t;
typedef __kernel_mode_t mode_t;
typedef __kernel_nlink_t nlink_t;
typedef __kernel_off_t off_t;
typedef __kernel_pid_t pid_t;
typedef __kernel_daddr_t daddr_t;
typedef __kernel_key_t key_t;
typedef __kernel_suseconds_t suseconds_t;
typedef __kernel_timer_t timer_t;
typedef __kernel_clockid_t clockid_t;
typedef __kernel_mqd_t mqd_t;

typedef __kernel_uid_t uid_t;
typedef __kernel_gid_t gid_t;

#if defined(__GNUC__)
typedef __kernel_loff_t loff_t;
#endif

/*
* The following typedefs are also protected by individual ifdefs for
* historical reasons:
*/
#ifndef _SIZE_T
#define _SIZE_T
typedef __kernel_size_t size_t;
#endif

#ifndef _SSIZE_T
#define _SSIZE_T
typedef __kernel_ssize_t ssize_t;
#endif

#ifndef _PTRDIFF_T
#define _PTRDIFF_T
typedef __kernel_ptrdiff_t ptrdiff_t;
#endif

#ifndef _TIME_T
#define _TIME_T
typedef __kernel_time_t time_t;
#endif

#ifndef _CLOCK_T
#define _CLOCK_T
typedef __kernel_clock_t clock_t;
#endif

#ifndef _CADDR_T
#define _CADDR_T
typedef __kernel_caddr_t caddr_t;
#endif

/* bsd */
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;

/* sysv */
typedef unsigned char unchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;

#ifndef __BIT_TYPES_DEFINED__
#define __BIT_TYPES_DEFINED__

typedef __u8 u_int8_t;
typedef __s8 int8_t;
typedef __u16 u_int16_t;
typedef __s16 int16_t;
typedef __u32 u_int32_t;
typedef __s32 int32_t;

#endif /* !(__BIT_TYPES_DEFINED__) */

typedef __u8 uint8_t;
typedef __u16 uint16_t;
typedef __u32 uint32_t;

#if defined(__GNUC__)
typedef __u64 uint64_t;
typedef __u64 u_int64_t;
typedef __s64 int64_t;
#endif

/* this is a special 64bit data type that is 8-byte aligned */ #define aligned_u64 __u64 __attribute__((aligned(8))) #define aligned_be64 __be64 __attribute__((aligned(8))) #define aligned_le64 __le64 __attribute__((aligned(8)))

/**
* The type used for indexing onto a disc or disc partition. *
* Linux always considers sectors to be 512 bytes long independently
* of the devices real block size.
*
* blkcnt_t is the type of the inode's block count.
*/
#ifdef CONFIG_LBD
typedef u64 sector_t;
typedef u64 blkcnt_t;
#else
typedef unsigned long sector_t;
typedef unsigned long blkcnt_t;
#endif

/*
* The type of an index into the pagecache. Use a #define so asm/types.h
* can override it.
*/
#ifndef pgoff_t
#define pgoff_t unsigned long
#endif

#endif /* __KERNEL_STRICT_NAMES */

/*
* Below are truly Linux-specific types that should never collide with
* any application/library that wants linux/types.h.
*/

#ifdef __CHECKER__
#define __bitwise__ __attribute__((bitwise))
#else
#define __bitwise__
#endif
#ifdef __CHECK_ENDIAN__
#define __bitwise __bitwise__
#else
#define __bitwise
#endif

typedef __u16 __bitwise __le16;
typedef __u16 __bitwise __be16;
typedef __u32 __bitwise __le32;
typedef __u32 __bitwise __be32;
typedef __u64 __bitwise __le64;
typedef __u64 __bitwise __be64;

typedef __u16 __bitwise __sum16;
typedef __u32 __bitwise __wsum;

#endif /* _LINUX_TYPES_H */

#3 lore raw
In reply to Ingo Molnar

[Ingo Molnar - Tue, Jan 13, 2009 at 01:59:28PM +0100]

| 
| * Cyrill Gorcunov <[email protected]> wrote:
| 
| > [Cyrill Gorcunov - Tue, Jan 13, 2009 at 03:09:05PM +0300]
| > | Impact: cleanup
| > | 
| > | 'make headers_check' warns that linux/types.h is
| > | preferred over asm/types.h. So be it.
| > | 
| > | Signed-off-by: Cyrill Gorcunov <[email protected]>
| > | CC: Jaswinder Singh Rajput <[email protected]>
| > | CC: Sam Ravnborg <[email protected]>
| > | CC: Harvey Harrison <[email protected]>
| > | ---
| > | 
| > |  arch/x86/include/asm/e820.h       |    2 ++
| > |  arch/x86/include/asm/kvm.h        |    2 +-
| > |  arch/x86/include/asm/mce.h        |    2 +-
| > |  arch/x86/include/asm/mtrr.h       |    1 +
| > |  arch/x86/include/asm/ptrace-abi.h |    2 +-
| > |  arch/x86/include/asm/sigcontext.h |    2 +-
| > |  arch/x86/include/asm/swab.h       |    2 +-
| > |  7 files changed, 8 insertions(+), 5 deletions(-)
| > |
| > ...
| > 
| > well... on the other hand I'm not sure if it's really
| > a good idea to include linux/types.h where we need only
| > __u[8,16] and so on definitions.
| 
| Well, linux/types.h is supposed to be a 'lightweight', 'core data types 
| only' kind of header file, so including it is not wrong per se.
| 
| Sam, is there some other preferred way perhaps to resolve these?
| 
| 	Ingo
| 

Until such a file not passed to some *.S. For example for e820.h we have it included to arch/x86/boot/header.S but fortunately we're bound by __ASSEMBLY__. So there linux/types.h shouldn't hurt. Will check others and report then.

- Cyrill -

#9 lore raw
In reply to Jaswinder Singh Rajput

[Jaswinder Singh Rajput - Tue, Jan 13, 2009 at 06:38:02PM +0530]

| On Tue, Jan 13, 2009 at 6:27 PM, Cyrill Gorcunov <[email protected]> wrote:
| > [Cyrill Gorcunov - Tue, Jan 13, 2009 at 03:09:05PM +0300]
| > | Impact: cleanup
| > |
| > | 'make headers_check' warns that linux/types.h is
| > | preferred over asm/types.h. So be it.
| > |
| > | Signed-off-by: Cyrill Gorcunov <[email protected]>
| > | CC: Jaswinder Singh Rajput <[email protected]>
| > | CC: Sam Ravnborg <[email protected]>
| > | CC: Harvey Harrison <[email protected]>
| > | ---
| > |
| > |  arch/x86/include/asm/e820.h       |    2 ++
| > |  arch/x86/include/asm/kvm.h        |    2 +-
| > |  arch/x86/include/asm/mce.h        |    2 +-
| > |  arch/x86/include/asm/mtrr.h       |    1 +
| > |  arch/x86/include/asm/ptrace-abi.h |    2 +-
| > |  arch/x86/include/asm/sigcontext.h |    2 +-
| > |  arch/x86/include/asm/swab.h       |    2 +-
| > |  7 files changed, 8 insertions(+), 5 deletions(-)
| > |
| > ...
| >
| > well... on the other hand I'm not sure if it's really
| > a good idea to include linux/types.h where we need only
| > __u[8,16] and so on definitions.
| >
| > Ingo, don't apply this patch please -- have to check
| > for other ways.
| >
| 
| I am attaching usr/include/linux/types.h for your reference which
| includes all these definations for userspace.
| 
| Thanks
| --
| JSR

yeah, thanks! I already have one in my git clone but anyway ;-)

- Cyrill -

#4 lore raw
In reply to Cyrill Gorcunov

[Cyrill Gorcunov - Tue, Jan 13, 2009 at 04:10:20PM +0300]
...

| | > 
| | > well... on the other hand I'm not sure if it's really
| | > a good idea to include linux/types.h where we need only
| | > __u[8,16] and so on definitions.
| | 
| | Well, linux/types.h is supposed to be a 'lightweight', 'core data types 
| | only' kind of header file, so including it is not wrong per se.
| | 
| | Sam, is there some other preferred way perhaps to resolve these?
| | 
| | 	Ingo
| | 
| 
| Until such a file not passed to some *.S. For example for e820.h
| we have it included to arch/x86/boot/header.S but fortunately
| we're bound by __ASSEMBLY__. So there linux/types.h shouldn't hurt.
| Will check others and report then.
| 
| 		- Cyrill -

ok, have checked -- this patch seems to be safe.

- Cyrill -

#5 lore raw
In reply to Cyrill Gorcunov
Quoted 39 lines · Cyrill Gorcunov

[Ingo Molnar - Tue, Jan 13, 2009 at 01:59:28PM +0100]

| 
| * Cyrill Gorcunov <[email protected]> wrote:
| 
| > [Cyrill Gorcunov - Tue, Jan 13, 2009 at 03:09:05PM +0300]
| > | Impact: cleanup
| > | 
| > | 'make headers_check' warns that linux/types.h is
| > | preferred over asm/types.h. So be it.
| > | 
| > | Signed-off-by: Cyrill Gorcunov <[email protected]>
| > | CC: Jaswinder Singh Rajput <[email protected]>
| > | CC: Sam Ravnborg <[email protected]>
| > | CC: Harvey Harrison <[email protected]>
| > | ---
| > | 
| > |  arch/x86/include/asm/e820.h       |    2 ++
| > |  arch/x86/include/asm/kvm.h        |    2 +-
| > |  arch/x86/include/asm/mce.h        |    2 +-
| > |  arch/x86/include/asm/mtrr.h       |    1 +
| > |  arch/x86/include/asm/ptrace-abi.h |    2 +-
| > |  arch/x86/include/asm/sigcontext.h |    2 +-
| > |  arch/x86/include/asm/swab.h       |    2 +-
| > |  7 files changed, 8 insertions(+), 5 deletions(-)
| > |
| > ...
| > 
| > well... on the other hand I'm not sure if it's really
| > a good idea to include linux/types.h where we need only
| > __u[8,16] and so on definitions.
| 
| Well, linux/types.h is supposed to be a 'lightweight', 'core data types 
| only' kind of header file, so including it is not wrong per se.
| 
| Sam, is there some other preferred way perhaps to resolve these?
| 
| 	Ingo
| 
Quoted 4 lines

Until such a file not passed to some *.S. For example for e820.h we have it included to arch/x86/boot/header.S but fortunately we're bound by __ASSEMBLY__. So there linux/types.h shouldn't hurt. Will check others and report then.

Any reason to not protect types.h with #ifndef __ASSEMBLY__ ?

Ingo

#6 lore raw

[Ingo Molnar - Tue, Jan 13, 2009 at 03:45:05PM +0100]
...

| > 
| > Until such a file not passed to some *.S. For example for e820.h we have 
| > it included to arch/x86/boot/header.S but fortunately we're bound by 
| > __ASSEMBLY__. So there linux/types.h shouldn't hurt. Will check others 
| > and report then.
| 
| Any reason to not protect types.h with #ifndef __ASSEMBLY__ ?
| 
| 	Ingo
| 

hmm... good question :) letme check

- Cyrill -

#7 lore raw

[Cyrill Gorcunov - Tue, Jan 13, 2009 at 05:49:56PM +0300]

| [Ingo Molnar - Tue, Jan 13, 2009 at 03:45:05PM +0100]
| ...
| | > 
| | > Until such a file not passed to some *.S. For example for e820.h we have 
| | > it included to arch/x86/boot/header.S but fortunately we're bound by 
| | > __ASSEMBLY__. So there linux/types.h shouldn't hurt. Will check others 
| | > and report then.
| | 
| | Any reason to not protect types.h with #ifndef __ASSEMBLY__ ?
| | 
| | 	Ingo
| | 
| 
| hmm... good question :) letme check
| 
| 		- Cyrill -

Dunno Ingo, it's dubious. I don't like the idea to start including types.h into any kind of *.S with #ifndef __ASSEMBLY__ protection. We export it into user space and I don't remember if it mentioned somewhere that user is not allowed to use -D__ASSEMBLY__.

Someone more experienced (then me) in this area should asked first :-)

- Cyrill -