1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // UNSUPPORTED: no-threads
10 // UNSUPPORTED: c++03, c++11
11 
12 // dylib support for shared_mutex was added in macosx10.12
13 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11}}
14 
15 // <shared_mutex>
16 
17 // template <class Mutex> class shared_lock;
18 
19 // shared_lock(mutex_type& m, adopt_lock_t);
20 
21 #include <shared_mutex>
22 #include <cassert>
23 #include <mutex>
24 #include "nasty_containers.h"
25 
26 #include "test_macros.h"
27 
main(int,char **)28 int main(int, char**)
29 {
30     {
31     typedef std::shared_timed_mutex M;
32     M m;
33     m.lock();
34     std::unique_lock<M> lk(m, std::adopt_lock);
35     assert(lk.mutex() == std::addressof(m));
36     assert(lk.owns_lock() == true);
37     }
38     {
39     typedef nasty_mutex M;
40     M m;
41     m.lock();
42     std::unique_lock<M> lk(m, std::adopt_lock);
43     assert(lk.mutex() == std::addressof(m));
44     assert(lk.owns_lock() == true);
45     }
46 
47   return 0;
48 }
49