- ;; Unaligned access is slower, but possible, so this is nice and simple.
- `(deref (sap-alien (sap+ ,sap ,offset) (* ,type))))
+ (let ((parsed-type
+ (sb!alien::parse-alien-type type (sb!kernel:make-null-lexenv))))
+ (cond ((sb!alien::alien-integer-type-p parsed-type)
+ ;; Unaligned access is slower, but possible, so this is nice and
+ ;; simple. Also, we're a big-endian machine, so we need to get
+ ;; byte offsets correct.
+ (let ((bits (sb!alien::alien-type-bits parsed-type)))
+ (let ((byte-offset
+ (cond ((< bits n-word-bits)
+ (- n-word-bytes
+ (ceiling bits n-byte-bits)))
+ (t 0))))
+ `(deref (sap-alien (sap+ ,sap
+ ,(+ byte-offset offset))
+ (* ,type))))))
+ (t
+ `(deref (sap-alien (sap+ ,sap ,offset) (* ,type)))))))