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/slab.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/slab.h')
-rw-r--r-- | include/linux/slab.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index 6b3e155b70bf..c1fb57d6107c 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -17,6 +17,7 @@ #include <linux/types.h> #include <linux/workqueue.h> #include <linux/percpu-refcount.h> +#include <linux/cleanup.h> /* @@ -211,6 +212,8 @@ void kfree(const void *objp); void kfree_sensitive(const void *objp); size_t __ksize(const void *objp); +DEFINE_FREE(kfree, void *, if (_T) kfree(_T)) + /** * ksize - Report actual allocation size of associated object * |