summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/bits/shared_ptr_base.h10
-rw-r--r--libstdc++-v3/include/parallel/compatibility.h17
-rw-r--r--libstdc++-v3/include/profile/impl/profiler_state.h11
-rw-r--r--libstdc++-v3/include/tr1/shared_ptr.h10
4 files changed, 29 insertions, 19 deletions
diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index c024b70fb50..ebdc7ed9452 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -1,6 +1,7 @@
// shared_ptr and weak_ptr implementation details -*- C++ -*-
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -193,7 +194,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
// No memory barrier is used here so there is no synchronization
// with other threads.
- return const_cast<const volatile _Atomic_word&>(_M_use_count);
+ return __atomic_load_n(&_M_use_count, __ATOMIC_RELAXED);
}
private:
@@ -245,8 +246,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Replace the current counter value with the old value + 1, as
// long as it's not changed meanwhile.
}
- while (!__sync_bool_compare_and_swap(&_M_use_count, __count,
- __count + 1));
+ while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
+ true, __ATOMIC_ACQ_REL,
+ __ATOMIC_RELAXED));
}
diff --git a/libstdc++-v3/include/parallel/compatibility.h b/libstdc++-v3/include/parallel/compatibility.h
index 9fffd8e012c..460345ef399 100644
--- a/libstdc++-v3/include/parallel/compatibility.h
+++ b/libstdc++-v3/include/parallel/compatibility.h
@@ -1,6 +1,6 @@
// -*- C++ -*-
-// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -102,7 +102,7 @@ namespace __gnu_parallel
return _InterlockedExchangeAdd(reinterpret_cast<volatile long*>(__ptr),
__addend);
#elif defined(__GNUC__)
- return __sync_fetch_and_add(__ptr, __addend);
+ return __atomic_fetch_add(__ptr, __addend, __ATOMIC_ACQ_REL);
#elif defined(__SUNPRO_CC) && defined(__sparc)
volatile int32_t __before, __after;
do
@@ -145,11 +145,11 @@ namespace __gnu_parallel
return _InterlockedExchangeAdd64(__ptr, __addend);
#endif
#elif defined(__GNUC__) && defined(__x86_64)
- return __sync_fetch_and_add(__ptr, __addend);
+ return __atomic_fetch_add(__ptr, __addend, __ATOMIC_ACQ_REL);
#elif defined(__GNUC__) && defined(__i386) && \
(defined(__i686) || defined(__pentium4) || defined(__athlon) \
|| defined(__k8) || defined(__core2))
- return __sync_fetch_and_add(__ptr, __addend);
+ return __atomic_fetch_add(__ptr, __addend, __ATOMIC_ACQ_REL);
#elif defined(__SUNPRO_CC) && defined(__sparc)
volatile int64_t __before, __after;
do
@@ -252,7 +252,8 @@ namespace __gnu_parallel
__replacement, __comparand)
== __comparand;
#elif defined(__GNUC__)
- return __sync_bool_compare_and_swap(__ptr, __comparand, __replacement);
+ return __atomic_compare_exchange_n(__ptr, &__comparand, __replacement, true,
+ __ATOMIC_ACQ_REL, __ATOMIC_RELAXED);
#elif defined(__SUNPRO_CC) && defined(__sparc)
return atomic_cas_32((volatile unsigned int*)__ptr, __comparand,
__replacement) == __comparand;
@@ -298,11 +299,13 @@ namespace __gnu_parallel
#endif
#elif defined(__GNUC__) && defined(__x86_64)
- return __sync_bool_compare_and_swap(__ptr, __comparand, __replacement);
+ return __atomic_compare_exchange_n(__ptr, &__comparand, __replacement, true,
+ __ATOMIC_ACQ_REL, __ATOMIC_RELAXED);
#elif defined(__GNUC__) && defined(__i386) && \
(defined(__i686) || defined(__pentium4) || defined(__athlon) \
|| defined(__k8) || defined(__core2))
- return __sync_bool_compare_and_swap(__ptr, __comparand, __replacement);
+ return __atomic_compare_exchange_n(__ptr, &__comparand, __replacement, true,
+ __ATOMIC_ACQ_REL, __ATOMIC_RELAXED);
#elif defined(__SUNPRO_CC) && defined(__sparc)
return atomic_cas_64((volatile unsigned long long*)__ptr,
__comparand, __replacement) == __comparand;
diff --git a/libstdc++-v3/include/profile/impl/profiler_state.h b/libstdc++-v3/include/profile/impl/profiler_state.h
index 111b97e0eca..573aa0eeb40 100644
--- a/libstdc++-v3/include/profile/impl/profiler_state.h
+++ b/libstdc++-v3/include/profile/impl/profiler_state.h
@@ -1,6 +1,6 @@
// -*- C++ -*-
//
-// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2012 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -45,9 +45,12 @@ namespace __gnu_profile
inline bool
__turn(__state_type __s)
- { return (_GLIBCXX_PROFILE_DATA(__state)
- == __sync_val_compare_and_swap(&_GLIBCXX_PROFILE_DATA(__state),
- __INVALID, __s)); }
+ {
+ __state_type inv(__INVALID);
+ return __atomic_compare_exchange_n(&_GLIBCXX_PROFILE_DATA(__state),
+ &inv, __s, true, __ATOMIC_ACQ_REL,
+ __ATOMIC_RELAXED);
+ }
inline bool
__turn_on()
diff --git a/libstdc++-v3/include/tr1/shared_ptr.h b/libstdc++-v3/include/tr1/shared_ptr.h
index c42084c9539..723e317646d 100644
--- a/libstdc++-v3/include/tr1/shared_ptr.h
+++ b/libstdc++-v3/include/tr1/shared_ptr.h
@@ -1,6 +1,7 @@
// <tr1/shared_ptr.h> -*- C++ -*-
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
+// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -246,9 +247,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Replace the current counter value with the old value + 1, as
// long as it's not changed meanwhile.
}
- while (!__sync_bool_compare_and_swap(&_M_use_count, __count,
- __count + 1));
- }
+ while (!__atomic_compare_exchange_n(&_M_use_count, &__count, __count + 1,
+ true, __ATOMIC_ACQ_REL,
+ __ATOMIC_RELAXED));
+ }
template<typename _Ptr, typename _Deleter, _Lock_policy _Lp>
class _Sp_counted_base_impl
OpenPOWER on IntegriCloud