[4/5] compel: Add plugins header

Submitted by Cyrill Gorcunov on Aug. 31, 2016, 1:48 p.m.

Details

Message ID 1472651309-4725-5-git-send-email-gorcunov@openvz.org
State Accepted
Series "compel: Split big patch"
Commit 99ee7b123d754eaee3283be214bc01dc1e436289
Headers show

Commit Message

Cyrill Gorcunov Aug. 31, 2016, 1:48 p.m.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 compel/include/uapi/plugins.h | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 compel/include/uapi/plugins.h

Patch hide | download patch | download mbox

diff --git a/compel/include/uapi/plugins.h b/compel/include/uapi/plugins.h
new file mode 100644
index 000000000000..e9ebfb67f7c7
--- /dev/null
+++ b/compel/include/uapi/plugins.h
@@ -0,0 +1,35 @@ 
+#ifndef UAPI_COMPEL_PLUGIN_H__
+#define UAPI_COMPEL_PLUGIN_H__
+
+#define __init	__attribute__((__used__)) __attribute__ ((__section__(".compel.init")))
+#define __exit	__attribute__((__used__)) __attribute__ ((__section__(".compel.exit")))
+
+#ifndef __ASSEMBLY__
+
+typedef struct {
+	const char	*name;
+	int		(*init)(void);
+	void		(*exit)(void);
+} plugin_init_t;
+
+#define plugin_register(___desc)				\
+	static const plugin_init_t * const			\
+	___ptr__##___desc __init = &___desc;
+
+#define PLUGIN_REGISTER(___id, ___name, ___init, ___exit)	\
+	static const plugin_init_t __plugin_desc_##___id = {	\
+		.name = ___name,				\
+		.init = ___init,				\
+		.exit = ___exit,				\
+	};							\
+	plugin_register(__plugin_desc_##___id);
+
+#define PLUGIN_REGISTER_DUMMY(___id)				\
+	static const plugin_init_t __plugin_desc_##___id = {	\
+		.name = #___id,					\
+	};							\
+	plugin_register(__plugin_desc_##___id);
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* UAPI_COMPEL_PLUGIN_H__ */