aboutsummaryrefslogtreecommitdiffstats
path: root/testing/sbcl/0001-Fix-sb-bsd-sockets-on-musl-libc.patch
blob: 52187156df49a5561b6b6c4a51c7367c9fa40786 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#2020/01/30 Patch has not yet been accepted upstream
From 46e1d8be04a87e6a2cb1c8be14beb99fe3702133 Mon Sep 17 00:00:00 2001
From: Eric Timmons <etimmons@mit.edu>
Date: Sun, 2 Dec 2018 14:02:33 -0500
Subject: [PATCH 1/4] Fix sb-bsd-sockets on musl libc

Musl libc does not define NETDB_INTERNAL or NETDB_SUCCESS. Add a build time test
to determine if these are defined. If they are defined, add the feature
:os-provides-netdb-internal. If this feature is missing, sb-bsd-sockets defaults
NETDB-INTERNAL to -1 and NETDB-SUCCESS to 0.
---
 contrib/sb-bsd-sockets/constants.lisp             |  4 ++--
 tools-for-build/grovel-features.sh                |  2 ++
 tools-for-build/os-provides-netdb-internal-test.c | 12 ++++++++++++
 3 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 tools-for-build/os-provides-netdb-internal-test.c

diff --git a/contrib/sb-bsd-sockets/constants.lisp b/contrib/sb-bsd-sockets/constants.lisp
index 88f5bb7c4..23fd87277 100644
--- a/contrib/sb-bsd-sockets/constants.lisp
+++ b/contrib/sb-bsd-sockets/constants.lisp
@@ -93,8 +93,8 @@
  (:integer EAFNOSUPPORT "EAFNOSUPPORT")
  (:integer EINPROGRESS "EINPROGRESS")
 
- (:integer NETDB-INTERNAL #+hpux "h_NETDB_INTERNAL" #-hpux "NETDB_INTERNAL" "See errno.")
- (:integer NETDB-SUCCESS #+hpux "h_NETDB_SUCCESS" #-hpux "NETDB_SUCCESS" "No problem.")
+ (:integer-no-check NETDB-INTERNAL #-os-provides-netdb-internal "-1" #+(and os-provides-netdb-internal hpux) "h_NETDB_INTERNAL" #+(and os-provides-netdb-internal (not hpux)) "NETDB_INTERNAL" "See errno.")
+ (:integer-no-check NETDB-SUCCESS #-os-provides-netdb-internal "0" #+(and os-provides-netdb-internal hpux) "h_NETDB_SUCCESS" #+(and os-provides-netdb-internal (not hpux)) "NETDB_SUCCESS" "No problem.")
  (:integer HOST-NOT-FOUND "HOST_NOT_FOUND" "Authoritative Answer Host not found.")
  (:integer TRY-AGAIN "TRY_AGAIN" "Non-Authoritative Host not found, or SERVERFAIL.")
  (:integer NO-RECOVERY "NO_RECOVERY" "Non recoverable errors, FORMERR, REFUSED, NOTIMP.")
diff --git a/tools-for-build/grovel-features.sh b/tools-for-build/grovel-features.sh
index 8f0ee7ffa..4790c0f11 100644
--- a/tools-for-build/grovel-features.sh
+++ b/tools-for-build/grovel-features.sh
@@ -33,6 +33,8 @@ featurep os-provides-getprotoby-r
 
 featurep os-provides-poll
 
+featurep os-provides-netdb-internal
+
 if [ $sbcl_arch == arm ] ; then
    featurep arm-softfp
 fi
diff --git a/tools-for-build/os-provides-netdb-internal-test.c b/tools-for-build/os-provides-netdb-internal-test.c
new file mode 100644
index 000000000..cab08cc41
--- /dev/null
+++ b/tools-for-build/os-provides-netdb-internal-test.c
@@ -0,0 +1,12 @@
+#include <netdb.h>
+
+int main ()
+{
+#if defined NETDB_INTERNAL && defined NETDB_SUCCESS
+    return 104;
+#elif defined h_NETDB_INTERNAL && defined h_NETDB_SUCCESS
+    return 104;
+#else
+    return 0;
+#endif
+}
-- 
2.24.1