OSDN Git Service

2010-11-02 Paolo Carlini <paolo.carlini@oracle.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / src / atomic.cc
index bff8fa9..822e022 100644 (file)
@@ -1,6 +1,6 @@
 // Support for atomic operations -*- C++ -*-
 
-// Copyright (C) 2008, 2009
+// Copyright (C) 2008, 2009, 2010
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -49,8 +49,8 @@ namespace
     };
 } // anonymous namespace
 
-namespace std
-{
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
   namespace __atomic0
   {
     bool
@@ -72,48 +72,51 @@ namespace std
 #endif
       _M_i = false;
     }
+
+  _GLIBCXX_BEGIN_EXTERN_C
+
+  bool
+  atomic_flag_test_and_set_explicit(__atomic_flag_base* __a,
+                                   memory_order __m) _GLIBCXX_NOTHROW
+  {
+    atomic_flag* d = static_cast<atomic_flag*>(__a);
+    return d->test_and_set(__m);
   }
 
-  extern "C"
+  void
+  atomic_flag_clear_explicit(__atomic_flag_base* __a,
+                            memory_order __m) _GLIBCXX_NOTHROW
   {
-    bool
-    atomic_flag_test_and_set_explicit(__atomic_flag_base* __a,
-                                     memory_order __m) throw ()
-    {
-      atomic_flag* d = static_cast<volatile atomic_flag*>(__a);
-      return d->test_and_set(__m);
-    }
+    atomic_flag* d = static_cast<atomic_flag*>(__a);
+    return d->clear(__m);
+  }
 
-    void
-    atomic_flag_clear_explicit(__atomic_flag_base* __a,
-                              memory_order __m) throw ()
-    {
-      atomic_flag* d = static_cast<volatile atomic_flag*>(__a);
-      return d->clear(__m);
-    }
+  void
+  __atomic_flag_wait_explicit(__atomic_flag_base* __a,
+                             memory_order __x) _GLIBCXX_NOTHROW
+  {
+    while (atomic_flag_test_and_set_explicit(__a, __x))
+      { };
+  }
 
-    void
-    __atomic_flag_wait_explicit(__atomic_flag_base* __a,
-                               memory_order __x) throw ()
-    {
-      while (atomic_flag_test_and_set_explicit(__a, __x))
-       { };
-    }
+  _GLIBCXX_CONST __atomic_flag_base*
+  __atomic_flag_for_address(const volatile void* __z) _GLIBCXX_NOTHROW
+  {
+    uintptr_t __u = reinterpret_cast<uintptr_t>(__z);
+    __u += (__u >> 2) + (__u << 4);
+    __u += (__u >> 7) + (__u << 5);
+    __u += (__u >> 17) + (__u << 13);
+    if (sizeof(uintptr_t) > 4)
+      __u += (__u >> 31);
+    __u &= ~((~uintptr_t(0)) << LOGSIZE);
+    return flag_table + __u;
+  }
 
-    __atomic_flag_base*
-    __atomic_flag_for_address(const void* __z) throw ()
-    {
-      uintptr_t __u = reinterpret_cast<uintptr_t>(__z);
-      __u += (__u >> 2) + (__u << 4);
-      __u += (__u >> 7) + (__u << 5);
-      __u += (__u >> 17) + (__u << 13);
-      if (sizeof(uintptr_t) > 4)
-       __u += (__u >> 31);
-      __u &= ~((~uintptr_t(0)) << LOGSIZE);
-      return flag_table + __u;
-    }
-  } // extern "C"
-} // namespace std
+  _GLIBCXX_END_EXTERN_C
+
+  } // namespace __atomic0
+
+_GLIBCXX_END_NAMESPACE
 
 
 // XXX GLIBCXX_ABI Deprecated
@@ -126,12 +129,15 @@ namespace std
 // In the future, GLIBCXX_ABI > 6 should remove all uses of
 // _GLIBCXX_*_SYMVER macros in this file.
 
+#if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC) \
+    && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE) \
+    && defined(_GLIBCXX_HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT)
+
 #define _GLIBCXX_ASM_SYMVER(cur, old, version) \
    asm (".symver " #cur "," #old "@@" #version);
 
-#if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC) \
-    && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE)
 _GLIBCXX_ASM_SYMVER(_ZNSt9__atomic011atomic_flag5clearESt12memory_order, _ZNVSt9__atomic011atomic_flag5clearESt12memory_order, GLIBCXX_3.4.11)
 
 _GLIBCXX_ASM_SYMVER(_ZNSt9__atomic011atomic_flag12test_and_setESt12memory_order, _ZNVSt9__atomic011atomic_flag12test_and_setESt12memory_order, GLIBCXX_3.4.11)
+
 #endif