Changeset 5756
- Timestamp:
- Jan 20, 2007, 9:31:12 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/lib/ffi-linuxppc64.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/lib/ffi-linuxppc64.lisp
r5737 r5756 15 15 ;;; http://opensource.franz.com/preamble.html 16 16 17 (in-package "CCL") 18 19 ;;; LinuxPPC64 20 ;;; Structures whose size is less than 64 bits are passed "right-justified" 21 ;;; in a GPR. 22 ;;; Structures passed by value are passed in GPRs as N doublewords. 23 ;;; If the structure would require > 64-bit alignment, this might result 24 ;;; in some GPRs/parameter area words being skipped. (We don't handle this). 25 ;;; All structures - of any size - are returned by passing a pointer 26 ;;; in the first argument. 27 28 (defun linux64::record-type-returns-structure-as-first-arg (rtype) 29 (when (and rtype 30 (not (typep rtype 'unsigned-byte)) 31 (not (member rtype *foreign-representation-type-keywords* 32 :test #'eq))) 33 (let* ((ftype (if (typep rtype 'foreign-type) 34 rtype 35 (parse-foreign-type rtype)))) 36 (typep ftype 'foreign-record-type)))) 37 38 (defun linux64::expand-ff-call (callform args) 39 (let* ((result-type-spec (or (car (last args)) :void))) 40 (multiple-value-bind (result-type error) 41 (parse-foreign-type result-type-spec) 42 (if error 43 (setq result-type-spec :void result-type *void-foreign-type*) 44 (setq args (butlast args))) 45 (collect ((argforms)) 46 (when (eq (car args) :monitor-exception-ports) 47 (argforms (pop args))) 48 (when (typep result-type 'foreign-record-type) 49 (setq result-type *void-foreign-type* 50 result-type-spec :void) 51 (argforms :address) 52 (argforms (pop args))) 53 (unless (evenp (length args)) 54 (error "~s should be an even-length list of alternating foreign types and values" args)) 55 (do* ((args args (cddr args))) 56 ((null args)) 57 (let* ((arg-type-spec (car args)) 58 (arg-value-form (cadr args))) 59 (if (or (member arg-type-spec *foreign-representation-type-keywords* 60 :test #'eq) 61 (typep arg-type-spec 'unsigned-byte)) 62 (progn 63 (argforms arg-type-spec) 64 (argforms arg-value-form)) 65 (let* ((ftype (parse-foreign-type arg-type-spec))) 66 (if (typep ftype 'foreign-record-type) 67 (let* ((bits (ensure-foreign-type-bits ftype))) 68 (if (< bits 64) 69 (progn 70 (argforms :unsigned-doubleword) 71 (argforms `(ash (%%get-unsigned-long-long ,arg-value-form) ,(- bits 64)))) 72 (progn 73 (argforms (ceiling bits 64)) 74 (argforms arg-value-form)))) 75 (progn 76 (argforms (foreign-type-to-representation-type ftype)) 77 (argforms arg-value-form))))))) 78 (argforms (foreign-type-to-representation-type result-type)) 79 `(,@callform ,@(argforms))))))
Note:
See TracChangeset
for help on using the changeset viewer.
