mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
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
This commit is contained in:
@@ -5,6 +5,15 @@
|
||||
|
||||
/* Compiler specific definitions for Clang compiler */
|
||||
|
||||
/*
|
||||
* Clang prior to 17 is being silly and considers many __cleanup() variables
|
||||
* as unused (because they are, their sole purpose is to go out of scope).
|
||||
*
|
||||
* https://reviews.llvm.org/D152180
|
||||
*/
|
||||
#undef __cleanup
|
||||
#define __cleanup(func) __maybe_unused __attribute__((__cleanup__(func)))
|
||||
|
||||
/* same as gcc, this was present in clang-2.6 so we can assume it works
|
||||
* with any version that can compile the kernel
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user