20 #ifndef _PEDIGREE_KERNEL_UTILITIES_THREADSAFETY_H 21 #define _PEDIGREE_KERNEL_UTILITIES_THREADSAFETY_H 25 #if defined(__clang__) 26 #define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) 28 #define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op 31 #define CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(capability(x)) 32 #define SCOPED_CAPABILITY THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) 33 #define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) 34 #define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) 35 #define ACQUIRED_BEFORE(...) \ 36 THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__)) 37 #define ACQUIRED_AFTER(...) \ 38 THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__)) 39 #define REQUIRES(...) \ 40 THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__)) 41 #define REQUIRES_SHARED(...) \ 42 THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__)) 43 #define ACQUIRE(...) \ 44 THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__)) 45 #define ACQUIRE_SHARED(...) \ 46 THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__)) 47 #define RELEASE(...) \ 48 THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__)) 49 #define RELEASE_SHARED(...) \ 50 THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__)) 51 #define TRY_ACQUIRE(...) \ 52 THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__)) 53 #define TRY_ACQUIRE_SHARED(...) \ 54 THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__)) 55 #define EXCLUDES(...) THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__)) 56 #define ASSERT_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) 57 #define ASSERT_SHARED_CAPABILITY(x) \ 58 THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) 59 #define RETURN_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) 60 #define NO_THREAD_SAFETY_ANALYSIS \ 61 THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)