[RFC 1/3] eal: add enhanced lock annotations
David Marchand
david.marchand at redhat.com
Mon Dec 2 13:53:14 CET 2024
Clang 3.6+ offers enhanced lock annotations when it comes to shared vs
exclusive capability/lock release.
Introduce macros for those new function attributes.
Signed-off-by: David Marchand <david.marchand at redhat.com>
---
doc/api/doxy-api.conf.in | 12 +++++++
lib/eal/include/rte_lock_annotations.h | 48 ++++++++++++++++++++++++++
2 files changed, 60 insertions(+)
diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in
index d23352d300..ac490e7631 100644
--- a/doc/api/doxy-api.conf.in
+++ b/doc/api/doxy-api.conf.in
@@ -103,6 +103,18 @@ PREDEFINED = __DOXYGEN__ \
__rte_shared_trylock_function(x)= \
__rte_assert_shared_lock(x)= \
__rte_unlock_function(x)= \
+ __rte_capability(x)= \
+ __rte_requires_capability(x)= \
+ __rte_acquire_capability(x)= \
+ __rte_try_acquire_capability(x)= \
+ __rte_release_capability(x)= \
+ __rte_assert_capability(x)= \
+ __rte_requires_shared_capability(x)= \
+ __rte_acquire_shared_capability(x)= \
+ __rte_try_acquire_shared_capability(x)= \
+ __rte_release_shared_capability(x)= \
+ __rte_assert_shared_capability(x)= \
+ __rte_exclude_capability(x)= \
__attribute__(x)=
OPTIMIZE_OUTPUT_FOR_C = YES
diff --git a/lib/eal/include/rte_lock_annotations.h b/lib/eal/include/rte_lock_annotations.h
index 2456a69352..4240458c53 100644
--- a/lib/eal/include/rte_lock_annotations.h
+++ b/lib/eal/include/rte_lock_annotations.h
@@ -43,6 +43,36 @@ extern "C" {
#define __rte_locks_excluded(...) \
__attribute__((locks_excluded(__VA_ARGS__)))
+
+#define __rte_capability(...) \
+ __attribute__((capability(__VA_ARGS__)))
+
+#define __rte_requires_capability(...) \
+ __attribute__((requires_capability(__VA_ARGS__)))
+#define __rte_acquire_capability(...) \
+ __attribute__((acquire_capability(__VA_ARGS__)))
+#define __rte_try_acquire_capability(ret, ...) \
+ __attribute__((try_acquire_capability(ret, __VA_ARGS__)))
+#define __rte_release_capability(...) \
+ __attribute__((release_capability(__VA_ARGS__)))
+#define __rte_assert_capability(...) \
+ __attribute__((assert_capability(__VA_ARGS__)))
+
+#define __rte_requires_shared_capability(...) \
+ __attribute__((requires_shared_capability(__VA_ARGS__)))
+#define __rte_acquire_shared_capability(...) \
+ __attribute__((acquire_shared_capability(__VA_ARGS__)))
+#define __rte_try_acquire_shared_capability(ret, ...) \
+ __attribute__((try_acquire_shared_capability(ret, __VA_ARGS__)))
+#define __rte_release_shared_capability(...) \
+ __attribute__((release_shared_capability(__VA_ARGS__)))
+#define __rte_assert_shared_capability(...) \
+ __attribute__((assert_shared_capability(__VA_ARGS__)))
+
+#define __rte_exclude_capability(...) \
+ __attribute__((exclude_capability(__VA_ARGS__)))
+
+
#define __rte_no_thread_safety_analysis \
__attribute__((no_thread_safety_analysis))
@@ -67,6 +97,24 @@ extern "C" {
#define __rte_locks_excluded(...)
+
+#define __rte_capability(...)
+
+#define __rte_requires_capability(...)
+#define __rte_acquire_capability(...)
+#define __rte_try_acquire_capability(...)
+#define __rte_release_capability(...)
+#define __rte_assert_capability(...)
+
+#define __rte_requires_shared_capability(...)
+#define __rte_acquire_shared_capability(...)
+#define __rte_try_acquire_shared_capability(...)
+#define __rte_release_shared_capability(...)
+#define __rte_assert_shared_capability(...)
+
+#define __rte_exclude_capability(...)
+
+
#define __rte_no_thread_safety_analysis
#endif /* RTE_ANNOTATE_LOCKS */
--
2.47.0
More information about the dev
mailing list