Raymond Toy pushed to branch issue-242-c-call-char-result-wrong at cmucl / cmucl
Commits:
-
3522814e
by Raymond Toy at 2023-07-01T11:06:10-07:00
1 changed file:
Changes:
... | ... | @@ -666,8 +666,8 @@ |
666 | 666 | ,val)))
|
667 | 667 | (t alien)))
|
668 | 668 | (case (alien-integer-type-bits type)
|
669 | - (8 `(ldb (byte 8 0) ,alien))
|
|
670 | - (16 `(ldb (byte 16 0) ,alien))
|
|
669 | + (8 `(ldb (byte 8 0) (truly-the (unsigned-byte 32) ,alien)))
|
|
670 | + (16 `(ldb (byte 16 0) (truly-the (unsigned-byte 32) ,alien)))
|
|
671 | 671 | (t alien))))
|
672 | 672 | |
673 | 673 | ;; signed numbers <= 32 bits need to be sign extended.
|
... | ... | @@ -715,8 +715,8 @@ |
715 | 715 | |
716 | 716 | (def-alien-type-class (boolean :include integer :include-args (signed)))
|
717 | 717 | |
718 | -(def-alien-type-translator boolean (&optional (bits vm:word-bits))
|
|
719 | - (make-alien-boolean-type :bits bits :signed nil))
|
|
718 | +(def-alien-type-translator boolean (&optional (bits 8))
|
|
719 | + (make-alien-boolean-type :bits bits :signed t))
|
|
720 | 720 | |
721 | 721 | (def-alien-type-method (boolean :unparse) (type)
|
722 | 722 | `(boolean ,(alien-boolean-type-bits type)))
|
... | ... | @@ -726,8 +726,10 @@ |
726 | 726 | `(member t nil))
|
727 | 727 | |
728 | 728 | (def-alien-type-method (boolean :naturalize-gen) (type alien)
|
729 | - (declare (ignore type))
|
|
730 | - `(not (zerop ,alien)))
|
|
729 | + ;; Mask out any unwanted bits. Important if the C code returns
|
|
730 | + ;; values in %al, or %ax
|
|
731 | + `(not (zerop (ldb (byte ,(alien-boolean-type-bits type) 0)
|
|
732 | + ,alien))))
|
|
731 | 733 | |
732 | 734 | (def-alien-type-method (boolean :deport-gen) (type value)
|
733 | 735 | (declare (ignore type))
|