Changeset 5792


Ignore:
Timestamp:
Jan 25, 2007, 3:32:10 AM (18 years ago)
Author:
Gary Byers
Message:

More plausible callback-bindings callback.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lib/ffi-linuxppc32.lisp

    r5790 r5792  
    103103            (setq argvars (cons struct-result-name argvars)
    104104                  argspecs (cons :address argspecs)
    105                   rtype *void-foreign-type))))
     105                  rtype *void-foreign-type*))))
    106106          (let* ((offset  96)
    107107                 (gpr 0)
     
    110110                  (argspecs argspecs (cdr argspecs)))
    111111                 ((null argvars)
    112                   (values (rlets) (lets) (dynamic-extent-names) (inits) rtype))
     112                  (values (rlets) (lets) (dynamic-extent-names) nil rtype))
    113113              (let* ((name (car argvars))
    114114                     (spec (car argspecs))
     
    120120                     (argtype (parse-foreign-type spec)))
    121121                (if (typep argtype 'foreign-record-type)
    122                   (setq spec :address))
     122                  (setq argtype (parse-foreign-type :address)))
    123123                (let* ((access-form
    124                         `(,(case spec
    125                                  (:single-float
    126                                    (incf nextfpr 8)
    127                                    (if (< fpr 96)
    128                                      (setq target fpr)
    129                                      (setq target (+ offset (logand offset 4))
    130                                            nextoffset (+ target 8)))
    131                                    '%get-single-float-from-double-ptr)
    132                                   (:double-float
    133                                    (incf nextfpr 8)
    134                                    (if (< fpr 96)
    135                                      (setq target fpr)
    136                                      (setq target (+ offset (logand offset 4))
    137                                            nextoffset (+ target 8)))
    138                                    '%get-double-float)
    139                                   (:signed-doubleword
    140                                    (if (< gpr 56)
     124                        `(,(cond
     125                            ((typep argtype 'foreign-single-float-type)
     126                             (incf nextfpr 8)
     127                             (if (< fpr 96)
     128                               (setq target fpr)
     129                               (setq target (+ offset (logand offset 4))
     130                                     nextoffset (+ target 8)))
     131                             '%get-single-float-from-double-ptr)
     132                            ((typep argtype 'foreign-double-float-type)
     133                             (incf nextfpr 8)
     134                             (if (< fpr 96)
     135                               (setq target fpr)
     136                               (setq target (+ offset (logand offset 4))
     137                                     nextoffset (+ target 8)))
     138                             '%get-double-float)
     139                            ((and (typep argtype 'foreign-integer-type)
     140                                  (= (foreign-integer-type-bits argtype) 64)
     141                                  (foreign-integer-type-signed argtype))
     142                             (if (< gpr 56)
    141143                                     (setq target (+ gpr (logand gpr 4))
    142144                                           nextgpr (+ 8 target))
     
    144146                                           nextoffset (+ 8 offset)))
    145147                                   '%%get-signed-longlong)
    146                                   (:unsigned-doubleword
    147                                    (if (< gpr 56)
    148                                      (setq target (+ gpr (logand gpr 4))
    149                                            nextgpr (+ 8 target))
    150                                      (setq target (+ offset (logand offset 4))
    151                                            nextoffset (+ 8 offset)))
    152                                    '%%get-unsigned-longlong)
    153                                   (t
    154                                    (incf nextgpr 4)
    155                                    (if (< gpr 64)
    156                                      (setq target gpr)
    157                                      (setq target offset nextoffset (+ offset 4)))
    158                                    (ecase type
    159                                      (:signed-fullword '%get-signed-long)
    160                                      (:signed-halfword (setq bias 2) '%get-signed-word)
    161                                      (:signed-byte (setq bias 3) '%get-signed-byte)
    162                                      (:unsigned-fullword '%get-unsigned-long)
    163                                      (:unsigned-halfword (setq bias 2) '%get-unsigned-word)
    164                                      (:unsigned-byte (setq bias 3) '%get-unsigned-byte)
    165                                      (:address '%get-ptr))))
     148                            ((and (typep argtype 'foreign-integer-type)
     149                                  (= (foreign-integer-type-bits argtype) 64)
     150                                  (not (foreign-integer-type-signed argtype)))
     151                             (if (< gpr 56)
     152                               (setq target (+ gpr (logand gpr 4))
     153                                     nextgpr (+ 8 target))
     154                               (setq target (+ offset (logand offset 4))
     155                                     nextoffset (+ 8 offset)))
     156                             '%%get-unsigned-longlong)
     157                            (t
     158                             (incf nextgpr 4)
     159                             (if (< gpr 64)
     160                               (setq target gpr)
     161                               (setq target offset nextoffset (+ offset 4)))
     162                             (cond ((typep argtype 'foreign-pointer-type) '%get-ptr)
     163                                   ((typep argtype 'foreign-integer-type)
     164                                    (let* ((bits (foreign-integer-type-bits argtype))
     165                                           (signed (foreign-integer-type-signed argtype)))
     166                                      (cond ((<= bits 8)
     167                                             (setq bias 3)
     168                                             (if signed
     169                                               '%get-signed-byte '
     170                                               '%get-unsigned-byte))
     171                                            ((<= bits 16)
     172                                             (setq bias 2)
     173                                             (if signed
     174                                               '%get-signed-word '
     175                                               '%get-unsigned-word))
     176                                            ((<= bits 32)
     177                                             (if signed
     178                                               '%get-signed-long '
     179                                               '%get-unsigned-long))
     180                                            (t
     181                                             (error "Don't know how to access foreign argument of type ~s" (unparse-foreign-type argtype))))))
     182                                   (t
     183                                    (error "Don't know how to access foreign argument of type ~s" (unparse-foreign-type argtype))))))
    166184                          ,stack-ptr
    167185                          ,(+ target bias))))
     
    169187                  (when (eq spec :address)
    170188                    (dynamic-extent-names name))
    171                   (setq gpr nextgpr fpr nextfpr offset nextoffset)))))
    172           (values (rlets)
    173                   (lets)
    174                   (dynamic-extent-names)
    175                   nil
    176                   rtype))))
     189                  (setq gpr nextgpr fpr nextfpr offset nextoffset))))))))
    177190               
    178191                 
Note: See TracChangeset for help on using the changeset viewer.