From cf0e45b763ed95539eebb343bfacfdbc47c0d643 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 15 Feb 2021 17:51:31 -0700 Subject: [PATCH] cs: unbreak Windows errno Restores the repair in 6e58310176, which accomodates certain modes of compiling the Chez Scheme kernel on Windows. --- racket/src/cs/rumble/foreign.ss | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/racket/src/cs/rumble/foreign.ss b/racket/src/cs/rumble/foreign.ss index 3762076cfa..e7f492a644 100644 --- a/racket/src/cs/rumble/foreign.ss +++ b/racket/src/cs/rumble/foreign.ss @@ -2048,7 +2048,19 @@ [else #f]))) ;; function is called with interrupts disabled -(define get-errno (foreign-procedure "(cs)s_errno" () int)) +(define get-errno + (cond + [(not (chez:memq (machine-type) '(a6nt ta6nt i3nt ti3nt))) + (foreign-procedure "(cs)s_errno" () int)] + [else + ;; On Windows, `errno` could be a different one from + ;; `_errno` in MSVCRT. Therefore fallback to the foreign function. + ;; See `save_errno_values` in `foreign.c` from Racket BC for more + ;; information. + (load-shared-object "msvcrt.dll") + (let ([get-&errno (foreign-procedure "_errno" () void*)]) + (lambda () + (foreign-ref 'int (get-&errno) 0)))])) ;; function is called with interrupts disabled (define get-last-error