summaryrefslogtreecommitdiff
path: root/glib/gatomic.c
diff options
context:
space:
mode:
authorManish Singh <yosh@gimp.org>2004-03-12 23:22:46 +0000
committerManish Singh <yosh@src.gnome.org>2004-03-12 23:22:46 +0000
commit89242d758b16aedda2b1c445afdf7e6b04fbad02 (patch)
tree2d93b183e42857f294861f9321edc3ec451e677c /glib/gatomic.c
parentfa3dc3e81bcb7c79eca5d25977e19cf5ecce19af (diff)
downloadglib-89242d758b16aedda2b1c445afdf7e6b04fbad02.tar.gz
Non-optimizing compile fails for two asm statements on PowerPC. Use
Fri Mar 12 15:21:22 2004 Manish Singh <yosh@gimp.org> * 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>, fix by Sebastian Wilhelmi. Bug #137006 has a possible alternate solution, but we'll be conservative for now.
Diffstat (limited to 'glib/gatomic.c')
-rw-r--r--glib/gatomic.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/glib/gatomic.c b/glib/gatomic.c
index 65ad743e4..e81e5d095 100644
--- a/glib/gatomic.c
+++ b/glib/gatomic.c
@@ -266,6 +266,9 @@ g_atomic_pointer_compare_and_exchange (gpointer *atomic,
* 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 unknown to the author */
gint
g_atomic_int_exchange_and_add (gint *atomic,
gint val)
@@ -295,6 +298,29 @@ g_atomic_int_add (gint *atomic,
: "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