| Flutter Impeller |

thread_safety.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #pragma once
6
7 #if defined(__clang__)
8 #define IPLR_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
9 #else
10 #define IPLR_THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
11 #endif
12
13 #define IPLR_CAPABILITY(x) IPLR_THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
14
15 #define IPLR_SCOPED_CAPABILITY \
16 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
17
18 #define IPLR_GUARDED_BY(x) IPLR_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
19
20 #define IPLR_PT_GUARDED_BY(x) \
21 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
22
23 #define IPLR_ACQUIRED_BEFORE(...) \
24 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__))
25
26 #define IPLR_ACQUIRED_AFTER(...) \
27 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__))
28
29 #define IPLR_REQUIRES(...) \
30 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(__VA_ARGS__))
31
32 #define IPLR_REQUIRES_SHARED(...) \
33 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(__VA_ARGS__))
34
35 #define IPLR_ACQUIRE(...) \
36 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(__VA_ARGS__))
37
38 #define IPLR_ACQUIRE_SHARED(...) \
39 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(__VA_ARGS__))
40
41 #define IPLR_RELEASE(...) \
42 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__))
43
44 #define IPLR_RELEASE_SHARED(...) \
45 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))
46
47 #define IPLR_RELEASE_GENERIC(...) \
48 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(__VA_ARGS__))
49
50 #define IPLR_TRY_ACQUIRE(...) \
51 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))
52
53 #define IPLR_TRY_ACQUIRE_SHARED(...) \
54 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(__VA_ARGS__))
55
56 #define IPLR_EXCLUDES(...) \
57 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__))
58
59 #define IPLR_ASSERT_CAPABILITY(x) \
60 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
61
62 #define IPLR_ASSERT_SHARED_CAPABILITY(x) \
63 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
64
65 #define IPLR_RETURN_CAPABILITY(x) \
66 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
67
68 #define IPLR_NO_THREAD_SAFETY_ANALYSIS \
69 IPLR_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)