Re: [GIT PULL -tip] fix 22 make headers_check - 200901

From: Arnd Bergmann
Date: Wed Feb 04 2009 - 06:57:50 EST


On Wednesday 04 February 2009, Jaswinder Singh Rajput wrote:
> On Wed, 2009-02-04 at 17:43 +1100, Herbert Xu wrote:
> > > -#include <asm/types.h>
> > > +#include <linux/types.h>
> > > #include <linux/ioctl.h>
> >
> > Awesome, you've just broken the userspace build of kvm as the
> > file linux/types.h conflicts with sys/types.h.
> >
>
> What I did is absolutely right.
>
> If there is any conflict then we need to solve it in better way.
>
> Can you please share what is the conflict and what you are expecting and
> what you are getting.

I fear that the problem might be more widespread than just kvm.
The problem is that <linux/types.h> without __KERNEL_STRICT_NAMES
defines the standard types that glibc provides in its own <sys/types.h>,
some of them even defined differently (e.g. the size of off_t depends
__USE_FILE_OFFSET64).

You should be able to do

#include <sys/types.h>
#define __KERNEL_STRICT_NAMES
#include <linux/types.h>

or

#include <sys/types.h>
#include <asm/types.h>

but not without the __KERNEL_STRICT_NAMES! This means that the
mass-conversion to <linux/types.h> was flawed and should be fixed
before 2.6.29 to avoid more trouble.

This is related to the point I brought up earlier with u_int32_t
and other types being problematic in user space. I would suggest
changing all the headers that you converted from <asm/types.h>
to <linux/types.h> again to <linux/strict_types.h>, and apply
the patch below to make that possible.

---
Subject: introduce <linux/strict_types.h>

Exported user space headers should not use <linux/types.h> as that
leaks a number of type names, which conflict with the <sys/types.h>
provided by many libc variants.

This introduces a <linux/strict_types.h> that can be safely included
by any other header file.

Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>

--- /dev/null
+++ b/include/linux/strict_types.h
@@ -0,0 +1,31 @@
+#ifndef __LINUX_STRICT_TYPES_H
+#define __LINUX_STRICT_TYPES_H
+
+#include <asm/types.h>
+/*
+ * 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_STRICT_TYPES_H */
diff --git a/include/linux/types.h b/include/linux/types.h
index 712ca53..beacdb7 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -9,7 +9,7 @@
#endif

#include <linux/posix_types.h>
-#include <asm/types.h>
+#include <linux/strict_types.h>

#ifndef __KERNEL_STRICT_NAMES

@@ -156,32 +156,6 @@ typedef unsigned long blkcnt_t;

#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;
-
#ifdef __KERNEL__
typedef unsigned __bitwise__ gfp_t;
typedef unsigned __bitwise__ fmode_t;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/