* Re: [parisc-linux] gcc (3.3.5) causing problems in our latest kernel.
[not found] <1112564457.5858.7.camel@mulgrave>
@ 2005-04-03 22:13 ` Matthew Wilcox
2005-04-03 23:56 ` James Bottomley
2005-04-03 23:43 ` John David Anglin
1 sibling, 1 reply; 5+ messages in thread
From: Matthew Wilcox @ 2005-04-03 22:13 UTC (permalink / raw)
To: James Bottomley; +Cc: PARISC list
On Sun, Apr 03, 2005 at 04:40:57PM -0500, James Bottomley wrote:
> The problem is that the macros depend on clever optimisation using
> sizeof(*ptr) as an argument to an inline function. The following
> program illustrates the issue:
Perhaps there's a difference between an inline function and a macro
in terms of constant propagation? If you turn __test_width() into
a macro, it should work (see the implementation of __get_user() in
asm-parisc/uaccess.h)
> extern void bad_function(void);
>
> static inline void __test_width(char *var, int size) {
> switch (size) {
> case 1:
> case 2:
> case 4:
> case 8:
> *var++ = 0;
> break;
> default:
> bad_function();
> }
> }
>
> #define test_width(x) __test_width((char *)(x), sizeof(x))
>
> main(int argc, char *argv) {
> int test;
>
> test_width(&test);
> }
>
> If I compile this on an ia64 box, everything is fine:
>
> jejb@titanic> gcc -O2 test.c
> jejb@titanic> gcc -v
> Reading specs from /usr/lib/gcc-lib/ia64-linux/3.3.5/specs
> Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --with-system-libunwind --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc ia64-linux
> Thread model: posix
> gcc version 3.3.5 (Debian 1:3.3.5-8)
>
> But on a parisc system it fails:
>
> jejb@raven> gcc -O2 test.c
> /tmp/cccwaI1E.o(.text+0x60): In function `main':
> : undefined reference to `bad_function'
> collect2: ld returned 1 exit status
> jejb@raven> gcc -v
> Reading specs from /usr/lib/gcc-lib/hppa-linux/3.3.5/specs
> Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-sjlj-exceptions --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc hppa-linux
> Thread model: posix
> gcc version 3.3.5 (Debian 1:3.3.5-5)
>
> Before I have to tell Dave Miller that his clever trick won't work for
> us, is there a way of fixing it?
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [parisc-linux] gcc (3.3.5) causing problems in our latest kernel.
[not found] <1112564457.5858.7.camel@mulgrave>
2005-04-03 22:13 ` [parisc-linux] gcc (3.3.5) causing problems in our latest kernel Matthew Wilcox
@ 2005-04-03 23:43 ` John David Anglin
2005-04-04 0:43 ` Randolph Chung
1 sibling, 1 reply; 5+ messages in thread
From: John David Anglin @ 2005-04-03 23:43 UTC (permalink / raw)
To: James Bottomley; +Cc: parisc-linux
> The problem is that the macros depend on clever optimisation using
> sizeof(*ptr) as an argument to an inline function. The following
> program illustrates the issue:
>
> extern void bad_function(void);
>
> static inline void __test_width(char *var, int size) {
> switch (size) {
> case 1:
> case 2:
> case 4:
> case 8:
> *var++ = 0;
> break;
> default:
> bad_function();
> }
> }
I think the optimization of switch statements is far from optimal.
I suspect that the optimization of if statements is better. A similar
issue causes warning from __put_user in a 32-bit build. Probably,
this should be a GCC PR.
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [parisc-linux] gcc (3.3.5) causing problems in our latest kernel.
2005-04-03 22:13 ` [parisc-linux] gcc (3.3.5) causing problems in our latest kernel Matthew Wilcox
@ 2005-04-03 23:56 ` James Bottomley
2005-04-04 0:07 ` Matthew Wilcox
0 siblings, 1 reply; 5+ messages in thread
From: James Bottomley @ 2005-04-03 23:56 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: PARISC list
On Sun, 2005-04-03 at 23:13 +0100, Matthew Wilcox wrote:
> Perhaps there's a difference between an inline function and a macro
> in terms of constant propagation? If you turn __test_width() into
> a macro, it should work (see the implementation of __get_user() in
> asm-parisc/uaccess.h)
Yes, if I change it to a pure #define, everything works OK.
However, unless we can get the inline function to work, I still have to
go back to davem ... Do I just tell him we can't fix our toolchain, so
how about this?
James
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [parisc-linux] gcc (3.3.5) causing problems in our latest kernel.
2005-04-03 23:56 ` James Bottomley
@ 2005-04-04 0:07 ` Matthew Wilcox
0 siblings, 0 replies; 5+ messages in thread
From: Matthew Wilcox @ 2005-04-04 0:07 UTC (permalink / raw)
To: James Bottomley; +Cc: PARISC list, Matthew Wilcox
On Sun, Apr 03, 2005 at 06:56:28PM -0500, James Bottomley wrote:
> On Sun, 2005-04-03 at 23:13 +0100, Matthew Wilcox wrote:
> > Perhaps there's a difference between an inline function and a macro
> > in terms of constant propagation? If you turn __test_width() into
> > a macro, it should work (see the implementation of __get_user() in
> > asm-parisc/uaccess.h)
>
> Yes, if I change it to a pure #define, everything works OK.
>
> However, unless we can get the inline function to work, I still have to
> go back to davem ... Do I just tell him we can't fix our toolchain, so
> how about this?
Even if we can fix the toolchain, there's going to be a lot of people
out there who'd have to upgrade. I'd prefer it if we didn't have to
force an upgrade ...
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [parisc-linux] gcc (3.3.5) causing problems in our latest kernel.
2005-04-03 23:43 ` John David Anglin
@ 2005-04-04 0:43 ` Randolph Chung
0 siblings, 0 replies; 5+ messages in thread
From: Randolph Chung @ 2005-04-04 0:43 UTC (permalink / raw)
To: John David Anglin; +Cc: James Bottomley, parisc-linux
> > static inline void __test_width(char *var, int size) {
> > switch (size) {
> > case 1:
> > case 2:
> > case 4:
> > case 8:
> > *var++ = 0;
> > break;
> > default:
> > bad_function();
> > }
> > }
>
> I think the optimization of switch statements is far from optimal.
> I suspect that the optimization of if statements is better. A similar
> issue causes warning from __put_user in a 32-bit build. Probably,
> this should be a GCC PR.
Try changing that function to
static inline void __test_width(char *var, const int size) {
willy says it worked for him :)
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-04-04 0:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1112564457.5858.7.camel@mulgrave>
2005-04-03 22:13 ` [parisc-linux] gcc (3.3.5) causing problems in our latest kernel Matthew Wilcox
2005-04-03 23:56 ` James Bottomley
2005-04-04 0:07 ` Matthew Wilcox
2005-04-03 23:43 ` John David Anglin
2005-04-04 0:43 ` Randolph Chung
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox