* [PATCH] gcc 3.0.1 warnings about multi-line literals
@ 2001-10-22 20:05 John Hawkes
2001-10-22 20:15 ` Benjamin LaHaise
0 siblings, 1 reply; 9+ messages in thread
From: John Hawkes @ 2001-10-22 20:05 UTC (permalink / raw)
To: linux-kernel; +Cc: torvalds
This patch eliminates gcc 3.0.1 warnings, "multi-line string literals are
deprecated", in two include/asm-i386 files. Patches cleanly for at least
2.4.10 and 2.4.12, and tested in 2.4.10.
John Hawkes
hawkes@sgi.com
diff -X /build4/hawkes/Build/ignore.dirs -Naur linux-2.4.12/include/asm-i386/checksum.h linux-2.4.12-3.0.1/include/asm-i386/checksum.h
--- linux-2.4.12/include/asm-i386/checksum.h Thu Jul 26 13:41:22 2001
+++ linux-2.4.12-3.0.1/include/asm-i386/checksum.h Mon Oct 22 10:40:14 2001
@@ -69,25 +69,24 @@
unsigned int ihl) {
unsigned int sum;
- __asm__ __volatile__("
- movl (%1), %0
- subl $4, %2
- jbe 2f
- addl 4(%1), %0
- adcl 8(%1), %0
- adcl 12(%1), %0
-1: adcl 16(%1), %0
- lea 4(%1), %1
- decl %2
- jne 1b
- adcl $0, %0
- movl %0, %2
- shrl $16, %0
- addw %w2, %w0
- adcl $0, %0
- notl %0
-2:
- "
+ __asm__ __volatile__(
+ "movl (%1), %0 \n\t" \
+ "subl $4, %2 \n\t" \
+ "jbe 2f \n\t" \
+ "addl 4(%1), %0 \n\t" \
+ "adcl 8(%1), %0 \n\t" \
+ "adcl 12(%1), %0 \n\t" \
+ "1:\t adcl 16(%1), %0 \n\t" \
+ "lea 4(%1), %1 \n\t" \
+ "decl %2 \n\t" \
+ "jne 1b \n\t" \
+ "adcl $0, %0 \n\t" \
+ "movl %0, %2 \n\t" \
+ "shrl $16, %0 \n\t" \
+ "addw %w2, %w0 \n\t" \
+ "adcl $0, %0 \n\t" \
+ "notl %0 \n\t" \
+ "2: "
/* Since the input registers which are loaded with iph and ipl
are modified, we must also specify them as outputs, or gcc
will assume they contain their original values. */
@@ -102,10 +101,8 @@
static inline unsigned int csum_fold(unsigned int sum)
{
- __asm__("
- addl %1, %0
- adcl $0xffff, %0
- "
+ __asm__("addl %1, %0 \n\t" \
+ "adcl $0xffff, %0 \n\t"
: "=r" (sum)
: "r" (sum << 16), "0" (sum & 0xffff0000)
);
@@ -118,12 +115,11 @@
unsigned short proto,
unsigned int sum)
{
- __asm__("
- addl %1, %0
- adcl %2, %0
- adcl %3, %0
- adcl $0, %0
- "
+ __asm__(
+ "addl %1, %0 \n\t" \
+ "adcl %2, %0 \n\t" \
+ "adcl %3, %0 \n\t" \
+ "adcl $0, %0 \n\t"
: "=r" (sum)
: "g" (daddr), "g"(saddr), "g"((ntohs(len)<<16)+proto*256), "0"(sum));
return sum;
@@ -158,19 +154,17 @@
unsigned short proto,
unsigned int sum)
{
- __asm__("
- addl 0(%1), %0
- adcl 4(%1), %0
- adcl 8(%1), %0
- adcl 12(%1), %0
- adcl 0(%2), %0
- adcl 4(%2), %0
- adcl 8(%2), %0
- adcl 12(%2), %0
- adcl %3, %0
- adcl %4, %0
- adcl $0, %0
- "
+ __asm__("addl 0(%1), %0 \n\t" \
+ "adcl 4(%1), %0 \n\t" \
+ "adcl 8(%1), %0 \n\t" \
+ "adcl 12(%1), %0 \n\t" \
+ "adcl 0(%2), %0 \n\t" \
+ "adcl 4(%2), %0 \n\t" \
+ "adcl 8(%2), %0 \n\t" \
+ "adcl 12(%2), %0 \n\t" \
+ "adcl %3, %0 \n\t" \
+ "adcl %4, %0 \n\t" \
+ "adcl $0, %0 \n\t"
: "=&r" (sum)
: "r" (saddr), "r" (daddr),
"r"(htonl(len)), "r"(htonl(proto)), "0"(sum));
diff -X /build4/hawkes/Build/ignore.dirs -Naur linux-2.4.12/include/asm-i386/floppy.h linux-2.4.12-3.0.1/include/asm-i386/floppy.h
--- linux-2.4.12/include/asm-i386/floppy.h Wed Oct 10 23:44:34 2001
+++ linux-2.4.12-3.0.1/include/asm-i386/floppy.h Mon Oct 22 10:44:36 2001
@@ -75,28 +75,28 @@
#ifndef NO_FLOPPY_ASSEMBLER
__asm__ (
- "testl %1,%1
- je 3f
-1: inb %w4,%b0
- andb $160,%b0
- cmpb $160,%b0
- jne 2f
- incw %w4
- testl %3,%3
- jne 4f
- inb %w4,%b0
- movb %0,(%2)
- jmp 5f
-4: movb (%2),%0
- outb %b0,%w4
-5: decw %w4
- outb %0,$0x80
- decl %1
- incl %2
- testl %1,%1
- jne 1b
-3: inb %w4,%b0
-2: "
+ "testl %1,%1 \n\t" \
+ "je 3f \n\t" \
+ "1:\t inb %w4,%b0 \n\t" \
+ "andb $160,%b0 \n\t" \
+ "cmpb $160,%b0 \n\t" \
+ "jne 2f \n\t" \
+ "incw %w4 \n\t" \
+ "testl %3,%3 \n\t" \
+ "jne 4f \n\t" \
+ "inb %w4,%b0 \n\t" \
+ "movb %0,(%2) \n\t" \
+ "jmp 5f \n\t" \
+ "4:\t movb (%2),%0 \n\t" \
+ "outb %b0,%w4 \n\t" \
+ "5:\t decw %w4 \n\t" \
+ "outb %0,$0x80 \n\t" \
+ "decl %1 \n\t" \
+ "incl %2 \n\t" \
+ "testl %1,%1 \n\t" \
+ "jne 1b \n\t" \
+ "3:\t inb %w4,%b0 \n\t" \
+ "2:\n\t"
: "=a" ((char) st),
"=c" ((long) virtual_dma_count),
"=S" ((long) virtual_dma_addr)
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] gcc 3.0.1 warnings about multi-line literals
2001-10-22 20:05 [PATCH] gcc 3.0.1 warnings about multi-line literals John Hawkes
@ 2001-10-22 20:15 ` Benjamin LaHaise
2001-10-22 20:45 ` Alan Cox
2001-10-22 20:51 ` H. Peter Anvin
0 siblings, 2 replies; 9+ messages in thread
From: Benjamin LaHaise @ 2001-10-22 20:15 UTC (permalink / raw)
To: John Hawkes; +Cc: linux-kernel, torvalds
On Mon, Oct 22, 2001 at 01:05:10PM -0700, John Hawkes wrote:
> This patch eliminates gcc 3.0.1 warnings, "multi-line string literals are
> deprecated", in two include/asm-i386 files. Patches cleanly for at least
> 2.4.10 and 2.4.12, and tested in 2.4.10.
Please reject this patch. The gcc folks are wrong in this case.
-ben
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gcc 3.0.1 warnings about multi-line literals
2001-10-22 20:15 ` Benjamin LaHaise
@ 2001-10-22 20:45 ` Alan Cox
2001-10-22 20:51 ` Benjamin LaHaise
2001-10-22 20:51 ` H. Peter Anvin
1 sibling, 1 reply; 9+ messages in thread
From: Alan Cox @ 2001-10-22 20:45 UTC (permalink / raw)
To: Benjamin LaHaise; +Cc: John Hawkes, linux-kernel, torvalds
> On Mon, Oct 22, 2001 at 01:05:10PM -0700, John Hawkes wrote:
> > This patch eliminates gcc 3.0.1 warnings, "multi-line string literals are
> > deprecated", in two include/asm-i386 files. Patches cleanly for at least
> > 2.4.10 and 2.4.12, and tested in 2.4.10.
>
> Please reject this patch. The gcc folks are wrong in this case.
Im curious - why do you make that specific claim. The multiline literals are
rather ugly.
Alan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gcc 3.0.1 warnings about multi-line literals
2001-10-22 20:45 ` Alan Cox
@ 2001-10-22 20:51 ` Benjamin LaHaise
2001-10-22 21:39 ` David S. Miller
2001-10-25 7:11 ` Richard Henderson
0 siblings, 2 replies; 9+ messages in thread
From: Benjamin LaHaise @ 2001-10-22 20:51 UTC (permalink / raw)
To: Alan Cox; +Cc: John Hawkes, linux-kernel, torvalds
On Mon, Oct 22, 2001 at 09:45:36PM +0100, Alan Cox wrote:
> > On Mon, Oct 22, 2001 at 01:05:10PM -0700, John Hawkes wrote:
> > > This patch eliminates gcc 3.0.1 warnings, "multi-line string literals are
> > > deprecated", in two include/asm-i386 files. Patches cleanly for at least
> > > 2.4.10 and 2.4.12, and tested in 2.4.10.
> >
> > Please reject this patch. The gcc folks are wrong in this case.
>
> Im curious - why do you make that specific claim. The multiline literals are
> rather ugly.
Which of the following is more readable:
/* try atomic lock inline, if that fails, spin out of line */
"\tbtsl $1,%0\n"
"\tbne 2f\n"
"1:\n"
"\t.section .text.lock\n\n"
"\t2:\tcmpl $0,%0\n"
"\tbne 2b\n"
"\trep ; nop\n"
"\tjmpl 1b\n\n"
"\t.section .previous\n"
or:
/* try atomic lock inline, if that fails, spin out of line */
" btsl $1,%0
1:
.section .text.lock
2: cmpl $0,%0
bne 2b
jmpl 1b
.section .previous"
or:
while (unlikely(test_and_set_bit(1, lock))) {
while (lock.value)
arch_pause();
}
Ooops, sorry, ignore 3 -- that's only possible in a world where there is
intrinsic support in the compiler to generate the assembly we're aiming
for. But of the two assembly versions, I think the second is much more
readable. The few gcc people I've spoken to locally about this agreed with
me when I showed them some of the inline assembly bits in the two forms as
above.
-ben
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] gcc 3.0.1 warnings about multi-line literals
2001-10-22 20:51 ` Benjamin LaHaise
@ 2001-10-22 21:39 ` David S. Miller
2001-10-23 12:04 ` David Howells
2001-10-25 7:11 ` Richard Henderson
1 sibling, 1 reply; 9+ messages in thread
From: David S. Miller @ 2001-10-22 21:39 UTC (permalink / raw)
To: bcrl; +Cc: alan, hawkes, linux-kernel, torvalds
From: Benjamin LaHaise <bcrl@redhat.com>
Date: Mon, 22 Oct 2001 16:51:57 -0400
On Mon, Oct 22, 2001 at 09:45:36PM +0100, Alan Cox wrote:
> > Please reject this patch. The gcc folks are wrong in this case.
>
> Im curious - why do you make that specific claim. The multiline literals are
> rather ugly.
Which of the following is more readable:
/* try atomic lock inline, if that fails, spin out of line */
"\tbtsl $1,%0\n"
It's only gross because you decided to make it so, try:
"btsl $1,%0\n\t"
Which is what I use just about everywhere now and I'm prefectly
fine with it.
Franks a lot,
David S. Miller
davem@redhat.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gcc 3.0.1 warnings about multi-line literals
2001-10-22 21:39 ` David S. Miller
@ 2001-10-23 12:04 ` David Howells
0 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2001-10-23 12:04 UTC (permalink / raw)
To: David S. Miller; +Cc: bcrl, alan, hawkes, linux-kernel, torvalds
"David S. Miller" <davem@redhat.com> wrote:
> /* try atomic lock inline, if that fails, spin out of line */
> "\tbtsl $1,%0\n"
>
> It's only gross because you decided to make it so, try:
>
> "btsl $1,%0\n\t"
You can also do things like:
" btsl $1,%0 \n"
" bne 2f \n"
"1: \n"
" .section .text.lock \n"
" \n"
"2: cmpl $0,%0 \n"
" bne 2b \n"
" rep ; nop \n"
" jmpl 1b \n"
" \n"
" .section .previous \n"
using tabs or spaces to pad out the assembly.
David
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gcc 3.0.1 warnings about multi-line literals
2001-10-22 20:51 ` Benjamin LaHaise
2001-10-22 21:39 ` David S. Miller
@ 2001-10-25 7:11 ` Richard Henderson
2001-10-25 16:47 ` Benjamin LaHaise
1 sibling, 1 reply; 9+ messages in thread
From: Richard Henderson @ 2001-10-25 7:11 UTC (permalink / raw)
To: Benjamin LaHaise; +Cc: Alan Cox, John Hawkes, linux-kernel, torvalds
On Mon, Oct 22, 2001 at 04:51:57PM -0400, Benjamin LaHaise wrote:
> Which of the following is more readable:
[...]
Or (4):
"btsl $0, %0 \n\
1: \n\
.section .text.lock \n\
2: cmpl $0,%0 \n\
bne 2b \n\
jmpl 1b \n\
.previous"
r~
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gcc 3.0.1 warnings about multi-line literals
2001-10-25 7:11 ` Richard Henderson
@ 2001-10-25 16:47 ` Benjamin LaHaise
0 siblings, 0 replies; 9+ messages in thread
From: Benjamin LaHaise @ 2001-10-25 16:47 UTC (permalink / raw)
To: Alan Cox, John Hawkes, linux-kernel, torvalds
On Thu, Oct 25, 2001 at 12:11:50AM -0700, Richard Henderson wrote:
> On Mon, Oct 22, 2001 at 04:51:57PM -0400, Benjamin LaHaise wrote:
> > Which of the following is more readable:
> [...]
>
> Or (4):
>
> "btsl $0, %0 \n\
Is this a long term supported format? It's certainly much better than
the string per line, and if it's going to say around, then I'm willing
to switch.
-ben
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] gcc 3.0.1 warnings about multi-line literals
2001-10-22 20:15 ` Benjamin LaHaise
2001-10-22 20:45 ` Alan Cox
@ 2001-10-22 20:51 ` H. Peter Anvin
1 sibling, 0 replies; 9+ messages in thread
From: H. Peter Anvin @ 2001-10-22 20:51 UTC (permalink / raw)
To: linux-kernel
Followup to: <20011022161527.K23213@redhat.com>
By author: Benjamin LaHaise <bcrl@redhat.com>
In newsgroup: linux.dev.kernel
>
> On Mon, Oct 22, 2001 at 01:05:10PM -0700, John Hawkes wrote:
> > This patch eliminates gcc 3.0.1 warnings, "multi-line string literals are
> > deprecated", in two include/asm-i386 files. Patches cleanly for at least
> > 2.4.10 and 2.4.12, and tested in 2.4.10.
>
> Please reject this patch. The gcc folks are wrong in this case.
>
It's not gcc even, it's C99 which are making these explicitly
deprecated. If you want a string literal which includes \n and are
mapped in that form, do either:
"foo\n"
"bar\n"
"baz\n"
... or ..
"foo\n\
bar\n\
baz"
I usually do the former.
-hpa
--
<hpa@transmeta.com> at work, <hpa@zytor.com> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt <amsp@zytor.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2001-10-25 16:47 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-22 20:05 [PATCH] gcc 3.0.1 warnings about multi-line literals John Hawkes
2001-10-22 20:15 ` Benjamin LaHaise
2001-10-22 20:45 ` Alan Cox
2001-10-22 20:51 ` Benjamin LaHaise
2001-10-22 21:39 ` David S. Miller
2001-10-23 12:04 ` David Howells
2001-10-25 7:11 ` Richard Henderson
2001-10-25 16:47 ` Benjamin LaHaise
2001-10-22 20:51 ` H. Peter Anvin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox