module.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  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. #ifndef QEMU_MODULE_H
  14. #define QEMU_MODULE_H
  15. /* This should not be used directly. Use block_init etc. instead. */
  16. #define module_init(function, type) \
  17. static void __attribute__((constructor)) do_qemu_init_ ## function(void) { \
  18. register_module_init(function, type); \
  19. }
  20. typedef enum {
  21. MODULE_INIT_BLOCK,
  22. MODULE_INIT_MACHINE,
  23. MODULE_INIT_QAPI,
  24. MODULE_INIT_QOM,
  25. MODULE_INIT_MAX
  26. } module_init_type;
  27. #define block_init(function) module_init(function, MODULE_INIT_BLOCK)
  28. #define machine_init(function) module_init(function, MODULE_INIT_MACHINE)
  29. #define qapi_init(function) module_init(function, MODULE_INIT_QAPI)
  30. #define type_init(function) module_init(function, MODULE_INIT_QOM)
  31. void register_module_init(void (*fn)(void), module_init_type type);
  32. void module_call_init(module_init_type type);
  33. #endif