Commit fa0ed2b0 by Jonathan Wakely Committed by Jonathan Wakely

* include/bits/atomic_futex.h [_GLIBCXX_HAVE_LINUX_FUTEX]

	(_M_load_and_test_until): Whitespace.
	(_M_load_and_test): Value-initialize the unused durations.
	(_M_load_when_equal): Add missing return value.

From-SVN: r226174
parent 776280c4
2015-07-24 Jonathan Wakely <jwakely@redhat.com>
* include/bits/atomic_futex.h [_GLIBCXX_HAVE_LINUX_FUTEX]
(_M_load_and_test_until): Whitespace.
(_M_load_and_test): Value-initialize the unused durations.
(_M_load_when_equal): Add missing return value.
2015-07-24 Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com> 2015-07-24 Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
* fragment.am (AM_CPPFLAGS): Add CPPFLAGS. * fragment.am (AM_CPPFLAGS): Add CPPFLAGS.
......
...@@ -93,15 +93,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -93,15 +93,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
for (;;) for (;;)
{ {
// Don't bother checking the value again because we expect the caller to // Don't bother checking the value again because we expect the caller
// have done it recently. // to have done it recently.
// memory_order_relaxed is sufficient because we can rely on just the // memory_order_relaxed is sufficient because we can rely on just the
// modification order (store_notify uses an atomic RMW operation too), // modification order (store_notify uses an atomic RMW operation too),
// and the futex syscalls synchronize between themselves. // and the futex syscalls synchronize between themselves.
_M_data.fetch_or(_Waiter_bit, memory_order_relaxed); _M_data.fetch_or(_Waiter_bit, memory_order_relaxed);
bool __ret; bool __ret = _M_futex_wait_until((unsigned*)(void*)&_M_data,
__ret = _M_futex_wait_until((unsigned*)(void*)&_M_data, __assumed | _Waiter_bit,
__assumed | _Waiter_bit, __has_timeout, __s, __ns); __has_timeout, __s, __ns);
// Fetch the current value after waiting (clears _Waiter_bit). // Fetch the current value after waiting (clears _Waiter_bit).
__assumed = _M_load(__mo); __assumed = _M_load(__mo);
if (!__ret || ((__operand == __assumed) == __equal)) if (!__ret || ((__operand == __assumed) == __equal))
...@@ -119,7 +119,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -119,7 +119,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool __equal, memory_order __mo) bool __equal, memory_order __mo)
{ {
return _M_load_and_test_until(__assumed, __operand, __equal, __mo, return _M_load_and_test_until(__assumed, __operand, __equal, __mo,
false, chrono::seconds(0), chrono::nanoseconds(0)); false, {}, {});
} }
// If a timeout occurs, returns a current value after the timeout; // If a timeout occurs, returns a current value after the timeout;
...@@ -146,7 +146,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -146,7 +146,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_load_when_not_equal(unsigned __val, memory_order __mo) _M_load_when_not_equal(unsigned __val, memory_order __mo)
{ {
unsigned __i = _M_load(__mo); unsigned __i = _M_load(__mo);
if ((__i & ~_Waiter_bit) != __val) return; if ((__i & ~_Waiter_bit) != __val)
return (__i & ~_Waiter_bit);
// TODO Spin-wait first. // TODO Spin-wait first.
return _M_load_and_test(__i, __val, false, __mo); return _M_load_and_test(__i, __val, false, __mo);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment