[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / thread / thread.mutex / thread.lock / thread.lock.shared / thread.lock.shared.mod / release.pass.cpp
blob9dfdd0b0ded2fa3b114f3cd86880429bc4447f35
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
12 // <shared_mutex>
14 // template <class Mutex> class shared_lock;
16 // mutex_type* release() noexcept;
18 #include <shared_mutex>
19 #include <cassert>
21 #include "test_macros.h"
23 struct mutex
25 static int lock_count;
26 static int unlock_count;
27 void lock_shared() {++lock_count;}
28 void unlock_shared() {++unlock_count;}
31 int mutex::lock_count = 0;
32 int mutex::unlock_count = 0;
34 mutex m;
36 int main(int, char**)
38 std::shared_lock<mutex> lk(m);
39 assert(lk.mutex() == &m);
40 assert(lk.owns_lock() == true);
41 assert(mutex::lock_count == 1);
42 assert(mutex::unlock_count == 0);
43 assert(lk.release() == &m);
44 assert(lk.mutex() == nullptr);
45 assert(lk.owns_lock() == false);
46 assert(mutex::lock_count == 1);
47 assert(mutex::unlock_count == 0);
48 static_assert(noexcept(lk.release()), "release must be noexcept");
50 return 0;