This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Silence PPC+ARM preprocessor warnings in atomicity.h


Hi,

I looked at the remaining PPC g++ testsuite fails today and found that they 
are nearly all caused by this warning:

In file included from 
/cvsx/gccmnp/libstdc++-v3/include/bits/basic_string.h:38,
                 from /cvsx/gccmnp/libstdc++-v3/include/bits/std_string.h:42,
                 from /cvsx/gccmnp/libstdc++-v3/include/bits/localefwd.h:38,
                 from /cvsx/gccmnp/libstdc++-v3/include/bits/std_ios.h:41,
                 from /cvsx/gccmnp/libstdc++-v3/include/bits/std_ostream.h:36,
                 from 
/cvsx/gccmnp/libstdc++-v3/include/bits/std_iostream.h:37,
                 from 
/cvsx/gccmnp/libstdc++-v3/include/backward/iostream.h:30,
                 from 
/cvsx/gccmnp/gcc/testsuite/g++.old-deja/g++.benjamin/15071.C:4:
/cvsx/obj/gccmnp/ppc-redhat-linux/libstdc++-v3/include/bits/atomicity.h:30:25: 
multi-line string constant

The fix is simple and appended. I modeled the style after the alpha 
atomicity.h. While I was at it, I fixed the ARM atomicity.h as well, with the 
exception of the missing comments, since I'm not sure if /**/ makes a valid 
assembler comment for ARM.

This patch brings back PPC to the state before the switch to libstdc++-v3/V3 
ABI, with the exception of g++.pt/static11.C, which wasn't failing before:

FAIL: g++.ext/instantiate1.C not instantiated (test for errors, line 18)
FAIL: g++.ext/instantiate1.C not instantiated (test for errors, line 20)
FAIL: g++.other/loop2.C caused compiler crash
FAIL: g++.pt/static11.C  Execution test

OK to commit?

Franz.

        * config/cpu/powerpc/bits/atomicity.h (__exchange_and_add): Silence
        preprocessor multi-line string warnings.
        (__atomic_add): Likewise.
        (__compare_and_swap): Likewise.
        (__always_swap): Likewise.
        (__test_and_set): Likewise.
        * config/cpu/arm/bits/atomicity.h (__exchange_and_add): Likewise.
        (__atomic_add): Likewise.
        (__compare_and_swap): Likewise.
        (__always_swap): Likewise.
        (__test_and_set): Likewise.

Index: libstdc++-v3/config/cpu/powerpc/bits/atomicity.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/config/cpu/powerpc/bits/atomicity.h,v
retrieving revision 1.5
diff -u -p -r1.5 atomicity.h
--- libstdc++-v3/config/cpu/powerpc/bits/atomicity.h	2000/11/27 18:17:40	1.5
+++ libstdc++-v3/config/cpu/powerpc/bits/atomicity.h	2000/11/28 21:05:56
@@ -27,12 +27,17 @@ __attribute__ ((__unused__))
 __exchange_and_add (volatile _Atomic_word* __mem, int __val)
 {
   _Atomic_word __tmp, __res;
-  __asm__ __volatile__ ("\
-0:	lwarx	%0,0,%2
-	add%I3	%1,%0,%3
-	stwcx.	%1,0,%2
-	bne-	0b
-" : "=&b"(__res), "=&r"(__tmp) : "r" (__mem), "Ir"(__val) : "cr0", "memory");
+  __asm__ __volatile__ (
+	"/* Inline exchange & add */\n"
+	"0:\t"
+	"lwarx    %0,0,%2 \n\t"
+	"add%I3   %1,%0,%3 \n\t"
+	"stwcx.   %1,0,%2 \n\t"
+	"bne-     0b \n\t"
+	"/* End exchange & add */"
+	: "=&b"(__res), "=&r"(__tmp)
+	: "r" (__mem), "Ir"(__val)
+	: "cr0", "memory");
   return __res;
 }
 
@@ -41,12 +46,17 @@ __attribute__ ((__unused__))
 __atomic_add (volatile _Atomic_word *__mem, int __val)
 {
   _Atomic_word __tmp;
-  __asm__ __volatile__ ("\
-0:	lwarx	%0,0,%1
-	add%I2	%0,%0,%2
-	stwcx.	%0,0,%1
-	bne-	0b
-" : "=&b"(__tmp) : "r" (__mem), "Ir"(__val) : "cr0", "memory");
+  __asm__ __volatile__ (
+	"/* Inline atomic add */\n"
+	"0:\t"
+	"lwarx    %0,0,%1 \n\t"
+	"add%I2   %0,%0,%2 \n\t"
+	"stwcx.   %0,0,%1 \n\t"
+	"bne-     0b \n\t"
+	"/* End atomic add */"
+	: "=&b"(__tmp)
+	: "r" (__mem), "Ir"(__val)
+	: "cr0", "memory");
 }
 
 static inline int
@@ -54,15 +64,20 @@ __attribute__ ((__unused__))
 __compare_and_swap (volatile long *__p, long int __oldval, long int __newval)
 {
   int __res;
-  __asm__ __volatile__ ("\
-0:	lwarx	%0,0,%1
-	sub%I2c.	%0,%0,%2
-	cntlzw	%0,%0
-	bne-	1f
-	stwcx.	%3,0,%1
-	bne-	0b
-1:
-" : "=&b"(__res) : "r"(__p), "Ir"(__oldval), "r"(__newval) : "cr0", "memory");
+  __asm__ __volatile__ (
+	"/* Inline compare & swap */\n"
+	"0:\t"
+	"lwarx    %0,0,%1  \n\t"
+	"sub%I2c. %0,%0,%2 \n\t"
+	"cntlzw   %0,%0 \n\t"
+	"bne-     1f \n\t"
+	"stwcx.   %3,0,%1 \n\t"
+	"bne-     0b \n"
+	"1:\n\t"
+	"/* End compare & swap */"
+	: "=&b"(__res)
+	: "r"(__p), "Ir"(__oldval), "r"(__newval)
+	: "cr0", "memory");
   return __res >> 5;
 }
 
@@ -71,11 +86,16 @@ __attribute__ ((__unused__))
 __always_swap (volatile long *__p, long int __newval)
 {
   long __res;
-  __asm__ __volatile__ ("\
-0:	lwarx	%0,0,%1
-	stwcx.	%2,0,%1
-	bne-	0b
-" : "=&r"(__res) : "r"(__p), "r"(__newval) : "cr0", "memory");
+  __asm__ __volatile__ (
+	"/* Inline always swap */\n"
+	"0:\t"
+	"lwarx    %0,0,%1 \n\t"
+	"stwcx.   %2,0,%1 \n\t"
+	"bne-     0b \n\t"
+	"/* End always swap */"
+	: "=&r"(__res)
+	: "r"(__p), "r"(__newval)
+	: "cr0", "memory");
   return __res;
 }
 
@@ -84,14 +104,19 @@ __attribute__ ((__unused__))
 __test_and_set (volatile long *__p, long int __newval)
 {
   int __res;
-  __asm__ __volatile__ ("\
-0:	lwarx	%0,0,%1
-	cmpwi	%0,0
-	bne-	1f
-	stwcx.	%2,0,%1
-	bne-	0b
-1:
-" : "=&r"(__res) : "r"(__p), "r"(__newval) : "cr0", "memory");
+  __asm__ __volatile__ (
+	"/* Inline test & set */\n"
+	"0:\t"
+	"lwarx    %0,0,%1 \n\t"
+	"cmpwi    %0,0 \n\t"
+	"bne-     1f \n\t"
+	"stwcx.   %2,0,%1 \n\t"
+	"bne-     0b \n"
+	"1:\n\t"
+	"/* End test & set */"
+	: "=&r"(__res)
+	: "r"(__p), "r"(__newval)
+	: "cr0", "memory");
   return __res;
 }
 
Index: libstdc++-v3/config/cpu/arm/bits/atomicity.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/config/cpu/arm/bits/atomicity.h,v
retrieving revision 1.3
diff -u -p -r1.3 atomicity.h
--- libstdc++-v3/config/cpu/arm/bits/atomicity.h	2000/11/27 20:07:15	1.3
+++ libstdc++-v3/config/cpu/arm/bits/atomicity.h	2000/11/28 21:05:56
@@ -27,16 +27,19 @@ __attribute__ ((__unused__))
 __exchange_and_add (volatile _Atomic_word* __mem, int __val)
 {
   _Atomic_word __tmp, __tmp2, __result;
-  __asm__ __volatile__ ("\
-0:      ldr     %0,[%3]
-        add     %1,%0,%4
-        swp     %2,%1,[%3]
-        cmp     %0,%2
-        swpne   %1,%2,[%3]
-        bne     0b
-" : "=&r"(__result), "=&r"(__tmp), "=&r"(__tmp2) 
-  : "r" (__mem), "r"(__val) 
-  : "cc", "memory");
+  __asm__ __volatile__ (
+	"\n"
+	"0:\t"
+	"ldr     %0,[%3] \n\t"
+	"add     %1,%0,%4 \n\t"
+	"swp     %2,%1,[%3] \n\t"
+	"cmp     %0,%2 \n\t"
+	"swpne   %1,%2,[%3] \n\t"
+	"bne     0b \n\t"
+	""
+	: "=&r"(__result), "=&r"(__tmp), "=&r"(__tmp2) 
+	: "r" (__mem), "r"(__val) 
+	: "cc", "memory");
   return __result;
 }
 
@@ -45,16 +48,19 @@ __attribute__ ((__unused__))
 __atomic_add (volatile _Atomic_word *__mem, int __val)
 {
   _Atomic_word __tmp, __tmp2, __tmp3;
-  __asm__ __volatile__ ("\
-0:      ldr     %0,[%3]
-        add     %1,%0,%4
-        swp     %2,%1,[%3]
-        cmp     %0,%2
-        swpne   %1,%2,[%3]
-        bne     0b
-" : "=&r"(__tmp), "=&r"(__tmp2), "=&r"(__tmp3) 
-  : "r" (__mem), "r"(__val) 
-  : "cc", "memory");
+  __asm__ __volatile__ (
+	"\n"
+	"0:\t"
+	"ldr     %0,[%3] \n\t"
+	"add     %1,%0,%4 \n\t"
+	"swp     %2,%1,[%3] \n\t"
+	"cmp     %0,%2 \n\t"
+	"swpne   %1,%2,[%3] \n\t"
+	"bne     0b \n\t"
+	""
+	: "=&r"(__tmp), "=&r"(__tmp2), "=&r"(__tmp3) 
+	: "r" (__mem), "r"(__val) 
+	: "cc", "memory");
 }
 
 static inline int
@@ -63,20 +69,23 @@ __compare_and_swap (volatile long *__p, 
 {
   int __result;
   long __tmp;
-  __asm__ __volatile__ ("\
-0:      ldr     %1,[%2]
-        mov     %0,#0
-        cmp     %1,%4
-        bne     1f
-        swp     %0,%3,[%2]
-        cmp     %1,%0
-        swpne   %1,%0,[%2]
-        bne     0b
-        mov     %0,#1
-1:
-" : "=&r"(__result), "=&r"(__tmp) 
-  : "r" (__p), "r" (__newval), "r" (__oldval) 
-  : "cc", "memory");
+  __asm__ __volatile__ (
+	"\n"
+	"0:\t"
+	"ldr     %1,[%2] \n\t"
+	"mov     %0,#0 \n\t"
+	"cmp     %1,%4 \n\t"
+	"bne     1f \n\t"
+	"swp     %0,%3,[%2] \n\t"
+	"cmp     %1,%0 \n\t"
+	"swpne   %1,%0,[%2] \n\t"
+	"bne     0b \n\t"
+	"mov     %0,#1 \n"
+	"1:\n\t"
+	""
+	: "=&r"(__result), "=&r"(__tmp) 
+	: "r" (__p), "r" (__newval), "r" (__oldval) 
+	: "cc", "memory");
   return __result;
 }
 
@@ -85,9 +94,13 @@ __attribute__ ((__unused__))
 __always_swap (volatile long *__p, long __newval)
 {
   long __result;
-  __asm__ __volatile__ ("\
-        swp     %0,%2,[%1]
-" : "=&r"(__result) : "r"(__p), "r"(__newval) : "memory");
+  __asm__ __volatile__ (
+	"\n\t"
+	"swp     %0,%2,[%1] \n\t"
+	""
+	: "=&r"(__result)
+	: "r"(__p), "r"(__newval)
+	: "memory");
   return __result;
 }
 
@@ -97,18 +110,21 @@ __test_and_set (volatile long *__p, long
 {
   int __result;
   long __tmp;
-  __asm__ __volatile__ ("\
-0:      ldr     %0,[%2]
-        cmp     %0,#0
-        bne     1f
-        swp     %1,%3,[%2]
-        cmp     %0,%1
-        swpne   %0,%1,[%2]
-        bne     0b
-1:
-" : "=&r"(__result), "=r" (__tmp) 
-  : "r"(__p), "r"(__newval) 
-  : "cc", "memory");
+  __asm__ __volatile__ (
+	"\n"
+	"0:\t"
+	"ldr     %0,[%2] \n\t"
+	"cmp     %0,#0 \n\t"
+	"bne     1f \n\t"
+	"swp     %1,%3,[%2] \n\t"
+	"cmp     %0,%1 \n\t"
+	"swpne   %0,%1,[%2] \n\t"
+	"bne     0b \n"
+	"1:\n\t"
+	""
+	: "=&r"(__result), "=r" (__tmp) 
+	: "r"(__p), "r"(__newval) 
+	: "cc", "memory");
   return __result;
 }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]