aboutsummaryrefslogtreecommitdiff
path: root/testing/sbcl/0001-Fix-sb-bsd-sockets-on-musl-libc.patch
blob: 88497a41b38293c20461be444716942f98c7e36a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#2020/01/30 Patch has not yet been accepted upstream
From be70a77e2b06e2442b38093adbe84b15ea065c8f Mon Sep 17 00:00:00 2001
From: Eric Timmons <etimmons@mit.edu>
Date: Sat, 1 Feb 2020 15:38:19 -0500
Subject: [PATCH 1/5] Make sb-bsd-sockets robust to the absence of NETDB_*

NETDB_INTERNAL and NETDB_SUCCESS are not defined by all libc
implementations (see: musl libc). If groveling fails for these values, set them
to NIL which effectively disables the corresponding Lisp conditions from being
signaled.
---
 contrib/sb-bsd-sockets/name-service.lisp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/contrib/sb-bsd-sockets/name-service.lisp b/contrib/sb-bsd-sockets/name-service.lisp
index 34c7262ea..97b505a5e 100644
--- a/contrib/sb-bsd-sockets/name-service.lisp
+++ b/contrib/sb-bsd-sockets/name-service.lisp
@@ -1,5 +1,16 @@
 (in-package :sb-bsd-sockets)
 
+;; If we're unable to grovel for NETDB_INTERNAL and NETDB_SUCCESS (not every
+;; libc sets them), set their constants to NIL. This effectively makes their
+;; respective conditions unreachable.
+#-win32
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (unless (constantp 'sockint::netdb-internal)
+    (defconstant sockint::netdb-internal nil "See errno."))
+  (unless (constantp 'sockint::netdb-success)
+    (defconstant sockint::netdb-success nil "No problem.")))
+
+
 (defclass host-ent ()
   ((name :initarg :name :reader host-ent-name
          :documentation "The name of the host")
@@ -195,7 +206,7 @@ (defun name-service-error (where &optional errno)
   (let ((*name-service-errno* (get-name-service-errno errno)))
     ;; Comment next to NETDB_INTERNAL in netdb.h says "See errno.".
     ;; This special case treatment hasn't actually been tested yet.
-    (if (and #-win32 (= *name-service-errno* sockint::NETDB-INTERNAL))
+    (if (and #-win32 sockint::netdb-internal #-win32 (= *name-service-errno* sockint::NETDB-INTERNAL))
         (socket-error where)
         (let ((condition
                (condition-for-name-service-errno *name-service-errno*)))
-- 
2.25.0