2007-06-21 22:52:59

by Joerg.Schilling

[permalink] [raw]
Subject: Linux Kernel include files


Hi all,

you might know that since ~ 2 years, the Sun Studio compilers
are available for Linux. Given the fact that they typically produce
faster code than GCC and that they offer more debug/optimizing features,
they are worth testing.

While it is no problem to use Sun Studio for non-Linux-specific programs,
it is impossible to compile programs using Sun Studio if these programs offer
Linux specific features.

Star ftp://ftp.berlios.de/pub/star/alpha/ offers support for archiving ext2
file flags. If star is compiled using Sun Studio, star's autoconfiguration will
disable support for the Linux specific features because it detects "broken"
include files.

Cdrtools ftp://ftp.berlios.de/pub/cdrecord/alpha/ offer support for an OS
dependent SCSI transport. Cdrtools cannot be compiled wihout support for SCSI
transport, so it is impossible to use Sun Studio to compile cdrtools.

Why does this happen?

Well, the reason is that in order to support Linux specific features, you need
to include Linux specific include files (the Linux kernel include files). As
these include files are currently not written in vanilla (ANSI) C but in a
GCC-C-variant, other compilers do not like these include files.

Is there some hope that at least the Linux kernel interface definition files and
everything recursively included from these files will be rewritten in vanilla
ANSI C?

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily


2007-06-21 23:25:43

by David Lang

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Fri, 22 Jun 2007, Joerg Schilling wrote:

> Is there some hope that at least the Linux kernel interface definition files and
> everything recursively included from these files will be rewritten in vanilla
> ANSI C?

this has been discussed many times and the answer is that the kernel is
not gong to change it's side of things to ANSI C.

that doesn't mean that one of the many projects out there to create
seperate interface headers won't do this.

however, there is another interesting thing going on at the moment. The
standards commity is currently deciding what will be in the next rev of
the C specs (tentitivly labels C1x for discussions, they are hopeing to
release them in '09 or '10)

some of the things that are GCC extentions are going to be added to the
spec (ahtough possibly with a change to the syntax)

so now is the time to talk to your local reps who go to these meetings and
make your suggestions for what should be added to the standard and what
should not be.

remember that anything to be added must be implemented somehwere,
preferrably by multiple seperate compilers.

David Lang

2007-06-21 23:40:38

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

[email protected] wrote:

> On Fri, 22 Jun 2007, Joerg Schilling wrote:
>
> > Is there some hope that at least the Linux kernel interface definition files and
> > everything recursively included from these files will be rewritten in vanilla
> > ANSI C?
>
> this has been discussed many times and the answer is that the kernel is
> not gong to change it's side of things to ANSI C.
>
> that doesn't mean that one of the many projects out there to create
> seperate interface headers won't do this.

The main problems are not really hard to fix......

- Most problems eem to be related to the fact that Linux does not
use C-99 based types in the kernel and the related type definitions
are not written in plain C. This is something that should be fixed
with a source consolidation program or by defining aliases to
C-99 types in case the compiler is not GCC.

- Other problems are caused by additional tag definitions that could
be disabled in case of a non-GCC compile.

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-21 23:52:25

by Arjan van de Ven

[permalink] [raw]
Subject: Re: Linux Kernel include files


> Cdrtools ftp://ftp.berlios.de/pub/cdrecord/alpha/ offer support for an OS
> dependent SCSI transport. Cdrtools cannot be compiled wihout support for SCSI
> transport, so it is impossible to use Sun Studio to compile cdrtools.
>
> Why does this happen?
>
> Well, the reason is that in order to support Linux specific features, you need
> to include Linux specific include files (the Linux kernel include files).


I assume you typoed and meant "cleaned up kernel include files as
installed by make headers_install" instead.

> As
> these include files are currently not written in vanilla (ANSI) C but in a
> GCC-C-variant, other compilers do not like these include files.

can you give a specific example of a header installed by make
headers_install that breaks this way and is hurting you? Because it may
well be possible to fix the problems, now that we have this special
cleanup phase since several releases....


2007-06-21 23:59:32

by Arnd Bergmann

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Friday 22 June 2007, [email protected] wrote:
> this has been discussed many times and the answer is that the kernel is
> not gong to change it's side of things to ANSI C.

I don't think that's entirely true with regard to the include files.
We have always tried not to step on anyone's toes there, e.g. regarding
the use of __u32 vs. uint32_t style types. It's certainly desirable
to make the kernel headers that are _meant_ for inclusion compatible
with standard compilers.

Mike Frysinger has posted a few patches that make the installed headers
friendlier to strict C99 users. While there was some negative feedback
about these patches, it was not about the idea of making the installed
headers C99 clean, but rather about the question whether those non-clean
parts should be exported in the first place.

Now whether a specific header file should be installed and potentially
included in user space is certainly debatable in many cases, but at
least it's now clearly defined through the include/*/Kbuild files.
If someone has a good reason to change which files are exported, he
should simply submit a patch against the list of exported files.

> that doesn't mean that one of the many projects out there to create
> seperate interface headers won't do this.

Those projects are all practically dead, since we have the
'make headers_install' target in the Linux source.

Arnd <><

2007-06-22 03:38:32

by David Woodhouse

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Fri, 2007-06-22 at 01:38 +0200, Joerg Schilling wrote:
> The main problems are not really hard to fix......
>
> - Most problems eem to be related to the fact that Linux does not
> use C-99 based types in the kernel and the related type definitions
> are not written in plain C. This is something that should be fixed
> with a source consolidation program or by defining aliases to
> C-99 types in case the compiler is not GCC.


The argument has been made that the standard C99 types are _optional_,
and anything included from a C library's headers without _explicitly_
being included by the user shouldn't define those types.

Personally, I think that's a load of bollocks. And it certainly doesn't
apply to Linux-specific files like <linux/cdrom.h>, which are perfectly
entitled to use a C standard from last millennium, regardless of
namespace 'pollution' issues. That's why we continue to use the crappy
__u32 types. Can you be more specific about why this is a problem? Don't
we mostly define those crappy types using arch-specific knowledge, as
'int', 'long', etc?

> - Other problems are caused by additional tag definitions that could
> be disabled in case of a non-GCC compile.

We mostly try to remove this from user-visible parts of exported
headers. Sometimes we just remove it altogether; other bits are stripped
at export time when you run 'make headers_install'. Again, can you be
more specific about the problem?

--
dwmw2

2007-06-22 05:24:43

by H. Peter Anvin

[permalink] [raw]
Subject: Re: Linux Kernel include files

David Woodhouse wrote:
>> The main problems are not really hard to fix......
>>
>> - Most problems eem to be related to the fact that Linux does not
>> use C-99 based types in the kernel and the related type definitions
>> are not written in plain C. This is something that should be fixed
>> with a source consolidation program or by defining aliases to
>> C-99 types in case the compiler is not GCC.
>
>
> The argument has been made that the standard C99 types are _optional_,
> and anything included from a C library's headers without _explicitly_
> being included by the user shouldn't define those types.
>
> Personally, I think that's a load of bollocks. And it certainly doesn't
> apply to Linux-specific files like <linux/cdrom.h>, which are perfectly
> entitled to use a C standard from last millennium, regardless of
> namespace 'pollution' issues. That's why we continue to use the crappy
> __u32 types. Can you be more specific about why this is a problem? Don't
> we mostly define those crappy types using arch-specific knowledge, as
> 'int', 'long', etc?
>

It definitely does hurt when using those types in files that may want to
be used by the C library (as opposed to the end user.)

However, there is no reason why there should be anything funny about the
declaration of those types.

-hpa

2007-06-22 15:00:29

by Adrian Bunk

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Fri, Jun 22, 2007 at 11:38:47AM +0800, David Woodhouse wrote:
> On Fri, 2007-06-22 at 01:38 +0200, Joerg Schilling wrote:
> > The main problems are not really hard to fix......
> >
> > - Most problems eem to be related to the fact that Linux does not
> > use C-99 based types in the kernel and the related type definitions
> > are not written in plain C. This is something that should be fixed
> > with a source consolidation program or by defining aliases to
> > C-99 types in case the compiler is not GCC.
>
>
> The argument has been made that the standard C99 types are _optional_,
> and anything included from a C library's headers without _explicitly_
> being included by the user shouldn't define those types.
>
> Personally, I think that's a load of bollocks. And it certainly doesn't
> apply to Linux-specific files like <linux/cdrom.h>, which are perfectly
> entitled to use a C standard from last millennium, regardless of
> namespace 'pollution' issues. That's why we continue to use the crappy
> __u32 types. Can you be more specific about why this is a problem? Don't
> we mostly define those crappy types using arch-specific knowledge, as
> 'int', 'long', etc?
>...

It would certainly help if Joerg would tell what exactly breaks, but I
spot one likely problem in include/asm-i386/types.h:

#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
typedef __signed__ long long __s64;
typedef unsigned long long __u64;
#endif

It might make sense to remove the #if and simply require that
a C compiler under Linux must know about the C99 "long long"?

> dwmw2

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2007-06-25 14:50:34

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

[email protected] wrote:

> On Fri, 22 Jun 2007, Joerg Schilling wrote:
>
> > Is there some hope that at least the Linux kernel interface definition files and
> > everything recursively included from these files will be rewritten in vanilla
> > ANSI C?
>
> this has been discussed many times and the answer is that the kernel is
> not gong to change it's side of things to ANSI C.

Well, there is no need to go to ANSI C as pre-ANSI would to it also.
The problem is non ANSI gcc extensions.

> that doesn't mean that one of the many projects out there to create
> seperate interface headers won't do this.
>
> however, there is another interesting thing going on at the moment. The
> standards commity is currently deciding what will be in the next rev of
> the C specs (tentitivly labels C1x for discussions, they are hopeing to
> release them in '09 or '10)
>
> some of the things that are GCC extentions are going to be added to the
> spec (ahtough possibly with a change to the syntax)

This may make sense after it did happen, but it does not help today.

> so now is the time to talk to your local reps who go to these meetings and
> make your suggestions for what should be added to the standard and what
> should not be.
>
> remember that anything to be added must be implemented somehwere,
> preferrably by multiple seperate compilers.

Using plain C in the Linux kernel include files would be sufficient for all
compilers that make sense to be supported.


J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-25 14:56:18

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

Arjan van de Ven <[email protected]> wrote:

>
> > Cdrtools ftp://ftp.berlios.de/pub/cdrecord/alpha/ offer support for an OS
> > dependent SCSI transport. Cdrtools cannot be compiled wihout support for SCSI
> > transport, so it is impossible to use Sun Studio to compile cdrtools.
> >
> > Why does this happen?
> >
> > Well, the reason is that in order to support Linux specific features, you need
> > to include Linux specific include files (the Linux kernel include files).
>
>
> I assume you typoed and meant "cleaned up kernel include files as
> installed by make headers_install" instead.

I am thinking about kernel include files that do correct preincludes for
type-cleanness and that work if you use them without #defining __KERNEL_

> > As
> > these include files are currently not written in vanilla (ANSI) C but in a
> > GCC-C-variant, other compilers do not like these include files.
>
> can you give a specific example of a header installed by make
> headers_install that breaks this way and is hurting you? Because it may
> well be possible to fix the problems, now that we have this special
> cleanup phase since several releases....

star needs "ext2_fs.h". This file is not usable at all on many Linux
distributions, even with GCC.

libscg (cdrtools) needs "scsi/sg.h" but it currently includes a lot of other
files:

scsi-linux-sg.c:#include <linux/version.h>
scsi-linux-sg.c:#include <asm/types.h>
scsi-linux-sg.c:#include <scsi/scsi.h>
scsi-linux-sg.c:#include <linux/scsi.h>
scsi-linux-sg.c:#include <linux/fs.h> /* From ancient versions, really needed? */
scsi-linux-sg.c:#include "block/blk.h" /* From ancient versions, really needed? */
scsi-linux-sg.c:#include "scsi/scsi.h"
scsi-linux-sg.c:#include "scsi/sg.h"
scsi-linux-sg.c:#include <linux/cdrom.h>

If there wase _one_ clean SCSI pass through interface on Linux,
things would be a lot easier.....


J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-25 15:08:44

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

Arnd Bergmann <[email protected]> wrote:

> On Friday 22 June 2007, [email protected] wrote:
> > this has been discussed many times and the answer is that the kernel is
> > not gong to change it's side of things to ANSI C.
>
> I don't think that's entirely true with regard to the include files.
> We have always tried not to step on anyone's toes there, e.g. regarding
> the use of __u32 vs. uint32_t style types. It's certainly desirable
> to make the kernel headers that are _meant_ for inclusion compatible
> with standard compilers.
>
> Mike Frysinger has posted a few patches that make the installed headers
> friendlier to strict C99 users. While there was some negative feedback
> about these patches, it was not about the idea of making the installed
> headers C99 clean, but rather about the question whether those non-clean
> parts should be exported in the first place.

Wouldn't it be simpler to ask the developers to deliver their include files
in a state that is clean for user space programs?

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-25 15:19:27

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

David Woodhouse <[email protected]> wrote:

> On Fri, 2007-06-22 at 01:38 +0200, Joerg Schilling wrote:
> > The main problems are not really hard to fix......
> >
> > - Most problems eem to be related to the fact that Linux does not
> > use C-99 based types in the kernel and the related type definitions
> > are not written in plain C. This is something that should be fixed
> > with a source consolidation program or by defining aliases to
> > C-99 types in case the compiler is not GCC.
>
>
> The argument has been made that the standard C99 types are _optional_,
> and anything included from a C library's headers without _explicitly_
> being included by the user shouldn't define those types.

????

This uses double negation and is close to unreadable.

A kernel include file that defines an interface to a user space program
should be self containing (that means that all includes for all non-standard
types should be done inside these include files). Whether or not C-99
types are used or not is less important than to use type definitions written
in clean C so compilers other than gcc may use them.

> Personally, I think that's a load of bollocks. And it certainly doesn't
> apply to Linux-specific files like <linux/cdrom.h>, which are perfectly
> entitled to use a C standard from last millennium, regardless of
> namespace 'pollution' issues. That's why we continue to use the crappy
> __u32 types. Can you be more specific about why this is a problem? Don't
> we mostly define those crappy types using arch-specific knowledge, as
> 'int', 'long', etc?

I recommend you to install Sun Studio and to try to compile star or cdrtools
using Sun Studio by calling "make CCOM_suncc".

ftp://ftp.berlios.de/pub/star/alpha/
ftp://ftp.berlios.de/pub/cdrecord/alpha/

You may need to hand edit the file incs/<arch-dir>/{xconfig.h!rules.conf}

in order to enable the auto-disabled features.

In any case, self reading the error messages from Sun Studio helps more than
trying to discuss it.

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-25 15:27:29

by Arjan van de Ven

[permalink] [raw]
Subject: Re: Linux Kernel include files


> > I assume you typoed and meant "cleaned up kernel include files as
> > installed by make headers_install" instead.
>
> I am thinking about kernel include files that do correct preincludes for
> type-cleanness and that work if you use them without #defining __KERNEL_

there is no __KERNEL__ in the "make headers_install"'d kernel headers.
And they are more or less sanity checked (no sanity check is complete
obviously) against certain common errors already (like including headers
that aren't installed).

if sanity checks are missing (and you seem to imply they do) then I'm
sure David welcomes suggestions for new sanity checks.
> > can you give a specific example of a header installed by make
> > headers_install that breaks this way and is hurting you? Because it may
> > well be possible to fix the problems, now that we have this special
> > cleanup phase since several releases....
>
> star needs "ext2_fs.h". This file is not usable at all on many Linux
> distributions, even with GCC.

oh I thought we were talking about the kernel, not about distributions.
Again, did you check the output of "make headers_install" (this is what
distributions are using going forward), and if so, can you give
*specific* examples of what we should add checks and fixes for?



--
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org

2007-06-25 15:28:18

by David Woodhouse

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Mon, 2007-06-25 at 17:17 +0200, Joerg Schilling wrote:
> David Woodhouse <[email protected]> wrote:
> > On Fri, 2007-06-22 at 01:38 +0200, Joerg Schilling wrote:
> A kernel include file that defines an interface to a user space program
> should be self containing (that means that all includes for all non-standard
> types should be done inside these include files). Whether or not C-99
> types are used or not is less important than to use type definitions written
> in clean C so compilers other than gcc may use them.

Yes. In general we try to achieve this. Most header files should include
<asm/types.h>, which tends to define the types we use in terms which
should work in any compiler.

> > Can you be more specific about why this is a problem? Don't
> > we mostly define those crappy types using arch-specific knowledge, as
> > 'int', 'long', etc?
>
> I recommend you to install Sun Studio and to try to compile star or cdrtools
> using Sun Studio by calling "make CCOM_suncc".
>
> ftp://ftp.berlios.de/pub/star/alpha/
> ftp://ftp.berlios.de/pub/cdrecord/alpha/
>
> You may need to hand edit the file incs/<arch-dir>/{xconfig.h!rules.conf}
>
> in order to enable the auto-disabled features.
>
> In any case, self reading the error messages from Sun Studio helps more than
> trying to discuss it.

I have no interest in doing this for myself, and I suspect that if I
tried it I'd find that Sun Studio doesn't exist for Linux/PowerPC
anyway. Please just show the error messages.

--
dwmw2

2007-06-25 15:31:49

by Robert P. J. Day

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Mon, 25 Jun 2007, Arjan van de Ven wrote:

> there is no __KERNEL__ in the "make headers_install"'d kernel headers.

not quite technically true, as "unifdef" isn't smart enough to factor
out __KERNEL__ if it's part of a larger, logical expression involving
the "||" operator. but that's being admittedly nitpicky.

rday

--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

2007-06-25 16:01:48

by David Lang

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Mon, 25 Jun 2007, Joerg Schilling wrote:

> Arnd Bergmann <[email protected]> wrote:
>
>> On Friday 22 June 2007, [email protected] wrote:
>>> this has been discussed many times and the answer is that the kernel is
>>> not gong to change it's side of things to ANSI C.
>>
>> I don't think that's entirely true with regard to the include files.
>> We have always tried not to step on anyone's toes there, e.g. regarding
>> the use of __u32 vs. uint32_t style types. It's certainly desirable
>> to make the kernel headers that are _meant_ for inclusion compatible
>> with standard compilers.
>>
>> Mike Frysinger has posted a few patches that make the installed headers
>> friendlier to strict C99 users. While there was some negative feedback
>> about these patches, it was not about the idea of making the installed
>> headers C99 clean, but rather about the question whether those non-clean
>> parts should be exported in the first place.
>
> Wouldn't it be simpler to ask the developers to deliver their include files
> in a state that is clean for user space programs?

that's what make headers_install does, as others have pointed out.

David Lang

2007-06-25 18:21:06

by Harald Arnesen

[permalink] [raw]
Subject: Re: Linux Kernel include files

David Woodhouse <[email protected]> writes:

>> > Can you be more specific about why this is a problem? Don't
>> > we mostly define those crappy types using arch-specific knowledge, as
>> > 'int', 'long', etc?
>>
>> I recommend you to install Sun Studio and to try to compile star or cdrtools
>> using Sun Studio by calling "make CCOM_suncc".
>>
>> ftp://ftp.berlios.de/pub/star/alpha/
>> ftp://ftp.berlios.de/pub/cdrecord/alpha/
>>
>> You may need to hand edit the file incs/<arch-dir>/{xconfig.h!rules.conf}
>>
>> in order to enable the auto-disabled features.
>>
>> In any case, self reading the error messages from Sun Studio helps more than
>> trying to discuss it.
>
> I have no interest in doing this for myself, and I suspect that if I
> tried it I'd find that Sun Studio doesn't exist for Linux/PowerPC
> anyway. Please just show the error messages.

Apart from the usual whining about GNU make, the error message is:
make: *** No rule to make target `CCOM_suncc'. Stop.

If I actually install smake, as J?rg recommends, the message becomes:
smake: Can't find any source for 'CCOM_suncc'.
smake: Couldn't make 'CCOM_suncc'.
--
Hilsen Harald.

2007-06-25 20:17:50

by Sam Ravnborg

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Mon, Jun 25, 2007 at 04:53:55PM +0200, Joerg Schilling wrote:
>
> star needs "ext2_fs.h". This file is not usable at all on many Linux
> distributions, even with GCC.

I was curious so I did:

$ mkdir ~/foo
$ cd ~/kernel/linux-2.6
$ make INSTALL_HDR_PATH=~/foo
$ cd ~/foo
$ cat j.c
#include <stdio.h>
#include "etx2_fs.h"

main()
{
printf("helloo\n");
}

$ gcc -o j j.c
=> No warning, no errors

$ gcc -ansi -pedantic -o j j.c
In file included from j.c:2:
ext2_fs.h:53:25: warning: ISO C does not permit named variadic macros

$ gcc -ansi -pedantic -std=c99 -o j j.c
In file included from j.c:2:
ext2_fs.h:53:25: warning: ISO C does not permit named variadic macros
j.c:5: warning: return type defaults to ‘int’

Is it this part you are referring to in the above or have I overlooked something?

Sam

2007-06-25 20:28:41

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

Harald Arnesen <[email protected]> wrote:

> David Woodhouse <[email protected]> writes:
>
> >> > Can you be more specific about why this is a problem? Don't
> >> > we mostly define those crappy types using arch-specific knowledge, as
> >> > 'int', 'long', etc?
> >>
> >> I recommend you to install Sun Studio and to try to compile star or cdrtools
> >> using Sun Studio by calling "make CCOM_suncc".
> >>
> >> ftp://ftp.berlios.de/pub/star/alpha/
> >> ftp://ftp.berlios.de/pub/cdrecord/alpha/
> >>
> >> You may need to hand edit the file incs/<arch-dir>/{xconfig.h!rules.conf}
> >>
> >> in order to enable the auto-disabled features.
> >>
> >> In any case, self reading the error messages from Sun Studio helps more than
> >> trying to discuss it.
> >
> > I have no interest in doing this for myself, and I suspect that if I
> > tried it I'd find that Sun Studio doesn't exist for Linux/PowerPC
> > anyway. Please just show the error messages.
>
> Apart from the usual whining about GNU make, the error message is:
> make: *** No rule to make target `CCOM_suncc'. Stop.
>
> If I actually install smake, as J?rg recommends, the message becomes:
> smake: Can't find any source for 'CCOM_suncc'.
> smake: Couldn't make 'CCOM_suncc'.

Well, I was in hope that a small typo (in special as the correct spelling is in
the file README.compile) should not be a problem.

You need to use CCOM=suncc

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-25 20:32:45

by David Woodhouse

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Mon, 2007-06-25 at 22:26 +0200, Joerg Schilling wrote:
> Well, I was in hope that a small typo (in special as the correct
> spelling is in the file README.compile) should not be a problem.
>
> You need to use CCOM=suncc

No, I need someone else to use CCOM=suncc for me. Unless suncc works on
Linux/PowerPC _and_ you find me a few extra hours in the day to deal
with bugs for someone who can't even be bothered to write a coherent bug
report.

--
dwmw2

2007-06-25 21:43:56

by Harald Arnesen

[permalink] [raw]
Subject: Re: Linux Kernel include files

[email protected] (Joerg Schilling) writes:

>> If I actually install smake, as J?rg recommends, the message becomes:
>> smake: Can't find any source for 'CCOM_suncc'.
>> smake: Couldn't make 'CCOM_suncc'.
>
> Well, I was in hope that a small typo (in special as the correct spelling is in
> the file README.compile) should not be a problem.
>
> You need to use CCOM=suncc

Then it (star, I haven't tried cdrtools yes) compiles and links fine.
There must be something wrong with your Linux installation.
--
Hilsen Harald.

2007-06-25 21:49:08

by Harald Arnesen

[permalink] [raw]
Subject: Re: Linux Kernel include files

Harald Arnesen <[email protected]> writes:

> [email protected] (Joerg Schilling) writes:
>
>>> If I actually install smake, as J?rg recommends, the message becomes:
>>> smake: Can't find any source for 'CCOM_suncc'.
>>> smake: Couldn't make 'CCOM_suncc'.
>>
>> Well, I was in hope that a small typo (in special as the correct spelling is in
>> the file README.compile) should not be a problem.
>>
>> You need to use CCOM=suncc
>
> Then it (star, I haven't tried cdrtools yes) compiles and links fine.
> There must be something wrong with your Linux installation.

FYI, cdrtools also compile and link fine with Sun's C compiler.
--
Hilsen Harald.

2007-06-25 21:51:30

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

Harald Arnesen <[email protected]> wrote:

> Harald Arnesen <[email protected]> writes:
>
> > [email protected] (Joerg Schilling) writes:
> >
> >>> If I actually install smake, as J?rg recommends, the message becomes:
> >>> smake: Can't find any source for 'CCOM_suncc'.
> >>> smake: Couldn't make 'CCOM_suncc'.
> >>
> >> Well, I was in hope that a small typo (in special as the correct spelling is in
> >> the file README.compile) should not be a problem.
> >>
> >> You need to use CCOM=suncc
> >
> > Then it (star, I haven't tried cdrtools yes) compiles and links fine.
> > There must be something wrong with your Linux installation.
>
> FYI, cdrtools also compile and link fine with Sun's C compiler.

Mmmmm, if you call "cdrecord -scanbus", what do you get?

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-25 22:30:51

by Harald Arnesen

[permalink] [raw]
Subject: Re: Linux Kernel include files

[email protected] (Joerg Schilling) writes:

>> FYI, cdrtools also compile and link fine with Sun's C compiler.
>
> Mmmmm, if you call "cdrecord -scanbus", what do you get?

I may have misunderstood your make system. I cd-ed into the cdrtools
directory, ran ./Gmake.linux clean (I had already compiled with GCC),
and then ./Gmake.linux CCOM=suncc. I didn't see any errors at the end of
the make output.

However, what confused me was that the cdrecord binary wasn't removed.
And scrolling back, I see several compile errors from Sun's C compiler.

Shouldn't "make clean" remove the executable files?
--
Hilsen Harald.

2007-06-25 22:44:40

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

Harald Arnesen <[email protected]> wrote:

> [email protected] (Joerg Schilling) writes:
>
> >> FYI, cdrtools also compile and link fine with Sun's C compiler.
> >
> > Mmmmm, if you call "cdrecord -scanbus", what do you get?
>
> I may have misunderstood your make system. I cd-ed into the cdrtools
> directory, ran ./Gmake.linux clean (I had already compiled with GCC),
> and then ./Gmake.linux CCOM=suncc. I didn't see any errors at the end of
> the make output.
>
> However, what confused me was that the cdrecord binary wasn't removed.
> And scrolling back, I see several compile errors from Sun's C compiler.
>
> Shouldn't "make clean" remove the executable files?

make clean only removes the *.o files.

If you call "make relink", all results are removed before recreating.

BTW: your problem is caused by a "bash" bug. With a shell that correctly
works with "sh -ce 'command...'", you would see an abort after the first
error.

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-26 15:38:40

by H. Peter Anvin

[permalink] [raw]
Subject: Re: Linux Kernel include files

Adrian Bunk wrote:
>
> It would certainly help if Joerg would tell what exactly breaks, but I
> spot one likely problem in include/asm-i386/types.h:
>
> #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
> typedef __signed__ long long __s64;
> typedef unsigned long long __u64;
> #endif
>
> It might make sense to remove the #if and simply require that
> a C compiler under Linux must know about the C99 "long long"?
>

Yes.

-hpa

2007-06-27 01:33:14

by Kyle Moffett

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Jun 22, 2007, at 11:00:38, Adrian Bunk wrote:
> It would certainly help if Joerg would tell what exactly breaks,
> but I spot one likely problem in include/asm-i386/types.h:
>
> #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
> typedef __signed__ long long __s64;
> typedef unsigned long long __u64;
> #endif
>
> It might make sense to remove the #if and simply require that a C
> compiler under Linux must know about the C99 "long long"?

Gah, this particular topic and a few other similar header-
compatibility ones show up once a month on LKML; I should probably
just make a patch to fix all the types.h files and be done with it.
The proper solution is this:

# if __STDC_VERSION__ >= 19901L
typedef signed long long __s64;
typedef unsigned long long __u64;
# elif defined(__GNUC__)
__extension__ typedef signed long long __s64;
__extension__ typedef unsigned long long __u64;
# else
# error "Your compiler doesn't support long long (IOW: It sucks).
Please get a new one"
# endif

That way if you have any kind of vaguely-long-long-compatible
compiler then it will work, and otherwise you'll get a nice useful
error message. It also makes sure that GCC doesn't spew warnings/
errors when in c89-pedantic mode. The "__extension__" keyword is
designed for use in implementation header files which want to use GCC-
isms unconditionally.

Cheers,
Kyle Moffett

2007-06-27 14:01:59

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

Sam Ravnborg <[email protected]> wrote:

> On Mon, Jun 25, 2007 at 04:53:55PM +0200, Joerg Schilling wrote:
> >
> > star needs "ext2_fs.h". This file is not usable at all on many Linux
> > distributions, even with GCC.
>
> I was curious so I did:
>
> $ mkdir ~/foo
> $ cd ~/kernel/linux-2.6
> $ make INSTALL_HDR_PATH=~/foo
> $ cd ~/foo
> $ cat j.c
> #include <stdio.h>
> #include "etx2_fs.h"
>
> main()
> {
> printf("helloo\n");
> }
>
> $ gcc -o j j.c
> => No warning, no errors
>

On Suse Linux 10.0, I get e.g.:

cat t.c
#include <stdio.h>
#include <linux/ext2_fs.h>

gcc -c t.c
In file included from /usr/include/linux/ext2_fs.h:20,
from t.c:2:
/usr/include/linux/ext2_fs_sb.h:40: error: syntax error before ?uid_t?
/usr/include/linux/ext2_fs_sb.h:49: error: syntax error before ?s_next_generation?
/usr/include/linux/ext2_fs_sb.h:51: error: syntax error before ?*? token
/usr/include/linux/ext2_fs_sb.h:56: error: syntax error before ?}? token

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-27 14:02:42

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

Harald Arnesen <[email protected]> wrote:

> [email protected] (Joerg Schilling) writes:
>
> >> If I actually install smake, as J?rg recommends, the message becomes:
> >> smake: Can't find any source for 'CCOM_suncc'.
> >> smake: Couldn't make 'CCOM_suncc'.
> >
> > Well, I was in hope that a small typo (in special as the correct spelling is in
> > the file README.compile) should not be a problem.
> >
> > You need to use CCOM=suncc
>
> Then it (star, I haven't tried cdrtools yes) compiles and links fine.
> There must be something wrong with your Linux installation.

Maybe because it automatically deactivates the Linux extensions if the
autoconfiguration sees broken include files. Did you see something like:

checking if Linux include file linux/ext2_fs.h is broken... yes
checking if Linux include file /usr/src/linux/include/linux/ext2_fs.h is broken... yes
checking if Linux include file scsi/scsi.h is broken... no
checking if Linux include file /usr/src/linux/include/scsi/scsi.h is broken... no
checking if Linux include file scsi/sg.h is broken... no
checking if Linux include file /usr/src/linux/include/scsi/sg.h is broken... no

Warning: *** /usr/src/linux/include contains broken include files ***
Warning: *** /usr/src/linux/include is not used this reason ***
Warning: This may result in the inability to use recent Linux kernel interfaces


Warning: *** linux/ext2_fs.h is not usable at all ***
Warning: *** This makes it impossible to support Linux file flags ***
You may try to compile using 'make COPTX=-DTRY_EXT2_FS'

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-27 14:11:58

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

Adrian Bunk <[email protected]> wrote:

> > Personally, I think that's a load of bollocks. And it certainly doesn't
> > apply to Linux-specific files like <linux/cdrom.h>, which are perfectly
> > entitled to use a C standard from last millennium, regardless of
> > namespace 'pollution' issues. That's why we continue to use the crappy
> > __u32 types. Can you be more specific about why this is a problem? Don't
> > we mostly define those crappy types using arch-specific knowledge, as
> > 'int', 'long', etc?
> >...
>
> It would certainly help if Joerg would tell what exactly breaks, but I
> spot one likely problem in include/asm-i386/types.h:
>
> #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
> typedef __signed__ long long __s64;
> typedef unsigned long long __u64;
> #endif
>
> It might make sense to remove the #if and simply require that
> a C compiler under Linux must know about the C99 "long long"?

The Sun compiler did support the long long type before gcc did.
This is not a problem.

I get e.g.:

==> COMPILING "scsihack.o"
"/usr/include/linux/byteorder/little_endian.h", line 43: inline keyword applied to __le64: must be a function identifier
"/usr/include/linux/byteorder/little_endian.h", line 43: syntax error before or at: __cpu_to_le64p
"/usr/include/linux/byteorder/little_endian.h", line 45: operands must have arithmetic type: op "*"
"/usr/include/linux/byteorder/little_endian.h", line 47: syntax error before or at: *
"/usr/include/linux/byteorder/little_endian.h", line 49: undefined symbol: p
"/usr/include/linux/byteorder/little_endian.h", line 49: cannot dereference non-pointer type
"/usr/include/linux/byteorder/little_endian.h", line 67: inline keyword applied to __be64: must be a function identifier
"/usr/include/linux/byteorder/little_endian.h", line 67: syntax error before or at: __cpu_to_be64p
"/usr/include/linux/byteorder/little_endian.h", line 69: syntax error before or at: __swab64p
"/usr/include/linux/byteorder/little_endian.h", line 71: syntax error before or at: *
"/usr/include/linux/byteorder/little_endian.h", line 73: undefined symbol: p
"scsi-linux-sg.c", line 1152: warning: statement not reached
cc: acomp failed for scsihack.c

And it seems that yout proposal did point into the right direction.

After copying /usr/include/linux/types.h to
/opt/sunstudio12/prod/include/cc/linux/types.h and removing all

#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
...
#endif

stuff, I got cdrtools compiled using "suncc" and I did even get a woring
cdrecord.

Thanks for the help!

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-27 15:40:32

by Adrian Bunk

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Tue, Jun 26, 2007 at 09:32:39PM -0400, Kyle Moffett wrote:
> On Jun 22, 2007, at 11:00:38, Adrian Bunk wrote:
>> It would certainly help if Joerg would tell what exactly breaks, but I
>> spot one likely problem in include/asm-i386/types.h:
>>
>> #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
>> typedef __signed__ long long __s64;
>> typedef unsigned long long __u64;
>> #endif
>>
>> It might make sense to remove the #if and simply require that a C compiler
>> under Linux must know about the C99 "long long"?
>
> Gah, this particular topic and a few other similar header-compatibility
> ones show up once a month on LKML; I should probably just make a patch to
> fix all the types.h files and be done with it. The proper solution is
> this:
>
> # if __STDC_VERSION__ >= 19901L
> typedef signed long long __s64;
> typedef unsigned long long __u64;
> # elif defined(__GNUC__)
> __extension__ typedef signed long long __s64;
> __extension__ typedef unsigned long long __u64;
> # else
> # error "Your compiler doesn't support long long (IOW: It sucks). Please
> get a new one"

This part is wrong.

gcc supported "long long" before C99 existed.
And Joerg said the Sun cc supported "long long" before gcc did.

> # endif
>
> That way if you have any kind of vaguely-long-long-compatible compiler then
> it will work, and otherwise you'll get a nice useful error message.

No, consider a pre-C99 gcc version that supports "long long".

> It
> also makes sure that GCC doesn't spew warnings/errors when in c89-pedantic
> mode. The "__extension__" keyword is designed for use in implementation
> header files which want to use GCC-isms unconditionally.

That's a good point I missed.

What about:

#if defined(__GNUC__) && __STDC_VERSION__ < 19901L
__extension__ typedef signed long long __s64;
__extension__ typedef unsigned long long __u64;
#else
typedef signed long long __s64;
typedef unsigned long long __u64;
#endif

> Cheers,
> Kyle Moffett

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2007-06-27 15:54:59

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

Adrian Bunk <[email protected]> wrote:

> That's a good point I missed.
>
> What about:
>
> #if defined(__GNUC__) && __STDC_VERSION__ < 19901L
> __extension__ typedef signed long long __s64;
> __extension__ typedef unsigned long long __u64;
> #else
> typedef signed long long __s64;
> typedef unsigned long long __u64;
> #endif

What about using:

#if (defined(__GNUC__) || defined(__SUNPRO_C)) && !defined(__STRICT_ANSI__)

Well, there seems to be one other compiler (the one from Intel).
It may be that if this compiler does not claim to be GCC, another
definituion needs to be added.

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-27 16:03:17

by Robert P. J. Day

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Wed, 27 Jun 2007, Joerg Schilling wrote:

> Adrian Bunk <[email protected]> wrote:
>
> > That's a good point I missed.
> >
> > What about:
> >
> > #if defined(__GNUC__) && __STDC_VERSION__ < 19901L
> > __extension__ typedef signed long long __s64;
> > __extension__ typedef unsigned long long __u64;
> > #else
> > typedef signed long long __s64;
> > typedef unsigned long long __u64;
> > #endif
>
> What about using:
>
> #if (defined(__GNUC__) || defined(__SUNPRO_C)) && !defined(__STRICT_ANSI__)
>
> Well, there seems to be one other compiler (the one from Intel).
> It may be that if this compiler does not claim to be GCC, another
> definituion needs to be added.

the intel compiler does indeed claim to be gcc.

rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

2007-06-27 16:05:09

by David Woodhouse

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Wed, 2007-06-27 at 16:00 +0200, Joerg Schilling wrote:
> Warning: *** linux/ext2_fs.h is not usable at all ***
> Warning: *** This makes it impossible to support Linux file flags ***
> You may try to compile using 'make COPTX=-DTRY_EXT2_FS'

Again, can you be _specific_? Amusing though your consistent 'Lunix is
broken' chants are, the only reason I'm bothering to participate in this
thread is on the off-chance that something _productive_ will come of it.

By the way, your mailer seems to be sometimes omitting In-Reply-To: and
References: headers, which RFC2822 says you SHOULD include in replies.

--
dwmw2

2007-06-27 16:39:57

by Adrian Bunk

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Wed, Jun 27, 2007 at 03:58:43PM +0200, Joerg Schilling wrote:
> Sam Ravnborg <[email protected]> wrote:
>
> > On Mon, Jun 25, 2007 at 04:53:55PM +0200, Joerg Schilling wrote:
> > >
> > > star needs "ext2_fs.h". This file is not usable at all on many Linux
> > > distributions, even with GCC.
> >
> > I was curious so I did:
> >
> > $ mkdir ~/foo
> > $ cd ~/kernel/linux-2.6
> > $ make INSTALL_HDR_PATH=~/foo
> > $ cd ~/foo
> > $ cat j.c
> > #include <stdio.h>
> > #include "etx2_fs.h"
> >
> > main()
> > {
> > printf("helloo\n");
> > }
> >
> > $ gcc -o j j.c
> > => No warning, no errors
> >
>
> On Suse Linux 10.0, I get e.g.:
>
> cat t.c
> #include <stdio.h>
> #include <linux/ext2_fs.h>
>
> gcc -c t.c
> In file included from /usr/include/linux/ext2_fs.h:20,
> from t.c:2:
> /usr/include/linux/ext2_fs_sb.h:40: error: syntax error before âuid_tâ
> /usr/include/linux/ext2_fs_sb.h:49: error: syntax error before âs_next_generationâ
> /usr/include/linux/ext2_fs_sb.h:51: error: syntax error before â*â token
> /usr/include/linux/ext2_fs_sb.h:56: error: syntax error before â}â token

Already fixed since kernel 2.6.18.

Our header were a mess and we are working on getting them better.
But we can't timetravel and fix old distributions.

> Jörg

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2007-06-27 16:44:58

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

Adrian Bunk <[email protected]> wrote:

> > On Suse Linux 10.0, I get e.g.:
> >
> > cat t.c
> > #include <stdio.h>
> > #include <linux/ext2_fs.h>
> >
> > gcc -c t.c
> > In file included from /usr/include/linux/ext2_fs.h:20,
> > from t.c:2:
> > /usr/include/linux/ext2_fs_sb.h:40: error: syntax error before âuid_tâ
> > /usr/include/linux/ext2_fs_sb.h:49: error: syntax error before âs_next_generationâ
> > /usr/include/linux/ext2_fs_sb.h:51: error: syntax error before â*â token
> > /usr/include/linux/ext2_fs_sb.h:56: error: syntax error before â}â token
>
> Already fixed since kernel 2.6.18.
>
> Our header were a mess and we are working on getting them better.
> But we can't timetravel and fix old distributions.

Well, I did report these kind of problems many years ago and as it has not been
fixed after some years, I was asuming that it is still the way I see it on Suse
10.0.



J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-27 17:17:17

by Sam Ravnborg

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Wed, Jun 27, 2007 at 03:58:43PM +0200, Joerg Schilling wrote:
> Sam Ravnborg <[email protected]> wrote:
>
> > On Mon, Jun 25, 2007 at 04:53:55PM +0200, Joerg Schilling wrote:
> > >
> > > star needs "ext2_fs.h". This file is not usable at all on many Linux
> > > distributions, even with GCC.
> >
> > I was curious so I did:
> >
> > $ mkdir ~/foo
> > $ cd ~/kernel/linux-2.6
> > $ make INSTALL_HDR_PATH=~/foo
> > $ cd ~/foo
> > $ cat j.c
> > #include <stdio.h>
> > #include "etx2_fs.h"
> >
> > main()
> > {
> > printf("helloo\n");
> > }
> >
> > $ gcc -o j j.c
> > => No warning, no errors
> >
>
> On Suse Linux 10.0, I get e.g.:
>
> cat t.c
> #include <stdio.h>
> #include <linux/ext2_fs.h>
>
> gcc -c t.c
> In file included from /usr/include/linux/ext2_fs.h:20,
> from t.c:2:
> /usr/include/linux/ext2_fs_sb.h:40: error: syntax error before ?uid_t?
> /usr/include/linux/ext2_fs_sb.h:49: error: syntax error before ?s_next_generation?
> /usr/include/linux/ext2_fs_sb.h:51: error: syntax error before ?*? token
> /usr/include/linux/ext2_fs_sb.h:56: error: syntax error before ?}? token

Hi J?rg.

For my test I used latest -git of the Linux kernel.
In this version the include of ext2_fs_bh.h is guarded
by __KERNEL__ like this:

#ifdef __KERNEL__
#include <linux/ext2_fs_sb.h>
static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb)
{
return sb->s_fs_info;
}

And therefore the include statement is removed in the exported set of kernel
include files.
So this particular issue is solved with the latest kernel and using the headers
prepared for export.

This tells me that we are on the right track with exporting the headers and sanitize them.

Sam

2007-06-27 17:32:25

by Adrian Bunk

[permalink] [raw]
Subject: Userspace compiler support of "long long"

On Wed, Jun 27, 2007 at 05:52:08PM +0200, Joerg Schilling wrote:
> Adrian Bunk <[email protected]> wrote:
>
> > That's a good point I missed.
> >
> > What about:
> >
> > #if defined(__GNUC__) && __STDC_VERSION__ < 19901L
> > __extension__ typedef signed long long __s64;
> > __extension__ typedef unsigned long long __u64;
> > #else
> > typedef signed long long __s64;
> > typedef unsigned long long __u64;
> > #endif
>
> What about using:
>
> #if (defined(__GNUC__) || defined(__SUNPRO_C)) && !defined(__STRICT_ANSI__)

AFAIR __extension__ was gcc specific.

Does the Sun cc provide options for strict C90 checking?
And if yes, what is it's syntax for disabling this checking for a line
of code?

> Well, there seems to be one other compiler (the one from Intel).
> It may be that if this compiler does not claim to be GCC, another
> definituion needs to be added.

AFAIR the Intel compiler claims to be gcc.

But these are by far not the only C compilers under Linux, and the more
important points are:

Is there any userspace Linux compiler that does not support "long long"?
If yes, is there any other way to tell that something is a
64bit int on 32bit architectures?

> Jörg

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2007-06-27 18:52:17

by Arjan van de Ven

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Wed, 2007-06-27 at 18:41 +0200, Joerg Schilling wrote:

> Well, I did report these kind of problems many years ago and as it has not been
> fixed after some years, I was asuming that it is still the way I see it on Suse
> 10.0.

I'd suggest reporting SuSE bugs to SuSE; that's more effective ;)
(although I don't know how they will deal with bugreports against older
versions)

your bug looks certainly valid.. just you're not using the "proper"
header set that the kernel developers suggest ;)


--
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org

2007-06-27 22:29:38

by H. Peter Anvin

[permalink] [raw]
Subject: Re: Linux Kernel include files

Joerg Schilling wrote:
>
> After copying /usr/include/linux/types.h to
> /opt/sunstudio12/prod/include/cc/linux/types.h and removing all
>
> #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
> ...
> #endif
>
> stuff, I got cdrtools compiled using "suncc" and I did even get a woring
> cdrecord.
>

Indeed, this guard is bogus.

-hpa

2007-06-27 22:31:22

by Kyle Moffett

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Jun 27, 2007, at 13:32:40, Adrian Bunk wrote:
> AFAIR the Intel compiler claims to be gcc.
>
> But these are by far not the only C compilers under Linux, and the
> more important points are:
>
> Is there any userspace Linux compiler that does not support "long
> long"?

Don't know, but I'd guess not.


> If yes, is there any other way to tell that something is a 64bit
> int on 32bit architectures?

Not that I know of. Probably the straight #else conditional is OK.
We should also merge up the types since *EVERY* linux architecture
has these same types:

typedef signed char __s8;
typedef unsigned char __u8;
typedef signed short __s16;
typedef unsigned short __u16;
typedef signed int __s32;
typedef unsigned int __u32;

Then all 64-bit archs have:
typedef signed long __s64;
typedef unsigned long __u64;

While all 32-bit archs have:
typedef signed long long __s64;
typedef unsigned long long __u64;

The only trick is if you care about building 32-bit compat code using
64-bit linux kernel headers. In that case we should probably just
make all archs use "long long" for their 64-bit integers, unless
there's some platform I'm not remembering where "long long" is 128-
bits or bigger. The other benefit is that people could then just use
the printf format "%llu" for 64-bit integers instead of having to
conditionalize it all over the place.

I'm working on a patch now.

Cheers,
Kyle Moffett

2007-06-27 22:36:37

by Bodo Eggert

[permalink] [raw]
Subject: Re: Linux Kernel include files

Arjan van de Ven <[email protected]> wrote:
> On Wed, 2007-06-27 at 18:41 +0200, Joerg Schilling wrote:

>> Well, I did report these kind of problems many years ago and as it has not
>> been fixed after some years, I was asuming that it is still the way I see it
>> on Suse 10.0.
>
> I'd suggest reporting SuSE bugs to SuSE; that's more effective ;)
> (although I don't know how they will deal with bugreports against older
> versions)
>
> your bug looks certainly valid.. just you're not using the "proper"
> header set that the kernel developers suggest ;)

Even though you put the smiley there, it does not seem fair to expect people
to know the latest bits of kernel developement and deployment procedures
unless hanging around on lkml is a requirement for linux users. I'm just
browsing that list, filtering and ignoring a lot. If I didn't do that, I
would not even suspect something like make headers_install to exist, nor
would I try to search for it.

@J?rg: The responsibility to maintain clean headers shifted only recently,
and there is possibly still a lot to do. If you can point out errors, they
can and probably will be fixed. But as you know, having a precise error
message or description does help.
--
W.I.N.D.O.W.S.:
Wireless Intelligent Neohuman Designed for Observation and Worldwide Sabotage
-- http://www.brunching.com/toys/toy-cyborger.html (down)
Fri?, Spammer: [email protected] [email protected]

2007-06-27 22:59:04

by Randy Dunlap

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Wed, 27 Jun 2007 18:30:52 -0400 Kyle Moffett wrote:

> On Jun 27, 2007, at 13:32:40, Adrian Bunk wrote:
> > AFAIR the Intel compiler claims to be gcc.
> >
> > But these are by far not the only C compilers under Linux, and the
> > more important points are:
> >
> > Is there any userspace Linux compiler that does not support "long
> > long"?
>
> Don't know, but I'd guess not.
>
>
> > If yes, is there any other way to tell that something is a 64bit
> > int on 32bit architectures?
>
> Not that I know of. Probably the straight #else conditional is OK.
> We should also merge up the types since *EVERY* linux architecture
> has these same types:
>
> typedef signed char __s8;
> typedef unsigned char __u8;
> typedef signed short __s16;
> typedef unsigned short __u16;
> typedef signed int __s32;
> typedef unsigned int __u32;
>
> Then all 64-bit archs have:
> typedef signed long __s64;
> typedef unsigned long __u64;
>
> While all 32-bit archs have:
> typedef signed long long __s64;
> typedef unsigned long long __u64;
>
> The only trick is if you care about building 32-bit compat code using
> 64-bit linux kernel headers. In that case we should probably just
> make all archs use "long long" for their 64-bit integers, unless
> there's some platform I'm not remembering where "long long" is 128-
> bits or bigger. The other benefit is that people could then just use
> the printf format "%llu" for 64-bit integers instead of having to
> conditionalize it all over the place.
>
> I'm working on a patch now.

LDD3 ch. 11 says that long on Sparc64 is 32 bits.
Same for "ppc" (don't know which power* arch. they mean by that).

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

2007-06-27 23:09:19

by Arjan van de Ven

[permalink] [raw]
Subject: Re: Linux Kernel include files


> @Jörg: The responsibility to maintain clean headers shifted only recently,

yes.. from distro to the kernel ;)

in the old case it was always a distro bug...

> and there is possibly still a lot to do. If you can point out errors, they
> can and probably will be fixed. But as you know, having a precise error
> message or description does help.

absolutely. if you find issues with the "real" kernel headers (eg the
make headers_install ones) ... as you have seen there's lots of interest
to make sure they're as useful as reasonably possible


--
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org

2007-06-27 23:22:21

by Randy Dunlap

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Wed, 27 Jun 2007 15:57:15 -0700 Randy Dunlap wrote:

> On Wed, 27 Jun 2007 18:30:52 -0400 Kyle Moffett wrote:
>
> > On Jun 27, 2007, at 13:32:40, Adrian Bunk wrote:
> > > AFAIR the Intel compiler claims to be gcc.
> > >
> > > But these are by far not the only C compilers under Linux, and the
> > > more important points are:
> > >
> > > Is there any userspace Linux compiler that does not support "long
> > > long"?
> >
> > Don't know, but I'd guess not.
> >
> >
> > > If yes, is there any other way to tell that something is a 64bit
> > > int on 32bit architectures?
> >
> > Not that I know of. Probably the straight #else conditional is OK.
> > We should also merge up the types since *EVERY* linux architecture
> > has these same types:
> >
> > typedef signed char __s8;
> > typedef unsigned char __u8;
> > typedef signed short __s16;
> > typedef unsigned short __u16;
> > typedef signed int __s32;
> > typedef unsigned int __u32;
> >
> > Then all 64-bit archs have:
> > typedef signed long __s64;
> > typedef unsigned long __u64;
> >
> > While all 32-bit archs have:
> > typedef signed long long __s64;
> > typedef unsigned long long __u64;
> >
> > The only trick is if you care about building 32-bit compat code using
> > 64-bit linux kernel headers. In that case we should probably just
> > make all archs use "long long" for their 64-bit integers, unless
> > there's some platform I'm not remembering where "long long" is 128-
> > bits or bigger. The other benefit is that people could then just use
> > the printf format "%llu" for 64-bit integers instead of having to
> > conditionalize it all over the place.
> >
> > I'm working on a patch now.
>
> LDD3 ch. 11 says that long on Sparc64 is 32 bits.
> Same for "ppc" (don't know which power* arch. they mean by that).

Hm, I suppose that table only applies to userspace, not kernel...

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

2007-06-28 00:31:18

by Andi Kleen

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Thursday 28 June 2007 00:30:52 Kyle Moffett wrote:
> On Jun 27, 2007, at 13:32:40, Adrian Bunk wrote:
> > AFAIR the Intel compiler claims to be gcc.
> >
> > But these are by far not the only C compilers under Linux, and the
> > more important points are:
> >
> > Is there any userspace Linux compiler that does not support "long
> > long"?
>
> Don't know, but I'd guess not.

Tendra C and probably lcc. I would guess tinycc too.

> The only trick is if you care about building 32-bit compat code using
> 64-bit linux kernel headers. In that case we should probably just
> make all archs use "long long" for their 64-bit integers, unless
> there's some platform I'm not remembering where "long long" is 128-
> bits or bigger. The other benefit is that people could then just use
> the printf format "%llu" for 64-bit integers instead of having to
> conditionalize it all over the place.
>
> I'm working on a patch now.

Changing this will give you a zillion warnings for printk formats.

-Andi

2007-06-28 02:13:00

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Wed, 27 Jun 2007, Randy Dunlap wrote:
> On Wed, 27 Jun 2007 15:57:15 -0700 Randy Dunlap wrote:
> > LDD3 ch. 11 says that long on Sparc64 is 32 bits.
> > Same for "ppc" (don't know which power* arch. they mean by that).
>
> Hm, I suppose that table only applies to userspace, not kernel...

32-bit userspace?

On 64-bit, `long' is 64-bit on all platforms supported by Linux.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2007-06-28 03:17:17

by Kyle McMartin

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Wed, Jun 27, 2007 at 04:16:48PM -0700, Randy Dunlap wrote:
> > LDD3 ch. 11 says that long on Sparc64 is 32 bits.
> > Same for "ppc" (don't know which power* arch. they mean by that).
>
> Hm, I suppose that table only applies to userspace, not kernel...
>

Doing 64-bit Linux non-LP64 would be an interesting exercise in masochism...

2007-06-28 03:58:11

by Matthew Wilcox

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Wed, Jun 27, 2007 at 06:30:52PM -0400, Kyle Moffett wrote:
> Then all 64-bit archs have:
> typedef signed long __s64;
> typedef unsigned long __u64;
>
> While all 32-bit archs have:
> typedef signed long long __s64;
> typedef unsigned long long __u64;

include/asm-parisc/types.h:typedef unsigned long long __u64;

For both 32 and 64-bit.

include/asm-sh64/types.h:typedef unsigned long long __u64;
include/asm-x86_64/types.h:typedef unsigned long long __u64;

So that's three architectures that violate your first assertion.

2007-06-28 04:17:17

by H. Peter Anvin

[permalink] [raw]
Subject: Re: Linux Kernel include files

Kyle Moffett wrote:
>
> Gah, this particular topic and a few other similar header-compatibility
> ones show up once a month on LKML; I should probably just make a patch
> to fix all the types.h files and be done with it. The proper solution
> is this:
>
> # if __STDC_VERSION__ >= 19901L
> typedef signed long long __s64;
> typedef unsigned long long __u64;
> # elif defined(__GNUC__)
> __extension__ typedef signed long long __s64;
> __extension__ typedef unsigned long long __u64;
> # else
> # error "Your compiler doesn't support long long (IOW: It sucks).
> Please get a new one"
> # endif
>
> That way if you have any kind of vaguely-long-long-compatible compiler
> then it will work, and otherwise you'll get a nice useful error
> message. It also makes sure that GCC doesn't spew warnings/errors when
> in c89-pedantic mode. The "__extension__" keyword is designed for use
> in implementation header files which want to use GCC-isms unconditionally.
>

__extension__ should be macroized if so.

However, since something that doesn't have "long long" won't be able to
compile those headers, there is absolutely no reason to not simply use
it -- you get an error message on that line, which is good enough.
There is definitely no reason to use a test like the one above, which is
wrong for several supportable compilers.

-hpa

2007-06-28 04:19:39

by H. Peter Anvin

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

Kyle Moffett wrote:
>>
> The only trick is if you care about building 32-bit compat code using
> 64-bit linux kernel headers. In that case we should probably just make
> all archs use "long long" for their 64-bit integers, unless there's some
> platform I'm not remembering where "long long" is 128-bits or bigger.
> The other benefit is that people could then just use the printf format
> "%llu" for 64-bit integers instead of having to conditionalize it all
> over the place.
>

No, you really don't want to do that, because then u64 != uint64_t on
those platforms.

-hpa

2007-06-28 06:50:19

by Jan Engelhardt

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"


On Jun 28 2007 04:12, Geert Uytterhoeven wrote:
>On Wed, 27 Jun 2007, Randy Dunlap wrote:
>> On Wed, 27 Jun 2007 15:57:15 -0700 Randy Dunlap wrote:
>> > LDD3 ch. 11 says that long on Sparc64 is 32 bits.
>> > Same for "ppc" (don't know which power* arch. they mean by that).
>>
>> Hm, I suppose that table only applies to userspace, not kernel...
>
>32-bit userspace?
>
>On 64-bit, `long' is 64-bit on all platforms supported by Linux.

All types are as wide as the compiler makes them.

Compiler short int long llong
Turbo C 16 16 32 -
GCC -m32 16 32 32 64
GCC -m64 16 32 64 64



Jan
--

2007-06-28 10:30:00

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

David Woodhouse <[email protected]> wrote:

> On Wed, 2007-06-27 at 16:00 +0200, Joerg Schilling wrote:
> > Warning: *** linux/ext2_fs.h is not usable at all ***
> > Warning: *** This makes it impossible to support Linux file flags ***
> > You may try to compile using 'make COPTX=-DTRY_EXT2_FS'
>
> Again, can you be _specific_? Amusing though your consistent 'Lunix is
> broken' chants are, the only reason I'm bothering to participate in this
> thread is on the off-chance that something _productive_ will come of it.

I have been forced to add this test as too many people reported that they
have no been able to compile star on their Linux distribution.


> By the way, your mailer seems to be sometimes omitting In-Reply-To: and
> References: headers, which RFC2822 says you SHOULD include in replies.

Sending such accusation without knowing the reason is not polite.

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-28 10:32:37

by Harald Arnesen

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

Adrian Bunk <[email protected]> writes:

> Is there any userspace Linux compiler that does not support "long long"?
> If yes, is there any other way to tell that something is a
> 64bit int on 32bit architectures?

TenDRA C:

"test.c", line 6: Error:
[ISO 6.5.2]: Illegal type specifier, 'long long', assuming 'long'.

--
Hilsen Harald.

2007-06-28 10:37:28

by David Woodhouse

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Thu, 2007-06-28 at 12:27 +0200, Joerg Schilling wrote:
> David Woodhouse <[email protected]> wrote:
>
> > On Wed, 2007-06-27 at 16:00 +0200, Joerg Schilling wrote:
> > > Warning: *** linux/ext2_fs.h is not usable at all ***
> > > Warning: *** This makes it impossible to support Linux file flags ***
> > > You may try to compile using 'make COPTX=-DTRY_EXT2_FS'
> >
> > Again, can you be _specific_? Amusing though your consistent 'Lunix is
> > broken' chants are, the only reason I'm bothering to participate in this
> > thread is on the off-chance that something _productive_ will come of it.
>
> I have been forced to add this test as too many people reported that they
> have no been able to compile star on their Linux distribution.

But do you not know _why_? What exactly are you testing _for_?

Bug reports which merely say 'is broken' are not helpful.

> > By the way, your mailer seems to be sometimes omitting In-Reply-To: and
> > References: headers, which RFC2822 says you SHOULD include in replies.
>
> Sending such accusation without knowing the reason is not polite.

It's not an accusation -- it's merely an observation. You may not have
noticed that your mailer was misbehaving; now you _do_ know, and if you
care about RFC compliance you might want to fix it. You're not _obliged_
to fix it, of course. I just thought you'd like to know.

--
dwmw2

2007-06-28 10:42:20

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

David Woodhouse <[email protected]> wrote:

> On Thu, 2007-06-28 at 12:27 +0200, Joerg Schilling wrote:
> > David Woodhouse <[email protected]> wrote:
> >
> > > On Wed, 2007-06-27 at 16:00 +0200, Joerg Schilling wrote:
> > > > Warning: *** linux/ext2_fs.h is not usable at all ***
> > > > Warning: *** This makes it impossible to support Linux file flags ***
> > > > You may try to compile using 'make COPTX=-DTRY_EXT2_FS'
> > >
> > > Again, can you be _specific_? Amusing though your consistent 'Lunix is
> > > broken' chants are, the only reason I'm bothering to participate in this
> > > thread is on the off-chance that something _productive_ will come of it.
> >
> > I have been forced to add this test as too many people reported that they
> > have no been able to compile star on their Linux distribution.
>
> But do you not know _why_? What exactly are you testing _for_?
>
> Bug reports which merely say 'is broken' are not helpful.

If you like to know what I test, I encourage you to check the autoconf
scripts. I am testing whether the named include file may be used from a
user space program.

As I did mention already, I was forced to add the test in order to be able to
compile at all.


> > > By the way, your mailer seems to be sometimes omitting In-Reply-To: and
> > > References: headers, which RFC2822 says you SHOULD include in replies.
> >
> > Sending such accusation without knowing the reason is not polite.
>
> It's not an accusation -- it's merely an observation. You may not have
> noticed that your mailer was misbehaving; now you _do_ know, and if you
> care about RFC compliance you might want to fix it. You're not _obliged_
> to fix it, of course. I just thought you'd like to know.

Well there you are: my mailer is definitely NOT missbehaving.
Please do not repeat similar accusations when not knowing the reason.

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-28 10:47:17

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

Harald Arnesen <[email protected]> wrote:

> Adrian Bunk <[email protected]> writes:
>
> > Is there any userspace Linux compiler that does not support "long long"?
> > If yes, is there any other way to tell that something is a
> > 64bit int on 32bit architectures?
>
> TenDRA C:
>
> "test.c", line 6: Error:
> [ISO 6.5.2]: Illegal type specifier, 'long long', assuming 'long'.

You cannot use this compiler for any program that uses an interface that
needs long long.

BTW: C99 requires long long but the Large File summit from 1995 did to the
same since 1995. An 32 bit OS that supports large files cannot have a compiler
that does not support long long.

If TenDRA C does support 64 bit integral type in a different way. TenDRA C
would need to deliver include files that take care about this fact.

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-28 10:49:25

by Joerg.Schilling

[permalink] [raw]
Subject: Re: Linux Kernel include files

Sam Ravnborg <[email protected]> wrote:

> > gcc -c t.c
> > In file included from /usr/include/linux/ext2_fs.h:20,
> > from t.c:2:
> > /usr/include/linux/ext2_fs_sb.h:40: error: syntax error before ?uid_t?
> > /usr/include/linux/ext2_fs_sb.h:49: error: syntax error before ?s_next_generation?
> > /usr/include/linux/ext2_fs_sb.h:51: error: syntax error before ?*? token
> > /usr/include/linux/ext2_fs_sb.h:56: error: syntax error before ?}? token
>
> Hi J?rg.
>
> For my test I used latest -git of the Linux kernel.
> In this version the include of ext2_fs_bh.h is guarded
> by __KERNEL__ like this:
>
> #ifdef __KERNEL__
> #include <linux/ext2_fs_sb.h>
> static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb)
> {
> return sb->s_fs_info;
> }
>

Thank you!

J?rg

--
EMail:[email protected] (home) J?rg Schilling D-13353 Berlin
[email protected] (uni)
[email protected] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

2007-06-28 10:57:16

by Jan-Benedict Glaw

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Thu, 2007-06-28 12:39:57 +0200, Joerg Schilling <[email protected]> wrote:
> > > > By the way, your mailer seems to be sometimes omitting In-Reply-To: and
> > > > References: headers, which RFC2822 says you SHOULD include in replies.
> > >
> > > Sending such accusation without knowing the reason is not polite.
> >
> > It's not an accusation -- it's merely an observation. You may not have
> > noticed that your mailer was misbehaving; now you _do_ know, and if you
> > care about RFC compliance you might want to fix it. You're not _obliged_
> > to fix it, of course. I just thought you'd like to know.
>
> Well there you are: my mailer is definitely NOT missbehaving.
> Please do not repeat similar accusations when not knowing the reason.

Just out of interest: In which cases do you want to break threading?

MfG, JBG

--
Jan-Benedict Glaw [email protected] +49-172-7608481
Signature of: What we do for ourselves dies with us. What we do for
the second : others and the world remains and is immortal. (Albert Pine)


Attachments:
(No filename) (1.07 kB)
signature.asc (189.00 B)
Digital signature
Download all attachments

2007-06-28 11:35:00

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Thu, 28 Jun 2007, Jan Engelhardt wrote:
> On Jun 28 2007 04:12, Geert Uytterhoeven wrote:
> >On Wed, 27 Jun 2007, Randy Dunlap wrote:
> >> On Wed, 27 Jun 2007 15:57:15 -0700 Randy Dunlap wrote:
> >> > LDD3 ch. 11 says that long on Sparc64 is 32 bits.
> >> > Same for "ppc" (don't know which power* arch. they mean by that).
> >>
> >> Hm, I suppose that table only applies to userspace, not kernel...
> >
> >32-bit userspace?
> >
> >On 64-bit, `long' is 64-bit on all platforms supported by Linux.
>
> All types are as wide as the compiler makes them.
>
> Compiler short int long llong
> Turbo C 16 16 32 -
> GCC -m32 16 32 32 64
> GCC -m64 16 32 64 64

We do not support building Linux with Turbo C (or MS Visual C for Win64
P64).

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2007-06-28 11:36:36

by David Woodhouse

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Thu, 2007-06-28 at 13:34 +0200, Geert Uytterhoeven wrote:
> We do not support building Linux with Turbo C (or MS Visual C for
> Win64 P64).

We're talking about types which are exposed to userspace.

--
dwmw2

2007-06-28 11:43:22

by Kyle Moffett

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Jun 27, 2007, at 20:30:42, Andi Kleen wrote:
> On Thursday 28 June 2007 00:30:52 Kyle Moffett wrote:
>> The only trick is if you care about building 32-bit compat code
>> using 64-bit linux kernel headers. In that case we should
>> probably just make all archs use "long long" for their 64-bit
>> integers, unless there's some platform I'm not remembering where
>> "long long" is 128-bits or bigger. The other benefit is that
>> people could then just use the printf format "%llu" for 64-bit
>> integers instead of having to conditionalize it all over the place.
>>
>> I'm working on a patch now.
>
> Changing this will give you a zillion warnings for printk formats.

Why? If this were a problem then we'd be getting a zillion warnings
*now* from all the 32-bit archs (which already use "long long" for 64-
bit. This would actually make it _easier_ to get the printk formats
right, as you could always use %ull for 64-bit types without having
to cast for 64-bit platforms.

This is another way to get around the "build 32-bit-compat userspace
on 64-bit kernel headers" problem: It tells GCC to use the
"smallest" available type of the given size, which ends up being
exactly the types we use now. On the other hand, it only works for
GCC which sort of ruins most of the reason for changing the types in
the first place.

typedef signed __s8 __attribute__((__mode__(__QI__)));
typedef unsigned __u8 __attribute__((__mode__(__QI__)));
typedef signed __s16 __attribute__((__mode__(__HI__)));
typedef unsigned __u16 __attribute__((__mode__(__HI__)));
typedef signed __s32 __attribute__((__mode__(__SI__)));
typedef unsigned __u32 __attribute__((__mode__(__SI__)));
typedef signed __s64 __attribute__((__mode__(__DI__)));
typedef unsigned __u64 __attribute__((__mode__(__DI__)));

Cheers,
Kyle Moffett

2007-06-28 11:54:21

by Kyle Moffett

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Jun 27, 2007, at 23:57:54, Matthew Wilcox wrote:
> On Wed, Jun 27, 2007 at 06:30:52PM -0400, Kyle Moffett wrote:
>> Then all 64-bit archs have:
>> typedef signed long __s64;
>> typedef unsigned long __u64;
>>
>> While all 32-bit archs have:
>> typedef signed long long __s64;
>> typedef unsigned long long __u64;
>
> include/asm-parisc/types.h:typedef unsigned long long __u64;
>
> For both 32 and 64-bit.
>
> include/asm-sh64/types.h:typedef unsigned long long __u64;
> include/asm-x86_64/types.h:typedef unsigned long long __u64;
>
> So that's three architectures that violate your first assertion.

Oh, ok, that makes it even easier to say this with certainty:
Changing the other 64-bit archs to use "long long" for their 64-bit
numbers will not cause additional warnings. I'm also almost certain
there are no architectures which use "long long" for 128-bit
integers. (Moreover, I can't find hardly anything which does 128-bit
integers at all).

Cheers,
Kyle Moffett

2007-06-28 12:10:28

by Jakub Jelinek

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Thu, Jun 28, 2007 at 07:53:51AM -0400, Kyle Moffett wrote:
> On Jun 27, 2007, at 23:57:54, Matthew Wilcox wrote:
> >On Wed, Jun 27, 2007 at 06:30:52PM -0400, Kyle Moffett wrote:
> >>Then all 64-bit archs have:
> >>typedef signed long __s64;
> >>typedef unsigned long __u64;
> >>
> >>While all 32-bit archs have:
> >>typedef signed long long __s64;
> >>typedef unsigned long long __u64;
> >
> >include/asm-parisc/types.h:typedef unsigned long long __u64;
> >
> >For both 32 and 64-bit.
> >
> >include/asm-sh64/types.h:typedef unsigned long long __u64;
> >include/asm-x86_64/types.h:typedef unsigned long long __u64;
> >
> >So that's three architectures that violate your first assertion.
>
> Oh, ok, that makes it even easier to say this with certainty:
> Changing the other 64-bit archs to use "long long" for their 64-bit
> numbers will not cause additional warnings. I'm also almost certain
> there are no architectures which use "long long" for 128-bit
> integers. (Moreover, I can't find hardly anything which does 128-bit
> integers at all).

unsigned long and unsigned long long have the same size, precision
and alignment on all LP64 arches, that's true. But they have
different ranks and more importantly they mangle differently in C++.
So, whether some user exposed type uses unsigned long or unsigned long long
is part of the ABI, whether that's size_t, uintptr_t, uint64_t, u_int64_t
or any other type, you can't change it without breaking the ABI.

Jakub

2007-06-28 12:12:27

by Kyle Moffett

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Jun 28, 2007, at 06:26:06, Harald Arnesen wrote:
> Adrian Bunk <[email protected]> writes:
>> Is there any userspace Linux compiler that does not support "long
>> long"? If yes, is there any other way to tell that something is a
>> 64bit int on 32bit architectures?
>
> TenDRA C:
>
> "test.c", line 6: Error:
> [ISO 6.5.2]: Illegal type specifier, 'long long', assuming 'long'.

I can't even find the docs for their "tcc". Their "tchk" appears to
have a "#pragma longlong type allow" or something, so I'd imagine the
same exists for tcc and would be required to build stuff using kernel
headers. On the other hand, their compiler looks so immature that it
does not appear to be worth spending much time worrying about now.
When somebody shows up with a solution for that compiler then we can
look at it at that time.

Cheers,
Kyle Moffett

2007-06-28 12:19:23

by Kyle Moffett

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Jun 28, 2007, at 08:08:03, Jakub Jelinek wrote:
> On Thu, Jun 28, 2007 at 07:53:51AM -0400, Kyle Moffett wrote:
>> Oh, ok, that makes it even easier to say this with certainty:
>> Changing the other 64-bit archs to use "long long" for their 64-
>> bit numbers will not cause additional warnings. I'm also almost
>> certain there are no architectures which use "long long" for 128-
>> bit integers. (Moreover, I can't find hardly anything which does
>> 128-bit integers at all).
>
> unsigned long and unsigned long long have the same size, precision
> and alignment on all LP64 arches, that's true. But they have
> different ranks and more importantly they mangle differently in C+
> +. So, whether some user exposed type uses unsigned long or
> unsigned long long is part of the ABI, whether that's size_t,
> uintptr_t, uint64_t, u_int64_t or any other type, you can't change
> it without breaking the ABI.

That sounds *extraordinarily* broken. Hopefully this would *not*
affect the type of a function which is passed a C "struct" containing
the "long long", right?

Hmm, I guess the question is: Do we support people directly passing
__u64 to C++ functions in userspace? I could understand, perhaps,
passing around structures defined in the kernel headers, but
certainly not the kernel-internal types. The only reason we even
export those is so we can have a private set of bit-size-defined
types with which to define kernel ABI structures.

Cheers,
Kyle Moffett

2007-06-28 12:20:37

by Kyle Moffett

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Jun 28, 2007, at 07:36:14, David Woodhouse wrote:
> On Thu, 2007-06-28 at 13:34 +0200, Geert Uytterhoeven wrote:
>> We do not support building Linux with Turbo C (or MS Visual C for
>> Win64 P64).
>
> We're talking about types which are exposed to userspace.

Yes, and all 64-bit software built using kernel headers must be built
in LP64 mode, anything else is pure insanity. On LP64 (IE: how the
kernel itself is compiled on EVERY 64-bit arch):

char == 8 bits
short == 16 bits
int == 32 bits
long == 64 bits
pointer == 64 bits
long long == 64 bits

On LP32 (IE: how the kernel itself is compiled on EVERY 32-bit arch):

char == 8 bits
short == 16 bits
int == 32 bits
long == 32 bits
pointer == 32 bits
long long == 64 bits

Ergo we can simply require that if you want to use kernel headers you
must be using the same mode as the kernel is compiled in (LP32 or LP64).

The simplest guaranteed-not-to-break way to do this on _every_
supported platform is:
typedef signed char __s8;
typedef unsigned char __s8;
typedef signed short __s16;
typedef unsigned short __s16;
typedef signed int __s32;
typedef unsigned int __s32;
# if __STDC_VERSION__ >= 19901L
typedef signed long long __s64;
typedef unsigned long long __s64;
# elif defined(__GNUC__)
__extension__ typedef signed long long __s64;
__extension__ typedef unsigned long long __s64;
# endif

If you have some other compiler that works under linux *AND* supports
a 64-bit type in non-C99-mode (whether "long long" or something
else), then they are welcome to submit patches to fix it.

Cheers,
Kyle Moffett

2007-06-28 13:49:27

by Jan Engelhardt

[permalink] [raw]
Subject: Re: Linux Kernel include files


On Jun 27 2007 19:18, Sam Ravnborg wrote:
>
>For my test I used latest -git of the Linux kernel.
>In this version the include of ext2_fs_bh.h is guarded
>by __KERNEL__ like this:
>
>#ifdef __KERNEL__
>#include <linux/ext2_fs_sb.h>
>static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb)
>{
> return sb->s_fs_info;
>}
[...]

I'll have to chime in here.
Test program:
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <linux/in.h> /* get IP_FREEBIND */

Creates a lot of error messages.
(Lots of redefinitions.)

$ rpm -q linux-kernel-headers glibc
linux-kernel-headers-2.6.21-7
glibc-2.6-5
(suse 10.3 factory)

So looks like there's still something to do.



Jan
--

2007-06-28 16:00:14

by Mark Brown

[permalink] [raw]
Subject: Re: Userspace compiler support of "long long"

On Thu, Jun 28, 2007 at 08:11:59AM -0400, Kyle Moffett wrote:

> I can't even find the docs for their "tcc". Their "tchk" appears to

tchk is the same thing pretty much with output disabled. There's a HTML
copy of the man page here:

http://www.penguin-soft.com/penguin/man/1/tendracc.html

It's packaged for Debian and therefore Ubuntu and other derived
distributions.

> have a "#pragma longlong type allow" or something, so I'd imagine the
> same exists for tcc and would be required to build stuff using kernel
> headers.

You just need to specify -Ysystem (or some other API selection option)
when building to get it to accept long long. Since TenDRA focuses on
strict standards conformance it defaults to something roughly equivalent
to GCC with -std=c89 -pedantic -Werror and requires the user to
explicitly enable support for any other APIs and features they want to
use.

> On the other hand, their compiler looks so immature that it
> does not appear to be worth spending much time worrying about now.
> When somebody shows up with a solution for that compiler then we can
> look at it at that time.

The compiler is solid enough but old - it predates C99 and has had no
real development since then beyond updating the system include overrides
to work with newer glibc versions.

--
"You grabbed my hand and we fell into it, like a daydream - or a fever."


Attachments:
(No filename) (1.36 kB)
signature.asc (307.00 B)
Digital signature
Download all attachments

2007-06-28 16:15:57

by Jan Engelhardt

[permalink] [raw]
Subject: Re: Linux Kernel include files


On Jun 28 2007 12:57, Jan-Benedict Glaw wrote:
>> >
>> > It's not an accusation -- it's merely an observation. You may not have
>> > noticed that your mailer was misbehaving; now you _do_ know, and if you
>> > care about RFC compliance you might want to fix it. You're not _obliged_
>> > to fix it, of course. I just thought you'd like to know.
>>
>> Well there you are: my mailer is definitely NOT missbehaving.
>> Please do not repeat similar accusations when not knowing the reason.
>
>Just out of interest: In which cases do you want to break threading?

The threading for this thread is ok.


Jan
--

2007-06-29 12:59:39

by David Woodhouse

[permalink] [raw]
Subject: Re: Linux Kernel include files

On Thu, 2007-06-28 at 15:49 +0200, Jan Engelhardt wrote:
> I'll have to chime in here.
> Test program:
> #include <sys/socket.h>
> #include <sys/stat.h>
> #include <sys/types.h>
> #include <arpa/inet.h>
> #include <netinet/in.h>
> #include <errno.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <unistd.h>
> #include <linux/in.h> /* get IP_FREEBIND */
>
> Creates a lot of error messages.
> (Lots of redefinitions.)
>
> $ rpm -q linux-kernel-headers glibc
> linux-kernel-headers-2.6.21-7
> glibc-2.6-5
> (suse 10.3 factory)
>
> So looks like there's still something to do.

Hm, yes. But what? Is it reasonable for people to include <linux/in.h>
and <netinet/in.h> at the same time?

It's suboptimal that they have to include <linux/in.h> for certain
definitions, but that file also provides conflicting definitions of
stuff which exists elsewhere.

Should we split <linux/in.h> into two parts?

--
dwmw2