X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcallback.impure.lisp;h=bc1ebe4cdb4ec7a30f671f039dcbbb30c1ead669;hb=7cde9fabcd145901785a468a87108f7d9c4291fc;hp=8dd89d739c1d5d328b71ba604c3cba2a27108fa7;hpb=6ddaf294e5a7e3b1792ed1d9c342894c38538773;p=sbcl.git diff --git a/tests/callback.impure.lisp b/tests/callback.impure.lisp index 8dd89d7..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 (and ppc darwin) x86) +#-(or (and ppc darwin) x86 x86-64) (quit :unix-status 104) ;;; simple callback for a function @@ -126,3 +126,25 @@ (assert (= 26 (alien-funcall foo))) +;;; 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)))) +