diff src/sysdll.c @ 2078:0bcc1e4dfd91

[xemacs-hg @ 2004-05-14 15:34:36 by james] Add support for loading modules with LTDL, the libtool library.
author james
date Fri, 14 May 2004 15:34:40 +0000
parents 91d4c8c65a0f
children 612eb81b76eb
line wrap: on
line diff
--- 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 <dl.h>
-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 <mach-o/dyld.h>
 
-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 <ltdl.h>
+
+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)
 {