Project
Loading...
Searching...
No Matches
ThreadSafetyAnalysis.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef O2_FRAMEWORK_THREADSAFETYANALYSIS_H_
12#define O2_FRAMEWORK_THREADSAFETYANALYSIS_H_
13
21
22// Assume that we only need this is someone else is not using the
23// same clang provided macros
24#ifndef O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__
25#if defined(__clang__) && (!defined(SWIG)) && defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
26#define O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
27#else
28#define O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
29#endif
30
31#define O2_DPL_CAPABILITY(x) \
32 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
33
34#define O2_DPL_SCOPED_CAPABILITY \
35 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
36
37#define O2_DPL_GUARDED_BY(x) \
38 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
39
40#define O2_DPL_PT_GUARDED_BY(x) \
41 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
42
43#define O2_DPL_ACQUIRED_BEFORE(...) \
44 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
45
46#define O2_DPL_ACQUIRED_AFTER(...) \
47 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
48
49#define O2_DPL_REQUIRES(...) \
50 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
51
52#define O2_DPL_REQUIRES_SHARED(...) \
53 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
54
55#define O2_DPL_ACQUIRE(...) \
56 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
57
58#define O2_DPL_ACQUIRE_SHARED(...) \
59 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
60
61#define O2_DPL_RELEASE(...) \
62 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
63
64#define O2_DPL_RELEASE_SHARED(...) \
65 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
66
67#define O2_DPL_RELEASE_GENERIC(...) \
68 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(__VA_ARGS__))
69
70#define O2_DPL_TRY_ACQUIRE(...) \
71 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
72
73#define O2_DPL_TRY_ACQUIRE_SHARED(...) \
74 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
75
76#define O2_DPL_EXCLUDES(...) \
77 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
78
79#define O2_DPL_ASSERT_CAPABILITY(x) \
80 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
81
82#define O2_DPL_ASSERT_SHARED_CAPABILITY(x) \
83 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
84
85#define O2_DPL_RETURN_CAPABILITY(x) \
86 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
87
88#define O2_DPL_NO_THREAD_SAFETY_ANALYSIS \
89 O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
90
91#endif // O2_DPL_THREAD_ANNOTATION_ATTRIBUTE__
92#endif // O2_FRAMEWORK_THREADSAFETYANALYSIS_H_