diff options
author | Peter Zijlstra <peterz@infradead.org> | 2023-05-26 13:23:48 +0300 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2023-06-26 12:14:18 +0300 |
commit | 54da6a0924311c7cf5015533991e44fb8eb12773 (patch) | |
tree | af497256995d40431b9c214e7faa45639bf3d991 /include/linux/compiler_attributes.h | |
parent | 9a1f37ebcfe061721564042254719dc8fd5c9fa0 (diff) | |
download | linux-54da6a0924311c7cf5015533991e44fb8eb12773.tar.xz |
locking: Introduce __cleanup() based infrastructure
Use __attribute__((__cleanup__(func))) to build:
- simple auto-release pointers using __free()
- 'classes' with constructor and destructor semantics for
scope-based resource management.
- lock guards based on the above classes.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20230612093537.614161713%40infradead.org
Diffstat (limited to 'include/linux/compiler_attributes.h')
-rw-r--r-- | include/linux/compiler_attributes.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h index e659cb6fded3..081deaef1f0f 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -70,6 +70,12 @@ #define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__))) /* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-cleanup-variable-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#cleanup + */ +#define __cleanup(func) __attribute__((__cleanup__(func))) + +/* * Note the long name. * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute |