Port __errno_location to FreeBSD (__error) across 11 libraries
ober
3e8bd41d2acb03c4de13a43292565a8905ec5882
--- a/lib/std/net/repl.sls +++ b/lib/std/net/repl.sls @@ -30,7 +30,10 @@ (define c-htons (foreign-procedure "htons" (unsigned-short) unsigned-short)) (define c-getsockname (foreign-procedure "getsockname" (int void* void*) int)) (define c-fcntl (foreign-procedure "fcntl" (int int int) int)) - (define c-errno-location (foreign-procedure "__errno_location" () void*)) + (define c-errno-location + (if (memq (machine-type) '(a6fb ta6fb i3fb ti3fb arm64fb)) + (foreign-procedure "__error" () void*) + (foreign-procedure "__errno_location" () void*))) (define (get-errno) (foreign-ref 'int (c-errno-location) 0)) ;; Constants --- a/lib/std/net/tcp-raw.sls +++ b/lib/std/net/tcp-raw.sls @@ -36,7 +36,10 @@ (define c-inet-pton (foreign-procedure "inet_pton" (int string void*) int)) ;; errno - (define c-errno-location (foreign-procedure "__errno_location" () void*)) + (define c-errno-location + (if (memq (machine-type) '(a6fb ta6fb i3fb ti3fb arm64fb)) + (foreign-procedure "__error" () void*) + (foreign-procedure "__errno_location" () void*))) (define (get-errno) (foreign-ref 'int (c-errno-location) 0)) (define EINTR 4) --- a/lib/std/net/tcp.sls +++ b/lib/std/net/tcp.sls @@ -50,7 +50,10 @@ (define c-fcntl (foreign-procedure "fcntl" (int int int) int)) ;; errno access for EINTR retry - (define c-errno-location (foreign-procedure "__errno_location" () void*)) + (define c-errno-location + (if (memq (machine-type) '(a6fb ta6fb i3fb ti3fb arm64fb)) + (foreign-procedure "__error" () void*) + (foreign-procedure "__errno_location" () void*))) (define (get-errno) (foreign-ref 'int (c-errno-location) 0)) (define EINTR 4) (define EAGAIN 11) --- a/lib/std/os/fcntl.sls +++ b/lib/std/os/fcntl.sls @@ -27,7 +27,10 @@ (define c-fcntl (foreign-procedure "fcntl" (int int int) int)) ;; errno access for error reporting - (define c-errno-location (foreign-procedure "__errno_location" () void*)) + (define c-errno-location + (if (memq (machine-type) '(a6fb ta6fb i3fb ti3fb arm64fb)) + (foreign-procedure "__error" () void*) + (foreign-procedure "__errno_location" () void*))) (define (get-errno) (foreign-ref 'int (c-errno-location) 0)) ;; ========== Constants ========== --- a/lib/std/os/flock.sls +++ b/lib/std/os/flock.sls @@ -23,7 +23,10 @@ (define c-flock (foreign-procedure "flock" (int int) int)) ;; errno access - (define c-errno-location (foreign-procedure "__errno_location" () void*)) + (define c-errno-location + (if (memq (machine-type) '(a6fb ta6fb i3fb ti3fb arm64fb)) + (foreign-procedure "__error" () void*) + (foreign-procedure "__errno_location" () void*))) (define (get-errno) (foreign-ref 'int (c-errno-location) 0)) (define EWOULDBLOCK 11) ;; same as EAGAIN on Linux --- a/lib/std/os/posix.sls +++ b/lib/std/os/posix.sls @@ -95,10 +95,12 @@ ;; ========== Errno ========== - ;; errno is thread-local via __errno_location on Linux + ;; errno is thread-local via __errno_location on Linux / __error on FreeBSD (define c-errno-location (guard (e [#t #f]) - (foreign-procedure "__errno_location" () void*))) + (if (memq (machine-type) '(a6fb ta6fb i3fb ti3fb arm64fb)) + (foreign-procedure "__error" () void*) + (foreign-procedure "__errno_location" () void*)))) (define (posix-errno) (if c-errno-location --- a/lib/std/os/signalfd.sls +++ b/lib/std/os/signalfd.sls @@ -54,7 +54,10 @@ (define c-sigprocmask (foreign-procedure "sigprocmask" (int void* void*) int)) ;; errno access - (define c-errno-location (foreign-procedure "__errno_location" () void*)) + (define c-errno-location + (if (memq (machine-type) '(a6fb ta6fb i3fb ti3fb arm64fb)) + (foreign-procedure "__error" () void*) + (foreign-procedure "__errno_location" () void*))) (define (get-errno) (foreign-ref 'int (c-errno-location) 0)) (define EINTR 4) --- a/lib/std/security/landlock.sls +++ b/lib/std/security/landlock.sls @@ -56,7 +56,9 @@ (define c-errno (guard (e [#t (lambda () 0)]) - (foreign-procedure "__errno_location" () void*))) + (if (memq (machine-type) '(a6fb ta6fb i3fb ti3fb arm64fb)) + (foreign-procedure "__error" () void*) + (foreign-procedure "__errno_location" () void*)))) (define (get-errno) (guard (e [#t 0]) --- a/lib/std/security/seccomp.sls +++ b/lib/std/security/seccomp.sls @@ -47,7 +47,9 @@ (define c-errno (guard (e [#t (lambda () 0)]) - (foreign-procedure "__errno_location" () void*))) + (if (memq (machine-type) '(a6fb ta6fb i3fb ti3fb arm64fb)) + (foreign-procedure "__error" () void*) + (foreign-procedure "__errno_location" () void*)))) (define (get-errno) (guard (e [#t 0]) --- a/lib/std/web/fastcgi.sls +++ b/lib/std/web/fastcgi.sls @@ -43,7 +43,10 @@ (define c-htons (foreign-procedure "htons" (unsigned-short) unsigned-short)) (define c-inet-pton (foreign-procedure "inet_pton" (int string void*) int)) (define c-fcntl (foreign-procedure "fcntl" (int int int) int)) - (define c-errno-location (foreign-procedure "__errno_location" () void*)) + (define c-errno-location + (if (memq (machine-type) '(a6fb ta6fb i3fb ti3fb arm64fb)) + (foreign-procedure "__error" () void*) + (foreign-procedure "__errno_location" () void*))) (define (get-errno) (foreign-ref 'int (c-errno-location) 0)) (define AF_INET 2) --- a/lib/std/web/rack.sls +++ b/lib/std/web/rack.sls @@ -38,7 +38,10 @@ (define c-htons (foreign-procedure "htons" (unsigned-short) unsigned-short)) (define c-inet-pton (foreign-procedure "inet_pton" (int string void*) int)) (define c-fcntl (foreign-procedure "fcntl" (int int int) int)) - (define c-errno-location (foreign-procedure "__errno_location" () void*)) + (define c-errno-location + (if (memq (machine-type) '(a6fb ta6fb i3fb ti3fb arm64fb)) + (foreign-procedure "__error" () void*) + (foreign-procedure "__errno_location" () void*))) (define (get-errno) (foreign-ref 'int (c-errno-location) 0)) (define AF_INET 2)