Patch(?) to linux-2.2.14pre2 asm's to appease gcc-2.95.2

Adam J. Richter (adam@yggdrasil.com)
Wed, 27 Oct 1999 21:38:44 -0700


There are still some __asm__ statements in 2.2.14pre2 that
gcc-2.95.2 on x86 does not like. Here is the patch. The one thing
that makes me a little uncertain about this patch is that, in
in2000.h and seagate.c, I had to change some register classes
from "edi" to "D" and "esi" to "S". Otherwise gcc generated
errors complaining about "incompatible register constraints."
I am not quite sure what the difference is between these register
classes. I would be interested in any feedback on whether or not
I did the right thing.

Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104
adam@yggdrasil.com \ / San Jose, California 95129-1034
+1 408 261-6630 | g g d r a s i l United States of America
fax +1 408 261-6631 "Free Software For The Rest Of Us."

diff -u -r linux-2.2.14pre2/drivers/char/hfmodem/refclock.c linux/drivers/char/hfmodem/refclock.c
--- linux-2.2.14pre2/drivers/char/hfmodem/refclock.c Sat Jul 18 11:47:49 1998
+++ linux/drivers/char/hfmodem/refclock.c Wed Oct 27 22:05:01 1999
@@ -129,12 +129,17 @@
if (rdtsc_ok) {
unsigned int tmp0, tmp1;
unsigned int tmp2, tmp3;
+ unsigned int junk;

- __asm__("rdtsc;\n\t"
+ __asm__ (
+ "rdtsc;\n\t"
"subl %2,%%eax\n\t"
- "sbbl %3,%%edx\n\t" : "=&a" (tmp0), "=&d" (tmp1)
- : "m" (dev->clk.starttime_lo), "m" (dev->clk.starttime_hi) : "ax", "dx");
- __asm__("mull %1" : "=d" (tmp2) : "m" (scale_rdtsc), "a" (tmp0) : "ax");
+ "sbbl %3,%%edx\n\t"
+ : "=&a" (tmp0), "=&d" (tmp1)
+ : "m" (dev->clk.starttime_lo), "m" (dev->clk.starttime_hi));
+ __asm__ __volatile__ ("mull %2"
+ : "=d" (tmp2), "=ax" (junk)
+ : "m" (scale_rdtsc), "a" (tmp0));
__asm__("mull %1" : "=a" (tmp3) : "m" (scale_rdtsc), "a" (tmp1) : "dx");
curtime = tmp2 + tmp3;
goto time_known;
diff -u -r linux-2.2.14pre2/drivers/net/sbni.c linux/drivers/net/sbni.c
--- linux-2.2.14pre2/drivers/net/sbni.c Tue Oct 19 17:14:01 1999
+++ linux/drivers/net/sbni.c Wed Oct 27 22:09:42 1999
@@ -302,6 +302,7 @@

static int sbni_rebuild_header(struct sk_buff *skb)
{
+#if defined(CONFIG_INET) || defined(CONFIG_INET_MODULE)
struct sbni_hard_header *hh = (struct sbni_hard_header *)skb;
/*
* Only ARP/IP is currently supported
@@ -311,7 +312,6 @@
* Try to get ARP to resolve the header.
*/

-#ifdef CONFIG_INET
return arp_find((unsigned char*)hh->h_dest, skb)? 1 : 0;
#else
return 0;
@@ -1359,8 +1359,9 @@

unsigned long calc_crc(char *mem, int len, unsigned initial)
{
+ unsigned long junk0, junk1, junk2;

- __asm__ (
+ __asm__ __volatile__ (
"xorl %%eax,%%eax\n\t"
"1:\n\t"
"lodsb\n\t"
@@ -1369,9 +1370,8 @@
"xorl (%%edi,%%eax,4),%%edx\n\t"
"loop 1b\n\t"
"movl %%edx,%%eax"
- :
+ : "=eax" (junk0), "=edx" (junk1), "=ecx" (junk2)
: "S" (mem), "D" (&crc32tab[0]), "c" (len), "d" (initial)
- : "eax", "edx", "ecx"
);
/* return crc; */
}
diff -u -r linux-2.2.14pre2/drivers/scsi/in2000.h linux/drivers/scsi/in2000.h
--- linux-2.2.14pre2/drivers/scsi/in2000.h Mon Aug 9 12:04:40 1999
+++ linux/drivers/scsi/in2000.h Wed Oct 27 22:35:56 1999
@@ -61,7 +61,8 @@
* 'esi'. Thanks Bill!)
*/

-#define FAST_READ2_IO() \
+#define FAST_READ2_IO() do { \
+ int junk0, junk1; \
__asm__ __volatile__ ("\n \
cld \n \
orl %%ecx, %%ecx \n \
@@ -69,11 +70,12 @@
rep \n \
insw (%%dx),%%es:(%%edi) \n \
1: " \
- : "=D" (sp) /* output */ \
- : "d" (f), "D" (sp), "c" (i) /* input */ \
- : "edx", "ecx", "edi" ) /* trashed */
+ : "=D" (sp), "=edx" (junk0), "=ecx"(junk1) /* output */ \
+ : "d" (f), "D" (sp), "c" (i)); /* input */ \
+ } while (0)

-#define FAST_WRITE2_IO() \
+#define FAST_WRITE2_IO() do { \
+ int junk0, junk1; \
__asm__ __volatile__ ("\n \
cld \n \
orl %%ecx, %%ecx \n \
@@ -81,9 +83,9 @@
rep \n \
outsw %%ds:(%%esi),(%%dx) \n \
1: " \
- : "=S" (sp) /* output */ \
- : "d" (f), "S" (sp), "c" (i) /* input */ \
- : "edx", "ecx", "esi" ) /* trashed */
+ : "=S" (sp), "=edx" (junk0), "=ecx"(junk1) /* output */ \
+ : "d" (f), "S" (sp), "c" (i)); /* input */ \
+ } while (0)


/* IN2000 io_port offsets */
diff -u -r linux-2.2.14pre2/drivers/scsi/seagate.c linux/drivers/scsi/seagate.c
--- linux-2.2.14pre2/drivers/scsi/seagate.c Tue Dec 29 11:40:35 1998
+++ linux/drivers/scsi/seagate.c Wed Oct 27 22:44:08 1999
@@ -734,6 +734,7 @@
struct scatterlist *buffer = NULL;
int clock, temp, nobuffs = 0, done = 0, len = 0;
unsigned long flags;
+ unsigned long junk0, junk1, junk2;

#ifdef DEBUG
int transfered = 0, phase = 0, newphase;
@@ -1169,7 +1170,7 @@

/* SJT: Start. Fast Write */
#ifdef SEAGATE_USE_ASM
- __asm__(
+ __asm__ __volatile__(
"cld\n\t"
#ifdef FAST32
"shr $2, %%ecx\n\t"
@@ -1182,9 +1183,8 @@
"movb %%al, (%%edi)\n\t"
#endif
"loop 1b;"
-/* output */ :
-/* input */ : "D" (phys_to_virt(st0x_dr)), "S" (data), "c" (SCint->transfersize)
-/* clobbered */ : "eax", "ecx", "esi" );
+/* output */ : "=eax" (junk0), "=ecx" (junk1), "=esi" (junk2)
+/* input */ : "D" (phys_to_virt(st0x_dr)), "S" (data), "c" (SCint->transfersize));
#else /* SEAGATE_USE_ASM */
{
#ifdef FAST32
@@ -1223,7 +1223,7 @@
/* Local variables : len = ecx , data = esi,
st0x_cr_sr = ebx, st0x_dr = edi
*/
- __asm__ (
+ __asm__ __volatile__(
/* Test for any data here at all. */
"orl %%ecx, %%ecx\n\t"
"jz 2f\n\t"
@@ -1246,9 +1246,8 @@
"movb %%al, (%%edi)\n\t"
"loop 1b\n\t"
"2:\n"
-/* output */ : "=S" (data), "=c" (len)
-/* input */ : "0" (data), "1" (len), "b" (phys_to_virt(st0x_cr_sr)), "D" (phys_to_virt(st0x_dr))
-/* clobbered */ : "eax", "ebx", "edi");
+/* output */ : "=S" (data), "=c" (len), "=eax" (junk0), "=ebx" (junk1), "=D" (junk2)
+/* input */ : "0" (data), "1" (len), "b" (phys_to_virt(st0x_cr_sr)), "D" (phys_to_virt(st0x_dr)));
#else /* SEAGATE_USE_ASM */
while (len)
{
@@ -1315,7 +1314,7 @@

/* SJT: Start. Fast Read */
#ifdef SEAGATE_USE_ASM
- __asm__(
+ __asm__ __volatile__(
"cld\n\t"
#ifdef FAST32
"shr $2, %%ecx\n\t"
@@ -1328,9 +1327,8 @@
"stosb\n\t"
#endif
"loop 1b\n\t"
-/* output */ :
-/* input */ : "S" (phys_to_virt(st0x_dr)), "D" (data), "c" (SCint->transfersize)
-/* clobbered */ : "eax", "ecx", "edi");
+/* output */ : "=eax" (junk0), "=ecx" (junk1), "=edi" (junk2)
+/* input */ : "S" (phys_to_virt(st0x_dr)), "D" (data), "c" (SCint->transfersize));
#else /* SEAGATE_USE_ASM */
{
#ifdef FAST32
@@ -1380,7 +1378,7 @@
*/
/* Local variables : ecx = len, edi = data
esi = st0x_cr_sr, ebx = st0x_dr */
- __asm__ (
+ __asm__ __volatile__(
/* Test for room to read */
"orl %%ecx, %%ecx\n\t"
"jz 2f\n\t"
@@ -1405,9 +1403,8 @@
"stosb\n\t"
"loop 1b\n\t"
"2:\n"
-/* output */ : "=D" (data), "=c" (len)
-/* input */ : "0" (data), "1" (len), "S" (phys_to_virt(st0x_cr_sr)), "b" (phys_to_virt(st0x_dr))
-/* clobbered */ : "eax","ebx", "esi");
+/* output */ : "=D" (data), "=c" (len), "=eax" (junk0) ,"=ebx" (junk1), "=S" (junk2)
+/* input */ : "0" (data), "1" (len), "S" (phys_to_virt(st0x_cr_sr)), "b" (phys_to_virt(st0x_dr)));
#else /* SEAGATE_USE_ASM */
while (len)
{

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/