[patch libstdc++] Optimize synchronization in std::future if futexes are available.

Jonathan Wakely jwakely@redhat.com
Sun Jan 18 14:39:00 GMT 2015


On 18/01/15 13:19 +0000, Jonathan Wakely wrote:
>On 17/01/15 19:51 -0700, Sandra Loosemore wrote:
>>On 01/17/2015 03:58 PM, Jonathan Wakely wrote:
>>>
>>>My fault, this additional chunk is needed alongside the patch I sent
>>>earlier:
>>>
>>>--- a/libstdc++-v3/include/bits/atomic_futex.h
>>>+++ b/libstdc++-v3/include/bits/atomic_futex.h
>>>@@ -35,7 +35,7 @@
>>>#include <bits/c++config.h>
>>>#include <atomic>
>>>#include <chrono>
>>>-#if !defined(_GLIBCXX_HAVE_LINUX_FUTEX)
>>>+#if ! (defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1)
>>>#include <mutex>
>>>#include <condition_variable>
>>>#endif
>>>
>>>What I sent earlier causes your target to use std::mutex and
>>>std::condition_variable, but without the bit above the headers aren't
>>>included.
>>
>>Still no joy:
>>/scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:45:3: 
>>error: '__atomic_futex_unsigned_base' has not been declared
>>  __atomic_futex_unsigned_base::_M_futex_wait_until(unsigned *__addr,
>>  ^
>>/scratch/sandra/arm-fsf2/src/gcc-mainline/libstdc++-v3/src/c++11/futex.cc:88:3: 
>>error: '__atomic_futex_unsigned_base' has not been declared
>>  __atomic_futex_unsigned_base::_M_futex_notify_all(unsigned* __addr)
>>  ^
>
>futex.cc needs the same change ...

>diff --git a/libstdc++-v3/src/c++11/futex.cc b/libstdc++-v3/src/c++11/futex.cc
>index ad766c8..f24b44e 100644
>--- a/libstdc++-v3/src/c++11/futex.cc
>+++ b/libstdc++-v3/src/c++11/futex.cc
>@@ -23,7 +23,7 @@
> // <http://www.gnu.org/licenses/>.
> 
> #include <bits/c++config.h>
>-#if defined(_GLIBCXX_HAVE_LINUX_FUTEX)
>+#if defined(_GLIBCXX_HAVE_LINUX_FUTEX) && ATOMIC_INT_LOCK_FREE > 1
> #include <bits/atomic_futex.h>
> #include <chrono>
> #include <climits>

I've committed the attached after succesfully building
arm-none-linux-gnueabi with it and testing on x86_64-linux.

(The other changes in the patch are just whitespace and making the
member variables private.)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 7915 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20150118/da3b87fc/attachment.bin>


More information about the Libstdc++ mailing list