modules.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
  3. (c) Copyright 2000-2004 Convergence (integrated media) GmbH
  4. All rights reserved.
  5. Written by Denis Oliver Kropp <dok@directfb.org>,
  6. Andreas Hundt <andi@fischlustig.de>,
  7. Sven Neumann <neo@directfb.org>,
  8. Ville Syrjälä <syrjala@sci.fi> and
  9. Claudio Ciccani <klan@users.sf.net>.
  10. This library is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU Lesser General Public
  12. License as published by the Free Software Foundation; either
  13. version 2 of the License, or (at your option) any later version.
  14. This library is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. Lesser General Public License for more details.
  18. You should have received a copy of the GNU Lesser General Public
  19. License along with this library; if not, write to the
  20. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  21. Boston, MA 02111-1307, USA.
  22. */
  23. #ifndef __DIRECT__MODULES_H__
  24. #define __DIRECT__MODULES_H__
  25. #include <pthread.h>
  26. #include <direct/types.h>
  27. #include <direct/list.h>
  28. #include <direct/util.h>
  29. struct __D_DirectModuleEntry {
  30. DirectLink link;
  31. int magic;
  32. DirectModuleDir *directory;
  33. bool loaded;
  34. bool dynamic;
  35. bool disabled;
  36. char *name;
  37. const void *funcs;
  38. int refs;
  39. char *file;
  40. void *handle;
  41. };
  42. struct __D_DirectModuleDir {
  43. pthread_mutex_t lock;
  44. const char *path;
  45. unsigned int abi_version;
  46. DirectLink *entries;
  47. DirectModuleEntry *loading;
  48. };
  49. #define DECLARE_MODULE_DIRECTORY(d) \
  50. extern DirectModuleDir d
  51. #define DEFINE_MODULE_DIRECTORY(d,p,n) \
  52. DirectModuleDir d = { \
  53. .lock = PTHREAD_MUTEX_INITIALIZER, \
  54. .path = p, \
  55. .abi_version = n, \
  56. .entries = NULL, \
  57. .loading = NULL, \
  58. }
  59. int direct_modules_explore_directory( DirectModuleDir *directory );
  60. void direct_modules_register( DirectModuleDir *directory,
  61. unsigned int abi_version,
  62. const char *name,
  63. const void *funcs );
  64. void direct_modules_unregister( DirectModuleDir *directory,
  65. const char *name );
  66. const void *direct_module_ref ( DirectModuleEntry *module );
  67. void direct_module_unref( DirectModuleEntry *module );
  68. #endif