From b5189bc516aa02d29396e1f8b31da9bd437c3a69 Mon Sep 17 00:00:00 2001 From: Matt Birkholz Date: Fri, 1 Jun 2018 14:17:58 -0700 Subject: [PATCH] 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. --- src/runtime/ffi.scm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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)) -- 2.25.1