dlfcn.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * dlfcn-win32
  3. * Copyright (c) 2007 Ramiro Polla
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. * THE SOFTWARE.
  22. */
  23. #ifndef DLFCN_H
  24. #define DLFCN_H
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #if defined(DLFCN_WIN32_SHARED)
  29. #if defined(DLFCN_WIN32_EXPORTS)
  30. # define DLFCN_EXPORT __declspec(dllexport)
  31. #else
  32. # define DLFCN_EXPORT __declspec(dllimport)
  33. #endif
  34. #else
  35. # define DLFCN_EXPORT
  36. #endif
  37. /* Relocations are performed when the object is loaded. */
  38. #define RTLD_NOW 0
  39. /* Relocations are performed at an implementation-defined time.
  40. * Windows API does not support lazy symbol resolving (when first reference
  41. * to a given symbol occurs). So RTLD_LAZY implementation is same as RTLD_NOW.
  42. */
  43. #define RTLD_LAZY RTLD_NOW
  44. /* All symbols are available for relocation processing of other modules. */
  45. #define RTLD_GLOBAL (1 << 1)
  46. /* All symbols are not made available for relocation processing by other modules. */
  47. #define RTLD_LOCAL (1 << 2)
  48. /* These two were added in The Open Group Base Specifications Issue 6.
  49. * Note: All other RTLD_* flags in any dlfcn.h are not standard compliant.
  50. */
  51. /* The symbol lookup happens in the normal global scope. */
  52. #define RTLD_DEFAULT ((void *)0)
  53. /* Specifies the next object after this one that defines name. */
  54. #define RTLD_NEXT ((void *)-1)
  55. /* Structure filled in by dladdr() */
  56. typedef struct dl_info
  57. {
  58. const char *dli_fname; /* Filename of defining object (thread unsafe and reused on every call to dladdr) */
  59. void *dli_fbase; /* Load address of that object */
  60. const char *dli_sname; /* Name of nearest lower symbol */
  61. void *dli_saddr; /* Exact value of nearest symbol */
  62. } Dl_info;
  63. /* Open a symbol table handle. */
  64. DLFCN_EXPORT void *dlopen(const char *file, int mode);
  65. /* Close a symbol table handle. */
  66. DLFCN_EXPORT int dlclose(void *handle);
  67. /* Get the address of a symbol from a symbol table handle. */
  68. DLFCN_EXPORT void *dlsym(void *handle, const char *name);
  69. /* Get diagnostic information. */
  70. DLFCN_EXPORT char *dlerror(void);
  71. /* Translate address to symbolic information (no POSIX standard) */
  72. DLFCN_EXPORT int dladdr(const void *addr, Dl_info *info);
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #endif /* DLFCN_H */