Commit b34b26b6 authored by jgarcia's avatar jgarcia

ECL now uses dlopen() in OS X so that shared libraries can be loaded.

parent c9a52b91
......@@ -2,11 +2,22 @@
Build this module with (compile-file "uffi.lsp")
Load it with (load "uffi.fas")
|#
(uffi:load-foreign-library "/usr/lib/libm.dylib")
;;
;; This toplevel statement notifies the compiler that we will
;; need this shared library at runtime. We do not need this
;; statement in windows.
;;
#-windows
(uffi:load-foreign-library #+darwin "/usr/lib/libm.dylib"
#-darwin "/usr/lib/libm.so")
;;
;; With this other statement, we import the C function sin(),
;; which operates on IEEE doubles.
;;
(uffi:def-function ("sin" c-sin) ((arg :double))
:returning :double)
;;
;; We now use this function and compare with the lisp version.
;;
(format t "~%Lisp sin:~t~d~%C sin:~t~d~%Difference:~t~d"
(sin 1.0d0) (c-sin 1.0d0) (- (sin 1.0d0) (c-sin 1.0d0)))
......@@ -96,6 +96,9 @@ ECL 1.0:
- DESCRIBE was not prepare for the number range types returned by TYPE-OF.
- In OS X, ECL can now load shared libraries (Extension *.dylib) thanks
to using dlopen() instead of the obsolete NSLinkModule() function.
* Visible changes:
- EXT:PROCESS-COMMAND-ARGS now allows for a default rule.
......
......@@ -19,19 +19,21 @@
#include <ecl/internal.h>
#ifdef ENABLE_DLOPEN
# ifdef HAVE_DLFCN_H
# include <dlfcn.h>
# define INIT_PREFIX "init_"
# endif
# ifdef HAVE_MACH_O_DYLD_H
# undef HAVE_DLFCN_H
# undef HAVE_LINK_H
# include <mach-o/dyld.h>
# define INIT_PREFIX "_init_"
# ifndef HAVE_DLFCN_H
# include <mach-o/dyld.h>
# define INIT_PREFIX "_init_"
# else
# undef HAVE_MACH_O_DYLD_H
# endif
# ifdef bool
# undef bool
# endif
# endif
# ifdef HAVE_DLFCN_H
# include <dlfcn.h>
# define INIT_PREFIX "init_"
# endif
# ifdef HAVE_LINK_H
# include <link.h>
# endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment