X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcallback.impure.lisp;h=bc1ebe4cdb4ec7a30f671f039dcbbb30c1ead669;hb=ffb8ca7616d75c88aae8f0939a241260ffdec051;hp=fe250405cab2ca7ee6c3c93a2c380e26b1576b66;hpb=4898ef32c639b1c7f4ee13a5ba566ce6debd03e6;p=sbcl.git diff --git a/tests/callback.impure.lisp b/tests/callback.impure.lisp index fe25040..bc1ebe4 100644 --- a/tests/callback.impure.lisp +++ b/tests/callback.impure.lisp @@ -14,7 +14,7 @@ (in-package :cl-user) ;;; callbacks only on a few platforms -#-(or darwin x86) +#-(or (and ppc darwin) x86 x86-64) (quit :unix-status 104) ;;; simple callback for a function @@ -126,4 +126,25 @@ (assert (= 26 (alien-funcall foo))) -(quit :unix-status 104) +;;; callbacks with void return values + +(with-test (:name void-return) + (sb-alien::alien-lambda void () + (values))) + +;;; tests for a sign extension problem in callback argument handling on x86-64 + +(defvar *add-two-ints* (sb-alien::alien-callback (function int int int) #'+)) + +(with-test (:name :sign-extension) + (assert (= (alien-funcall *add-two-ints* #x-80000000 1) -2147483647))) + +;;; On x86 This'll signal a TYPE-ERROR "The value -2147483649 is not of type +;;; (SIGNED-BYTE 32)". On x86-64 it'll wrap around to 2147483647, probably +;;; due to the sign-extension done by the (INTEGER :NATURALIZE-GEN) +;;; alien-type-method. I believe the former behaviour is the one we want. +;;; -- JES, 2005-10-16 + +(with-test (:name :underflow-detection :fails-on :x86-64) + (assert (raises-error? (alien-funcall *add-two-ints* #x-80000000 -1)))) +