linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Horsten <thomas@horsten.com>
To: "ismail (cartman) donmez" <voidcartman@yahoo.com>,
	"David S. Miller" <davem@redhat.com>,
	marcelo@conectiva.com.br
Cc: hch@infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] 2.4.21-rc1: byteorder.h breaks with __STRICT_ANSI__ defined (trivial)
Date: Wed, 7 May 2003 07:44:27 +0100	[thread overview]
Message-ID: <200305070744.27207.thomas@horsten.com> (raw)
In-Reply-To: <200305070850.59912.voidcartman@yahoo.com>

On Wednesday 07 May 2003 6:50 am, ismail (cartman) donmez wrote:
> On Tuesday 06 May 2003 18:40, Thomas Horsten wrote:
> > --- linux-2.4.21-rc1-orig/include/asm-i386/types.h	2002-08-03
> > 01:39:45.000000000 +0100
> > +++ linux-2.4.21-rc1-ac4/include/asm-i386/types.h	2003-05-06
> > 15:07:06.000000000 +0100
> > @@ -17,10 +17,8 @@
> >  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
>
> Imho this is bad here you define a long long variable even if userspace
> apps use -ansi flag where Ansi standart has no support for long long
> variables. I think this should be fixed in userspace.

Well if you look at my earlier patch (where I changed byteorder.h instead), 
you'll see that the two places conflict for sure, and is objectively an error 
- hence the need for a fix, whatever you think about userland including these 
headers in general:

1. In types.h we define __u64 only if __STRICT_ANSI__ is *not* defined.
2. In byteorder.h we declare an inline function that uses __u64, regardless of 
whether __STRICT_ANSI__ is defined (new in 2.4.21).

It causes a compile error in the most trivial circumstance: Create a .c file 
with just one line, e.g. "include <asm/types.h>" and compile it with -ansi.

My reasoning for the original patch was: The new code added in 2.4.21 causes 
the break, __u64 is not going to be defined if -ansi is (and this has been 
the case all along, so that means with 99.9% certainty that nobody are 
actually using even the old macro version of swab64, or it would have broken 
then). So, take the inline swab64 out if __STRICT_ANSI__ is defined and don't 
use "long long".

Then David said he didn't like the approach since another header might use 
swab64 (I don't think its highly likely but it's certainly a possibility). So 
then I suggested this fix instead which he liked more. This fix is also not 
100% correct in that it breaks ANSI C, (but I'm sure other kernel headers 
might do that just as well), but at least swab64 will always be available, 
and it will work when compiling with GCC on x86 platform even with -ansi on 
(remember that the file being patched is in asm-x86 so this won't affect 
other platforms).

Another argument for the second solution is that if the userland apps are not 
supposed to include the headers in the first place then why would we ever 
check for __STRICT_ANSI__ in kernel headers.

However I do not agree with that - I think it makes total sense for userland 
to include kernel headers when we are talking e.g. specific device driver 
interface. Imagine Joe Admin has firewall which is a pretty old Slackware 
with 2.2 kernel and wants to upgrade to 2.4 to get from ipchains to iptables 
(all just an example). He just downloads the 2.4 kernel and builds it, 
symlinks to /usr/src/linux so his /usr/include/linux and ../asm will point to 
the new kernel then he goes on to build the iptables userland binary - oops, 
this didn't work if he'd relied on a separate set of kernel headers and a 
package didn't happen to be available, also what's the use of maintaining two 
sets of essentially the same header when we could just sanitize the Linux 
ones a bit (read: just enough that they don't break userland).

In summary I'm not too concerned which of the two solutions are included but I 
think one should be for sure. It's just plain wrong to have the #ifdef 
__STRICT_ANSI__ in one place and not the other.

// Thomas


  reply	other threads:[~2003-05-07  6:31 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-06  9:16 [PATCH] 2.4.21-rc1: byteorder.h breaks with __STRICT_ANSI__ defined (trivial) Thomas Horsten
2003-05-06  9:19 ` David S. Miller
2003-05-06  9:38 ` Christoph Hellwig
2003-05-06  9:47   ` Thomas Horsten
2003-05-06  9:49     ` Christoph Hellwig
2003-05-06 10:03       ` David S. Miller
2003-05-06 14:10         ` Thomas Horsten
2003-05-06 13:06           ` David S. Miller
2003-05-06 15:40             ` Thomas Horsten
2003-05-07  5:50               ` ismail (cartman) donmez
2003-05-07  6:44                 ` Thomas Horsten [this message]
2003-05-07  6:45                   ` Christoph Hellwig
2003-05-07  5:44                     ` David S. Miller
2003-05-07  6:55                       ` Christoph Hellwig
2003-05-07  6:59                     ` Thomas Horsten
2003-05-07  5:53                       ` David S. Miller
2003-05-06 21:19           ` David Woodhouse
2003-05-07  3:06             ` David S. Miller
2003-05-07  5:26               ` Christoph Hellwig
2003-05-07  5:07                 ` David S. Miller
2003-05-07  6:20                   ` Christoph Hellwig
2003-05-07  5:19                     ` David S. Miller
2003-05-07  6:28                       ` Christoph Hellwig
2003-05-07  5:27                         ` David S. Miller
2003-05-07  6:41                           ` Christoph Hellwig
2003-05-07  5:42                             ` David S. Miller
     [not found] <20030506110259.A29633@infradead.org>
2003-05-06 10:24 ` Thomas Horsten
2003-11-06 17:36 Martin Schlemmer
2003-11-06 17:37 ` David S. Miller
2003-11-06 18:32   ` Martin Schlemmer
2003-11-06 18:42     ` Martin Schlemmer
2003-11-06 19:37       ` David S. Miller
2003-11-06 20:09         ` Martin Schlemmer
2003-11-06 20:05           ` David S. Miller
2003-11-06 20:29             ` Martin Schlemmer
2003-11-06 20:27               ` David S. Miller
2003-11-06 21:18                 ` Martin Schlemmer
2003-11-06 21:18                   ` David S. Miller
2003-11-06 21:59                     ` Martin Schlemmer
2003-11-06 21:24                   ` Daniel Jacobowitz
2003-11-06 20:40               ` H. Peter Anvin
2003-11-06 22:31                 ` David S. Miller
2003-11-06 23:40                   ` H. Peter Anvin
2003-11-06 21:21             ` Daniel Jacobowitz

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=200305070744.27207.thomas@horsten.com \
    --to=thomas@horsten.com \
    --cc=davem@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    --cc=voidcartman@yahoo.com \
    /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;
as well as URLs for NNTP newsgroup(s).