Here is what I use to compile Bordeaux-Threads with XCVB. Is it possible to apply it upstream?
[ François-René ÐVB Rideau | Reflection&Cybernethics | http://fare.tunes.org ] It is not recognized in the full amplitude of the word that all freedom is essentially self-liberation -- that I can have only so much freedom as I procure for myself by my ownness. -- Max Stirner
Index: src/cffi-gcl.lisp =================================================================== --- src/cffi-gcl.lisp (revision 315654) +++ src/cffi-gcl.lisp (working copy) @@ -41,6 +41,8 @@ ;;;# Administrivia +#+xcvb (module ()) + (defpackage #:cffi-sys (:use #:common-lisp #:alexandria) (:export @@ -248,9 +250,11 @@ (defentry size-of (int) (int "size_of")) ;; TODO: all this is doable inside the defcfun; figure that out.. +(eval-when (:compile-toplevel :load-toplevel :execute) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (size-of (position type-keyword +cffi-types+))) +) (defcfun "int align_of(int type)" 0 "switch (type) { Index: src/libraries.lisp =================================================================== --- src/libraries.lisp (revision 315654) +++ src/libraries.lisp (working copy) @@ -26,6 +26,10 @@ ;;; DEALINGS IN THE SOFTWARE. ;;; +#+xcvb +(module + (:depends-on ("src/package"))) + (in-package #:cffi) ;;;# Finding Foreign Libraries Index: src/early-types.lisp =================================================================== --- src/early-types.lisp (revision 315654) +++ src/early-types.lisp (working copy) @@ -32,6 +32,10 @@ ;;; definitions are in a separate file because they may be used in ;;; compiler macros defined later on. +#+xcvb +(module + (:depends-on ("src/utils"))) + (in-package #:cffi) ;;;# Foreign Types @@ -50,6 +54,7 @@ ;;; Type parsers, defined with DEFINE-PARSE-METHOD should return a ;;; subtype of the foreign-type class. +(eval-when (:compile-toplevel :load-toplevel :execute) (defvar *type-parsers* (make-hash-table) "Hash table of defined type parsers.") @@ -525,3 +530,4 @@ :actual-type nil) (actual-type memoized-type) (parse-type ',base-type))) memoized-type)))) +) ;; end EVAL-WHEN Index: src/features.lisp =================================================================== --- src/features.lisp (revision 315654) +++ src/features.lisp (working copy) @@ -25,6 +25,18 @@ ;;; DEALINGS IN THE SOFTWARE. ;;; +#+xcvb +(module + (:depends-on ((:cond ((:featurep :openmcl) "src/cffi-openmcl") + ((:featurep :sbcl) "src/cffi-sbcl") + ((:featurep :cmu) "src/cffi-cmucl") + ((:featurep :scl) "src/cffi-scl") + ((:featurep :clisp) "src/cffi-clisp") + ((:featurep :lispworks) "src/cffi-lispworks") + ((:featurep :ecl) "src/cffi-ecl") + ((:featurep :cormanlisp) "src/cffi-corman"))))) + + (in-package #:cl-user) (eval-when (:compile-toplevel :load-toplevel :execute) Index: src/cffi-clisp.lisp =================================================================== --- src/cffi-clisp.lisp (revision 315654) +++ src/cffi-clisp.lisp (working copy) @@ -28,6 +28,8 @@ ;;;# Administrivia +#+xcvb (module ()) + (defpackage #:cffi-sys (:use #:common-lisp #:alexandria) (:export @@ -92,9 +94,11 @@ (:pointer 'ffi:c-pointer) (:void nil))) +(eval-when (:compile-toplevel :load-toplevel :execute) (defun %foreign-type-size (type) "Return the size in bytes of objects having foreign type TYPE." (nth-value 0 (ffi:sizeof (convert-foreign-type type)))) +) ;; end EVAL-WHEN ;; Remind me to buy a beer for whoever made getting the alignment ;; of foreign types part of the public interface in CLisp. :-) Index: src/cffi-corman.lisp =================================================================== --- src/cffi-corman.lisp (revision 315654) +++ src/cffi-corman.lisp (working copy) @@ -31,6 +31,8 @@ ;;;# Administrivia +#+xcvb (module ()) + (defpackage #:cffi-sys (:use #:common-lisp #:c-types) (:import-from #:alexandria #:with-unique-names) @@ -216,9 +218,11 @@ ;;;# Calling Foreign Functions +(eval-when (:compile-toplevel :load-toplevel :execute) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (sizeof (convert-foreign-type type-keyword))) +) ;; end EVAL-WHEN ;;; Couldn't find anything in sys/ffi.lisp and the C declaration parser ;;; doesn't seem to care about alignment so we'll assume that it's the Index: src/cffi-scl.lisp =================================================================== --- src/cffi-scl.lisp (revision 315654) +++ src/cffi-scl.lisp (working copy) @@ -28,6 +28,8 @@ ;;;# Administrivia +#+xcvb (module ()) + (defpackage #:cffi-sys (:use #:common-lisp #:alien #:c-call) (:import-from #:alexandria #:once-only #:with-unique-names) @@ -239,12 +241,14 @@ (:pointer 'system-area-pointer) (:void 'void))) +(eval-when (:compile-toplevel :load-toplevel :execute) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (values (truncate (alien-internals:alien-type-bits (alien-internals:parse-alien-type (convert-foreign-type type-keyword))) 8))) +) (defun %foreign-type-alignment (type-keyword) "Return the alignment in bytes of a foreign type." Index: src/cffi-sbcl.lisp =================================================================== --- src/cffi-sbcl.lisp (revision 315654) +++ src/cffi-sbcl.lisp (working copy) @@ -27,6 +27,8 @@ ;;;# Administrivia +#+xcvb (module ()) + (defpackage #:cffi-sys (:use #:common-lisp #:sb-alien) (:import-from #:alexandria @@ -229,6 +231,7 @@ ;;;# Calling Foreign Functions +(eval-when (:compile-toplevel :load-toplevel :execute) (defun convert-foreign-type (type-keyword) "Convert a CFFI type keyword to an SB-ALIEN type." (ecase type-keyword @@ -263,6 +266,7 @@ (/ (sb-alien-internals:alien-type-alignment (sb-alien-internals:parse-alien-type (convert-foreign-type type-keyword) nil)) 8)) +) ;; end EVAL-WHEN (defun foreign-funcall-type-and-args (args) "Return an SB-ALIEN function type for ARGS." Index: src/strings.lisp =================================================================== --- src/strings.lisp (revision 315654) +++ src/strings.lisp (working copy) @@ -26,6 +26,10 @@ ;;; DEALINGS IN THE SOFTWARE. ;;; +#+xcvb +(module + (:depends-on ("src/types"))) + (in-package #:cffi) ;;;# Foreign String Conversion Index: src/cffi-allegro.lisp =================================================================== --- src/cffi-allegro.lisp (revision 315654) +++ src/cffi-allegro.lisp (working copy) @@ -27,6 +27,8 @@ ;;;# Administrivia +#+xcvb (module ()) + (defpackage #:cffi-sys (:use #:common-lisp) (:import-from #:alexandria #:if-let #:with-unique-names #:once-only) @@ -224,9 +226,11 @@ ;;;# Calling Foreign Functions +(eval-when (:compile-toplevel :load-toplevel :execute) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (ff:sizeof-fobject (convert-foreign-type type-keyword))) +) ;; end EVAL-WHEN (defun %foreign-type-alignment (type-keyword) "Returns the alignment in bytes of a foreign type." Index: src/package.lisp =================================================================== --- src/package.lisp (revision 315654) +++ src/package.lisp (working copy) @@ -25,6 +25,17 @@ ;;; DEALINGS IN THE SOFTWARE. ;;; +#+xcvb +(module + (:depends-on ((:cond ((:featurep :openmcl) "src/cffi-openmcl") + ((:featurep :sbcl) "src/cffi-sbcl") + ((:featurep :cmu) "src/cffi-cmucl") + ((:featurep :scl) "src/cffi-scl") + ((:featurep :clisp) "src/cffi-clisp") + ((:featurep :lispworks) "src/cffi-lispworks") + ((:featurep :ecl) "src/cffi-ecl") + ((:featurep :cormanlisp) "src/cffi-corman"))))) + (in-package #:cl-user) (defpackage #:cffi Index: src/utils.lisp =================================================================== --- src/utils.lisp (revision 315654) +++ src/utils.lisp (working copy) @@ -25,6 +25,8 @@ ;;; DEALINGS IN THE SOFTWARE. ;;; +#+xcvb (module (:depends-on ("src/package"))) + (in-package #:cffi) (defmacro discard-docstring (body-var &optional force) @@ -46,6 +48,7 @@ ;;; used by DEFINE-PARSE-METHOD and DEFCTYPE to warn users when ;;; they're defining types whose names belongs to the KEYWORD or CL ;;; packages. CFFI itself gets to use keywords without a warning. +(eval-when (:compile-toplevel :load-toplevel :execute) (defun warn-if-kw-or-belongs-to-cl (name) (let ((package (symbol-package name))) (when (or (eq package (find-package '#:cl)) @@ -54,3 +57,4 @@ (warn "Defining a foreign type named ~S. This symbol belongs to the ~A ~ package and that may interfere with other code using CFFI." name (package-name package))))) +) ;; end EVAL-WHEN Index: src/cffi-lispworks.lisp =================================================================== --- src/cffi-lispworks.lisp (revision 315654) +++ src/cffi-lispworks.lisp (working copy) @@ -27,6 +27,8 @@ ;;;# Administrivia +#+xcvb (module ()) + (defpackage #:cffi-sys (:use #:cl #:alexandria) (:export @@ -256,9 +258,11 @@ ;;;# Foreign Type Operations +(eval-when (:compile-toplevel :load-toplevel :execute) (defun %foreign-type-size (type) "Return the size in bytes of a foreign type." (fli:size-of (convert-foreign-type type))) +) (defun %foreign-type-alignment (type) "Return the structure alignment in bytes of foreign type." Index: src/cffi-openmcl.lisp =================================================================== --- src/cffi-openmcl.lisp (revision 315654) +++ src/cffi-openmcl.lisp (working copy) @@ -27,6 +27,8 @@ ;;;# Administrivia +#+xcvb (module ()) + (defpackage #:cffi-sys (:use #:common-lisp #:ccl) (:import-from #:alexandria #:once-only #:if-let) @@ -211,11 +213,13 @@ (:pointer :address) (:void :void))) +(eval-when (:compile-toplevel :load-toplevel :execute) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (/ (ccl::foreign-type-bits (ccl::parse-foreign-type (convert-foreign-type type-keyword))) 8)) +) ;; There be dragons here. See the following thread for details: ;; http://clozure.com/pipermail/openmcl-devel/2005-June/002777.html Index: src/foreign-vars.lisp =================================================================== --- src/foreign-vars.lisp (revision 315654) +++ src/foreign-vars.lisp (working copy) @@ -25,6 +25,10 @@ ;;; DEALINGS IN THE SOFTWARE. ;;; +#+xcvb +(module + (:depends-on ("src/package"))) + (in-package #:cffi) ;;;# Accessing Foreign Globals Index: src/enum.lisp =================================================================== --- src/enum.lisp (revision 315654) +++ src/enum.lisp (working copy) @@ -25,6 +25,8 @@ ;;; DEALINGS IN THE SOFTWARE. ;;; +#+xcvb (module (:depends-on ("src/early-types"))) + (in-package #:cffi) ;;;# Foreign Constants as Lisp Keywords Index: src/types.lisp =================================================================== --- src/types.lisp (revision 315654) +++ src/types.lisp (working copy) @@ -26,6 +26,10 @@ ;;; DEALINGS IN THE SOFTWARE. ;;; +#+xcvb +(module + (:depends-on ("src/early-types"))) + (in-package #:cffi) ;;;# Built-In Types Index: src/functions.lisp =================================================================== --- src/functions.lisp (revision 315654) +++ src/functions.lisp (working copy) @@ -26,6 +26,10 @@ ;;; DEALINGS IN THE SOFTWARE. ;;; +#+xcvb +(module + (:depends-on ("src/early-types"))) + (in-package #:cffi) ;;;# Calling Foreign Functions Index: src/cffi-ecl.lisp =================================================================== --- src/cffi-ecl.lisp (revision 315654) +++ src/cffi-ecl.lisp (working copy) @@ -27,6 +27,8 @@ ;;;# Administrivia +#+xcvb (module ()) + (defpackage #:cffi-sys (:use #:common-lisp #:alexandria) (:export @@ -196,10 +198,12 @@ (or (third (find type-keyword +translation-table+ :key #'second)) (error "~S is not a valid CFFI type" type-keyword))) +(eval-when (:compile-toplevel :load-toplevel :execute) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (nth-value 0 (ffi:size-of-foreign-type (cffi-type->ecl-type type-keyword)))) +) (defun %foreign-type-alignment (type-keyword) "Return the alignment in bytes of a foreign type." Index: src/cffi-cmucl.lisp =================================================================== --- src/cffi-cmucl.lisp (revision 315654) +++ src/cffi-cmucl.lisp (working copy) @@ -27,6 +27,8 @@ ;;;# Administrivia +#+xcvb (module ()) + (defpackage #:cffi-sys (:use #:common-lisp #:alien #:c-call) (:import-from #:alexandria #:once-only #:with-unique-names #:if-let) @@ -240,11 +242,13 @@ (:pointer 'system-area-pointer) (:void 'void))) +(eval-when (:compile-toplevel :load-toplevel :execute) (defun %foreign-type-size (type-keyword) "Return the size in bytes of a foreign type." (/ (alien-internals:alien-type-bits (alien-internals:parse-alien-type (convert-foreign-type type-keyword))) 8)) +) ;; end EVAL-WHEN (defun %foreign-type-alignment (type-keyword) "Return the alignment in bytes of a foreign type." Index: cffi.asd =================================================================== --- cffi.asd (revision 315654) +++ cffi.asd (working copy) @@ -28,12 +28,14 @@ #-(or openmcl sbcl cmu scl clisp lispworks ecl allegro cormanlisp) (error "Sorry, this Lisp is not yet supported. Patches welcome!") +(in-package :asdf) + (defsystem cffi :description "The Common Foreign Function Interface" :author "James Bielman <jame...@jamesjb.com>" :version "0.10.4" :licence "MIT" - :depends-on (alexandria trivial-features babel) + :depends-on (:alexandria :trivial-features :babel) :components ((:module src :serial t
_______________________________________________ cffi-devel mailing list cffi-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel