[Clang][SME2] Enable multi-vector loads & stores for SME2 (#75821)
[llvm-project.git] / compiler-rt / lib / gwp_asan / mutex.h
blob34b91a2880ddcfc12fae4b939cb59a7454f76526
1 //===-- mutex.h -------------------------------------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #ifndef GWP_ASAN_MUTEX_H_
10 #define GWP_ASAN_MUTEX_H_
12 #include "gwp_asan/platform_specific/mutex_fuchsia.h" // IWYU pragma: keep
13 #include "gwp_asan/platform_specific/mutex_posix.h" // IWYU pragma: keep
15 namespace gwp_asan {
16 class Mutex final : PlatformMutex {
17 public:
18 constexpr Mutex() = default;
19 ~Mutex() = default;
20 Mutex(const Mutex &) = delete;
21 Mutex &operator=(const Mutex &) = delete;
22 // Lock the mutex.
23 void lock();
24 // Nonblocking trylock of the mutex. Returns true if the lock was acquired.
25 bool tryLock();
26 // Unlock the mutex.
27 void unlock();
30 class ScopedLock {
31 public:
32 explicit ScopedLock(Mutex &Mx) : Mu(Mx) { Mu.lock(); }
33 ~ScopedLock() { Mu.unlock(); }
34 ScopedLock(const ScopedLock &) = delete;
35 ScopedLock &operator=(const ScopedLock &) = delete;
37 private:
38 Mutex Μ
40 } // namespace gwp_asan
42 #endif // GWP_ASAN_MUTEX_H_