P4.2: declare fcntl as varargs in nREPL FFI
ober
a072c03727dacc402be2ee61054e19572a0f9aec
--- a/src/std/nrepl.ss +++ b/src/std/nrepl.ss @@ -1467,7 +1467,12 @@ (def c-close (foreign-procedure "close" (int) int)) (def c-setsockopt (foreign-procedure "setsockopt" (int int int u8* int) int)) (def c-htons (foreign-procedure "htons" (unsigned-short) unsigned-short)) -(def c-fcntl (foreign-procedure "fcntl" (int int int) int)) +;; P4.2: fcntl is varargs (int int, ...). On macOS arm64 fixed-args use +;; one register file and varargs another — declaring a fixed (int int int) +;; binding lands the third arg in the wrong slot and the kernel sees junk +;; (e.g. F_SETFL silently rejects, or worse, sets the wrong flag). The +;; __varargs_after attribute tells Chez where the variadic boundary is. +(def c-fcntl (foreign-procedure (__varargs_after 2) "fcntl" (int int int) int)) (def c-getsockname (foreign-procedure "getsockname" (int u8* u8*) int)) (def c-read (foreign-procedure "read" (int u8* size_t) ssize_t)) (def c-write (foreign-procedure "write" (int u8* size_t) ssize_t))