DPDK 25.03.0-rc1
rte_lock_annotations.h
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2022 Red Hat, Inc.
3 */
4
5#ifndef RTE_LOCK_ANNOTATIONS_H
6#define RTE_LOCK_ANNOTATIONS_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#ifdef RTE_ANNOTATE_LOCKS
13
14#define __rte_lockable \
15 __attribute__((lockable))
16
17#define __rte_guarded_by(...) \
18 __attribute__((guarded_by(__VA_ARGS__)))
19#define __rte_guarded_var \
20 __attribute__((guarded_var))
21
22#define __rte_exclusive_locks_required(...) \
23 __attribute__((exclusive_locks_required(__VA_ARGS__)))
24#define __rte_exclusive_lock_function(...) \
25 __attribute__((exclusive_lock_function(__VA_ARGS__)))
26#define __rte_exclusive_trylock_function(ret, ...) \
27 __attribute__((exclusive_trylock_function(ret, __VA_ARGS__)))
28#define __rte_assert_exclusive_lock(...) \
29 __attribute__((assert_exclusive_lock(__VA_ARGS__)))
30
31#define __rte_shared_locks_required(...) \
32 __attribute__((shared_locks_required(__VA_ARGS__)))
33#define __rte_shared_lock_function(...) \
34 __attribute__((shared_lock_function(__VA_ARGS__)))
35#define __rte_shared_trylock_function(ret, ...) \
36 __attribute__((shared_trylock_function(ret, __VA_ARGS__)))
37#define __rte_assert_shared_lock(...) \
38 __attribute__((assert_shared_lock(__VA_ARGS__)))
39
40#define __rte_unlock_function(...) \
41 __attribute__((unlock_function(__VA_ARGS__)))
42
43#define __rte_locks_excluded(...) \
44 __attribute__((locks_excluded(__VA_ARGS__)))
45
46
47#if defined(__clang__) && __clang_major__ >= 11
48#define __rte_capability(...) \
49 __attribute__((capability(__VA_ARGS__)))
50#else
51#define __rte_capability(...) \
52 __attribute__((capability("mutex")))
53#endif
54
55#define __rte_requires_capability(...) \
56 __attribute__((requires_capability(__VA_ARGS__)))
57#define __rte_acquire_capability(...) \
58 __attribute__((acquire_capability(__VA_ARGS__)))
59#define __rte_try_acquire_capability(ret, ...) \
60 __attribute__((try_acquire_capability(ret, __VA_ARGS__)))
61#define __rte_release_capability(...) \
62 __attribute__((release_capability(__VA_ARGS__)))
63#define __rte_assert_capability(...) \
64 __attribute__((assert_capability(__VA_ARGS__)))
65
66#define __rte_requires_shared_capability(...) \
67 __attribute__((requires_shared_capability(__VA_ARGS__)))
68#define __rte_acquire_shared_capability(...) \
69 __attribute__((acquire_shared_capability(__VA_ARGS__)))
70#define __rte_try_acquire_shared_capability(ret, ...) \
71 __attribute__((try_acquire_shared_capability(ret, __VA_ARGS__)))
72#define __rte_release_shared_capability(...) \
73 __attribute__((release_shared_capability(__VA_ARGS__)))
74#define __rte_assert_shared_capability(...) \
75 __attribute__((assert_shared_capability(__VA_ARGS__)))
76
77#define __rte_exclude_capability(...) \
78 __attribute__((exclude_capability(__VA_ARGS__)))
79
80
81#define __rte_no_thread_safety_analysis \
82 __attribute__((no_thread_safety_analysis))
83
84#else /* ! RTE_ANNOTATE_LOCKS */
85
86#define __rte_lockable
87
88#define __rte_guarded_by(...)
89#define __rte_guarded_var
90
91#define __rte_exclusive_locks_required(...)
92#define __rte_exclusive_lock_function(...)
93#define __rte_exclusive_trylock_function(...)
94#define __rte_assert_exclusive_lock(...)
95
96#define __rte_shared_locks_required(...)
97#define __rte_shared_lock_function(...)
98#define __rte_shared_trylock_function(...)
99#define __rte_assert_shared_lock(...)
100
101#define __rte_unlock_function(...)
102
103#define __rte_locks_excluded(...)
104
105
106#define __rte_capability(...)
107
108#define __rte_requires_capability(...)
109#define __rte_acquire_capability(...)
110#define __rte_try_acquire_capability(...)
111#define __rte_release_capability(...)
112#define __rte_assert_capability(...)
113
114#define __rte_requires_shared_capability(...)
115#define __rte_acquire_shared_capability(...)
116#define __rte_try_acquire_shared_capability(...)
117#define __rte_release_shared_capability(...)
118#define __rte_assert_shared_capability(...)
119
120#define __rte_exclude_capability(...)
121
122
123#define __rte_no_thread_safety_analysis
124
125#endif /* RTE_ANNOTATE_LOCKS */
126
127#ifdef __cplusplus
128}
129#endif
130
131#endif /* RTE_LOCK_ANNOTATIONS_H */