From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50827 invoked by alias); 2 Sep 2015 10:51:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 50810 invoked by uid 89); 2 Sep 2015 10:51:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 02 Sep 2015 10:51:06 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id B20A08EA26; Wed, 2 Sep 2015 10:51:04 +0000 (UTC) Received: from localhost (ovpn-116-43.ams2.redhat.com [10.36.116.43]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t82Ap33u009847; Wed, 2 Sep 2015 06:51:04 -0400 Date: Wed, 02 Sep 2015 10:51:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: Sebastian Huber Subject: [patch] libstdc++/67408 Handle distinct __gthread_recursive_mutex_t type. Message-ID: <20150902105103.GI2631@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MrRUTeZlqqNo1jQ9" Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-09/txt/msg00127.txt.bz2 --MrRUTeZlqqNo1jQ9 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-length: 241 This makes recursive_timed_mutex work for non-pthreads targets where __gthread_mutex_t and __gthread_recursive_mutex_t are not the same type. Thanks to Sebastian for the bug report and patch. Tested powerpc64le-linux, committed to trunk. --MrRUTeZlqqNo1jQ9 Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-length: 1714 commit 852d09122561d301b2980b6f9c97e88c5499006c Author: Jonathan Wakely Date: Wed Sep 2 11:39:46 2015 +0100 2015-09-02 Sebastian Huber PR libstdc++/67408 * include/std/mutex (__timed_mutex_impl::_M_try_lock_until): Use _Derived::_M_timedlock(). (timed_mutex): Add _M_timedlock() and make base class a friend. (recursive_timed_mutex): Likewise. diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index deb85df..790508c 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -230,8 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static_cast(__ns.count()) }; - auto __mutex = static_cast<_Derived*>(this)->native_handle(); - return !__gthread_mutex_timedlock(__mutex, &__ts); + return static_cast<_Derived*>(this)->_M_timedlock(__ts); } template @@ -293,6 +292,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION native_handle_type native_handle() { return &_M_mutex; } + + private: + friend class __timed_mutex_impl; + + bool + _M_timedlock(const __gthread_time_t& __ts) + { return !__gthread_mutex_timedlock(&_M_mutex, &__ts); } }; /// recursive_timed_mutex @@ -346,6 +352,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION native_handle_type native_handle() { return &_M_mutex; } + + private: + friend class __timed_mutex_impl; + + bool + _M_timedlock(const __gthread_time_t& __ts) + { return !__gthread_recursive_mutex_timedlock(&_M_mutex, &__ts); } }; #endif #endif // _GLIBCXX_HAS_GTHREADS --MrRUTeZlqqNo1jQ9--