about summary refs log tree commit diff
path: root/include/atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/atomic.h')
-rw-r--r--include/atomic.h41
1 files changed, 38 insertions, 3 deletions
diff --git a/include/atomic.h b/include/atomic.h
index 8a23f6ee9e..8b76435a81 100644
--- a/include/atomic.h
+++ b/include/atomic.h
@@ -1,5 +1,5 @@
 /* Internal macros for atomic operations for GNU C Library.
-   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -108,7 +108,7 @@
      __typeof (*(mem)) __value = (newvalue);				      \
 									      \
      do									      \
-       __oldval = (*__memp);						      \
+       __oldval = *__memp;						      \
      while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp,   \
 								    __value,  \
 								    __oldval),\
@@ -130,7 +130,7 @@
      __typeof (*(mem)) __value = (value);				      \
 									      \
      do									      \
-       __oldval = (*__memp);						      \
+       __oldval = *__memp;						      \
      while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp,   \
 								    __oldval  \
 								    + __value,\
@@ -141,6 +141,41 @@
 #endif
 
 
+
+#ifndef atomic_max
+# define atomic_max(mem, value) \
+  do {									      \
+    __typeof (*(mem)) __oldval;						      \
+    __typeof (mem) __memp = (mem);					      \
+    __typeof (*(mem)) __value = (value);				      \
+    do {								      \
+      __oldval = *__memp;						      \
+      if (__oldval >= __value)						      \
+	break;								      \
+    } while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp,  \
+								     __value, \
+								     __oldval),\
+			       0));					      \
+  } while (0)
+#endif
+
+#ifndef atomic_min
+# define atomic_min(mem, value) \
+  do {									      \
+    __typeof (*(mem)) __oldval;						      \
+    __typeof (mem) __memp = (mem);					      \
+    __typeof (*(mem)) __value = (value);				      \
+    do {								      \
+      __oldval = *__memp;						      \
+      if (__oldval <= __value)						      \
+	break;								      \
+    } while (__builtin_expect (atomic_compare_and_exchange_bool_acq (__memp,  \
+								     __value, \
+								     __oldval),\
+			       0));					      \
+  } while (0)
+#endif
+
 #ifndef atomic_add
 # define atomic_add(mem, value) (void) atomic_exchange_and_add ((mem), (value))
 #endif