Commit 8d2cddc1 by Jonathan Wakely Committed by Jonathan Wakely

shared_mutex: Implement N3659.

	* include/std/shared_mutex: Implement N3659.
	* include/bits/c++14_warning.h: New.
	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* testsuite/30_threads/shared_lock/cons/1.cc: New.
	* testsuite/30_threads/shared_lock/locking/2.cc: New.
	* testsuite/30_threads/shared_lock/cons/2.cc: New.
	* testsuite/30_threads/shared_lock/locking/3.cc: New.
	* testsuite/30_threads/shared_lock/cons/3.cc: New.
	* testsuite/30_threads/shared_lock/locking/4.cc: New.
	* testsuite/30_threads/shared_lock/cons/4.cc: New.
	* testsuite/30_threads/shared_lock/modifiers/1.cc: New.
	* testsuite/30_threads/shared_lock/cons/5.cc: New.
	* testsuite/30_threads/shared_lock/modifiers/2.cc: New.
	* testsuite/30_threads/shared_lock/cons/6.cc: New.
	* testsuite/30_threads/shared_lock/requirements/
	explicit_instantiation.cc: New.
	* testsuite/30_threads/shared_lock/locking/1.cc: New.
	* testsuite/30_threads/shared_lock/requirements/typedefs.cc: New.
	* testsuite/30_threads/shared_mutex/cons/1.cc: New.
	* testsuite/30_threads/shared_mutex/cons/assign_neg.cc: New.
	* testsuite/30_threads/shared_mutex/cons/copy_neg.cc: New.
	* testsuite/30_threads/shared_mutex/requirements/
	standard_layout.cc: New.
	* testsuite/30_threads/shared_mutex/try_lock/1.cc: New.
	* testsuite/30_threads/shared_mutex/try_lock/2.cc: New.

From-SVN: r200134
parent 393f9fed
2013-06-16 Jonathan Wakely <jwakely.gcc@gmail.com>
* include/std/shared_mutex: Implement N3659.
* include/bits/c++14_warning.h: New.
* include/Makefile.am: Add new headers.
* include/Makefile.in: Regenerate.
* testsuite/30_threads/shared_lock/cons/1.cc: New.
* testsuite/30_threads/shared_lock/locking/2.cc: New.
* testsuite/30_threads/shared_lock/cons/2.cc: New.
* testsuite/30_threads/shared_lock/locking/3.cc: New.
* testsuite/30_threads/shared_lock/cons/3.cc: New.
* testsuite/30_threads/shared_lock/locking/4.cc: New.
* testsuite/30_threads/shared_lock/cons/4.cc: New.
* testsuite/30_threads/shared_lock/modifiers/1.cc: New.
* testsuite/30_threads/shared_lock/cons/5.cc: New.
* testsuite/30_threads/shared_lock/modifiers/2.cc: New.
* testsuite/30_threads/shared_lock/cons/6.cc: New.
* testsuite/30_threads/shared_lock/requirements/
explicit_instantiation.cc: New.
* testsuite/30_threads/shared_lock/locking/1.cc: New.
* testsuite/30_threads/shared_lock/requirements/typedefs.cc: New.
* testsuite/30_threads/shared_mutex/cons/1.cc: New.
* testsuite/30_threads/shared_mutex/cons/assign_neg.cc: New.
* testsuite/30_threads/shared_mutex/cons/copy_neg.cc: New.
* testsuite/30_threads/shared_mutex/requirements/
standard_layout.cc: New.
* testsuite/30_threads/shared_mutex/try_lock/1.cc: New.
* testsuite/30_threads/shared_mutex/try_lock/2.cc: New.
2013-06-15 Paolo Carlini <paolo.carlini@oracle.com> 2013-06-15 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/57619 PR libstdc++/57619
......
...@@ -58,6 +58,7 @@ std_headers = \ ...@@ -58,6 +58,7 @@ std_headers = \
${std_srcdir}/regex \ ${std_srcdir}/regex \
${std_srcdir}/scoped_allocator \ ${std_srcdir}/scoped_allocator \
${std_srcdir}/set \ ${std_srcdir}/set \
${std_srcdir}/shared_mutex \
${std_srcdir}/sstream \ ${std_srcdir}/sstream \
${std_srcdir}/stack \ ${std_srcdir}/stack \
${std_srcdir}/stdexcept \ ${std_srcdir}/stdexcept \
...@@ -87,6 +88,7 @@ bits_headers = \ ...@@ -87,6 +88,7 @@ bits_headers = \
${bits_srcdir}/basic_string.tcc \ ${bits_srcdir}/basic_string.tcc \
${bits_srcdir}/boost_concept_check.h \ ${bits_srcdir}/boost_concept_check.h \
${bits_srcdir}/c++0x_warning.h \ ${bits_srcdir}/c++0x_warning.h \
${bits_srcdir}/c++14_warning.h \
${bits_srcdir}/char_traits.h \ ${bits_srcdir}/char_traits.h \
${bits_srcdir}/codecvt.h \ ${bits_srcdir}/codecvt.h \
${bits_srcdir}/concept_check.h \ ${bits_srcdir}/concept_check.h \
......
...@@ -320,6 +320,7 @@ std_headers = \ ...@@ -320,6 +320,7 @@ std_headers = \
${std_srcdir}/regex \ ${std_srcdir}/regex \
${std_srcdir}/scoped_allocator \ ${std_srcdir}/scoped_allocator \
${std_srcdir}/set \ ${std_srcdir}/set \
${std_srcdir}/shared_mutex \
${std_srcdir}/sstream \ ${std_srcdir}/sstream \
${std_srcdir}/stack \ ${std_srcdir}/stack \
${std_srcdir}/stdexcept \ ${std_srcdir}/stdexcept \
...@@ -349,6 +350,7 @@ bits_headers = \ ...@@ -349,6 +350,7 @@ bits_headers = \
${bits_srcdir}/basic_string.tcc \ ${bits_srcdir}/basic_string.tcc \
${bits_srcdir}/boost_concept_check.h \ ${bits_srcdir}/boost_concept_check.h \
${bits_srcdir}/c++0x_warning.h \ ${bits_srcdir}/c++0x_warning.h \
${bits_srcdir}/c++14_warning.h \
${bits_srcdir}/char_traits.h \ ${bits_srcdir}/char_traits.h \
${bits_srcdir}/codecvt.h \ ${bits_srcdir}/codecvt.h \
${bits_srcdir}/concept_check.h \ ${bits_srcdir}/concept_check.h \
......
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file bits/c++14_warning.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{iosfwd}
*/
#ifndef _CXX14_WARNING_H
#define _CXX14_WARNING_H 1
#if __cplusplus <= 201103L
#error This file requires compiler and library support for the forthcoming \
ISO C++ 2014 standard. This support is currently experimental, and must be \
enabled with the -std=c++1y or -std=gnu++1y compiler options.
#endif
#endif
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
try
{
lock_type lock;
VERIFY( !lock.owns_lock() );
VERIFY( !(bool)lock );
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
try
{
mutex_type m;
lock_type lock(m);
VERIFY( lock.owns_lock() );
VERIFY( (bool)lock );
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
try
{
mutex_type m;
lock_type lock(m, std::defer_lock);
VERIFY( !lock.owns_lock() );
VERIFY( !(bool)lock );
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
try
{
mutex_type m;
lock_type lock(m, std::try_to_lock);
VERIFY( lock.owns_lock() );
VERIFY( (bool)lock );
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads-timed "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <chrono>
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
typedef std::chrono::system_clock clock_type;
try
{
clock_type::time_point t = clock_type::now() + std::chrono::seconds(5);
mutex_type m;
lock_type lock(m, t);
VERIFY( lock.owns_lock() );
VERIFY( (bool)lock );
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads-timed "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <chrono>
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
typedef std::chrono::system_clock clock_type;
try
{
clock_type::duration d = std::chrono::seconds(5);
mutex_type m;
lock_type lock(m, d);
VERIFY( lock.owns_lock() );
VERIFY( (bool)lock );
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
try
{
mutex_type m;
lock_type l(m, std::defer_lock);
l.lock();
VERIFY( (bool)l );
VERIFY( l.owns_lock() );
l.unlock();
VERIFY( !(bool)l );
VERIFY( !l.owns_lock() );
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
try
{
lock_type l;
// Lock shared_lock w/o mutex
try
{
l.lock();
}
catch (const std::system_error& ex)
{
VERIFY( ex.code() == std::make_error_code
(std::errc::operation_not_permitted) );
}
catch (...)
{
VERIFY( false );
}
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
}
void test02()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
try
{
mutex_type m;
lock_type l(m);
// Lock already locked shared_lock.
try
{
l.lock();
}
catch (const std::system_error& ex)
{
VERIFY( ex.code() == std::make_error_code
(std::errc::resource_deadlock_would_occur) );
}
catch (...)
{
VERIFY( false );
}
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
}
int main()
{
test01();
test02();
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads-timed "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <chrono>
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
try
{
mutex_type m;
lock_type l(m, std::defer_lock);
try
{
l.try_lock_for(std::chrono::milliseconds(100));
}
catch(const std::system_error&)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
VERIFY( l.owns_lock() );
}
catch (const std::system_error&)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads-timed "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <chrono>
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_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);
try
{
l.try_lock_until(t);
}
catch(const std::system_error&)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
VERIFY( l.owns_lock() );
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
try
{
mutex_type m;
lock_type l1(m);
lock_type l2;
try
{
l1.swap(l2);
}
catch (const std::system_error&)
{
VERIFY( false );
}
catch(...)
{
VERIFY( false );
}
VERIFY( !(bool)l1 );
VERIFY( (bool)l2 );
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
typedef std::shared_lock<mutex_type> lock_type;
try
{
mutex_type m;
lock_type l1(m);
lock_type l2;
try
{
l1.swap(l2);
}
catch (const std::system_error&)
{
VERIFY( false );
}
catch(...)
{
VERIFY( false );
}
VERIFY( !(bool)l1 );
VERIFY( (bool)l2 );
}
catch (const std::system_error&)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do compile }
// { dg-options "-std=gnu++1y" }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// NB: This file is for testing with NO OTHER INCLUDES.
#include <shared_mutex>
namespace std
{
template class shared_lock<shared_mutex>;
}
// { dg-do compile }
// { dg-options "-std=gnu++1y" }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// NB: This file is for testing with NO OTHER INCLUDES.
#include <shared_mutex>
void test01()
{
// Check for required typedefs
typedef std::shared_lock<std::shared_mutex> test_type;
typedef test_type::mutex_type mutex_type;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
try
{
mutex_type m1;
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do compile }
// { dg-options "-std=gnu++1y" }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2008-2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
void test01()
{
// assign
typedef std::shared_mutex mutex_type;
mutex_type m1;
mutex_type m2;
m1 = m2; // { dg-error "deleted" }
}
// { dg-prune-output "include" }
// { dg-do compile }
// { dg-options "-std=gnu++1y" }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
void test01()
{
// assign
typedef std::shared_mutex mutex_type;
mutex_type m1;
mutex_type m2(m1); // { dg-error "deleted" }
}
// { dg-prune-output "include" }
// { dg-do compile }
// { dg-options "-std=gnu++1y" }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <testsuite_common_types.h>
void test01()
{
__gnu_test::standard_layout test;
test.operator()<std::shared_mutex>();
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
try
{
mutex_type m;
bool b = m.try_lock();
VERIFY( b );
m.unlock();
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* powerpc-ibm-aix* } }
// { dg-options " -std=gnu++1y -pthreads" { target *-*-solaris* } }
// { dg-options " -std=gnu++1y " { target *-*-cygwin *-*-darwin* } }
// { dg-require-cstdint "" }
// { dg-require-gthreads "" }
// Copyright (C) 2013 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
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <shared_mutex>
#include <thread>
#include <system_error>
#include <testsuite_hooks.h>
int main()
{
bool test __attribute__((unused)) = true;
typedef std::shared_mutex mutex_type;
try
{
mutex_type m;
m.lock();
bool b;
std::thread t([&] {
try
{
b = m.try_lock();
}
catch (const std::system_error& e)
{
VERIFY( false );
}
});
t.join();
VERIFY( !b );
m.unlock();
}
catch (const std::system_error& e)
{
VERIFY( false );
}
catch (...)
{
VERIFY( false );
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment