From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 7712D385480F; Wed, 23 Jun 2021 10:08:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7712D385480F MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-1742] libstdc++: Avoid "__lockable" name defined as macro by newlib X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: da13e4ebebb07a47d5fb50eab8893f8fe38683df X-Git-Newrev: 75404109dce57d2f8dac0f90808010233928418f Message-Id: <20210623100856.7712D385480F@sourceware.org> Date: Wed, 23 Jun 2021 10:08:56 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2021 10:08:56 -0000 https://gcc.gnu.org/g:75404109dce57d2f8dac0f90808010233928418f commit r12-1742-g75404109dce57d2f8dac0f90808010233928418f Author: Jonathan Wakely Date: Wed Jun 23 11:05:51 2021 +0100 libstdc++: Avoid "__lockable" name defined as macro by newlib libstdc++-v3/ChangeLog: * include/std/mutex (__detail::__try_lock_impl): Rename parameter to avoid clashing with newlib's __lockable macro. (try_lock): Add 'inline' specifier. * testsuite/17_intro/names.cc: Add check for __lockable. * testsuite/30_threads/try_lock/5.cc: Add options for pthreads. Diff: --- libstdc++-v3/include/std/mutex | 6 +++--- libstdc++-v3/testsuite/17_intro/names.cc | 6 ++++++ libstdc++-v3/testsuite/30_threads/try_lock/5.cc | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index c18ca1a1955..eeb51fdb840 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -517,9 +517,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Lock the last lockable, after all previous ones are locked. template inline int - __try_lock_impl(_Lockable& __lockable) + __try_lock_impl(_Lockable& __l) { - if (unique_lock<_Lockable> __lock{__lockable, try_to_lock}) + if (unique_lock<_Lockable> __lock{__l, try_to_lock}) { __lock.release(); return -1; @@ -585,7 +585,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Sequentially calls try_lock() on each argument. */ template - int + inline int try_lock(_L1& __l1, _L2& __l2, _L3&... __l3) { return __detail::__try_lock_impl(__l1, __l2, __l3...); diff --git a/libstdc++-v3/testsuite/17_intro/names.cc b/libstdc++-v3/testsuite/17_intro/names.cc index 624e3ed9ccf..534dab70ff5 100644 --- a/libstdc++-v3/testsuite/17_intro/names.cc +++ b/libstdc++-v3/testsuite/17_intro/names.cc @@ -16,6 +16,7 @@ // . // { dg-do compile } +// { dg-add-options no_pch } // Define macros for some common variables names that we must not use for // naming variables, parameters etc. in the library. @@ -216,6 +217,11 @@ #undef y #endif +#if ! __has_include() +// newlib's defines __lockable as a macro, so we can't use it. +# define __lockable cannot be used as an identifier +#endif + #ifdef __sun__ // See https://gcc.gnu.org/ml/libstdc++/2019-05/msg00175.html #undef ptr diff --git a/libstdc++-v3/testsuite/30_threads/try_lock/5.cc b/libstdc++-v3/testsuite/30_threads/try_lock/5.cc index a5574ff01fb..b9ce1cc9b90 100644 --- a/libstdc++-v3/testsuite/30_threads/try_lock/5.cc +++ b/libstdc++-v3/testsuite/30_threads/try_lock/5.cc @@ -1,4 +1,7 @@ -// { dg-do run { target c++11 } } +// { dg-do run } +// { dg-additional-options "-pthread" { target pthread } } +// { dg-require-effective-target c++11 } +// { dg-require-gthreads "" } #include #include