[CRIU] [RFC PATCH 05/21] compiler.h: add basic attribute cleanup machinery

Ivan Shapovalov intelfx at intelfx.name
Fri Feb 19 06:50:28 PST 2016


Signed-off-by: Ivan Shapovalov <intelfx at intelfx.name>
---
 criu/include/compiler.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/criu/include/compiler.h b/criu/include/compiler.h
index 6bce935..37a6880 100644
--- a/criu/include/compiler.h
+++ b/criu/include/compiler.h
@@ -44,6 +44,15 @@
  */
 #define __stack_aligned__	__attribute__((aligned(16)))
 
+#define __cleanup(x)            __attribute__((cleanup(x)))
+#define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func)                 \
+	static inline void func##p(type *arg)                   \
+	{                                                       \
+		if (*arg) {                                     \
+			func(*arg);                             \
+		}                                               \
+	}
+
 #ifndef offsetof
 # define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
 #endif
-- 
2.7.1



More information about the CRIU mailing list