blob: c4ccd5716640070649ed5638107273e9933cb06e [file] [log] [blame]
Anthony Liguori0bfe3ca2009-05-14 19:29:53 +01001/*
2 * QEMU Module Infrastructure
3 *
4 * Copyright IBM, Corp. 2009
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
11 *
12 */
13
14#ifndef QEMU_MODULE_H
15#define QEMU_MODULE_H
16
17/* This should not be used directly. Use block_init etc. instead. */
18#define module_init(function, type) \
19static void __attribute__((constructor)) do_qemu_init_ ## function(void) { \
Anthony Liguorif7897432009-05-14 17:57:31 -050020 register_module_init(function, type); \
Anthony Liguori0bfe3ca2009-05-14 19:29:53 +010021}
22
23typedef enum {
24 MODULE_INIT_BLOCK,
Anthony Liguorif80f9ec2009-05-20 18:38:09 -050025 MODULE_INIT_MACHINE,
Michael Rothc7aa8412011-07-19 14:50:31 -050026 MODULE_INIT_QAPI,
Andreas Färber83f7d432012-02-09 15:20:55 +010027 MODULE_INIT_QOM,
Anthony Liguorif7897432009-05-14 17:57:31 -050028 MODULE_INIT_MAX
Anthony Liguori0bfe3ca2009-05-14 19:29:53 +010029} module_init_type;
30
31#define block_init(function) module_init(function, MODULE_INIT_BLOCK)
Anthony Liguorif80f9ec2009-05-20 18:38:09 -050032#define machine_init(function) module_init(function, MODULE_INIT_MACHINE)
Michael Rothc7aa8412011-07-19 14:50:31 -050033#define qapi_init(function) module_init(function, MODULE_INIT_QAPI)
Andreas Färber83f7d432012-02-09 15:20:55 +010034#define type_init(function) module_init(function, MODULE_INIT_QOM)
Anthony Liguori0bfe3ca2009-05-14 19:29:53 +010035
36void register_module_init(void (*fn)(void), module_init_type type);
37
38void module_call_init(module_init_type type);
39
40#endif