about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-02-05 07:22:09 +0000
committerUlrich Drepper <drepper@redhat.com>2003-02-05 07:22:09 +0000
commitec609a8e77b592e5f8ef95fd2c1d44015a45d063 (patch)
tree1d77381453eb5a67438d98d6089b2a2cb037f8d6
parentd45e874013d6c45bb5b77a4022555e72357eddcb (diff)
downloadglibc-ec609a8e77b592e5f8ef95fd2c1d44015a45d063.tar.gz
glibc-ec609a8e77b592e5f8ef95fd2c1d44015a45d063.tar.xz
glibc-ec609a8e77b592e5f8ef95fd2c1d44015a45d063.zip
Update.
	* atomic.h: Add a couple more default implementations.
	(atomic_compare_and_exchange_acq): Use
-rw-r--r--nptl/ChangeLog3
-rw-r--r--nptl/atomic.h50
2 files changed, 42 insertions, 11 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index f018cccbb3..215ec8d495 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,6 +1,7 @@
 2003-02-04  Ulrich Drepper  <drepper@redhat.com>
 
-	* atomic.h (atomic_compare_and_exchange_acq): Use
+	* atomic.h: Add a couple more default implementations.
+	(atomic_compare_and_exchange_acq): Use
 	__arch_compare_and_exchange_32_acq in return value definition.  It
 	always exists.
 	(atomic_bit_set): Renamed from atomic_set_bit.
diff --git a/nptl/atomic.h b/nptl/atomic.h
index c8ea95f834..85a43c01e6 100644
--- a/nptl/atomic.h
+++ b/nptl/atomic.h
@@ -60,7 +60,7 @@
      while (atomic_compare_and_exchange_acq (__memp, __oldval + __value,      \
 					     __oldval));		      \
 									      \
-     __value; })
+     __oldval; })
 #endif
 
 
@@ -74,23 +74,53 @@
 #endif
 
 
+#ifndef atomic_increment_and_test
+# define atomic_increment_and_test(mem) \
+  (atomic_exchange_and_add (mem, 1) == 0)
+#endif
+
+
 #ifndef atomic_decrement
 # define atomic_decrement(mem) atomic_add (mem, -1)
 #endif
 
 
+#ifndef atomic_decrement_and_test
+# define atomic_decrement_and_test(mem) \
+  (atomic_exchange_and_add (mem, -1) == 0)
+#endif
+
+
+#ifdef atomic_add_negative
+# define atomic_add_negative(mem, value) \
+  (atomic_exchange_and_add (mem, value) < 0)
+#endif
+
+
+#ifndef atomic_add_zero
+# define atomic_add_zero(mem, value) \
+  (atomic_exchange_and_add (mem, value) == 0)
+#endif
+
+
 #ifndef atomic_bit_set
 # define atomic_bit_set(mem, bit) \
-  (void) ({ __typeof (mem) __memp = (mem);				      \
-	    __typeof (*mem) __mask = (1 << (bit));			      \
-	    __typeof (*mem) __oldval;					      \
+  (void) atomic_bit_test_set(mem, bit)
+#endif
+
+
+#ifndef atomic_bit_test_set
+# define atomic_bit_test_set(mem, bit) \
+  ({ __typeof (*mem) __oldval;						      \
+     __typeof (mem) __memp = (mem);					      \
+     __typeof (*mem) __mask = (1 << (bit));				      \
+									      \
+     do									      \
+       __oldval = (*__memp);						      \
+     while (atomic_compare_and_exchange_acq (__memp,			      \
+					     __oldval | __mask, __oldval));   \
 									      \
-	    do								      \
-	      __oldval = *__memp;					      \
-	     while (atomic_compare_and_exchange_acq (__memp,		      \
-						     __oldval | __mask,	      \
-						     __oldval));	      \
-	      }})
+     __oldval & __mask; })
 #endif