public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Jaswinder Singh Rajput <jaswinder@kernel.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	mingo@elte.hu, x86@kernel.org, sam@ravnborg.org, hpa@zytor.com,
	jirislaby@gmail.com, gregkh@suse.de, davem@davemloft.net,
	xyzzy@speakeasy.org, arnd@arndb.de, mchehab@infradead.org,
	jens.axboe@oracle.com, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org, Avi Kivity <avi@redhat.com>
Subject: Re: [GIT PULL -tip] fix 22 make headers_check - 200901
Date: Wed, 4 Feb 2009 12:55:52 +0100	[thread overview]
Message-ID: <200902041255.53264.arnd@arndb.de> (raw)
In-Reply-To: <1233734645.3198.2.camel@localhost.localdomain>

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@arndb.de>

--- /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;

  parent reply	other threads:[~2009-02-04 11:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-24 12:56 [GIT PULL -tip] fix 22 make headers_check - 200901 Jaswinder Singh Rajput
2009-01-24 13:43 ` Jaswinder Singh Rajput
2009-01-26 12:50   ` Ingo Molnar
2009-02-04  6:43 ` Herbert Xu
2009-02-04  8:04   ` Jaswinder Singh Rajput
2009-02-04  8:12     ` Avi Kivity
2009-02-04  8:13     ` Avi Kivity
2009-02-04  8:37       ` Jaswinder Singh Rajput
2009-02-04 11:55     ` Arnd Bergmann [this message]
2009-02-04 14:18       ` Ingo Molnar
2009-02-04 17:33       ` H. Peter Anvin
2009-02-05 14:30         ` Arnd Bergmann
2009-02-05 15:17           ` H. Peter Anvin
2009-02-05 16:07             ` [PATCH] Make exported headers use strict posix types Arnd Bergmann
2009-02-05 17:54               ` H. Peter Anvin
2009-02-05 18:45               ` Arnd Bergmann
2009-02-17  9:38               ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200902041255.53264.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=avi@redhat.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@suse.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=jaswinder@kernel.org \
    --cc=jens.axboe@oracle.com \
    --cc=jirislaby@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=mingo@elte.hu \
    --cc=sam@ravnborg.org \
    --cc=x86@kernel.org \
    --cc=xyzzy@speakeasy.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox