Skip to content

Commit 748f20f

Browse files
Revert the upstream picolibc removal of dummyhost library. (#463)
This is not an approach that is going to be used in later releases, but it does give us time to work on a more complete solution. Upstream change for reference: picolibc/picolibc@6972284
2 parents 0cf8282 + ae05700 commit 748f20f

File tree

1 file changed

+231
-0
lines changed

1 file changed

+231
-0
lines changed
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
From 12b4ed4c5744c995e901bb54e659109f9e03efb4 Mon Sep 17 00:00:00 2001
2+
From: Mark Murray <[email protected]>
3+
Date: Mon, 4 Aug 2025 11:21:18 +0100
4+
Subject: [PATCH] Revert "Delete 'dummyhost'."
5+
6+
Needed for the 21.x release to buy us time to properly fix
7+
https://jira.arm.com/browse/LLVMREQ-935
8+
9+
This reverts commit 6972284de615b135522f0eb247a2cf04f7021ba4.
10+
---
11+
dummyhost/exit.c | 43 ++++++++++++++++++++++++
12+
dummyhost/iob.c | 76 +++++++++++++++++++++++++++++++++++++++++++
13+
dummyhost/meson.build | 58 +++++++++++++++++++++++++++++++++
14+
meson.build | 3 ++
15+
4 files changed, 180 insertions(+)
16+
create mode 100644 dummyhost/exit.c
17+
create mode 100644 dummyhost/iob.c
18+
create mode 100644 dummyhost/meson.build
19+
20+
diff --git a/dummyhost/exit.c b/dummyhost/exit.c
21+
new file mode 100644
22+
index 000000000..eee23f5c8
23+
--- /dev/null
24+
+++ b/dummyhost/exit.c
25+
@@ -0,0 +1,43 @@
26+
+/*
27+
+ * SPDX-License-Identifier: BSD-3-Clause
28+
+ *
29+
+ * Copyright © 2023 Keith Packard
30+
+ *
31+
+ * Redistribution and use in source and binary forms, with or without
32+
+ * modification, are permitted provided that the following conditions
33+
+ * are met:
34+
+ *
35+
+ * 1. Redistributions of source code must retain the above copyright
36+
+ * notice, this list of conditions and the following disclaimer.
37+
+ *
38+
+ * 2. Redistributions in binary form must reproduce the above
39+
+ * copyright notice, this list of conditions and the following
40+
+ * disclaimer in the documentation and/or other materials provided
41+
+ * with the distribution.
42+
+ *
43+
+ * 3. Neither the name of the copyright holder nor the names of its
44+
+ * contributors may be used to endorse or promote products derived
45+
+ * from this software without specific prior written permission.
46+
+ *
47+
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48+
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49+
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
50+
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
51+
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
52+
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
53+
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
54+
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55+
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
56+
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
57+
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
58+
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
59+
+ */
60+
+
61+
+#include <unistd.h>
62+
+
63+
+__noreturn void
64+
+_exit(int code)
65+
+{
66+
+ (void) code;
67+
+ for (;;);
68+
+}
69+
diff --git a/dummyhost/iob.c b/dummyhost/iob.c
70+
new file mode 100644
71+
index 000000000..81d60e479
72+
--- /dev/null
73+
+++ b/dummyhost/iob.c
74+
@@ -0,0 +1,76 @@
75+
+/*
76+
+ * SPDX-License-Identifier: BSD-3-Clause
77+
+ *
78+
+ * Copyright © 2019 Keith Packard
79+
+ *
80+
+ * Redistribution and use in source and binary forms, with or without
81+
+ * modification, are permitted provided that the following conditions
82+
+ * are met:
83+
+ *
84+
+ * 1. Redistributions of source code must retain the above copyright
85+
+ * notice, this list of conditions and the following disclaimer.
86+
+ *
87+
+ * 2. Redistributions in binary form must reproduce the above
88+
+ * copyright notice, this list of conditions and the following
89+
+ * disclaimer in the documentation and/or other materials provided
90+
+ * with the distribution.
91+
+ *
92+
+ * 3. Neither the name of the copyright holder nor the names of its
93+
+ * contributors may be used to endorse or promote products derived
94+
+ * from this software without specific prior written permission.
95+
+ *
96+
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
97+
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
98+
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
99+
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
100+
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
101+
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
102+
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
103+
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
104+
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
105+
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
106+
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
107+
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
108+
+ */
109+
+
110+
+#include <stdio.h>
111+
+
112+
+/*
113+
+ * Dummy stdio hooks. This allows programs to link without requiring
114+
+ * any system-dependent functions. This is only used if the program
115+
+ * doesn't provide its own version of stdin, stdout, stderr
116+
+ */
117+
+
118+
+static int
119+
+dummy_putc(char c, FILE *file)
120+
+{
121+
+ (void) c;
122+
+ (void) file;
123+
+ return (unsigned char) c;
124+
+}
125+
+
126+
+static int
127+
+dummy_getc(FILE *file)
128+
+{
129+
+ (void) file;
130+
+ return EOF;
131+
+}
132+
+
133+
+static int
134+
+dummy_flush(FILE *file)
135+
+{
136+
+ (void) file;
137+
+ return 0;
138+
+}
139+
+
140+
+static FILE __stdio = FDEV_SETUP_STREAM(dummy_putc, dummy_getc, dummy_flush, _FDEV_SETUP_RW);
141+
+
142+
+#ifdef __strong_reference
143+
+#define STDIO_ALIAS(x) __strong_reference(stdin, x);
144+
+#else
145+
+#define STDIO_ALIAS(x) FILE *const x = &__stdio;
146+
+#endif
147+
+
148+
+FILE *const stdin = &__stdio;
149+
+STDIO_ALIAS(stdout);
150+
+STDIO_ALIAS(stderr);
151+
diff --git a/dummyhost/meson.build b/dummyhost/meson.build
152+
new file mode 100644
153+
index 000000000..1acaabd73
154+
--- /dev/null
155+
+++ b/dummyhost/meson.build
156+
@@ -0,0 +1,58 @@
157+
+#
158+
+# SPDX-License-Identifier: BSD-3-Clause
159+
+#
160+
+# Copyright © 2019 Keith Packard
161+
+#
162+
+# Redistribution and use in source and binary forms, with or without
163+
+# modification, are permitted provided that the following conditions
164+
+# are met:
165+
+#
166+
+# 1. Redistributions of source code must retain the above copyright
167+
+# notice, this list of conditions and the following disclaimer.
168+
+#
169+
+# 2. Redistributions in binary form must reproduce the above
170+
+# copyright notice, this list of conditions and the following
171+
+# disclaimer in the documentation and/or other materials provided
172+
+# with the distribution.
173+
+#
174+
+# 3. Neither the name of the copyright holder nor the names of its
175+
+# contributors may be used to endorse or promote products derived
176+
+# from this software without specific prior written permission.
177+
+#
178+
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
179+
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
180+
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
181+
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
182+
+# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
183+
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
184+
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
185+
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
186+
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
187+
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
188+
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
189+
+# OF THE POSSIBILITY OF SUCH DAMAGE.
190+
+#
191+
+
192+
+srcs_dummyhost = [
193+
+ 'iob.c',
194+
+ 'exit.c',
195+
+]
196+
+
197+
+foreach params : targets
198+
+ target = params['name']
199+
+ target_dir = params['dir']
200+
+ target_c_args = params['c_args']
201+
+ target_lib_prefix = params['lib_prefix']
202+
+
203+
+ instdir = join_paths(lib_dir, target_dir)
204+
+
205+
+ libdummyhost_name = 'dummyhost'
206+
+
207+
+ set_variable('lib_dummyhost' + target,
208+
+ static_library(join_paths(target_dir, target_lib_prefix + libdummyhost_name),
209+
+ srcs_dummyhost,
210+
+ install : true,
211+
+ install_dir : instdir,
212+
+ include_directories : inc,
213+
+ c_args : target_c_args + c_args))
214+
+endforeach
215+
diff --git a/meson.build b/meson.build
216+
index 00f8ba8b1..710d4be25 100644
217+
--- a/meson.build
218+
+++ b/meson.build
219+
@@ -1558,6 +1558,9 @@ bios_bin = []
220+
if enable_semihost
221+
subdir('semihost')
222+
endif
223+
+if tinystdio
224+
+ subdir('dummyhost')
225+
+endif
226+
227+
conf_data.set('__SEMIHOST', has_semihost, description: 'Semihost APIs supported')
228+
conf_data.set('__ARM_SEMIHOST', has_arm_semihost, description: 'ARM Semihost APIs supported')
229+
--
230+
2.34.1
231+

0 commit comments

Comments
 (0)