Use __attribute__((__cleanup__(func))) to buid various guards:
- ptr_guard()
- void_guard() / void_scope()
- lock_guard() / lock_scope()
- double_lock_guard() / double_lock_scope()
Where the _guard thingies are variables with scope-based cleanup and
the _scope thingies are basically do-once for-loops with the same.
The CPP is rather impenetrable -- but I'll attempt to write proper
comments if/when people think this is worth pursuing.
Actual usage in the next patch
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
include/linux/compiler_attributes.h | 2
include/linux/irqflags.h | 7 ++
include/linux/guards.h | 118 ++++++++++++++++++++++++++++++++++++
include/linux/mutex.h | 5 +
include/linux/preempt.h | 4 +
include/linux/rcupdate.h | 3
include/linux/sched/task.h | 2
include/linux/spinlock.h | 23 +++++++
8 files changed, 164 insertions(+)