-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
-// { dg-options " -std=gnu++0x -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* powerpc-ibm-aix* } }
-// { dg-options " -std=gnu++0x -pthreads" { target *-*-solaris* } }
-// { dg-options " -std=gnu++0x " { target *-*-cygwin *-*-darwin* } }
-// { dg-require-cstdint "" }
-// { dg-require-gthreads-timed "" }
+// { dg-do run }
+// { dg-additional-options "-pthread" { target pthread } }
+// { dg-require-effective-target c++11 }
+// { dg-require-gthreads "" }
-// Copyright (C) 2008-2014 Free Software Foundation, Inc.
+// Copyright (C) 2008-2024 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
#include <system_error>
#include <testsuite_hooks.h>
-int main()
+template <typename clock_type>
+void test()
{
- bool test __attribute__((unused)) = true;
typedef std::timed_mutex mutex_type;
typedef std::unique_lock<mutex_type> lock_type;
- typedef std::chrono::system_clock clock_type;
try
{
mutex_type m;
lock_type l(m, std::defer_lock);
- clock_type::time_point t = clock_type::now() + std::chrono::seconds(1);
+ const typename clock_type::time_point t = clock_type::now()
+ + std::chrono::seconds(1);
try
{
- l.try_lock_until(t);
+ VERIFY( l.try_lock_until(t) );
}
catch(const std::system_error&)
{
{
VERIFY( false );
}
+}
+int main()
+{
+ test<std::chrono::system_clock>();
+ test<std::chrono::steady_clock>();
return 0;
}