|
@ -5,56 +5,107 @@ |
|
|
#ifndef STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H_ |
|
|
#ifndef STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H_ |
|
|
#define STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H_ |
|
|
#define STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H_ |
|
|
|
|
|
|
|
|
// Some environments provide custom macros to aid in static thread-safety |
|
|
|
|
|
// analysis. Provide empty definitions of such macros unless they are already |
|
|
|
|
|
// defined. |
|
|
|
|
|
|
|
|
// Use Clang's thread safety analysis annotations when available. In other |
|
|
|
|
|
// environments, the macros receive empty definitions. |
|
|
|
|
|
// Usage documentation: https://clang.llvm.org/docs/ThreadSafetyAnalysis.html |
|
|
|
|
|
|
|
|
|
|
|
#if !defined(THREAD_ANNOTATION_ATTRIBUTE__) |
|
|
|
|
|
|
|
|
|
|
|
#if defined(__clang__) |
|
|
|
|
|
|
|
|
|
|
|
#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) |
|
|
|
|
|
#else |
|
|
|
|
|
#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#endif // !defined(THREAD_ANNOTATION_ATTRIBUTE__) |
|
|
|
|
|
|
|
|
|
|
|
#ifndef GUARDED_BY |
|
|
|
|
|
#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifndef PT_GUARDED_BY |
|
|
|
|
|
#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifndef ACQUIRED_AFTER |
|
|
|
|
|
#define ACQUIRED_AFTER(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__)) |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifndef ACQUIRED_BEFORE |
|
|
|
|
|
#define ACQUIRED_BEFORE(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__)) |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef EXCLUSIVE_LOCKS_REQUIRED |
|
|
#ifndef EXCLUSIVE_LOCKS_REQUIRED |
|
|
#define EXCLUSIVE_LOCKS_REQUIRED(...) |
|
|
|
|
|
|
|
|
#define EXCLUSIVE_LOCKS_REQUIRED(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__)) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef SHARED_LOCKS_REQUIRED |
|
|
#ifndef SHARED_LOCKS_REQUIRED |
|
|
#define SHARED_LOCKS_REQUIRED(...) |
|
|
|
|
|
|
|
|
#define SHARED_LOCKS_REQUIRED(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__)) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef LOCKS_EXCLUDED |
|
|
#ifndef LOCKS_EXCLUDED |
|
|
#define LOCKS_EXCLUDED(...) |
|
|
|
|
|
|
|
|
#define LOCKS_EXCLUDED(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__)) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef LOCK_RETURNED |
|
|
#ifndef LOCK_RETURNED |
|
|
#define LOCK_RETURNED(x) |
|
|
|
|
|
|
|
|
#define LOCK_RETURNED(x) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef LOCKABLE |
|
|
#ifndef LOCKABLE |
|
|
#define LOCKABLE |
|
|
|
|
|
|
|
|
#define LOCKABLE \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(lockable) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef SCOPED_LOCKABLE |
|
|
#ifndef SCOPED_LOCKABLE |
|
|
#define SCOPED_LOCKABLE |
|
|
|
|
|
|
|
|
#define SCOPED_LOCKABLE \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef EXCLUSIVE_LOCK_FUNCTION |
|
|
#ifndef EXCLUSIVE_LOCK_FUNCTION |
|
|
#define EXCLUSIVE_LOCK_FUNCTION(...) |
|
|
|
|
|
|
|
|
#define EXCLUSIVE_LOCK_FUNCTION(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__)) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef SHARED_LOCK_FUNCTION |
|
|
#ifndef SHARED_LOCK_FUNCTION |
|
|
#define SHARED_LOCK_FUNCTION(...) |
|
|
|
|
|
|
|
|
#define SHARED_LOCK_FUNCTION(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__)) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef EXCLUSIVE_TRYLOCK_FUNCTION |
|
|
#ifndef EXCLUSIVE_TRYLOCK_FUNCTION |
|
|
#define EXCLUSIVE_TRYLOCK_FUNCTION(...) |
|
|
|
|
|
|
|
|
#define EXCLUSIVE_TRYLOCK_FUNCTION(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__)) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef SHARED_TRYLOCK_FUNCTION |
|
|
#ifndef SHARED_TRYLOCK_FUNCTION |
|
|
#define SHARED_TRYLOCK_FUNCTION(...) |
|
|
|
|
|
|
|
|
#define SHARED_TRYLOCK_FUNCTION(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__)) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef UNLOCK_FUNCTION |
|
|
#ifndef UNLOCK_FUNCTION |
|
|
#define UNLOCK_FUNCTION(...) |
|
|
|
|
|
|
|
|
#define UNLOCK_FUNCTION(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__)) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifndef NO_THREAD_SAFETY_ANALYSIS |
|
|
#ifndef NO_THREAD_SAFETY_ANALYSIS |
|
|
#define NO_THREAD_SAFETY_ANALYSIS |
|
|
|
|
|
|
|
|
#define NO_THREAD_SAFETY_ANALYSIS \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifndef ASSERT_EXCLUSIVE_LOCK |
|
|
|
|
|
#define ASSERT_EXCLUSIVE_LOCK(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(assert_exclusive_lock(__VA_ARGS__)) |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifndef ASSERT_SHARED_LOCK |
|
|
|
|
|
#define ASSERT_SHARED_LOCK(...) \ |
|
|
|
|
|
THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_lock(__VA_ARGS__)) |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#endif // STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H_ |
|
|
#endif // STORAGE_LEVELDB_PORT_THREAD_ANNOTATIONS_H_ |