lt__private.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* lt__private.h -- internal apis for libltdl
  2. Copyright (C) 2004-2008, 2011-2015 Free Software Foundation, Inc.
  3. Written by Gary V. Vaughan, 2004
  4. NOTE: The canonical source of this file is maintained with the
  5. GNU Libtool package. Report bugs to bug-libtool@gnu.org.
  6. This library is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Lesser General Public
  8. License as published by the Free Software Foundation; either
  9. version 2 of the License, or (at your option) any later version.
  10. As a special exception to the GNU Lesser General Public License,
  11. if you distribute this file as part of a program or library that
  12. is built using GNU libtool, you may include this file under the
  13. same distribution terms that you use for the rest of that program.
  14. GNU Libltdl 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
  17. GNU Lesser General Public License for more details.
  18. You should have received a copy of the GNU Lesser General Public
  19. License along with GNU Libltdl; see the file COPYING.LIB. If not, a
  20. copy con be downloaded from http://www.gnu.org/licenses/lgpl.html,
  21. or obtained by writing to the Free Software Foundation, Inc.,
  22. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #if !defined LT__PRIVATE_H
  25. #define LT__PRIVATE_H 1
  26. #if defined LT_CONFIG_H
  27. # include LT_CONFIG_H
  28. #else
  29. # include <config.h>
  30. #endif
  31. #include <stdio.h>
  32. #include <ctype.h>
  33. #include <assert.h>
  34. #include <errno.h>
  35. #include <string.h>
  36. #if defined HAVE_UNISTD_H
  37. # include <unistd.h>
  38. #endif
  39. /* Import internal interfaces... */
  40. #include "lt__alloc.h"
  41. #include "lt__dirent.h"
  42. #include "lt__strl.h"
  43. #include "lt__glibc.h"
  44. /* ...and all exported interfaces. */
  45. #include "ltdl.h"
  46. #if defined WITH_DMALLOC
  47. # include <dmalloc.h>
  48. #endif
  49. /* DLL building support on win32 hosts; mostly to workaround their
  50. ridiculous implementation of data symbol exporting. */
  51. #ifndef LT_GLOBAL_DATA
  52. # if defined __WINDOWS__ || defined __CYGWIN__
  53. # if defined DLL_EXPORT /* defined by libtool (if required) */
  54. # define LT_GLOBAL_DATA __declspec(dllexport)
  55. # endif
  56. # endif
  57. # ifndef LT_GLOBAL_DATA
  58. # define LT_GLOBAL_DATA /* static linking or !__WINDOWS__ */
  59. # endif
  60. #endif
  61. #ifndef __attribute__
  62. # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
  63. # define __attribute__(x)
  64. # endif
  65. #endif
  66. #ifndef LT__UNUSED
  67. # define LT__UNUSED __attribute__ ((__unused__))
  68. #endif
  69. LT_BEGIN_C_DECLS
  70. #if !defined errno
  71. extern int errno;
  72. #endif
  73. LT_SCOPE void lt__alloc_die_callback (void);
  74. /* For readability: */
  75. #define STRNEQ(s1, s2) (strcmp((s1), (s2)) != 0)
  76. #define STREQ(s1, s2) (strcmp((s1), (s2)) == 0)
  77. /* --- OPAQUE STRUCTURES DECLARED IN LTDL.H --- */
  78. /* This type is used for the array of interface data sets in each handler. */
  79. typedef struct {
  80. lt_dlinterface_id key;
  81. void * data;
  82. } lt_interface_data;
  83. struct lt__handle {
  84. lt_dlhandle next;
  85. const lt_dlvtable * vtable; /* dlopening interface */
  86. lt_dlinfo info; /* user visible fields */
  87. int depcount; /* number of dependencies */
  88. lt_dlhandle * deplibs; /* dependencies */
  89. lt_module module; /* system module handle */
  90. void * system; /* system specific data */
  91. lt_interface_data * interface_data; /* per caller associated data */
  92. int flags; /* various boolean stats */
  93. };
  94. struct lt__advise {
  95. unsigned int try_ext:1; /* try system library extensions. */
  96. unsigned int is_resident:1; /* module can't be unloaded. */
  97. unsigned int is_symglobal:1; /* module symbols can satisfy
  98. subsequently loaded modules. */
  99. unsigned int is_symlocal:1; /* module symbols are only available
  100. locally. */
  101. unsigned int try_preload_only:1;/* only preloaded modules will be tried. */
  102. };
  103. /* --- ERROR HANDLING --- */
  104. /* Extract the diagnostic strings from the error table macro in the same
  105. order as the enumerated indices in lt_error.h. */
  106. #define LT__STRERROR(name) lt__error_string(LT_CONC(LT_ERROR_,name))
  107. #define LT__GETERROR(lvalue) (lvalue) = lt__get_last_error()
  108. #define LT__SETERRORSTR(errormsg) lt__set_last_error(errormsg)
  109. #define LT__SETERROR(errorcode) LT__SETERRORSTR(LT__STRERROR(errorcode))
  110. LT_SCOPE const char *lt__error_string (int errorcode);
  111. LT_SCOPE const char *lt__get_last_error (void);
  112. LT_SCOPE const char *lt__set_last_error (const char *errormsg);
  113. LT_END_C_DECLS
  114. #endif /*!defined LT__PRIVATE_H*/