summaryrefslogtreecommitdiff
path: root/experimental/sbcl/musl-libc.patch
blob: 1aa5cb557340f5df83f9409e8396e4728cdcc5a7 (plain) (blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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/src/runtime/linux-os.c b/src/runtime/linux-os.c
index fa4f5e490..60b5fea4e 100644
--- a/src/runtime/linux-os.c
+++ b/src/runtime/linux-os.c
@@ -187,8 +187,15 @@ isnptl (void)
       if (strstr (buf, "NPTL")) {
           return 1;
       }
+      else {
+          return 0;
+      }
+  }
+  else {
+      /* If the configuration variable is empty, just assume we have a
+       * good enough thread implementation. */
+      return 1;
   }
-  return 0;
 }
 #endif
 
diff --git a/tests/foreign.test.sh b/tests/foreign.test.sh
index 7fb757813..9ba8ed3cf 100755
--- a/tests/foreign.test.sh
+++ b/tests/foreign.test.sh
@@ -248,16 +248,23 @@ cat > $TEST_FILESTEM.test.lisp <<EOF
   (assert (= 13 foo))
   (assert (= 42 (bar)))
   (note "/original definitions ok")
-  (rename-file "$TEST_FILESTEM-b.so" "$TEST_FILESTEM-b.bak")
-  (rename-file "$TEST_FILESTEM-b2.so" "$TEST_FILESTEM-b.so")
-  (load-shared-object (truename "$TEST_FILESTEM-b.so"))
-  (note "/reloading ok")
-  (assert (= 42 foo))
-  (assert (= 13 (bar)))
-  (note "/redefined versions ok")
-  (rename-file "$TEST_FILESTEM-b.so" "$TEST_FILESTEM-b2.so")
-  (rename-file "$TEST_FILESTEM-b.bak" "$TEST_FILESTEM-b.so")
-  (note "/renamed back to originals")
+  ;; test late resolution
+  (eval-when (:compile-toplevel :load-toplevel :execute)
+   (setq *features* (union *features* sb-impl:+internal-features+)))
+  #+dlclose-is-noop
+  (note "/skipping reloading tests")
+  #-dlclose-is-noop
+  (progn
+    (rename-file "$TEST_FILESTEM-b.so" "$TEST_FILESTEM-b.bak")
+    (rename-file "$TEST_FILESTEM-b2.so" "$TEST_FILESTEM-b.so")
+    (load-shared-object (truename "$TEST_FILESTEM-b.so"))
+    (note "/reloading ok")
+    (assert (= 42 foo))
+    (assert (= 13 (bar)))
+    (note "/redefined versions ok")
+    (rename-file "$TEST_FILESTEM-b.so" "$TEST_FILESTEM-b2.so")
+    (rename-file "$TEST_FILESTEM-b.bak" "$TEST_FILESTEM-b.so")
+    (note "/renamed back to originals"))
 
   ;; test late resolution
   #+linkage-table
@@ -274,13 +278,17 @@ cat > $TEST_FILESTEM.test.lisp <<EOF
     (load-shared-object (truename "$TEST_FILESTEM-c.so"))
     (assert (= 43 late-foo))
     (assert (= 14 (late-bar)))
-    (unload-shared-object (truename "$TEST_FILESTEM-c.so"))
-    (multiple-value-bind (val err) (ignore-errors late-foo)
-      (assert (not val))
-      (assert (typep err 'undefined-alien-error)))
-    (multiple-value-bind (val err) (ignore-errors (late-bar))
-      (assert (not val))
-      (assert (typep err 'undefined-alien-error)))
+    #+dlclose-is-noop
+    (note "/skipping unloading tests")
+    #-dlclose-is-noop
+    (progn
+      (unload-shared-object (truename "$TEST_FILESTEM-c.so"))
+      (multiple-value-bind (val err) (ignore-errors late-foo)
+        (assert (not val))
+        (assert (typep err 'undefined-alien-error)))
+      (multiple-value-bind (val err) (ignore-errors (late-bar))
+        (assert (not val))
+        (assert (typep err 'undefined-alien-error))))
     (note "/linkage table ok"))
 
   (sb-ext:exit :code $EXIT_LISP_WIN) ; success convention for Lisp program
diff --git a/tools-for-build/Makefile b/tools-for-build/Makefile
index 3f6e4ecf9..39bab2b92 100644
--- a/tools-for-build/Makefile
+++ b/tools-for-build/Makefile
@@ -16,6 +16,9 @@ LDLIBS:=$(OS_LIBS)
 
 all: grovel-headers determine-endianness where-is-mcontext
 
+dlclose-is-noop-test-helper.so: dlclose-is-noop-test-helper.c
+	@$(CC) $(LDFLAGS) -shared $< -o $@ $(LOADLIBES) $(LDLIBS)
+
 clean:
 	rm -f *.o grovel-headers determine-endianness where-is-mcontext
 	rm -f *.exe
diff --git a/tools-for-build/dlclose-is-noop-test-helper.c b/tools-for-build/dlclose-is-noop-test-helper.c
new file mode 100644
index 000000000..4be7a8e5b
--- /dev/null
+++ b/tools-for-build/dlclose-is-noop-test-helper.c
@@ -0,0 +1 @@
+int sbcl_dl_close_test = 42;
diff --git a/tools-for-build/dlclose-is-noop-test.c b/tools-for-build/dlclose-is-noop-test.c
new file mode 100644
index 000000000..f4eab26a5
--- /dev/null
+++ b/tools-for-build/dlclose-is-noop-test.c
@@ -0,0 +1,19 @@
+/* test to build and run so that we know if we have a noop dlclose
+ */
+
+#include <dlfcn.h>
+#include <stddef.h>
+
+int main ()
+{
+   void * handle = dlopen("./dlclose-is-noop-test-helper.so", RTLD_NOW | RTLD_GLOBAL);
+   dlclose(handle);
+
+   handle = dlopen("./dlclose-is-noop-test-helper.so", RTLD_NOW | RTLD_NOLOAD);
+
+   if (handle != NULL) {
+       return 104;
+   } else {
+       return 0;
+   }
+}
diff --git a/tools-for-build/grovel-features.sh b/tools-for-build/grovel-features.sh
index ffc4307eb..bf1448a6a 100644
--- a/tools-for-build/grovel-features.sh
+++ b/tools-for-build/grovel-features.sh
@@ -36,3 +36,12 @@
 if [ "$sbcl_arch" = arm ] ; then
    featurep arm-softfp
 fi
+
+featurep os-provides-netdb-internal
+
+# We need a helper shared library to test dlclose-is-noop
+$GNUMAKE dlclose-is-noop-test-helper.so > /dev/null 2>&1
+
+featurep dlclose-is-noop
+
+rm -f dlclose-is-noop-test-helper.so
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
+}