Skip to contentSkip to conversation

gcc 3.0.1 warnings about multi-line literals

PATCH In review John Hawkes 7 participants 9 messages Oct 22, 2001 – Oct 25, 2001

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gcc 3.0.1 warnings about multi-line literals

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
[email protected]

include/asm-i386/checksum.h +36 -42
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
@@ -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));
include/asm-i386/floppy.h +22 -22

50 lines not on this page · raw message

#1 lore raw
Quoted 3 lines · John Hawkes

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

#2 lore raw
Quoted 6 lines · John Hawkes
Quoted 3 lines

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

#3 lore raw
In reply to Benjamin LaHaise
Quoted 9 lines · Alan Cox
Quoted 6 lines · John Hawkes
Quoted 3 lines

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

#4 lore raw

From: Benjamin LaHaise <[email protected]>
Date: Mon, 22 Oct 2001 16:51:57 -0400

Quoted 4 lines · Alan Cox
Quoted 1 line

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
[email protected]

#5 lore raw
Quoted 6 lines · David S. Miller

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

#6 lore raw
In reply to Benjamin LaHaise
Quoted 1 line · Benjamin LaHaise

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~

#7 lore raw
In reply to Benjamin LaHaise
Quoted 7 lines · Richard Henderson
Quoted 1 line · Benjamin LaHaise

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

#8 lore raw
In reply to John Hawkes
Followup to:  <[email protected]>
By author:    Benjamin LaHaise <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 8 lines · John Hawkes
Quoted 3 lines

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

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt	<[email protected]>