[RFC PATCH 05/10] perf workqueue: add sparse annotation header
From: Riccardo Mancini
Date: Tue Jul 13 2021 - 08:11:47 EST
This patch adds a simple header containing sparse annotations.
TODO: what is the best place to put this?
Signed-off-by: Riccardo Mancini <rickyman7@xxxxxxxxx>
---
tools/perf/util/workqueue/sparse.h | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 tools/perf/util/workqueue/sparse.h
diff --git a/tools/perf/util/workqueue/sparse.h b/tools/perf/util/workqueue/sparse.h
new file mode 100644
index 0000000000000000..644f6db8f050ab50
--- /dev/null
+++ b/tools/perf/util/workqueue/sparse.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __WORKQUEUE_SPARSE_H
+#define __WORKQUEUE_SPARSE_H
+
+#ifdef __CHECKER__
+# define __must_hold(x) __attribute__((context(x, 1, 1)))
+# define __acquires(x) __attribute__((context(x, 0, 1)))
+# define __releases(x) __attribute__((context(x, 1, 0)))
+# define __acquire(x) __context__(x, 1)
+# define __release(x) __context__(x, -1)
+# define __cond_lock(x, c) ((c) ? ({ __acquire(x); 1; }) : 0)
+#else
+# define __must_hold(x)
+# define __acquires(x)
+# define __releases(x)
+# define __acquire(x) ((void)0)
+# define __release(x) ((void)0)
+# define __cond_lock(x, c) (c)
+#endif
+
+#endif /* __WORKQUEUE_SPARSE_H */
--
2.31.1