X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fforeign.lisp;h=29d1d7a931ec444bbaa46655937b57241e38c537;hb=dca55270cf662763243dfc8ee207370473da2a6f;hp=2e41227eed63465c0248e315e6f03a0736030cf3;hpb=2d4a0df3457bcd50916b33d374da592d8776db0a;p=sbcl.git diff --git a/src/code/foreign.lisp b/src/code/foreign.lisp index 2e41227..29d1d7a 100644 --- a/src/code/foreign.lisp +++ b/src/code/foreign.lisp @@ -52,7 +52,7 @@ ;;; On any OS where we don't support foreign object file loading, any ;;; query of a foreign symbol value is answered with "no definition ;;; known", i.e. NIL. -#-(or linux sunos FreeBSD OpenBSD) +#-(or linux sunos FreeBSD OpenBSD NetBSD darwin) (defun get-dynamic-foreign-symbol-address (symbol) (declare (type simple-string symbol) (ignore symbol)) nil) @@ -62,7 +62,7 @@ ;;; work on any ELF system with dlopen(3) and dlsym(3) ;;; It also works on OpenBSD, which isn't ELF, but is otherwise modern ;;; enough to have a fairly well working dlopen/dlsym implementation. -#-(or linux sunos FreeBSD OpenBSD) +#-(or linux sunos FreeBSD OpenBSD NetBSD darwin) (macrolet ((define-unsupported-fun (fun-name) `(defun ,fun-name (&rest rest) "unsupported on this system" @@ -70,7 +70,7 @@ (error 'unsupported-operator :name ',fun-name)))) (define-unsupported-fun load-1-foreign) (define-unsupported-fun load-foreign)) -#+(or linux sunos FreeBSD OpenBSD) +#+(or linux sunos FreeBSD OpenBSD NetBSD darwin) (progn ;;; flags for dlopen() @@ -112,7 +112,9 @@ *after-save-initializations*) (defvar *dso-linker* "/usr/bin/ld") -(defvar *dso-linker-options* '("-shared" "-o")) +(defvar *dso-linker-options* + #-darwin '("-shared" "-o") + #+darwin '("-bundle" "-o")) (sb-alien:define-alien-routine dlopen system-area-pointer (file sb-alien:c-string) (mode sb-alien:int)) @@ -174,7 +176,7 @@ ;; that the list isn't guaranteed to be in reverse order of loading, ;; at least not if a file is loaded more than once. Is this the ;; right thing? (In what cases does it matter?) - (dolist (handle *handles-from-dlopen*) + (dolist (handle (reverse *handles-from-dlopen*)) ;; KLUDGE: We implicitly exclude the possibility that the variable ;; could actually be NULL, but the man page for dlsym(3) ;; recommends doing a more careful test. -- WHN 20000825 @@ -182,6 +184,14 @@ (unless (zerop possible-result) (return possible-result))))) +;;; Dan Barlow's quick summary from IRC 2003-06-21: +;;; fwiw, load-foreign does random stuff with ld so that you can use +;;; it with static libraries +;;; if you have shared objects, load-1-foreign will do fine +;;; and +;;; I think my position on this matter is consistent with Tim Moore's: +;;; use (cmucl equivalent of) load-1-foreign, load-foreign is arse +;;; though he may say ass (defun load-foreign (files &key (libraries '("-lc"))