// Lock the last lockable, after all previous ones are locked.
template<typename _Lockable>
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;
* Sequentially calls try_lock() on each argument.
*/
template<typename _L1, typename _L2, typename... _L3>
- int
+ inline int
try_lock(_L1& __l1, _L2& __l2, _L3&... __l3)
{
return __detail::__try_lock_impl(__l1, __l2, __l3...);
// <http://www.gnu.org/licenses/>.
// { 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.
#undef y
#endif
+#if ! __has_include(<newlib.h>)
+// newlib's <sys/cdefs.h> 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
-// { 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 <mutex>
#include <testsuite_hooks.h>