stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r292352 - in /incubator/stdcxx/trunk: include/rw/_mutex.h src/i86/atomic.s src/sparc/atomic-64.s
Date Thu, 29 Sep 2005 00:09:28 GMT
Author: sebor
Date: Wed Sep 28 17:09:21 2005
New Revision: 292352

URL: http://svn.apache.org/viewcvs?rev=292352&view=rev
Log:
2005-09-28  Martin Sebor  <sebor@roguewave.com>

	STDCXX-43
	* i86/atomic.s (__rw_atomic_add): renamed to __rw_atomic_add32.
	(__rw_atomic_xchg): renamed to __rw_atomic_xchg32.
	* sparc/atomic-64.s: Ditto.
	* _mutex.h: Simplified by factoring out common code from platform
	specific blocks to a single platform-independent block (wherever
	possible).
	(__rw_atomic_add): renamed to __rw_atomic_add32.
	(__rw_atomic_xchg): renamed to __rw_atomic_xchg32.


Modified:
    incubator/stdcxx/trunk/include/rw/_mutex.h
    incubator/stdcxx/trunk/src/i86/atomic.s
    incubator/stdcxx/trunk/src/sparc/atomic-64.s

Modified: incubator/stdcxx/trunk/include/rw/_mutex.h
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/include/rw/_mutex.h?rev=292352&r1=292351&r2=292352&view=diff
==============================================================================
--- incubator/stdcxx/trunk/include/rw/_mutex.h (original)
+++ incubator/stdcxx/trunk/include/rw/_mutex.h Wed Sep 28 17:09:21 2005
@@ -1,6 +1,7 @@
 /***************************************************************************
  *
- * _mutex.h - Definitions of classes and inline functions providing MT safety
+ * _mutex.h - definitions of classes and inline functions
+ *            for thread safety and atomic operations
  *
  * This is an internal header file used to implement the C++ Standard
  * Library. It should never be #included directly by a program.
@@ -644,89 +645,90 @@
 // modify their argument and return its original value (__ATOMIC_XXX_LONG
 // is misnamed -- it actually operates on an int, not a long)
 
-inline
-int __rw_atomic_preincrement (int &__x, bool)
+inline int
+__rw_atomic_preincrement (int &__x, bool)
 {
     return 1 + __ATOMIC_INCREMENT_LONG (&__x);
 }
 
 
-inline
-unsigned __rw_atomic_preincrement (unsigned &__x, bool)
+inline unsigned
+__rw_atomic_preincrement (unsigned &__x, bool)
 {
     return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (int&, __x),
                                      false);
 }
 
 
-inline
-long __rw_atomic_preincrement (long &__x, bool)
+inline long
+__rw_atomic_preincrement (long &__x, bool)
 {
     return 1 + __ATOMIC_INCREMENT_QUAD (&__x);
 }
 
 
-inline
-unsigned long __rw_atomic_preincrement (unsigned long &__x, bool)
+inline unsigned long
+__rw_atomic_preincrement (unsigned long &__x, bool)
 {
     return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (long&, __x),
                                      false);
 }
 
 
-inline
-int __rw_atomic_predecrement (int &__x, bool)
+inline int
+__rw_atomic_predecrement (int &__x, bool)
 {
     return __ATOMIC_DECREMENT_LONG (&__x) - 1;
 }
 
-inline
-unsigned __rw_atomic_predecrement (unsigned &__x, bool)
+
+inline unsigned
+__rw_atomic_predecrement (unsigned &__x, bool)
 {
     return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (int&, __x),
                                      false);
 }
 
 
-inline
-long __rw_atomic_predecrement (long &__x, bool)
+inline long
+__rw_atomic_predecrement (long &__x, bool)
 {
     return __ATOMIC_DECREMENT_QUAD (&__x) - 1;
 }
 
 
-inline
-unsigned long __rw_atomic_predecrement (unsigned long &__x, bool)
+inline unsigned long
+__rw_atomic_predecrement (unsigned long &__x, bool)
 {
     return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (long&, __x),
                                      false);
 }
 
 
-inline
-int __rw_atomic_exchange (int &__x, int __y, bool)
+inline int
+__rw_atomic_exchange (int &__x, int __y, bool)
 {
     return __ATOMIC_EXCH_LONG (&__x, __y);
 }
 
 
-inline
-unsigned __rw_atomic_exchange (unsigned &__x, unsigned __y, bool)
+inline unsigned
+__rw_atomic_exchange (unsigned &__x, unsigned __y, bool)
 {
     return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (unsigned&, __x),
                                  _RWSTD_STATIC_CAST (int, __y), false);
 }
 
 
-inline
-long __rw_atomic_exchange (long &__x, long __y, bool)
+inline long
+__rw_atomic_exchange (long &__x, long __y, bool)
 {
     return __ATOMIC_EXCH_QUAD (&__x, __y);
 }
 
 
-inline
-unsigned long __rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
+inline unsigned long
+__rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
 {
     return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (long&, __x),
                                  _RWSTD_STATIC_CAST (long, __y), false);
@@ -744,129 +746,119 @@
 // exchange returns the original value, and add returns the incremented
 // value
 
-#  if defined (_LP64)
-
-long __rw_atomic_xchg (long*, long);
-long __rw_atomic_add (long*, long);
 int  __rw_atomic_xchg32 (int*, int);
 int  __rw_atomic_add32 (int*, int);
 
-#  else   // if !defined (_LP64)
-
-int __rw_atomic_xchg32 (int*, int);
-int __rw_atomic_add32 (int*, int);
-
-
-inline long __rw_atomic_xchg (long* __x, long __y)
-{
-    _RWSTD_COMPILE_ASSERT (sizeof (int) == sizeof (long));
-
-    return __rw_atomic_xchg32 (_RWSTD_REINTERPRET_CAST(int*, __x),
-                               _RWSTD_STATIC_CAST (int, __y));
-}
-
-
-inline long __rw_atomic_add (long* __x, long __y)
-{
-    _RWSTD_COMPILE_ASSERT (sizeof (int) == sizeof (long));
+#  if defined (_LP64)
 
-    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (int*, __x),
-                              _RWSTD_STATIC_CAST (int, __y));
-}
+long __rw_atomic_xchg64 (long*, long);
+long __rw_atomic_add64 (long*, long);
 
-#  endif   // _LP64
+#  endif   // !_LP64
 
 }   // extern "C"
 
 
-inline int __rw_atomic_preincrement (int &__x, bool)
+inline int
+__rw_atomic_preincrement (int &__x, bool)
 {
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (int));
     return __rw_atomic_add32 (&__x, 1);
 }
 
 
-inline unsigned __rw_atomic_preincrement (unsigned &__x, bool)
+inline unsigned
+__rw_atomic_preincrement (unsigned &__x, bool)
 {
-    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (int&, __x),
-                                     false);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned));
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (int*, &__x), 1);
 }
 
 
-inline long __rw_atomic_preincrement (long &__x, bool)
+inline int
+__rw_atomic_predecrement (int &__x, bool)
 {
-    return __rw_atomic_add (&__x, 1);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (int));
+    return __rw_atomic_add32 (&__x, -1);
 }
 
 
-inline unsigned long __rw_atomic_preincrement (unsigned long &__x, bool)
+inline unsigned
+__rw_atomic_predecrement (unsigned &__x, bool)
 {
-    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                     false);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned));
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (int*, &__x), -1);
 }
 
-inline int __rw_atomic_predecrement (int &__x, bool)
+
+inline int
+__rw_atomic_exchange (int &__x, int __y, bool)
 {
-    return __rw_atomic_add32 (&__x, -1);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (int));
+    return __rw_atomic_xchg32 (&__x, __y);
 }
 
 
-inline unsigned __rw_atomic_predecrement (unsigned &__x, bool)
+inline unsigned
+__rw_atomic_exchange (unsigned &__x, unsigned __y, bool)
 {
-    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (int&, __x),
-                                     false);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned));
+    return __rw_atomic_xchg32 (_RWSTD_REINTERPRET_CAST (int*, &__x),
+                               _RWSTD_STATIC_CAST (int, __y));
 }
 
+#  if _RWSTD_INT_SIZE < _RWSTD_LONG_SIZE
 
-inline long __rw_atomic_predecrement (long &__x, bool)
+inline long
+__rw_atomic_preincrement (long &__x, bool)
 {
-    return __rw_atomic_add (&__x, -1);
+    _RWSTD_COMPILE_ASSERT (8 == sizeof (long));
+    return __rw_atomic_add64 (&__x, 1);
 }
 
 
-inline unsigned long __rw_atomic_predecrement (unsigned long &__x, bool)
+inline unsigned long
+__rw_atomic_preincrement (unsigned long &__x, bool)
 {
-    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                     false);
+    _RWSTD_COMPILE_ASSERT (8 == sizeof (unsigned long));
+    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (long*, &__x), 1);
 }
 
 
-#    if _RWSTD_LLONG_SIZE == _RWSTD_LONG_SIZE
-
 
-#    endif   // _RWSTD_LLONG_SIZE == _RWSTD_LONG_SIZE
-
-
-inline int __rw_atomic_exchange (int &__x, int __y, bool)
+inline long
+__rw_atomic_predecrement (long &__x, bool)
 {
-    return __rw_atomic_xchg32 (&__x, __y);
+    _RWSTD_COMPILE_ASSERT (8 == sizeof (long));
+    return __rw_atomic_add64 (&__x, -1);
 }
 
 
-inline unsigned __rw_atomic_exchange (unsigned &__x, unsigned __y, bool)
+inline unsigned long
+__rw_atomic_predecrement (unsigned long &__x, bool)
 {
-    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (int&, __x),
-                                 _RWSTD_STATIC_CAST (int, __y), false);
+    _RWSTD_COMPILE_ASSERT (8 == sizeof (unsigned long));
+    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (long*, &__x), -1);
 }
 
 
-inline long __rw_atomic_exchange (long &__x, long __y, bool)
+inline long
+__rw_atomic_exchange (long &__x, long __y, bool)
 {
-    return __rw_atomic_xchg (&__x, __y);
+    _RWSTD_COMPILE_ASSERT (8 == sizeof (long));
+    return __rw_atomic_xchg64 (&__x, __y);
 }
 
 
-inline
-unsigned long __rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
+inline unsigned long
+__rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
 {
-    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                 _RWSTD_STATIC_CAST (long, __y), false);
+    _RWSTD_COMPILE_ASSERT (8 == sizeof (unsigned long));
+    return __rw_atomic_xchg64 (_RWSTD_REINTERPRET_CAST (long*, &__x),
+                               _RWSTD_STATIC_CAST (long, __y));
 }
 
-
-#    if _RWSTD_LLONG_SIZE == _RWSTD_LONG_SIZE
-
-
-#    endif   // _RWSTD_LLONG_SIZE == _RWSTD_LONG_SIZE
+#  endif   // _RWSTD_INT_SIZE < _RWSTD_LONG_SIZE
 
 /********************** AIX **************************************/
 
@@ -879,89 +871,87 @@
 
 _RWSTD_NAMESPACE (__rw) {
 
-inline
-int __rw_atomic_preincrement (int &__x, bool)
+inline int
+__rw_atomic_preincrement (int &__x, bool)
 {
     return fetch_and_add (&__x, 1) + 1;
 }
 
 
-inline
-unsigned __rw_atomic_preincrement (unsigned &__x, bool)
+inline unsigned
+__rw_atomic_preincrement (unsigned &__x, bool)
 {
-  
-    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST(int&, __x),
-                                     false);
+    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (int&, __x));
 }
 
 
-inline
-long __rw_atomic_preincrement (long &__x, bool)
+inline int
+__rw_atomic_predecrement (int &__x, bool)
 {
-    return fetch_and_addlp (&__x, 1) + 1;
+    return fetch_and_add(&__x,-1) - 1;
 }
 
-
-inline
-unsigned long __rw_atomic_preincrement (unsigned long &__x, bool)
+inline unsigned
+__rw_atomic_predecrement (unsigned &__x, bool)
 {
-  return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                   false);
+    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (int&, __x),
+                                     false);
 }
 
 
-inline
-int __rw_atomic_predecrement (int &__x, bool)
+inline int
+__rw_atomic_exchange (int &__x, int __y, bool)
 {
-    return fetch_and_add(&__x,-1) - 1;
-}
+    int __tmp;
 
-inline
-unsigned __rw_atomic_predecrement (unsigned &__x, bool)
-{
-    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (int&, __x),
-                                     false);
+    do {
+        __tmp = __x;
+    } while (!compare_and_swap (&__x, &__tmp, __y));
+
+    return __tmp;
 }
 
 
-inline
-long __rw_atomic_predecrement (long &__x, bool)
+inline unsigned
+__rw_atomic_exchange (unsigned &__x, unsigned __y, bool)
 {
-    return fetch_and_addlp (&__x, -1) - 1;
+    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (int&, __x),
+                                 _RWSTD_STATIC_CAST (int, __y), false);
 }
 
 
-inline
-unsigned long __rw_atomic_predecrement (unsigned long &__x, bool)
+#  if _RWSTD_INT_SIZE < _RWSTD_LONG_SIZE
+
+inline long
+__rw_atomic_preincrement (long &__x, bool)
 {
-    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                     false);
+    return fetch_and_addlp (&__x, 1) + 1;
 }
 
 
-inline
-int __rw_atomic_exchange (int &__x, int __y, bool)
+inline unsigned long
+__rw_atomic_preincrement (unsigned long &__x, bool)
 {
-    int __tmp;
-
-    do {
-        __tmp = __x;
-    } while (!compare_and_swap (&__x, &__tmp, __y));
+  return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (long&, __x),
+                                   false);
+}
 
-    return __tmp;
+inline long
+__rw_atomic_predecrement (long &__x, bool)
+{
+    return fetch_and_addlp (&__x, -1) - 1;
 }
 
 
-inline
-unsigned __rw_atomic_exchange (unsigned &__x, unsigned __y, bool)
+inline unsigned long
+__rw_atomic_predecrement (unsigned long &__x, bool)
 {
-    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (int&, __x),
-                                 _RWSTD_STATIC_CAST (int, __y), false);
+    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (long&, __x),
+                                     false);
 }
 
-
-inline
-long __rw_atomic_exchange (long &__x, long __y, bool)
+inline long
+__rw_atomic_exchange (long &__x, long __y, bool)
 {
     long __tmp;
 
@@ -973,13 +963,16 @@
 }
 
 
-inline
-unsigned long __rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
+inline unsigned long
+__rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
 {
     return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (long&, __x),
                                  _RWSTD_STATIC_CAST (long, __y), false);
 }
 
+#  endif   // _RWSTD_INT_SIZE < _RWSTD_LONG_SIZE
+
+
 /********************** SGI **************************************/
 
 #elif    defined (__sgi) && defined (__host_mips) \
@@ -992,145 +985,157 @@
 _RWSTD_NAMESPACE (__rw) {
 
 
-inline
-unsigned long __rw_atomic_preincrement (unsigned long &__x, bool)
+inline unsigned
+__rw_atomic_preincrement (unsigned &__x, bool)
 {
-    return __add_then_test (&__x, 1);
+    return __add_then_test32 (&__x, 1);
 }
 
 
-inline
-unsigned __rw_atomic_preincrement (unsigned &__x, bool)
+inline int
+__rw_atomic_preincrement (int &__x, bool)
 {
-    return __add_then_test32 (&__x, 1);
+    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (unsigned int&,__x),false);
 }
 
 
-inline
-int __rw_atomic_preincrement (int &__x, bool)
+inline unsigned
+__rw_atomic_predecrement (unsigned &__x, bool)
 {
-    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (unsigned int&,__x),false);
+    return __add_then_test32 (&__x, -1);
 }
 
 
-inline
-long __rw_atomic_preincrement (long &__x, bool)
+inline int
+__rw_atomic_predecrement (int &__x, bool)
 {
-    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST(unsigned long&, __x),
+    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (unsigned &, __x),
                                      false);
 }
 
 
-inline
-unsigned __rw_atomic_predecrement (unsigned &__x, bool)
+inline unsigned
+__rw_atomic_exchange (unsigned &__x, unsigned __y, bool)
 {
-    return __add_then_test32 (&__x, -1);
+    return __test_and_set32 (&__x, __y);
 }
 
 
-inline
-unsigned long __rw_atomic_predecrement (unsigned long &__x, bool)
+inline int
+__rw_atomic_exchange (int &__x, int __y, bool)
 {
-    return __add_then_test (&__x, -1);
+    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (unsigned int&, __x),
+                                 _RWSTD_STATIC_CAST (unsigned int, __y), false);
 }
 
 
-inline
-int __rw_atomic_predecrement (int &__x, bool)
+#  if _RWSTD_INT_SIZE < _RWSTD_LONG_SIZE
+
+inline unsigned long
+__rw_atomic_preincrement (unsigned long &__x, bool)
 {
-    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (unsigned &, __x),
-                                     false);
+    return __add_then_test (&__x, 1);
 }
 
 
-
-inline
-long __rw_atomic_predecrement (long &__x, bool)
+inline long
+__rw_atomic_preincrement (long &__x, bool)
 {
-    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (unsigned long&, __x),
+    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST(unsigned long&,
+                                                             __x),
                                      false);
 }
 
-
-inline
-unsigned long __rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
+inline unsigned long
+__rw_atomic_predecrement (unsigned long &__x, bool)
 {
-    return __test_and_set (&__x, __y);
+    return __add_then_test (&__x, -1);
 }
 
 
-inline
-unsigned __rw_atomic_exchange (unsigned &__x, unsigned __y, bool)
+inline long
+__rw_atomic_predecrement (long &__x, bool)
 {
-    return __test_and_set32 (&__x, __y);
+    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (unsigned long&,
+                                                              __x),
+                                     false);
 }
 
 
-inline
-int __rw_atomic_exchange (int &__x, int __y, bool)
+inline unsigned long
+__rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
 {
-    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (unsigned int&, __x),
-                                 _RWSTD_STATIC_CAST (unsigned int, __y), false);
+    return __test_and_set (&__x, __y);
 }
 
 
-inline
-long __rw_atomic_exchange (long &__x, long __y, bool)
+inline long
+__rw_atomic_exchange (long &__x, long __y, bool)
 {
     return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (unsigned long&, __x),
-                                 _RWSTD_STATIC_CAST (unsigned long, __y), false);
+                                 _RWSTD_STATIC_CAST (unsigned long, __y),
+                                 false);
 }
 
+#  endif   // _RWSTD_INT_SIZE < _RWSTD_LONG_SIZE
+
 /********************** PA-RISC 2.0 ************************************/
 
 #elif defined (_PA_RISC2_0) && !defined (_RWSTD_NO_ATOMIC_OPERATIONS)
 
-// defined in assembler file "atomic-pa2.s"
-// Special constraint: The value of both the argument
-// and the result must not be zero
-extern "C" int __rw_atomic_incr32 (int*);
-extern "C" int __rw_atomic_decr32 (int*);
-extern "C" int __rw_atomic_xchg32 (int*, int);
+extern "C" {
+
+// special constraint: the value of both the argument and the result
+// must not be zero
 
-inline
-int __rw_string_atomic_preincrement (int &__x, bool)
+int __rw_atomic_incr32 (int*);
+int __rw_atomic_decr32 (int*);
+int __rw_atomic_xchg32 (int*, int);
+
+}   // extern "C"
+
+
+inline int
+__rw_string_atomic_preincrement (int &__x, bool)
 {
     return  __rw_atomic_incr32 (&__x);
 }
 
 
-inline
-unsigned __rw_string_atomic_preincrement (unsigned &__x, bool)
+inline unsigned
+__rw_string_atomic_preincrement (unsigned &__x, bool)
 {
   
     return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST(int&, __x),
                                      false);
 }
 
-inline
-int __rw_string_atomic_predecrement (int &__x, bool)
+
+inline int
+__rw_string_atomic_predecrement (int &__x, bool)
 {
     return  __rw_atomic_decr32 (&__x);
 }
 
 
-inline
-unsigned __rw_string_atomic_predecrement (unsigned &__x, bool)
+inline unsigned
+__rw_string_atomic_predecrement (unsigned &__x, bool)
 {
   
     return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST(int&, __x),
                                      false);
 }
 
-inline
-int __rw_string_atomic_exchange (int &__x, int __y, bool)
+
+inline int
+__rw_string_atomic_exchange (int &__x, int __y, bool)
 {
     return __rw_atomic_xchg32 (&__x, __y);
 }
 
 
-inline
-unsigned __rw_string_atomic_exchange (unsigned &__x, unsigned __y, bool)
+inline unsigned
+__rw_string_atomic_exchange (unsigned &__x, unsigned __y, bool)
 {
     return __rw_string_atomic_exchange (_RWSTD_REINTERPRET_CAST(int&, __x),
                                         _RWSTD_STATIC_CAST(int,__y),
@@ -1147,11 +1152,11 @@
 
 char __rw_atomic_add8 (char*, int);
 short __rw_atomic_add16 (short*, short);
-int __rw_atomic_add (int*, int);
+int __rw_atomic_add32 (int*, int);
 
 char __rw_atomic_xchg8 (char*, char);
 short __rw_atomic_xchg16 (short*, short);
-int __rw_atomic_xchg (int*, int);
+int __rw_atomic_xchg32 (int*, int);
 
 }   // extern "C"
 
@@ -1199,14 +1204,16 @@
 inline int
 __rw_atomic_preincrement (int &__x, bool)
 {
-    return __rw_atomic_add (&__x, 1);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (int));
+    return __rw_atomic_add32 (&__x, 1);
 }
 
 
 inline unsigned int
 __rw_atomic_preincrement (unsigned int &__x, bool)
 {
-    return __rw_atomic_add (_RWSTD_REINTERPRET_CAST (int*, &__x), 1);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned int));
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (int*, &__x), 1);
 }
 
 
@@ -1214,17 +1221,15 @@
 __rw_atomic_preincrement (long &__x, bool)
 {
     _RWSTD_COMPILE_ASSERT (sizeof (long) == sizeof (int));
-
-    return __rw_atomic_add (_RWSTD_REINTERPRET_CAST (int*, &__x), 1);
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (int*, &__x), 1);
 }
 
 
 inline unsigned long
 __rw_atomic_preincrement (unsigned long &__x, bool)
 {
-    _RWSTD_COMPILE_ASSERT (sizeof (unsigned long) == sizeof (int));
-
-    return __rw_atomic_add (_RWSTD_REINTERPRET_CAST (int*, &__x), 1);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned long));
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (int*, &__x), 1);
 }
 
 
@@ -1271,30 +1276,32 @@
 inline int
 __rw_atomic_predecrement (int &__x, bool)
 {
-    return __rw_atomic_add (&__x, -1);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (int));
+    return __rw_atomic_add32 (&__x, -1);
 }
 
 
 inline unsigned int
 __rw_atomic_predecrement (unsigned int &__x, bool)
 {
-    return __rw_atomic_add (_RWSTD_REINTERPRET_CAST (int*, &__x), -1);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned int));
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (int*, &__x), -1);
 }
 
 
 inline long
 __rw_atomic_predecrement (long &__x, bool)
 {
-    _RWSTD_COMPILE_ASSERT (sizeof (long) == sizeof (int));
-    return __rw_atomic_add (_RWSTD_REINTERPRET_CAST (int*, &__x), -1);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (long));
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (int*, &__x), -1);
 }
 
 
 inline unsigned long
 __rw_atomic_predecrement (unsigned long &__x, bool)
 {
-    _RWSTD_COMPILE_ASSERT (sizeof (unsigned long) == sizeof (int));
-    return __rw_atomic_add (_RWSTD_REINTERPRET_CAST (int*, &__x), -1);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned long));
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (int*, &__x), -1);
 }
 
 
@@ -1344,33 +1351,35 @@
 inline int
 __rw_atomic_exchange (int &__x, int __y, bool)
 {
-    return __rw_atomic_xchg (&__x, __y);
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (int));
+    return __rw_atomic_xchg32 (&__x, __y);
 }
 
 
 inline unsigned int
 __rw_atomic_exchange (unsigned int &__x, unsigned int __y, bool)
 {
-    return __rw_atomic_xchg (_RWSTD_REINTERPRET_CAST (int*, &__x),
-                             _RWSTD_STATIC_CAST (int, __y));
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned int));
+    return __rw_atomic_xchg32 (_RWSTD_REINTERPRET_CAST (int*, &__x),
+                               _RWSTD_STATIC_CAST (int, __y));
 }
 
 
 inline long
 __rw_atomic_exchange (long &__x, long __y, bool)
 {
-    _RWSTD_COMPILE_ASSERT (sizeof (long) == sizeof (int));
-    return __rw_atomic_xchg (_RWSTD_REINTERPRET_CAST (int*, &__x),
-                             _RWSTD_STATIC_CAST (int, __y));
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (long));
+    return __rw_atomic_xchg32 (_RWSTD_REINTERPRET_CAST (int*, &__x),
+                               _RWSTD_STATIC_CAST (int, __y));
 }
 
 
 inline unsigned long
 __rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
 {
-    _RWSTD_COMPILE_ASSERT (sizeof (unsigned long) == sizeof (int));
-    return __rw_atomic_xchg (_RWSTD_REINTERPRET_CAST (int*, &__x),
-                             _RWSTD_STATIC_CAST (int, __y));
+    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned long));
+    return __rw_atomic_xchg32 (_RWSTD_REINTERPRET_CAST (int*, &__x),
+                               _RWSTD_STATIC_CAST (int, __y));
 }
 
 /********************** WIN 32/64 ************************************/
@@ -1383,225 +1392,54 @@
 // InterlockedExchange atomically sets the value pointed to by the first
 // argument to that of the second argument and returns the original value
 
-inline
-long __rw_atomic_preincrement (long &__x, bool)
-{
-    return InterlockedIncrement (&__x);
-}
-
-
-inline
-unsigned long __rw_atomic_preincrement (unsigned long &__x, bool)
-{
-    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                     false);
-}
-
-
-inline
-int __rw_atomic_preincrement (int &__x, bool)
+inline int
+__rw_atomic_preincrement (int &__x, bool)
 {
     _RWSTD_COMPILE_ASSERT (sizeof __x == sizeof (long));
-
-    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                     false);
+    return InterlockedIncrement (_RWSTD_REINTERPRET_CAST (long*, __x));
 }
 
 
-inline
-unsigned int __rw_atomic_preincrement (unsigned int &__x, bool)
+inline unsigned int
+__rw_atomic_preincrement (unsigned int &__x, bool)
 {
-    _RWSTD_COMPILE_ASSERT (sizeof __x == sizeof (long));
-
     return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (long&, __x),
                                      false);
 }
 
 
-inline
-long __rw_atomic_predecrement (long &__x, bool)
-{
-    return InterlockedDecrement (&__x);
-}
-
-
-inline
-unsigned long __rw_atomic_predecrement (unsigned long &__x, bool)
-{
-    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                     false);
-}
-
-
-inline
-int __rw_atomic_predecrement (int &__x, bool)
+inline int
+__rw_atomic_predecrement (int &__x, bool)
 {
     _RWSTD_COMPILE_ASSERT (sizeof __x == sizeof (long));
-
-    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                     false);
+    return InterlockedDecrement (_RWSTD_REINTERPRET_CAST (long*, __x));
 }
 
 
-inline
-unsigned int __rw_atomic_predecrement (unsigned int &__x, bool)
+inline unsigned int
+__rw_atomic_predecrement (unsigned int &__x, bool)
 {
-    _RWSTD_COMPILE_ASSERT (sizeof __x == sizeof (long));
-
-    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (long&, __x),
+    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (int&, __x),
                                      false);
 }
 
 
-inline
-long __rw_atomic_exchange (long &__x, long __y, bool)
-{
-    return InterlockedExchange (&__x, __y);
-}
-
-
-inline
-unsigned long __rw_atomic_exchange (unsigned long &__x, unsigned long __y,
-                                    bool)
-{
-    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                 _RWSTD_STATIC_CAST (long, __y), false);
-}
-
-
-inline
-int __rw_atomic_exchange (int &__x, int __y, bool)
-{
-    _RWSTD_COMPILE_ASSERT (sizeof __x == sizeof (long));
-
-    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                 _RWSTD_STATIC_CAST (long, __y), false);
-}
-
-
-inline
-unsigned int __rw_atomic_exchange (unsigned int &__x, unsigned int __y, bool)
+inline int
+__rw_atomic_exchange (int &__x, int __y, bool)
 {
     _RWSTD_COMPILE_ASSERT (sizeof __x == sizeof (long));
-
-    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (long&, __x),
-                                 _RWSTD_STATIC_CAST (long, __y), false);
-}
-
-
-inline
-long __rw_atomic_preincrement (long &__x, __rw_mutex_base &__mutex)
-{
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_preincrement (__x, false);
-}
-
-
-inline
-unsigned long __rw_atomic_preincrement (unsigned long   &__x,
-                                        __rw_mutex_base &__mutex)
-{
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_preincrement (__x, false);
-}
-
-
-inline
-int __rw_atomic_preincrement (int &__x, __rw_mutex_base &__mutex)
-{
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_preincrement (__x, false);
-}
-
-
-inline
-unsigned int __rw_atomic_preincrement (unsigned int    &__x,
-                                       __rw_mutex_base &__mutex)
-{
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_preincrement (__x, false);
-}
-
-
-inline
-long __rw_atomic_predecrement (long &__x, __rw_mutex_base &__mutex)
-{
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_predecrement (__x, false);
-}
-
-
-inline
-unsigned long __rw_atomic_predecrement (unsigned long   &__x,
-                                        __rw_mutex_base &__mutex)
-{
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_predecrement (__x, false);
-}
-
-
-inline
-int __rw_atomic_predecrement (int &__x, __rw_mutex_base &__mutex)
-{
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_predecrement (__x, false);
-}
-
-
-inline
-unsigned int __rw_atomic_predecrement (unsigned int    &__x,
-                                       __rw_mutex_base &__mutex)
-{
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_predecrement (__x, false);
-}
-
-inline
-long __rw_atomic_exchange (long &__x, long __y, __rw_mutex_base &__mutex)
-{
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_exchange (__x, __y, false);
-}
-
-
-inline
-unsigned long __rw_atomic_exchange (unsigned long &__x, unsigned long __y,
-                                    __rw_mutex_base &__mutex)
-{
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_exchange (__x, __y, false);
+    return InterlockedExchange (_RWSTD_REINTERPRET_CAST (long*, __x),
+                                _RWSTD_STATIC_CAST (long, __y));
 }
 
 
-inline
-int __rw_atomic_exchange (int &__x, int __y, __rw_mutex_base &__mutex)
-{
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_exchange (__x, __y, false);
-}
-
-
-inline
-unsigned int __rw_atomic_exchange (unsigned int &__x, unsigned int __y,
-                                   __rw_mutex_base &__mutex)
+inline unsigned int
+__rw_atomic_exchange (unsigned int &__x, unsigned int __y, bool)
 {
-    _RWSTD_UNUSED (__mutex);
-
-    return __rw_atomic_exchange (__x, __y, false);
+    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (int&, __x),
+                                 _RWSTD_STATIC_CAST (int, __y), false);
 }
 
-
 /********************** IA64 ******************************************/
 
 #elif defined (__ia64) && !defined (_RWSTD_NO_ATOMIC_OPERATIONS)
@@ -1627,7 +1465,8 @@
 {
     _RWSTD_COMPILE_ASSERT (1 == sizeof (char));
 
-    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x), +1);
+    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x),
+                             +1);
 }
 
 
@@ -1636,7 +1475,8 @@
 {
     _RWSTD_COMPILE_ASSERT (1 == sizeof (signed char));
 
-    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x), +1);
+    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x),
+                             +1);
 }
 
 
@@ -1645,7 +1485,8 @@
 {
     _RWSTD_COMPILE_ASSERT (1 == sizeof (unsigned char));
 
-    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x), +1);
+    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x),
+                             +1);
 }
 
 
@@ -1654,7 +1495,8 @@
 {
     _RWSTD_COMPILE_ASSERT (2 == sizeof (short));
 
-    return __rw_atomic_add16 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT16_T*, &__x), +1);
+    return __rw_atomic_add16 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT16_T*, &__x),
+                              +1);
 }
 
 
@@ -1663,7 +1505,8 @@
 {
     _RWSTD_COMPILE_ASSERT (2 == sizeof (unsigned short));
 
-    return __rw_atomic_add16 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT16_T*, &__x), +1);
+    return __rw_atomic_add16 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT16_T*, &__x),
+                              +1);
 }
 
 
@@ -1672,7 +1515,8 @@
 {
     _RWSTD_COMPILE_ASSERT (4 == sizeof (int));
 
-    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x), +1);
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x),
+                              +1);
 }
 
 
@@ -1681,37 +1525,20 @@
 {
     _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned int));
 
-    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x), +1);
-}
-
-
-#if 4 == _RWSTD_LONG_SIZE
-
-inline long
-__rw_atomic_preincrement (long &__x, bool)
-{
-    _RWSTD_COMPILE_ASSERT (4 == sizeof (long));
-
-    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x), +1);
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x),
+                              +1);
 }
 
 
-inline unsigned long
-__rw_atomic_preincrement (unsigned long &__x, bool)
-{
-    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned long));
-
-    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x), +1);
-}
-
-#else   // if 4 != _RWSTD_LONG_SIZE
+#if 4 < _RWSTD_LONG_SIZE
 
 inline long
 __rw_atomic_preincrement (long &__x, bool)
 {
     _RWSTD_COMPILE_ASSERT (8 == sizeof (long));
 
-    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x), +1);
+    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x),
+                              +1);
 }
 
 
@@ -1720,7 +1547,8 @@
 {
     _RWSTD_COMPILE_ASSERT (8 == sizeof (unsigned long));
 
-    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x), +1);
+    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x),
+                              +1);
 }
 
 #endif   // _RWSTD_LONG_SIZE
@@ -1731,7 +1559,8 @@
 {
     _RWSTD_COMPILE_ASSERT (1 == sizeof (char));
 
-    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x), -1);
+    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x),
+                             -1);
 }
 
 
@@ -1740,7 +1569,8 @@
 {
     _RWSTD_COMPILE_ASSERT (1 == sizeof (signed char));
 
-    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x), -1);
+    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x),
+                             -1);
 }
 
 
@@ -1749,7 +1579,8 @@
 {
     _RWSTD_COMPILE_ASSERT (1 == sizeof (unsigned char));
 
-    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x), -1);
+    return __rw_atomic_add8 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT8_T*, &__x),
+                             -1);
 }
 
 
@@ -1758,7 +1589,8 @@
 {
     _RWSTD_COMPILE_ASSERT (2 == sizeof (short));
 
-    return __rw_atomic_add16 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT16_T*, &__x), -1);
+    return __rw_atomic_add16 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT16_T*, &__x),
+                              -1);
 }
 
 
@@ -1767,7 +1599,8 @@
 {
     _RWSTD_COMPILE_ASSERT (2 == sizeof (unsigned short));
 
-    return __rw_atomic_add16 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT16_T*, &__x), -1);
+    return __rw_atomic_add16 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT16_T*, &__x),
+                              -1);
 }
 
 
@@ -1776,7 +1609,8 @@
 {
     _RWSTD_COMPILE_ASSERT (4 == sizeof (int));
 
-    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x), -1);
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x),
+                              -1);
 }
 
 
@@ -1785,37 +1619,20 @@
 {
     _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned int));
 
-    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x), -1);
-}
-
-
-#if 4 == _RWSTD_LONG_SIZE
-
-inline long
-__rw_atomic_predecrement (long &__x, bool)
-{
-    _RWSTD_COMPILE_ASSERT (4 == sizeof (long));
-
-    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x), -1);
+    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x),
+                              -1);
 }
 
 
-inline unsigned long
-__rw_atomic_predecrement (unsigned long &__x, bool)
-{
-    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned long));
-
-    return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x), -1);
-}
-
-#else   // if 4 != _RWSTD_LONG_SIZE
+#if 4 < _RWSTD_LONG_SIZE
 
 inline long
 __rw_atomic_predecrement (long &__x, bool)
 {
     _RWSTD_COMPILE_ASSERT (8 == sizeof (long));
 
-    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x), -1);
+    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x),
+                              -1);
 }
 
 
@@ -1824,7 +1641,8 @@
 {
     _RWSTD_COMPILE_ASSERT (8 == sizeof (long));
 
-    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x), -1);
+    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x),
+                              -1);
 }
 
 #endif   // _RWSTD_LONG_SIZE
@@ -1899,28 +1717,7 @@
 }
 
 
-#  if _RWSTD_LONG_SIZE == _RWSTD_INT_SIZE
-
-inline long
-__rw_atomic_exchange (long &__x, long __y, bool)
-{
-    _RWSTD_COMPILE_ASSERT (4 == sizeof (long));
-
-    return __rw_atomic_xchg32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x),
-                               _RWSTD_STATIC_CAST (_RWSTD_INT32_T, __y));
-}
-
-
-inline unsigned long
-__rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
-{
-    _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned long));
-
-    return __rw_atomic_xchg32 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT32_T*, &__x),
-                               _RWSTD_STATIC_CAST (_RWSTD_INT32_T, __y));
-}
-
-#  else   // if _RWSTD_LONG_SIZE != _RWSTD_INT_SIZE
+#  if 4 < _RWSTD_LONG_SIZE
 
 inline long
 __rw_atomic_exchange (long &__x, long __y, bool)
@@ -1943,74 +1740,60 @@
 
 #  endif   // _RWSTD_LONG_SIZE == _RWSTD_INT_SIZE
 
-#  ifdef _RWSTD_LONG_LONG
-#    if _RWSTD_LLONG_SIZE != _RWSTD_LONG_SIZE
-
-inline _RWSTD_LONG_LONG
-__rw_atomic_preincrement (_RWSTD_LONG_LONG &__x, bool)
-{
-    _RWSTD_COMPILE_ASSERT (8 == sizeof (_RWSTD_LONG_LONG));
+#endif   // IA64
 
-    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x),
-                              +1);
-}
+/********************** generic long functions ************************/
 
+#if _RWSTD_LONG_SIZE == _RWSTD_INT_SIZE
 
-inline unsigned _RWSTD_LONG_LONG
-__rw_atomic_preincrement (unsigned _RWSTD_LONG_LONG &__x, bool)
+inline long
+__rw_atomic_preincrement (long &__x, bool)
 {
-    _RWSTD_COMPILE_ASSERT (8 == sizeof (unsigned _RWSTD_LONG_LONG));
-
-    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x),
-                              +1);
+    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (int&, __x),
+                                     false);
 }
 
-
-inline _RWSTD_LONG_LONG
-__rw_atomic_predecrement (_RWSTD_LONG_LONG &__x, bool)
+inline unsigned long
+__rw_atomic_preincrement (unsigned long &__x, bool)
 {
-    _RWSTD_COMPILE_ASSERT (8 == sizeof (_RWSTD_LONG_LONG));
-
-    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x),
-                              -1);
+    return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (int&, __x),
+                                     false);
 }
 
-
-inline unsigned _RWSTD_LONG_LONG
-__rw_atomic_predecrement (unsigned _RWSTD_LONG_LONG &__x, bool)
+inline long
+__rw_atomic_predecrement (long &__x, bool)
 {
-    _RWSTD_COMPILE_ASSERT (8 == sizeof (unsigned _RWSTD_LONG_LONG));
-
-    return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x),
-                              -1);
+    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (int&, __x),
+                                     false);
 }
 
-
-inline _RWSTD_LONG_LONG
-__rw_atomic_exchange (_RWSTD_LONG_LONG &__x, _RWSTD_LONG_LONG __y, bool)
+inline unsigned long
+__rw_atomic_predecrement (unsigned long &__x, bool)
 {
-    _RWSTD_COMPILE_ASSERT (8 == sizeof (_RWSTD_LONG_LONG));
-
-    return __rw_atomic_xchg64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x),
-                               _RWSTD_STATIC_CAST (_RWSTD_INT64_T, __y));
+    return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (int&, __x),
+                                     false);
 }
 
-
-inline unsigned _RWSTD_LONG_LONG
-__rw_atomic_exchange (unsigned _RWSTD_LONG_LONG &__x,
-                      unsigned _RWSTD_LONG_LONG __y, bool)
+inline long
+__rw_atomic_exchange (long &__x, long __y, bool)
 {
-    _RWSTD_COMPILE_ASSERT (8 == sizeof (unsigned _RWSTD_LONG_LONG));
-
-    return __rw_atomic_xchg64 (_RWSTD_REINTERPRET_CAST (_RWSTD_INT64_T*, &__x),
-                               _RWSTD_STATIC_CAST (_RWSTD_INT64_T, __y));
+    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (int&, __x),
+                                 _RWSTD_STATIC_CAST (int, __y),
+                                 false);
 }
 
-#    endif   // _RWSTD_LLONG_SIZE != _RWSTD_LONG_SIZE
-#  endif   // _RWSTD_LONG_LONG
+inline unsigned long
+__rw_atomic_exchange (unsigned long &__x,
+                      unsigned long __y, bool)
+{
+    return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (int&, __x),
+                                 _RWSTD_STATIC_CAST (int, __y),
+                                 false);
+}
 
-#endif   // IA64
+#endif   // _RWSTD_LONG_SIZE == _RWSTD_INT_SIZE
 
+/********************** generic long long functions *******************/
 
 #ifdef _RWSTD_LONG_LONG
 #  if _RWSTD_LLONG_SIZE == _RWSTD_LONG_SIZE

Modified: incubator/stdcxx/trunk/src/i86/atomic.s
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/src/i86/atomic.s?rev=292352&r1=292351&r2=292352&view=diff
==============================================================================
--- incubator/stdcxx/trunk/src/i86/atomic.s (original)
+++ incubator/stdcxx/trunk/src/i86/atomic.s Wed Sep 28 17:09:21 2005
@@ -1,6 +1,6 @@
 /***************************************************************************
  *
- * atomic-i86.s
+ * atomic.s
  *
  * $Id$
  *
@@ -55,15 +55,15 @@
 
 
 /***************************************************************************
- * extern "C" int __rw_atomic_xchg (int *x, int y);
+ * extern "C" int __rw_atomic_xchg32 (int *x, int y);
  *
  * Atomically assigns the 32-bit value y to *x and returns
  * the original (before assignment) 32-bit value of *x.
  **************************************************************************/
 
-    .globl __rw_atomic_xchg
-    .type __rw_atomic_xchg, @function
-__rw_atomic_xchg:                  /* ; int (int *x, int y)           */
+    .globl __rw_atomic_xchg32
+    .type __rw_atomic_xchg32, @function
+__rw_atomic_xchg32:                /* ; int (int *x, int y)           */
     movl          4(%esp), %ecx    /* ; %ecx = x                      */
     movl          8(%esp), %eax    /* ; %eax = y                      */
     xchgl         %eax, (%ecx)     /* ; %eax <-> (%ecx)               */
@@ -117,15 +117,15 @@
 
 
 /***************************************************************************
- * extern "C" int __rw_atomic_add (int *x, int y);
+ * extern "C" int __rw_atomic_add32 (int *x, int y);
  *
  * Atomically increments the 32-bit value *x by y and returns
  * the new (after increment) 32-bit value of *x.
  **************************************************************************/
 
-    .globl __rw_atomic_add
-    .type __rw_atomic_add, @function
-__rw_atomic_add:                   /* ; long (long *dst, long inc)    */
+    .globl __rw_atomic_add32
+    .type __rw_atomic_add32, @function
+__rw_atomic_add32:                 /* ; long (long *dst, long inc)    */
     movl           4(%esp), %ecx   /* ; %ecx = dst                    */
     movl           8(%esp), %edx   /* ; %edx = inc                    */
     movl           %edx, %eax      /* ; */

Modified: incubator/stdcxx/trunk/src/sparc/atomic-64.s
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/src/sparc/atomic-64.s?rev=292352&r1=292351&r2=292352&view=diff
==============================================================================
--- incubator/stdcxx/trunk/src/sparc/atomic-64.s (original)
+++ incubator/stdcxx/trunk/src/sparc/atomic-64.s Wed Sep 28 17:09:21 2005
@@ -40,28 +40,28 @@
 
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! extern "C" int __rw_atomic_xchg (long *x, long y);
+! extern "C" int __rw_atomic_xchg64 (long *x, long y);
 !
 ! Atomically assigns the 64-bit value value y to *x and returns
 ! the original (before assignment) 64-bit value of *x.
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-    .type __rw_atomic_xchg, #function
-    .global __rw_atomic_xchg
+    .type __rw_atomic_xchg64, #function
+    .global __rw_atomic_xchg64
 
-__rw_atomic_xchg:             ! (long *x: %o0, long y: %o1)
-    mov     %o1, %o3          ! %o3 <- y
-.__rw_retry_xchg:
-    ldx     [%o0], %o2        ! %o2 <- *x
-    casx    [%o0], %o2, %o3   ! atomic operation:
-                              !   if [%o0] == %o2, [%o0] <-> %o3
-                              !   else %o3 <- [%o0]
-    cmp     %o2, %o3          ! if swap succeeded, both %o2 and %o3
-                              !   contain the original value of *x
-    bne,a   .__rw_retry_xchg  ! otherwise goto retry
-    mov     %o1, %o3          ! %o3 <- y
+__rw_atomic_xchg64:            ! (long *x: %o0, long y: %o1)
+    mov     %o1, %o3           ! %o3 <- y
+.__rw_retry_xchg64:
+    ldx     [%o0], %o2         ! %o2 <- *x
+    casx    [%o0], %o2, %o3    ! atomic operation:
+                               !   if [%o0] == %o2, [%o0] <-> %o3
+                               !   else %o3 <- [%o0]
+    cmp     %o2, %o3           ! if swap succeeded, both %o2 and %o3
+                               !   contain the original value of *x
+    bne,a   .__rw_retry_xchg64 ! otherwise goto retry
+    mov     %o1, %o3           ! %o3 <- y
     retl
-    mov     %o3, %o0          ! return result (old value)
+    mov     %o3, %o0           ! return result (old value)
 
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@@ -75,7 +75,7 @@
     .global __rw_atomic_add32
 
 __rw_atomic_add32:            ! (int *x: %o0, int y: %o1)
-.__rw_retry:
+.__rw_retry_add32:
     ld      [%o0], %o2        ! load *x into %o2
     add     %o2, %o1, %o3     ! %o3 = %o1 + %o2
     cas     [%o0], %o2, %o3   ! atomic operation:
@@ -83,7 +83,7 @@
                               !   else copy [%o0] into %o3
     cmp     %o2, %o3          ! if swap succeeded %o2 and %o3 are
                               !   both the old value
-    bne     .__rw_retry       ! otherwise retry
+    bne     .__rw_retry_add32 ! otherwise retry
     nop
     add     %o3, %o1, %o0     ! return result (new value)
     retl                     
@@ -91,17 +91,17 @@
 
 
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! extern "C" int __rw_atomic_add (long *x, long y);
+! extern "C" int __rw_atomic_add64 (long *x, long y);
 !
 ! Atomically increments the 64-bit value value *x by y and returns
 ! the new (after increment) 64-bit value of *x.
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-    .type __rw_atomic_add, #function
-    .global __rw_atomic_add
+    .type __rw_atomic_add64, #function
+    .global __rw_atomic_add64
 
-__rw_atomic_add:              ! (long *x: %o0, long y: %o1)
-.__rw_retry_add:
+__rw_atomic_add64:            ! (long *x: %o0, long y: %o1)
+.__rw_retry_add64:
     ldx     [%o0], %o2        ! load *x into %o2
     add     %o2, %o1, %o3     ! %o3 = %o1 + %o2
     casx    [%o0], %o2, %o3   ! atomic operation:
@@ -109,7 +109,7 @@
                               !   else copy [%o0] into %o3
     cmp     %o2, %o3          ! if swap succeeded %o2 and %o3 are
                               !   both the old value
-    bne     .__rw_retry_add   ! otherwise retry
+    bne     .__rw_retry_add64 ! otherwise retry
     nop
     add     %o3, %o1, %o0     ! return result (new value)
     retl                     



Mime
View raw message