+1999-03-18 Thomas Tanner <tanner@gmx.de>
+
+ * NEWS: improved support for BeOS and Cygwin
+ * libltdl/ltdl.c: added two new error messages (cannot_open_error,
+ cannot_close_error), use them where approriate,
+ BeOS support (thanks to Xavier Pianet), on BeOS search modules
+ additionally in ADDON_PATH
+ * libtool.m4: rewrote AC_CHECK_LIBM: BeOS and Cygwin don't have
+ libm and *-ncr-sysv4.3* requires libmw
+ * ltconfig.in: don't check for LoadLibrary, hardcode dlopen
+ configuration for BeOS and Cygwin
+ * ltmain.in: ignore -lm on BeOS and Cygwin, always ignore -lc
+
1999-03-17 Alexandre Oliva <oliva@dcc.unicamp.br>
* ltconfig.in (hpux*, hardcode_minus_L): should be no, we have +b
static const char dlopen_not_supported_error[] = "dlopen support not available";
static const char file_not_found_error[] = "file not found";
static const char no_symbols_error[] = "no symbols defined";
+static const char cannot_open_error[] = "can't open the module";
+static const char cannot_close_error[] = "can't close the module";
static const char symbol_error[] = "symbol not found";
static const char memory_error[] = "not enough memory";
static const char invalid_handle_error[] = "invalid handle";
# include <dlfcn.h>
#endif
-#if ! HAVE_DLERROR /* not all platforms have dlerror() */
-#define dlerror() unknown_error
-#endif
-
#ifdef RTLD_GLOBAL
# define LTDL_GLOBAL RTLD_GLOBAL
#else
{
handle->handle = dlopen(filename, LTDL_GLOBAL | LTDL_LAZY_OR_NOW);
if (!handle->handle) {
+#if HAVE_DLERROR
last_error = dlerror();
+#else
+ last_error = cannot_open_error;
+#endif
return 1;
}
return 0;
lt_dlhandle handle;
{
if (dlclose(handle->handle) != 0) {
+#if HAVE_DLERROR
last_error = dlerror();
+#else
+ last_error = cannot_close_error;
+#endif
return 1;
}
return 0;
lt_ptr_t address = dlsym(handle->handle, symbol);
if (!address)
+#if HAVE_DLERROR
last_error = dlerror();
+#else
+ last_error = symbol_error;
+#endif
return address;
}
{
handle->handle = shl_load(filename, LTDL_BIND_FLAGS, 0L);
if (!handle->handle) {
- last_error = unknown_error;
+ last_error = cannot_open_error;
return 1;
}
return 0;
lt_dlhandle handle;
{
if (shl_unload((shl_t) (handle->handle)) != 0) {
- last_error = unknown_error;
+ last_error = cannot_close_error;
return 1;
}
return 0;
if (shl_findsym((shl_t) (handle->handle), symbol, TYPE_UNDEFINED,
&address) != 0 || !(handle->handle) || !address) {
- last_error = unknown_error;
+ last_error = symbol_error;
return 0;
}
return address;
return 1;
}
if (dld_link(filename) != 0) {
- last_error = unknown_error;
+ last_error = cannot_open_error;
lt_dlfree(handle->handle);
return 1;
}
lt_dlhandle handle;
{
if (dld_unlink_by_file((char*)(handle->handle), 1) != 0) {
- last_error = unknown_error;
+ last_error = cannot_close_error;
return 1;
}
lt_dlfree(handle->filename);
lt_ptr_t address = dld_get_func(symbol);
if (!address)
- last_error = unknown_error;
+ last_error = symbol_error;
return address;
}
{
handle->handle = LoadLibrary(filename);
if (!handle->handle) {
- last_error = unknown_error;
+ last_error = cannot_open_error;
return 1;
}
return 0;
lt_dlhandle handle;
{
if (FreeLibrary(handle->handle) != 0) {
- last_error = unknown_error;
+ last_error = cannot_close_error;
return 1;
}
return 0;
lt_ptr_t address = GetProcAddress(handle->handle, symbol);
if (!address)
- last_error = unknown_error;
+ last_error = symbol_error;
return address;
}
#endif
+#ifdef __BEOS__
+
+/* dynamic linking for BeOS */
+
+#include <kernel/image.h>
+
+static int
+bedl_init ()
+{
+ return 0;
+}
+
+static int
+bedl_exit ()
+{
+ return 0;
+}
+
+static int
+bedl_open (handle, filename)
+ lt_dlhandle handle;
+ const char *filename;
+{
+ image_id image = 0;
+
+ if (filename) {
+ image = load_add_on(filename);
+ } else {
+ image_info info;
+ int32 cookie = 0;
+ if (get_next_image_info(0, &cookie, &info) == B_OK)
+ image = load_add_on(info.name);
+ }
+ if (image <= 0) {
+ last_error = cannot_open_error;
+ return 1;
+ }
+ handle->handle = (void*) image;
+ return 0;
+}
+
+static int
+bedl_close (handle)
+ lt_dlhandle handle;
+{
+ if (unload_add_on((image_id)handle->handle) != B_OK) {
+ last_error = cannot_close_error;
+ return 1;
+ }
+ return 0;
+}
+
+static lt_ptr_t
+bedl_sym (handle, symbol)
+ lt_dlhandle handle;
+ const char *symbol;
+{
+ lt_ptr_t address = 0;
+ image_id image = (image_id)handle->handle;
+
+ if (get_image_symbol(image, symbol, B_SYMBOL_TYPE_ANY,
+ &address) != B_OK) {
+ last_error = symbol_error;
+ return 0;
+ }
+ return address;
+}
+
+static
+lt_dltype_t
+bedl = { LTDL_TYPE_TOP, 0, bedl_init, bedl_exit,
+ bedl_open, bedl_close, bedl_sym };
+
+#undef LTDL_TYPE_TOP
+#define LTDL_TYPE_TOP &bedl
+
+#endif
+
/* emulate dynamic linking using preloaded_symbols */
typedef struct lt_dlsymlists_t {
file = (FILE*) find_file(basename,
getenv("LTDL_LIBRARY_PATH"),
&dir, 0);
+#ifdef __BEOS__
+ if (!file)
+ file = (FILE*) find_file(basename,
+ getenv("ADDON_PATH"),
+ &dir, 0);
+#endif
#ifdef LTDL_SHLIBPATH_VAR
if (!file)
file = (FILE*) find_file(basename,
library_names_spec='${libname}.so'
dynamic_linker="$host_os ld.so"
shlibpath_var=LIBRARY_PATH
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
;;
bsdi4*)
need_lib_prefix=no
# FIXME: first we should search . and the directory the executable is in
shlibpath_var=PATH
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
;;
freebsd1*)
lt_cv_dlopen="shl_load"
else
echo "$ac_t""no" 1>&6
-echo $ac_n "checking for LoadLibrary""... $ac_c" 1>&6
-echo "$progname:@LINENO@: checking for LoadLibrary" >&5
-if eval "test \"`echo '$''{'ac_cv_func_LoadLibrary'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line @LINENO@ "ltconfig"
-/* System header to define __stub macros and hopefully few prototypes,
- which can conflict with char LoadLibrary(); below. */
-#include <assert.h>
-/* Override any gcc2 internal prototype to avoid an error. */
-/* We use char because int might match the return type of a gcc2
- builtin and then its argument prototype would still apply. */
-char LoadLibrary();
-
-int main() {
-
-/* The GNU C library defines this for functions which it implements
- to always fail with ENOSYS. Some functions are actually named
- something starting with __ and the normal name is an alias. */
-#if defined (__stub_LoadLibrary) || defined (__stub___LoadLibrary)
-choke me
-#else
-LoadLibrary();
-#endif
-
-; return 0; }
-EOF
-if { (eval echo $progname:@LINENO@: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- eval "ac_cv_func_LoadLibrary=yes"
-else
- echo "$progname: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- eval "ac_cv_func_LoadLibrary=no"
-fi
-rm -f conftest*
-fi
-
-if eval "test \"`echo '$ac_cv_func_'LoadLibrary`\" = yes"; then
- echo "$ac_t""yes" 1>&6
- lt_cv_dlopen="LoadLibrary"
-else
- echo "$ac_t""no" 1>&6
-fi
-
-
fi