cs: unbreak Windows errno

Restores the repair in 6e58310176, which accomodates certain modes of
compiling the Chez Scheme kernel on Windows.
This commit is contained in:
Matthew Flatt 2021-02-15 17:51:31 -07:00
parent 1fd516c502
commit cf0e45b763

View File

@ -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