From: Matt Birkholz Date: Fri, 1 Jun 2018 21:17:58 +0000 (-0700) Subject: runtime/ffi: Save/restore floenv around callouts. X-Git-Tag: mit-scheme-pucked-x11-0.3.1~6^2~16 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=b5189bc516aa02d29396e1f8b31da9bd437c3a69;p=mit-scheme.git runtime/ffi: Save/restore floenv around callouts. The c-call primitive can "alienate" the floenv, but cooperating with c-call-continue to save/restore it is... more difficult than doing it in Scheme. And fix some trailing whitespace, indentation. --- diff --git a/src/runtime/ffi.scm b/src/runtime/ffi.scm index 7acd8f1e3..4c5dd8689 100644 --- a/src/runtime/ffi.scm +++ b/src/runtime/ffi.scm @@ -228,7 +228,7 @@ USA. (define-integrable alien-function/filename %alien-function/filename) (define-integrable (alien-function/name alienf) - (string-tail (%alien-function/name alienf) 4)) + (string-tail (%alien-function/name alienf) 4)) (define (%set-alien-function/address! alienf address) (let ((qr (integer-divide address %radix))) @@ -362,15 +362,18 @@ USA. (guarantee-alien-function alien-function 'call-alien) (alien-function-cache! alien-function) (for-each - (lambda (arg) - (if (alien-function? arg) - (alien-function-cache! arg))) - args) + (lambda (arg) + (if (alien-function? arg) + (alien-function-cache! arg))) + args) (with-thread-events-blocked (lambda () (without-interrupts (lambda () - (call-alien* alien-function args)))))) + (let* ((saved (flo:environment)) + (value (call-alien* alien-function args))) + (flo:set-environment! saved) + value)))))) #;(define-integrable (call-alien* alien-function args) (apply (ucode-primitive c-call -1) alien-function args))