[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / thread / thread.mutex / thread.lock / thread.lock.unique / thread.lock.unique.mod / release.pass.cpp
blob4f2d59c3d333d4be5e8636621730b2f785b87154
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
11 // <mutex>
13 // template <class Mutex> class unique_lock;
15 // mutex_type* release() noexcept;
17 #include <mutex>
18 #include <cassert>
20 #include "test_macros.h"
22 struct mutex
24 static int lock_count;
25 static int unlock_count;
26 void lock() {++lock_count;}
27 void unlock() {++unlock_count;}
30 int mutex::lock_count = 0;
31 int mutex::unlock_count = 0;
33 mutex m;
35 int main(int, char**)
37 std::unique_lock<mutex> lk(m);
38 assert(lk.mutex() == &m);
39 assert(lk.owns_lock() == true);
40 assert(mutex::lock_count == 1);
41 assert(mutex::unlock_count == 0);
42 assert(lk.release() == &m);
43 assert(lk.mutex() == nullptr);
44 assert(lk.owns_lock() == false);
45 assert(mutex::lock_count == 1);
46 assert(mutex::unlock_count == 0);
48 return 0;