chiark / gitweb /
64-bit patch for SBCL from Gabriel Ebner
authorespen <espen>
Sun, 26 Feb 2006 16:12:25 +0000 (16:12 +0000)
committerespen <espen>
Sun, 26 Feb 2006 16:12:25 +0000 (16:12 +0000)
glib/ffi.lisp
glib/gtype.lisp
glib/proxy.lisp

index c9e6051ba8a4c6fe4331cc8486663097b9b089ed..d57069698ea803d8c94ca0a8218ec4d3acd719c0 100644 (file)
@@ -20,7 +20,7 @@
 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-;; $Id: ffi.lisp,v 1.27 2006/02/26 15:50:32 espen Exp $
+;; $Id: ffi.lisp,v 1.28 2006/02/26 16:12:25 espen Exp $
 
 (in-package "GLIB")
 
@@ -393,19 +393,48 @@ (define-type-generic unbound-value (type-spec)
   "Returns a value which should be intepreted as unbound for slots with virtual allocation")
 
 
+#+sbcl
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defun sb-sizeof-bits (type)
+    (sb-alien-internals:alien-type-bits
+     (sb-alien-internals:parse-alien-type type nil)))
+
+  (defun sb-sizeof (type)
+    (/ (sb-sizeof-bits type) 8)))
+
+
 ;; Sizes of fundamental C types in bytes (8 bits)
-(defconstant +size-of-short+ 2)
-(defconstant +size-of-int+ 4)
-(defconstant +size-of-long+ 4)
-(defconstant +size-of-pointer+ 4)
-(defconstant +size-of-float+ 4)
-(defconstant +size-of-double+ 8)
+(defconstant +size-of-short+
+  #+sbcl (sb-sizeof 'sb-alien:short)
+  #-sbcl 2)
+(defconstant +size-of-int+
+  #+sbcl (sb-sizeof 'sb-alien:int)
+  #-sbcl 4)
+(defconstant +size-of-long+
+  #+sbcl (sb-sizeof 'sb-alien:long)
+  #-sbcl 4)
+(defconstant +size-of-pointer+
+  #+sbcl (sb-sizeof 'sb-alien:system-area-pointer)
+  #-sbcl 4)
+(defconstant +size-of-float+
+  #+sbcl (sb-sizeof 'sb-alien:float)
+  #-sbcl 4)
+(defconstant +size-of-double+
+  #+sbcl (sb-sizeof 'sb-alien:double)
+  #-sbcl 8)
+
 
 ;; Sizes of fundamental C types in bits
 (defconstant +bits-of-byte+ 8)
-(defconstant +bits-of-short+ 16)
-(defconstant +bits-of-int+ 32)
-(defconstant +bits-of-long+ 32)
+(defconstant +bits-of-short+
+  #+sbcl (sb-sizeof-bits 'sb-alien:short)
+  #-sbcl 16)
+(defconstant +bits-of-int+
+  #+sbcl (sb-sizeof-bits 'sb-alien:int)
+  #-sbcl 32)
+(defconstant +bits-of-long+
+  #+sbcl (sb-sizeof-bits 'sb-alien:long)
+  #-sbcl 32)
 
 
 (deftype int () '(signed-byte #.+bits-of-int+))
index 6b7a3b1844d41b5dce8d412c2cdfa6171f68fbcf..d05cc35e87b0320e1d38b1efff58024fdae22f0e 100644 (file)
@@ -20,7 +20,7 @@
 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-;; $Id: gtype.lisp,v 1.47 2006/02/26 15:30:01 espen Exp $
+;; $Id: gtype.lisp,v 1.48 2006/02/26 16:12:25 espen Exp $
 
 (in-package "GLIB")
 
@@ -30,7 +30,7 @@ (use-prefix "g")
 (defbinding type-init () nil)
 (type-init)
 
-(deftype type-number () '(unsigned 32))
+(deftype type-number () 'unsigned-long)
 
 (deftype gtype () 'symbol)
 
@@ -197,7 +197,8 @@   (defun %find-types-in-library (pathname prefixes ignore)
       (unwind-protect
          (loop 
           as symbol = (let ((line (read-line (process-output process) nil)))
-                        (when line (subseq line 11)))                    
+                        (when line 
+                          (subseq line (1+ (position #\Space line :from-end t)))))
           while symbol
           when (and
                 (> (length symbol) 9)
index 6177bf1af324d5c5a16613fe185775800928a86d..f2b193d897dbbd0b17512dc0ff7ca8fea74fbb2f 100644 (file)
@@ -20,7 +20,7 @@
 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-;; $Id: proxy.lisp,v 1.36 2006/02/26 15:30:01 espen Exp $
+;; $Id: proxy.lisp,v 1.37 2006/02/26 16:12:25 espen Exp $
 
 (in-package "GLIB")
 
@@ -450,8 +450,12 @@   (defmethod initialize-internal-slot-functions ((slotd effective-alien-slot-def
 
     (call-next-method))
   
-  ;; TODO: call some C code to detect this a compile time
-  (defconstant +struct-alignmen+ 4)
+  (defconstant +struct-alignmen+
+    #+sbcl (/ (sb-alien-internals:alien-type-alignment
+               (sb-alien-internals:parse-alien-type
+               'system-area-pointer nil))
+             8)
+    #-sbcl 4)
 
   (defun align-offset (size)
     (if (zerop (mod size +struct-alignmen+))