tools: Add sparse context/locking annotations in compiler-types.h
authorRiccardo Mancini <rickyman7@gmail.com>
Fri, 30 Jul 2021 15:34:12 +0000 (17:34 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 19 Aug 2021 18:39:22 +0000 (15:39 -0300)
This patch copies sparse context/locking annotations from
include/compiler-types.h to tools/include/compiler-types.h.

Committer notes:

This will be used in the upcoming workqueue patchset.

Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http //lore.kernel.org/lkml/58b2f161ce856ec8b499f4dcf60a10adc84651e0.1627657061.git.rickyman7@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/include/linux/compiler_types.h

index feea090..24ae305 100644 (file)
 #define __has_builtin(x) (0)
 #endif
 
+#ifdef __CHECKER__
+/* context/locking */
+# 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 /* __CHECKER__ */
+/* context/locking */
+# 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 /* __CHECKER__ */
+
 /* Compiler specific macros. */
 #ifdef __GNUC__
 #include <linux/compiler-gcc.h>