From b8dfd2784c2c7daab4fb862e27c23c325cef239e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Mon, 16 Dec 2019 11:43:41 +0100 Subject: [PATCH] tests: ffi: add a smoke test for complex float handling --- src/tests/normal-tests/foreign-interface.lsp | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/tests/normal-tests/foreign-interface.lsp b/src/tests/normal-tests/foreign-interface.lsp index b1a026a2a..13b62a69e 100644 --- a/src/tests/normal-tests/foreign-interface.lsp +++ b/src/tests/normal-tests/foreign-interface.lsp @@ -112,3 +112,27 @@ int (*foo)(int) = (int (*)(int))#0; (test ffi.0005.string-is-array (finishes (si::make-foreign-data-from-array "dan"))) + +;;; Date: 2019-12-16 +;;; Description: +;;; Regression test to ensure correct complex float handling by +;;; the interface. On some platforms libffi is miscompiled to +;;; mishandle complex float return values. See the commit message +;;; in a commit ad5fe834. +#+complex-float +(defun ffi.0006.complex-floats () + ;; dffi + (let* ((arg #C(10.0s0 0.5s0)) + (expect (atanh arg))) + (finishes (ffi:def-function "catanhf" ((x :csfloat)) + :returning :csfloat + :module :default)) + (is (= expect (catanhf arg)))) + ;; sffi + #-ecl-bytecmp + (let* ((arg #C(10.0s0 0.5s0)) + (expect (atanh arg))) + (finishes (ffi:def-function "catanhf" ((x :csfloat)) + :returning :csfloat)) + (compile 'catanhf) + (is (= expect (catanhf arg)))))