Skip to contentSkip to conversation

multiline string cleanup

PATCH In review J . A . Magallon 3 participants 4 messages Mar 30, 2001 – Apr 2, 2001

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 multiline string cleanup

Hi, kernel developers.

This is one other try to make kernel sources gcc-3.0 friendly. This cleans some muti-line asm strings in checksum.h and floppy.h (this were the only ones reported in my kernel build, perhaps there are more in drivers I do not use).

I have not tested the changes with older binutils, as Alan suggested, but the changes are made following other __asm__ pieces in the kernel. They build with gcc-3.0-20010326 snapshot and binutils-2.10.1.0.2.

BTW, I have a doubt: as assembler is written in the rest of kernel (get, for example, system.h):

static inline unsigned long _get_base(char * addr)

{
    unsigned long __base;
    __asm__("movb %3,%%dh\n\t"
        "movb %2,%%dl\n\t"
        "shll $16,%%edx\n\t"
        "movw %1,%%dx"
        :"=&d" (__base)
        :"m" (*((addr)+2)),
         "m" (*((addr)+4)),
         "m" (*((addr)+7)));
    return __base;
}

the first asm line is not tabbed, the result is:

movb %3,%%dh

	movb %2,%%dl
	shll $16,%%edx
	movw %1,%%dx

so is really format (tabs) so important ?

Patch inlined
=============== patch-mls

include/asm-i386/checksum.h renamed from include/asm-i386/checksum.h.orig +38 -42
@@ -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"
+	"1:\tadcl 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"
+	"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,9 @@
 
 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"
 		: "=r" (sum)
 		: "r" (sum << 16), "0" (sum & 0xffff0000)
 	);
@@ -118,12 +116,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"
 	: "=r" (sum)
 	: "g" (daddr), "g"(saddr), "g"((ntohs(len)<<16)+proto*256), "0"(sum));
     return sum;
@@ -158,19 +155,18 @@
 						     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"
 		: "=&r" (sum)
 		: "r" (saddr), "r" (daddr), 
 		  "r"(htonl(len)), "r"(htonl(proto)), "0"(sum));
include/asm-i386/floppy.h renamed from include/asm-i386/floppy.h.orig +22 -22

50 lines not on this page · raw message

Signature · 4 lines
J.A. Magallon                                          #  Let the source
mailto:[email protected]                              #  be with you, Luke... 

Linux werewolf 2.4.3 #2 SMP Fri Mar 30 15:42:05 CEST 2001 i686
#1 lore raw
Quoted 4 lines · J . A . Magallon

This is one other try to make kernel sources gcc-3.0 friendly. This cleans some muti-line asm strings in checksum.h and floppy.h (this were the only ones reported in my kernel build, perhaps there are more in drivers I do not use).

I surely hope the gcc guys will just remove that silly warning again, because it makes it impossible to write readable inline assembly now.

-Andi

#2 lore raw
In reply to J . A . Magallon
Quoted 8 lines · Andi Kleen
Quoted 4 lines · J . A . Magallon

This is one other try to make kernel sources gcc-3.0 friendly. This cleans some muti-line asm strings in checksum.h and floppy.h (this were the only ones reported in my kernel build, perhaps there are more in drivers I do not use).

I surely hope the gcc guys will just remove that silly warning again, because it makes it impossible to write readable inline assembly now.

If it's a silly warning, then we should turn it off in linux/Makefile. I dunno that the kernel can dictate to gcc here what to do...

Also some multiline string cleanups have already made it into the kernel -- though that is not conclusive, as it may just be maintainer preference.

Jeff

Signature · 3 lines
Jeff Garzik       | May you have warm words on a cold evening,
Building 1024     | a full moon on a dark night,
MandrakeSoft      | and a smooth road all the way to your door.
#3 lore raw
In reply to J . A . Magallon
Quoted 7 lines · Jeff Garzik
Quoted 5 lines · Andi Kleen
Quoted 4 lines · J . A . Magallon

This is one other try to make kernel sources gcc-3.0 friendly. This cleans some muti-line asm strings in checksum.h and floppy.h (this were the only ones reported in my kernel build, perhaps there are more in drivers I do not use).

Quoted 5 lines
Quoted 2 lines

I surely hope the gcc guys will just remove that silly warning again, because it makes it impossible to write readable inline assembly now.

If it's a silly warning, then we should turn it off in linux/Makefile. I dunno that the kernel can dictate to gcc here what to do...

It unfortunately cannot be turned off ATM (it is "deprecation warning" where someone is trying to warn you that the next release of gcc may not support multi line strings anymore).

Quoted 3 lines

Also some multiline string cleanups have already made it into the kernel -- though that is not conclusive, as it may just be maintainer preference.

Longer inline assembly without multi strings is hard to read and very nasty to edit, so I don't see that as a "cleanup", but as a pessimization towards less maintainable code.

-Andi