From ab3c0ddb0d71dc214b61d11deb8770196ef46c05 Mon Sep 17 00:00:00 2001 From: Riccardo Mancini Date: Fri, 30 Jul 2021 17:34:12 +0200 Subject: tools: Add sparse context/locking annotations in compiler-types.h 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 Cc: Alexey Bayduraev Cc: Ian Rogers Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: http //lore.kernel.org/lkml/58b2f161ce856ec8b499f4dcf60a10adc84651e0.1627657061.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/compiler_types.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tools/include/linux/compiler_types.h') diff --git a/tools/include/linux/compiler_types.h b/tools/include/linux/compiler_types.h index feea09029f61..24ae3054f304 100644 --- a/tools/include/linux/compiler_types.h +++ b/tools/include/linux/compiler_types.h @@ -13,6 +13,24 @@ #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 -- cgit v1.2.3-59-g8ed1b