# HG changeset patch # User james # Date 1084548880 0 # Node ID 0bcc1e4dfd9103f8fdfdeaa67006e2f180f36de1 # Parent 8f6c15382b3116ef3f97d1f6a0c668b3dc209d8b [xemacs-hg @ 2004-05-14 15:34:36 by james] Add support for loading modules with LTDL, the libtool library. diff -r 8f6c15382b31 -r 0bcc1e4dfd91 lib-src/config.values.in --- a/lib-src/config.values.in Thu May 13 21:50:28 2004 +0000 +++ b/lib-src/config.values.in Fri May 14 15:34:40 2004 +0000 @@ -44,6 +44,7 @@ INSTALL_SCRIPT "@INSTALL_SCRIPT@" LDFLAGS "@LDFLAGS@" LIBS "@LIBS@" +LIBSTDCPP "@LIBSTDCPP@" LISPDIR "@LISPDIR@" LISPDIR_USER_DEFINED "@LISPDIR_USER_DEFINED@" LN_S "@LN_S@" @@ -72,6 +73,7 @@ SRC_SUBDIR_DEPS "@SRC_SUBDIR_DEPS@" SUBDIR_MAKEFILES "@SUBDIR_MAKEFILES@" XEMACS_CC "@XEMACS_CC@" +XE_CFLAGS "@XE_CFLAGS@" X_CFLAGS "@X_CFLAGS@" X_EXTRA_LIBS "@X_EXTRA_LIBS@" X_LIBS "@X_LIBS@" diff -r 8f6c15382b31 -r 0bcc1e4dfd91 src/ChangeLog --- a/src/ChangeLog Thu May 13 21:50:28 2004 +0000 +++ b/src/ChangeLog Fri May 14 15:34:40 2004 +0000 @@ -1,3 +1,11 @@ +2004-05-10 Jerry James + + * config.h.in: Add HAVE_LTDL. + * emodules.c: Include LTDL headers, if needed. + * emodules.c (vars_of_module): Add LTDL initialization code. + * sysdll.c: Remove unused dll_init functions. Add LTDL support. + * sysdll.h: Remove dll_init declaration and adjust spacing. + 2004-05-05 Chuck Hines * dgif_lib.c (DGifSlurp): Changed do-while to while to stop diff -r 8f6c15382b31 -r 0bcc1e4dfd91 src/config.h.in --- a/src/config.h.in Thu May 13 21:50:28 2004 +0000 +++ b/src/config.h.in Fri May 14 15:34:40 2004 +0000 @@ -306,6 +306,7 @@ #undef HAVE__DLERROR #undef HAVE_SHL_LOAD #undef HAVE_DYLD +#undef HAVE_LTDL #undef DLSYM_NEEDS_UNDERSCORE #undef HAVE_SHLIB diff -r 8f6c15382b31 -r 0bcc1e4dfd91 src/emodules.c --- a/src/emodules.c Thu May 13 21:50:28 2004 +0000 +++ b/src/emodules.c Fri May 14 15:34:40 2004 +0000 @@ -20,6 +20,9 @@ #include "emodules.h" #include "sysdll.h" +#ifdef HAVE_LTDL +#include +#endif /* Load path */ static Lisp_Object Vmodule_load_path; @@ -587,6 +590,13 @@ reinit_vars_of_module (); +#ifdef HAVE_LTDL + lt_dlinit (); + lt_dlmalloc = (lt_ptr (*) (size_t)) xmalloc; + lt_dlrealloc = (lt_ptr (*) (lt_ptr, size_t)) xrealloc; + lt_dlfree = (void (*) (lt_ptr)) xfree_1; +#endif + DEFVAR_LISP ("module-version", &Vmodule_version /* Emacs dynamic loading mechanism version, as a string. diff -r 8f6c15382b31 -r 0bcc1e4dfd91 src/sysdll.c --- a/src/sysdll.c Thu May 13 21:50:28 2004 +0000 +++ b/src/sysdll.c Fri May 14 15:34:40 2004 +0000 @@ -62,12 +62,6 @@ # endif #endif -int -dll_init (const Extbyte *arg) -{ - return 0; -} - dll_handle dll_open (Lisp_Object fname) { @@ -121,12 +115,6 @@ #elif defined(HAVE_SHL_LOAD) /* This is the HP/UX version */ #include -int -dll_init (const Extbyte *arg) -{ - return 0; -} - dll_handle dll_open (Lisp_Object fname) { @@ -184,12 +172,6 @@ #include "syswindows.h" #include "sysfile.h" -int -dll_init (const Extbyte *arg) -{ - return 0; -} - dll_handle dll_open (Lisp_Object fname) { @@ -238,12 +220,6 @@ #include -int -dll_init (const Extbyte *arg) -{ - return 0; -} - dll_handle dll_open (Lisp_Object fname) { @@ -451,14 +427,53 @@ NSLinkEditError(&c, &errorNumber, &fileNameWithError, &errorString); return build_ext_string (errorString, Qnative); } +#elif HAVE_LTDL +/* Libtool's libltdl */ +#include + +dll_handle +dll_open (Lisp_Object fname) +{ + Extbyte *soname; + + if (NILP (fname)) + { + soname = NULL; + } + else + { + LISP_STRING_TO_EXTERNAL (fname, soname, Qdll_filename_encoding); + } + return (dll_handle) lt_dlopen (soname); +} + +int +dll_close (dll_handle h) +{ + return lt_dlclose ((lt_dlhandle) h); +} + +dll_func +dll_function (dll_handle h, const CIbyte *n) +{ + MAYBE_PREPEND_UNDERSCORE (n); + return (dll_func) lt_dlsym ((lt_dlhandle) h, n); +} + +dll_var +dll_variable (dll_handle h, const CIbyte *n) +{ + MAYBE_PREPEND_UNDERSCORE (n); + return (dll_var) lt_dlsym ((lt_dlhandle) h, n); +} + +Lisp_Object +dll_error () +{ + return build_ext_string (lt_dlerror (), Qnative); +} #else /* Catchall if we don't know about this system's method of dynamic loading */ -int -dll_init (const Extbyte *arg) -{ - return -1; -} - dll_handle dll_open (Lisp_Object fname) { diff -r 8f6c15382b31 -r 0bcc1e4dfd91 src/sysdll.h --- a/src/sysdll.h Thu May 13 21:50:28 2004 +0000 +++ b/src/sysdll.h Fri May 14 15:34:40 2004 +0000 @@ -28,13 +28,11 @@ typedef void * dll_func; typedef void * dll_var; -extern int dll_init(const Extbyte *); -extern int dll_shutdown(void); -extern dll_handle dll_open(Lisp_Object); -extern int dll_close(dll_handle); -extern dll_func dll_function(dll_handle, const CIbyte *); -extern dll_var dll_variable(dll_handle, const CIbyte *); -extern Lisp_Object dll_error(void); +extern dll_handle dll_open (Lisp_Object); +extern int dll_close (dll_handle); +extern dll_func dll_function (dll_handle, const CIbyte *); +extern dll_var dll_variable (dll_handle, const CIbyte *); +extern Lisp_Object dll_error (void); /* More stand-ins ... */