summaryrefslogtreecommitdiff
path: root/packages/picolibc
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2021-01-14 23:08:48 (GMT)
committerKeith Packard <keithp@keithp.com>2021-06-17 17:30:25 (GMT)
commit3e259dbaf8a42310a4ee60a0d816bde8551e1be3 (patch)
tree8ff0781950383241037999b2a8fba98343d71fd1 /packages/picolibc
parent5ab29fbf3e4e4dbd71ea9d01d15f6a575bd71562 (diff)
Switch to picolibc version 1.5.1
This version includes a small link fix for the sample crt0 on riscv. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'packages/picolibc')
-rw-r--r--packages/picolibc/1.5.1/0001-libc-Remove-include-sys-select.h-from-sys-types.h.patch30
-rw-r--r--packages/picolibc/1.5.1/0002-tinystdio-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch77
-rw-r--r--packages/picolibc/1.5.1/0003-libc-Expose-wchar-stdio-prototypes-even-for-TINY_STD.patch108
-rw-r--r--packages/picolibc/1.5.1/chksum4
-rw-r--r--packages/picolibc/1.5.1/version.desc (renamed from packages/picolibc/1.5/version.desc)0
-rw-r--r--packages/picolibc/1.5/chksum4
6 files changed, 219 insertions, 4 deletions
diff --git a/packages/picolibc/1.5.1/0001-libc-Remove-include-sys-select.h-from-sys-types.h.patch b/packages/picolibc/1.5.1/0001-libc-Remove-include-sys-select.h-from-sys-types.h.patch
new file mode 100644
index 0000000..5536cd4
--- /dev/null
+++ b/packages/picolibc/1.5.1/0001-libc-Remove-include-sys-select.h-from-sys-types.h.patch
@@ -0,0 +1,30 @@
+From 9d0640874425e9f3f265c9baff7a47139b25ea7d Mon Sep 17 00:00:00 2001
+From: Keith Packard <keithp@keithp.com>
+Date: Thu, 14 Jan 2021 17:54:22 -0800
+Subject: [PATCH 1/2] libc: Remove #include <sys/select.h> from sys/types.h
+
+picolibc's sys/select.h is likely to be replaced by the underlying
+operating system version (as it is on Zephyr). Don't include it from
+sys/types.h as that version may depend on other definitions in
+sys/types.h which haven't yet been defined.
+
+Signed-off-by: Keith Packard <keithp@keithp.com>
+---
+ newlib/libc/include/sys/types.h | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h
+index ea25222c2..1a0abcb83 100644
+--- a/newlib/libc/include/sys/types.h
++++ b/newlib/libc/include/sys/types.h
+@@ -75,7 +75,6 @@ typedef __intptr_t register_t;
+
+ #if __BSD_VISIBLE
+ #include <machine/endian.h>
+-#include <sys/select.h>
+ # define physadr physadr_t
+ # define quad quad_t
+
+--
+2.30.0
+
diff --git a/packages/picolibc/1.5.1/0002-tinystdio-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch b/packages/picolibc/1.5.1/0002-tinystdio-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch
new file mode 100644
index 0000000..754957e
--- /dev/null
+++ b/packages/picolibc/1.5.1/0002-tinystdio-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch
@@ -0,0 +1,77 @@
+From 9df2d784439720abbf67fa96c6515a5c4a9f230a Mon Sep 17 00:00:00 2001
+From: Keith Packard <keithp@keithp.com>
+Date: Thu, 14 Jan 2021 18:48:44 -0800
+Subject: [PATCH 2/2] tinystdio: Fix snprintf(buf, 0, ...) to not smash buffer
+
+snprintf(buf, 0) should not write anything to the destination, not
+even a trailing '\0'. The tinystdio implementation had a signed
+comparison bug where this case would cause a null to be placed in the
+output buffer at the size of the data that would have been written.
+
+Add a test to make sure snprintf respects the 'len' parameter
+correctly.
+
+Signed-off-by: Keith Packard <keithp@keithp.com>
+---
+ newlib/libc/tinystdio/snprintf.c | 2 +-
+ test/printf_scanf.c | 31 +++++++++++++++++++++++++++++++
+ 2 files changed, 32 insertions(+), 1 deletion(-)
+
+diff --git a/newlib/libc/tinystdio/snprintf.c b/newlib/libc/tinystdio/snprintf.c
+index 52d2f84d3..1052c9338 100644
+--- a/newlib/libc/tinystdio/snprintf.c
++++ b/newlib/libc/tinystdio/snprintf.c
+@@ -56,7 +56,7 @@ snprintf(char *s, size_t n, const char *fmt, ...)
+ i = vfprintf(&f.file, fmt, ap);
+ va_end(ap);
+
+- if (n >= 0 && i >= 0)
++ if ((int) n >= 0 && i >= 0)
+ s[i < n ? i : n] = 0;
+
+ return i;
+diff --git a/test/printf_scanf.c b/test/printf_scanf.c
+index 2bc83e1d0..f89f46e4f 100644
+--- a/test/printf_scanf.c
++++ b/test/printf_scanf.c
+@@ -96,6 +96,37 @@ main(int argc, char **argv)
+ fflush(stdout);
+ }
+ #endif
++
++ /*
++ * test snprintf to make sure it doesn't overwrite the specified buffer
++ * length (even if that is zero)
++ */
++ for (x = 0; x <= 6; x++) {
++ char tbuf[10] = "xxxxxxxxx";
++ const char ref[10] = "xxxxxxxxx";
++ int i = snprintf(tbuf, x, "%s", "123");
++ int y = x <= 4 ? x : 4;
++ if (i != 3) {
++ printf("snprintf(tbuf, %d, \"%%s\", \"123\") return %d instead of %d\n",
++ x, i, 3);
++ errors++;
++ }
++ int l = strlen(tbuf);
++ if (y > 0 && l != y - 1) {
++ printf("returned buffer len want %d got %d\n", y - 1, l);
++ errors++;
++ }
++ if (y > 0 && strncmp(tbuf, "123", y - 1) != 0) {
++ strncpy(buf, "123", y - 1);
++ buf[y-1] = '\0';
++ printf("returned buffer want %s got %s\n", buf, tbuf);
++ errors++;
++ }
++ if (memcmp(tbuf + y, ref + y, sizeof(tbuf) - y) != 0) {
++ printf("tail of buf mangled %s\n", tbuf + y);
++ errors++;
++ }
++ }
+ for (x = 0; x < 32; x++) {
+ unsigned int v = 0x12345678 >> x;
+ unsigned int r;
+--
+2.30.0
+
diff --git a/packages/picolibc/1.5.1/0003-libc-Expose-wchar-stdio-prototypes-even-for-TINY_STD.patch b/packages/picolibc/1.5.1/0003-libc-Expose-wchar-stdio-prototypes-even-for-TINY_STD.patch
new file mode 100644
index 0000000..5e1c5a8
--- /dev/null
+++ b/packages/picolibc/1.5.1/0003-libc-Expose-wchar-stdio-prototypes-even-for-TINY_STD.patch
@@ -0,0 +1,108 @@
+From f0c62653bbcf68291a7dd621db367a9fef666183 Mon Sep 17 00:00:00 2001
+From: Keith Packard <keithp@keithp.com>
+Date: Sun, 24 Jan 2021 15:27:14 -0800
+Subject: [PATCH 3/3] libc: Expose wchar stdio prototypes even for TINY_STDIO
+
+This makes libstdc++ happy when wrapping these names, even though they
+aren't actually available for appplications.
+
+Signed-off-by: Keith Packard <keithp@keithp.com>
+---
+ newlib/libc/include/wchar.h | 39 +++++++++++++++++++------------------
+ 1 file changed, 20 insertions(+), 19 deletions(-)
+
+diff --git a/newlib/libc/include/wchar.h b/newlib/libc/include/wchar.h
+index 8a9c4b0fe..5dc3af93c 100644
+--- a/newlib/libc/include/wchar.h
++++ b/newlib/libc/include/wchar.h
+@@ -217,8 +217,6 @@ float wcstof_l (const wchar_t *, wchar_t **, locale_t);
+ long double wcstold_l (const wchar_t *, wchar_t **, locale_t);
+ #endif
+
+-#ifndef TINY_STDIO
+-
+ wint_t fgetwc (__FILE *);
+ wchar_t *fgetws (wchar_t *__restrict, int, __FILE *__restrict);
+ wint_t fputwc (wchar_t, __FILE *);
+@@ -232,6 +230,8 @@ wint_t putwc (wchar_t, __FILE *);
+ wint_t putwchar (wchar_t);
+ wint_t ungetwc (wint_t wc, __FILE *);
+
++#ifndef TINY_STDIO
++
+ struct _reent;
+
+ wint_t _fgetwc_r (struct _reent *, __FILE *);
+@@ -253,6 +253,24 @@ wint_t _putwchar_r (struct _reent *, wchar_t);
+ wint_t _putwchar_unlocked_r (struct _reent *, wchar_t);
+ wint_t _ungetwc_r (struct _reent *, wint_t wc, __FILE *);
+
++int _fwprintf_r (struct _reent *, __FILE *, const wchar_t *, ...);
++int _swprintf_r (struct _reent *, wchar_t *, size_t, const wchar_t *, ...);
++int _vfwprintf_r (struct _reent *, __FILE *, const wchar_t *, va_list);
++int _vswprintf_r (struct _reent *, wchar_t *, size_t, const wchar_t *, va_list);
++int _vwprintf_r (struct _reent *, const wchar_t *, va_list);
++int _wprintf_r (struct _reent *, const wchar_t *, ...);
++
++int _fwscanf_r (struct _reent *, __FILE *, const wchar_t *, ...);
++int _swscanf_r (struct _reent *, const wchar_t *, const wchar_t *, ...);
++int _vfwscanf_r (struct _reent *, __FILE *, const wchar_t *, va_list);
++int _vswscanf_r (struct _reent *, const wchar_t *, const wchar_t *, va_list);
++int _vwscanf_r (struct _reent *, const wchar_t *, va_list);
++int _wscanf_r (struct _reent *, const wchar_t *, ...);
++
++__FILE *_open_wmemstream_r (struct _reent *, wchar_t **, size_t *);
++
++#endif
++
+ #if __GNU_VISIBLE
+ wint_t fgetwc_unlocked (__FILE *);
+ wchar_t *fgetws_unlocked (wchar_t *__restrict, int, __FILE *__restrict);
+@@ -267,7 +285,6 @@ wint_t putwchar_unlocked (wchar_t);
+ #if __POSIX_VISIBLE >= 200809
+ __FILE *open_wmemstream (wchar_t **, size_t *);
+ #endif
+-__FILE *_open_wmemstream_r (struct _reent *, wchar_t **, size_t *);
+
+ #if __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE >= 500
+ int fwprintf (__FILE *__restrict, const wchar_t *__restrict, ...);
+@@ -281,13 +298,6 @@ int vwprintf (const wchar_t *__restrict, va_list);
+ int wprintf (const wchar_t *__restrict, ...);
+ #endif
+
+-int _fwprintf_r (struct _reent *, __FILE *, const wchar_t *, ...);
+-int _swprintf_r (struct _reent *, wchar_t *, size_t, const wchar_t *, ...);
+-int _vfwprintf_r (struct _reent *, __FILE *, const wchar_t *, va_list);
+-int _vswprintf_r (struct _reent *, wchar_t *, size_t, const wchar_t *, va_list);
+-int _vwprintf_r (struct _reent *, const wchar_t *, va_list);
+-int _wprintf_r (struct _reent *, const wchar_t *, ...);
+-
+ #if __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE >= 500
+ int fwscanf (__FILE *__restrict, const wchar_t *__restrict, ...);
+ int swscanf (const wchar_t *__restrict,
+@@ -300,13 +310,6 @@ int vwscanf (const wchar_t *__restrict, va_list);
+ int wscanf (const wchar_t *__restrict, ...);
+ #endif
+
+-int _fwscanf_r (struct _reent *, __FILE *, const wchar_t *, ...);
+-int _swscanf_r (struct _reent *, const wchar_t *, const wchar_t *, ...);
+-int _vfwscanf_r (struct _reent *, __FILE *, const wchar_t *, va_list);
+-int _vswscanf_r (struct _reent *, const wchar_t *, const wchar_t *, va_list);
+-int _vwscanf_r (struct _reent *, const wchar_t *, va_list);
+-int _wscanf_r (struct _reent *, const wchar_t *, ...);
+-
+ #define getwc(fp) fgetwc(fp)
+ #define putwc(wc,fp) fputwc((wc), (fp))
+ #define getwchar() fgetwc(stdin)
+@@ -319,8 +322,6 @@ int _wscanf_r (struct _reent *, const wchar_t *, ...);
+ #define putwchar_unlocked(wc) fputwc_unlocked((wc), stdout)
+ #endif
+
+-#endif /* !TINY_STDIO */
+-
+ _END_STD_C
+
+ #if __SSP_FORTIFY_LEVEL > 0
+--
+2.30.0
+
diff --git a/packages/picolibc/1.5.1/chksum b/packages/picolibc/1.5.1/chksum
new file mode 100644
index 0000000..01fb145
--- /dev/null
+++ b/packages/picolibc/1.5.1/chksum
@@ -0,0 +1,4 @@
+md5 picolibc-1.5.1.tar.xz e2221b038181ae0c9f7b0bd3b1353d9e
+sha1 picolibc-1.5.1.tar.xz ad86b3f02fa7fc62563984f2c1a20ee8b4e566b9
+sha256 picolibc-1.5.1.tar.xz 06b34f34af4cef1be16e7d2e6de9f0c3aa9980dd7fd86c8b1b78331efbfa9db6
+sha512 picolibc-1.5.1.tar.xz 882ad8a20ab6dd8816a8b468834c3fcd66dd57f668f9fcb53e92b99c643377e15df2c37e80f6212c82d4ec63320575e0f7158c071edf5d8f66bb58aa4eecfd24
diff --git a/packages/picolibc/1.5/version.desc b/packages/picolibc/1.5.1/version.desc
index e69de29..e69de29 100644
--- a/packages/picolibc/1.5/version.desc
+++ b/packages/picolibc/1.5.1/version.desc
diff --git a/packages/picolibc/1.5/chksum b/packages/picolibc/1.5/chksum
deleted file mode 100644
index c5240fb..0000000
--- a/packages/picolibc/1.5/chksum
+++ /dev/null
@@ -1,4 +0,0 @@
-md5 picolibc-1.5.tar.xz f883ccdb907f13bd79ccecb6b677cc99
-sha1 picolibc-1.5.tar.xz 549b03479feab74042c58ca5903f2a5fd63dca65
-sha256 picolibc-1.5.tar.xz 88bd1b6e050145e285cb61c8cf4ce75714a8eb5d80cf89d0d0edc4f3fa067db1
-sha512 picolibc-1.5.tar.xz 7f50bc4bc7d8dbfb6feba09eee896918f5ac8b57d27c2d8158f17dc7d6778b80798c87edee92cf20d27b1dd2b3d1bfb157cfd9084019fdb7a6173ef959f03a92