Re: glib CVS HEAD does not compile on powerpc (gatomic asm problem)



Hi,

> >> Current CVS builds for me on OS X with gcc 3.3 and RH with gcc 3.2.3. So
> >> what version of gcc and what platform are you using?
> > 
> > 
> > debian sid powerpc, I tried both of gcc 3.[23].3. Same error.
> 
> Found it!
>
> -O2 makes the difference. I have optimization turned off locally 
> (because I have a slow machine and compiling is more important for me 
> than running programs)

Good catch. Odd behavior though. I could also reproduce here now and
fixed it with the attached patch. Compiles now for -O2 and no -O

Yosh, could you please commit the patch. I don't have CVS-write-access
right now (and won't have for another week or more)

Bye,
Sebastian
-- 
Sebastian Wilhelmi                 |            här ovanför alla molnen
mailto:seppi seppi de              |     är himmlen så förunderligt blå
http://seppi.de                    |
Index: glib/gatomic.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gatomic.c,v
retrieving revision 1.6
diff -u -b -r1.6 gatomic.c
--- glib/gatomic.c	5 Mar 2004 21:10:45 -0000	1.6
+++ glib/gatomic.c	12 Mar 2004 16:38:17 -0000
@@ -266,6 +266,9 @@
  * and CVS version 1.3 of glibc's sysdeps/powerpc/powerpc32/bits/atomic.h 
  * and CVS version 1.2 of glibc's sysdeps/powerpc/powerpc64/bits/atomic.h 
  */
+#   ifdef __OPTIMIZE__
+/* Non-optimizing compile bails on the following two asm statements
+ * for reasons unkown to the author */
 gint
 g_atomic_int_exchange_and_add (gint *atomic, 
 			       gint val)
@@ -295,6 +298,29 @@
 		    : "b" (atomic), "r" (val), "2" (*atomic)
 		    : "cr0", "memory");
 }
+#   else /* !__OPTIMIZE__ */
+gint
+g_atomic_int_exchange_and_add (gint *atomic, 
+			       gint val)
+{
+  gint result;
+  do
+    result = *atomic;
+  while (!g_atomic_int_compare_and_exchange (atomic, result, result + val));
+
+  return result;
+}
+ 
+void
+g_atomic_int_add (gint *atomic, 
+		  gint val)
+{
+  gint result;
+  do
+    result = *atomic;
+  while (!g_atomic_int_compare_and_exchange (atomic, result, result + val));
+}
+#   endif /* !__OPTIMIZE__ */
 
 #   if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
 gboolean
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/glib/ChangeLog,v
retrieving revision 1.1534
diff -u -b -r1.1534 ChangeLog
--- ChangeLog	9 Mar 2004 14:43:38 -0000	1.1534
+++ ChangeLog	12 Mar 2004 16:38:21 -0000
@@ -1,3 +1,9 @@
+2004-03-12  Sebastian Wilhelmi  <seppi seppi de>
+
+	* glib/gatomic.c: Non-optimizing compile fails for two asm
+	statements on PowerPC. Use generic implementaton for those
+	cases. Spotted by Christof Petig <christof petig-baender de>.
+
 Tue Mar  9 09:16:11 2004  Owen Taylor  <otaylor redhat com>
 
 	* === Released 2.3.6 ===


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]