* configure.ac: Change target-libasan to target-libsanitizer.
[official-gcc.git] / libsanitizer / asan / asan_lock.h
blob2392e3c0e7b5a18275c5ff81d713d35ce9c71501
1 //===-- asan_lock.h ---------------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // A wrapper for a simple lock.
11 //===----------------------------------------------------------------------===//
12 #ifndef ASAN_LOCK_H
13 #define ASAN_LOCK_H
15 #include "sanitizer_common/sanitizer_mutex.h"
16 #include "asan_internal.h"
18 // The locks in ASan are global objects and they are never destroyed to avoid
19 // at-exit races (that is, a lock is being used by other threads while the main
20 // thread is doing atexit destructors).
21 // We define the class using opaque storage to avoid including system headers.
23 namespace __asan {
25 class AsanLock {
26 public:
27 explicit AsanLock(LinkerInitialized);
28 void Lock();
29 void Unlock();
30 bool IsLocked() { return owner_ != 0; }
31 private:
32 uptr opaque_storage_[10];
33 uptr owner_; // for debugging and for malloc_introspection_t interface
36 typedef GenericScopedLock<AsanLock> ScopedLock;
38 } // namespace __asan
40 #endif // ASAN_LOCK_H