Skip to content
Snippets Groups Projects
Commit 733fde03 authored by rtoy's avatar rtoy
Browse files

Fix issue with callbacks when given args shorter than int. The reason

was the CALLBACK-ACCESSOR-FORM was assuming a little-endian machine
but sparc is big-endian.
parent a5fa2c23
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain. ;;; Carnegie Mellon University, and has been placed in the public domain.
;;; ;;;
(ext:file-comment (ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/sparc/c-call.lisp,v 1.24 2005/05/03 20:20:12 rtoy Exp $") "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/sparc/c-call.lisp,v 1.25 2005/08/12 19:45:11 rtoy Exp $")
;;; ;;;
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
...@@ -317,27 +317,35 @@ ...@@ -317,27 +317,35 @@
compatible-function-types-p)) compatible-function-types-p))
(defun callback-accessor-form (type sp offset) (defun callback-accessor-form (type sp offset)
(typecase (alien::parse-alien-type type) (let ((parsed-type (alien::parse-alien-type type)))
(alien::double$ (typecase parsed-type
;; Due to sparc calling conventions, a double arg doesn't have to (alien::double$
;; be aligned on a double word boundary. We have to get the two ;; Due to sparc calling conventions, a double arg doesn't have to
;; words separately and create the double from them. Doubles are ;; be aligned on a double word boundary. We have to get the two
;; stored in big-endian order, naturally. ;; words separately and create the double from them. Doubles are
`(kernel:make-double-float ;; stored in big-endian order, naturally.
(alien:deref (sap-alien (sys:sap+ ,sp ,offset) (* c-call:int))) `(kernel:make-double-float
(alien:deref (sap-alien (sys:sap+ ,sp (+ ,offset vm:word-bytes)) (alien:deref (sap-alien (sys:sap+ ,sp ,offset) (* c-call:int)))
(* c-call:unsigned-int))))) (alien:deref (sap-alien (sys:sap+ ,sp (+ ,offset vm:word-bytes))
(alien::integer-64$ (* c-call:unsigned-int)))))
;; Same as for double, above (alien::integer-64$
`(let ((hi (alien:deref (sap-alien (sys:sap+ ,sp ,offset) ;; Same as for double, above
(* c-call:int)))) `(let ((hi (alien:deref (sap-alien (sys:sap+ ,sp ,offset)
(lo (alien:deref (sap-alien (sys:sap+ ,sp (* c-call:int))))
(+ ,offset vm:word-bytes)) (lo (alien:deref (sap-alien (sys:sap+ ,sp
(* c-call:unsigned-int))))) (+ ,offset vm:word-bytes))
(+ (ash hi vm:word-bits) lo))) (* c-call:unsigned-int)))))
(t (+ (ash hi vm:word-bits) lo)))
;; All other objects can be accessed directly. (t
`(deref (sap-alien (sys:sap+ ,sp ,offset) (* ,type)))))) ;; All other objects can be accessed directly. But we need to
;; get the offset right, since the offset we're given is the
;; start of the object, and we're a big-endian machine.
(let ((byte-offset
(- vm:word-bytes
(ceiling (alien::alien-integer-type-bits parsed-type)
vm:byte-bits))))
`(deref (sap-alien (sys:sap+ ,sp ,(+ byte-offset offset))
(* ,type))))))))
(defun compatible-function-types-p (type1 type2) (defun compatible-function-types-p (type1 type2)
(flet ((machine-rep (type) (flet ((machine-rep (type)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment