1 //===-- asan_lock.h ---------------------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of AddressSanitizer, an address sanity checker.
10 // A wrapper for a simple lock.
11 //===----------------------------------------------------------------------===//
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.
27 explicit AsanLock(LinkerInitialized
);
30 bool IsLocked() { return owner_
!= 0; }
32 uptr opaque_storage_
[10];
33 uptr owner_
; // for debugging and for malloc_introspection_t interface
36 typedef GenericScopedLock
<AsanLock
> ScopedLock
;