]> Git Repo - qemu.git/blame - include/qemu/module.h
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
[qemu.git] / include / qemu / module.h
CommitLineData
0bfe3ca5
AL
1/*
2 * QEMU Module Infrastructure
3 *
4 * Copyright IBM, Corp. 2009
5 *
6 * Authors:
7 * Anthony Liguori <[email protected]>
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
e26110cf
FZ
17#include "qemu/osdep.h"
18
19#define DSO_STAMP_FUN glue(qemu_stamp, CONFIG_STAMP)
20#define DSO_STAMP_FUN_STR stringify(DSO_STAMP_FUN)
21
22#ifdef BUILD_DSO
23void DSO_STAMP_FUN(void);
24/* This is a dummy symbol to identify a loaded DSO as a QEMU module, so we can
25 * distinguish "version mismatch" from "not a QEMU module", when the stamp
26 * check fails during module loading */
27void qemu_module_dummy(void);
28
29#define module_init(function, type) \
30static void __attribute__((constructor)) do_qemu_init_ ## function(void) \
31{ \
32 register_dso_module_init(function, type); \
33}
34#else
0bfe3ca5
AL
35/* This should not be used directly. Use block_init etc. instead. */
36#define module_init(function, type) \
e26110cf
FZ
37static void __attribute__((constructor)) do_qemu_init_ ## function(void) \
38{ \
f7897430 39 register_module_init(function, type); \
0bfe3ca5 40}
e26110cf 41#endif
0bfe3ca5
AL
42
43typedef enum {
44 MODULE_INIT_BLOCK,
f80f9ec9 45 MODULE_INIT_MACHINE,
c7aa841e 46 MODULE_INIT_QAPI,
83f7d43a 47 MODULE_INIT_QOM,
f7897430 48 MODULE_INIT_MAX
0bfe3ca5
AL
49} module_init_type;
50
51#define block_init(function) module_init(function, MODULE_INIT_BLOCK)
f80f9ec9 52#define machine_init(function) module_init(function, MODULE_INIT_MACHINE)
c7aa841e 53#define qapi_init(function) module_init(function, MODULE_INIT_QAPI)
83f7d43a 54#define type_init(function) module_init(function, MODULE_INIT_QOM)
0bfe3ca5
AL
55
56void register_module_init(void (*fn)(void), module_init_type type);
e26110cf 57void register_dso_module_init(void (*fn)(void), module_init_type type);
0bfe3ca5
AL
58
59void module_call_init(module_init_type type);
60
61#endif
This page took 0.4416 seconds and 4 git commands to generate.