From 86c2982568de1ad4d4cc12a65b19231331484405 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Thu, 10 Feb 2022 18:00:59 -0800 Subject: Run patches thru `manage-packages -P` This refreshes the line numbers, removes any fuzz (which would make any future forward ports easier) and standardizes the patch/file headers (which makes them easier to read). Signed-off-by: Alexey Neyman --- ...ake-ungetc-buffer-type-purely-architectur.patch | 150 +++++++++++++++++++ ...d-ARM-exception-information-to-link-rules.patch | 31 ++++ ...ake-ungetc-buffer-type-purely-architectur.patch | 159 --------------------- ...d-ARM-exception-information-to-link-rules.patch | 36 ----- ...icolibc-include-directory-to-cc1plus-spec.patch | 26 ++++ ...icolibc-include-directory-to-cc1plus-spec.patch | 31 ---- ...ove-include-sys-select.h-from-sys-types.h.patch | 25 ++++ ...ove-include-sys-select.h-from-sys-types.h.patch | 30 ---- ...-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch | 70 +++++++++ ...-wchar-stdio-prototypes-even-for-TINY_STD.patch | 103 +++++++++++++ ...-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch | 77 ---------- ...-wchar-stdio-prototypes-even-for-TINY_STD.patch | 108 -------------- 12 files changed, 405 insertions(+), 441 deletions(-) create mode 100644 packages/picolibc/1.4.7/0000-tinystdio-Make-ungetc-buffer-type-purely-architectur.patch create mode 100644 packages/picolibc/1.4.7/0001-Add-ARM-exception-information-to-link-rules.patch delete mode 100644 packages/picolibc/1.4.7/0001-tinystdio-Make-ungetc-buffer-type-purely-architectur.patch delete mode 100644 packages/picolibc/1.4.7/0002-Add-ARM-exception-information-to-link-rules.patch create mode 100644 packages/picolibc/1.4.7/0002-Add-picolibc-include-directory-to-cc1plus-spec.patch delete mode 100644 packages/picolibc/1.4.7/0003-Add-picolibc-include-directory-to-cc1plus-spec.patch create mode 100644 packages/picolibc/1.5.1/0000-libc-Remove-include-sys-select.h-from-sys-types.h.patch delete mode 100644 packages/picolibc/1.5.1/0001-libc-Remove-include-sys-select.h-from-sys-types.h.patch create mode 100644 packages/picolibc/1.5.1/0001-tinystdio-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch create mode 100644 packages/picolibc/1.5.1/0002-libc-Expose-wchar-stdio-prototypes-even-for-TINY_STD.patch delete mode 100644 packages/picolibc/1.5.1/0002-tinystdio-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch delete mode 100644 packages/picolibc/1.5.1/0003-libc-Expose-wchar-stdio-prototypes-even-for-TINY_STD.patch (limited to 'packages/picolibc') diff --git a/packages/picolibc/1.4.7/0000-tinystdio-Make-ungetc-buffer-type-purely-architectur.patch b/packages/picolibc/1.4.7/0000-tinystdio-Make-ungetc-buffer-type-purely-architectur.patch new file mode 100644 index 00000000..4b3ecbdf --- /dev/null +++ b/packages/picolibc/1.4.7/0000-tinystdio-Make-ungetc-buffer-type-purely-architectur.patch @@ -0,0 +1,150 @@ +From 2adb30bd8e64bf06fb5366585e305c28c4325e01 Mon Sep 17 00:00:00 2001 +From: Keith Packard +Date: Tue, 3 Nov 2020 16:36:48 -0800 +Subject: [PATCH] tinystdio: Make ungetc buffer type purely + architecture-specific + +Instead of attempting to figure out what type this object should be +based on compiler support for atomics, just make it 32-bits on RISC-V +when using atomic ungetc, otherwise make it 16-bits, then select +whether there are 'real' atomics based on compiler support for the +chosen type, which may depend on the compiler options used to build +the library. + +This ensures that the picolibc ABI is consistent for each +architecture. + +This also removes the use of stdatomic.h from stdio.h, which isn't +supported by C++. + +Signed-off-by: Keith Packard +--- + newlib/libc/tinystdio/exchange.c | 2 - + newlib/libc/tinystdio/stdio.h | 39 +++++++++++++--------------------- + newlib/libc/tinystdio/stdio_private.h | 24 ++++++++++++++------ + 3 files changed, 34 insertions(+), 31 deletions(-) + +--- a/newlib/libc/tinystdio/exchange.c ++++ b/newlib/libc/tinystdio/exchange.c +@@ -39,7 +39,7 @@ + #if defined(ATOMIC_UNGETC) && !defined(PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP) + + __ungetc_t +-__picolibc_non_atomic_exchange_ungetc(__ungetc_store_t *p, __ungetc_t v) ++__picolibc_non_atomic_exchange_ungetc(__ungetc_t *p, __ungetc_t v) + { + return __non_atomic_exchange_ungetc(p, v); + } +--- a/newlib/libc/tinystdio/stdio.h ++++ b/newlib/libc/tinystdio/stdio.h +@@ -224,38 +224,31 @@ + * elements of it beyond by using the official interfaces provided. + */ + +-/* Use 32-bit ungetc storage when doing atomic ungetc and when +- * the platform has 4-byte swap intrinsics but not 2-byte swap +- * intrinsics, as is the case for RISC-V processors. This increases +- * the size of the __file struct by four bytes. +- */ +- + #ifdef ATOMIC_UNGETC +-#include +-# ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 +- +-# define PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP +-typedef atomic_uint_least32_t __ungetc_store_t; +-typedef uint_least32_t __ungetc_t; +- +-# else +-# ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 ++#ifdef __riscv ++/* ++ * Use 32-bit ungetc storage when doing atomic ungetc on RISC-V, which ++ * has 4-byte swap intrinsics but not 2-byte swap intrinsics. This ++ * increases the size of the __file struct by four bytes. ++ */ ++#define __PICOLIBC_UNGETC_SIZE 4 ++#endif ++#endif + +-# define PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP +-typedef atomic_uint_least16_t __ungetc_store_t; +-typedef uint_least16_t __ungetc_t; ++#ifndef __PICOLIBC_UNGETC_SIZE ++#define __PICOLIBC_UNGETC_SIZE 2 ++#endif + +-# endif +-# endif ++#if __PICOLIBC_UNGETC_SIZE == 4 ++typedef uint32_t __ungetc_t; + #endif + +-#ifndef PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP +-typedef uint16_t __ungetc_store_t; ++#if __PICOLIBC_UNGETC_SIZE == 2 + typedef uint16_t __ungetc_t; + #endif + + struct __file { +- __ungetc_store_t unget; /* ungetc() buffer */ ++ __ungetc_t unget; /* ungetc() buffer */ + uint8_t flags; /* flags, see below */ + #define __SRD 0x0001 /* OK to read */ + #define __SWR 0x0002 /* OK to write */ +--- a/newlib/libc/tinystdio/stdio_private.h ++++ b/newlib/libc/tinystdio/stdio_private.h +@@ -141,7 +141,7 @@ + __atof_engine(uint32_t m10, int e10); + + static inline uint16_t +-__non_atomic_exchange_ungetc(__ungetc_store_t *p, __ungetc_t v) ++__non_atomic_exchange_ungetc(__ungetc_t *p, __ungetc_t v) + { + __ungetc_t e = *p; + *p = v; +@@ -159,28 +159,38 @@ + + #ifdef ATOMIC_UNGETC + ++#if __PICOLIBC_UNGETC_SIZE == 4 && defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) ++#define PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP ++#endif ++ ++#if __PICOLIBC_UNGETC_SIZE == 2 && defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) ++#define PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP ++#endif ++ + #ifdef PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP + + /* Use built-in atomic functions if they exist */ + #include + static inline bool +-__atomic_compare_exchange_ungetc(__ungetc_store_t *p, __ungetc_t d, __ungetc_t v) ++__atomic_compare_exchange_ungetc(__ungetc_t *p, __ungetc_t d, __ungetc_t v) + { +- return atomic_compare_exchange_weak(p, &d, v); ++ _Atomic __ungetc_t *pa = (_Atomic __ungetc_t *) p; ++ return atomic_compare_exchange_weak(pa, &d, v); + } + static inline __ungetc_t +-__atomic_exchange_ungetc(__ungetc_store_t *p, __ungetc_t v) ++__atomic_exchange_ungetc(__ungetc_t *p, __ungetc_t v) + { +- return atomic_exchange_explicit(p, v, memory_order_relaxed); ++ _Atomic __ungetc_t *pa = (_Atomic __ungetc_t *) p; ++ return atomic_exchange_explicit(pa, v, memory_order_relaxed); + } + + #else + + bool +-__atomic_compare_exchange_ungetc(__ungetc_store_t *p, __ungetc_t d, __ungetc_t v); ++__atomic_compare_exchange_ungetc(__ungetc_t *p, __ungetc_t d, __ungetc_t v); + + __ungetc_t +-__atomic_exchange_ungetc(__ungetc_store_t *p, __ungetc_t v); ++__atomic_exchange_ungetc(__ungetc_t *p, __ungetc_t v); + + #endif /* PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP */ + diff --git a/packages/picolibc/1.4.7/0001-Add-ARM-exception-information-to-link-rules.patch b/packages/picolibc/1.4.7/0001-Add-ARM-exception-information-to-link-rules.patch new file mode 100644 index 00000000..233eafa1 --- /dev/null +++ b/packages/picolibc/1.4.7/0001-Add-ARM-exception-information-to-link-rules.patch @@ -0,0 +1,31 @@ +From 9c39c93d4897c9ee1659dd6df7433d097a84be4a Mon Sep 17 00:00:00 2001 +From: Keith Packard +Date: Wed, 4 Nov 2020 17:36:14 -0800 +Subject: [PATCH] Add ARM exception information to link rules + +Place any ARM exeception information in ROM for C++ support. + +Signed-off-by: Keith Packard +--- + picolibc.ld | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/picolibc.ld ++++ b/picolibc.ld +@@ -94,6 +94,16 @@ + *(.got .got.*) + } >flash AT>flash :text + ++ .ARM.extab : { ++ *(.ARM.extab* .gnu.linkonce.armextab.*) ++ } >flash AT>flash :text ++ ++ PROVIDE (__exidx_start = .); ++ .ARM.exidx : { ++ *(.ARM.exidx*) ++ } >flash AT>flash :text ++ PROVIDE(__exidx_end = .); ++ + . = ALIGN(8); + + .preinit_array : { diff --git a/packages/picolibc/1.4.7/0001-tinystdio-Make-ungetc-buffer-type-purely-architectur.patch b/packages/picolibc/1.4.7/0001-tinystdio-Make-ungetc-buffer-type-purely-architectur.patch deleted file mode 100644 index 0bedf41d..00000000 --- a/packages/picolibc/1.4.7/0001-tinystdio-Make-ungetc-buffer-type-purely-architectur.patch +++ /dev/null @@ -1,159 +0,0 @@ -From 2adb30bd8e64bf06fb5366585e305c28c4325e01 Mon Sep 17 00:00:00 2001 -From: Keith Packard -Date: Tue, 3 Nov 2020 16:36:48 -0800 -Subject: [PATCH] tinystdio: Make ungetc buffer type purely - architecture-specific - -Instead of attempting to figure out what type this object should be -based on compiler support for atomics, just make it 32-bits on RISC-V -when using atomic ungetc, otherwise make it 16-bits, then select -whether there are 'real' atomics based on compiler support for the -chosen type, which may depend on the compiler options used to build -the library. - -This ensures that the picolibc ABI is consistent for each -architecture. - -This also removes the use of stdatomic.h from stdio.h, which isn't -supported by C++. - -Signed-off-by: Keith Packard ---- - newlib/libc/tinystdio/exchange.c | 2 +- - newlib/libc/tinystdio/stdio.h | 39 +++++++++++---------------- - newlib/libc/tinystdio/stdio_private.h | 24 ++++++++++++----- - 3 files changed, 34 insertions(+), 31 deletions(-) - -diff --git a/newlib/libc/tinystdio/exchange.c b/newlib/libc/tinystdio/exchange.c -index 1272ae36e..e8c785f8a 100644 ---- a/newlib/libc/tinystdio/exchange.c -+++ b/newlib/libc/tinystdio/exchange.c -@@ -39,7 +39,7 @@ - #if defined(ATOMIC_UNGETC) && !defined(PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP) - - __ungetc_t --__picolibc_non_atomic_exchange_ungetc(__ungetc_store_t *p, __ungetc_t v) -+__picolibc_non_atomic_exchange_ungetc(__ungetc_t *p, __ungetc_t v) - { - return __non_atomic_exchange_ungetc(p, v); - } -diff --git a/newlib/libc/tinystdio/stdio.h b/newlib/libc/tinystdio/stdio.h -index 1e36f73e9..8bc0f8843 100644 ---- a/newlib/libc/tinystdio/stdio.h -+++ b/newlib/libc/tinystdio/stdio.h -@@ -224,38 +224,31 @@ - * elements of it beyond by using the official interfaces provided. - */ - --/* Use 32-bit ungetc storage when doing atomic ungetc and when -- * the platform has 4-byte swap intrinsics but not 2-byte swap -- * intrinsics, as is the case for RISC-V processors. This increases -- * the size of the __file struct by four bytes. -- */ -- - #ifdef ATOMIC_UNGETC --#include --# ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 -- --# define PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP --typedef atomic_uint_least32_t __ungetc_store_t; --typedef uint_least32_t __ungetc_t; -- --# else --# ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 -+#ifdef __riscv -+/* -+ * Use 32-bit ungetc storage when doing atomic ungetc on RISC-V, which -+ * has 4-byte swap intrinsics but not 2-byte swap intrinsics. This -+ * increases the size of the __file struct by four bytes. -+ */ -+#define __PICOLIBC_UNGETC_SIZE 4 -+#endif -+#endif - --# define PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP --typedef atomic_uint_least16_t __ungetc_store_t; --typedef uint_least16_t __ungetc_t; -+#ifndef __PICOLIBC_UNGETC_SIZE -+#define __PICOLIBC_UNGETC_SIZE 2 -+#endif - --# endif --# endif -+#if __PICOLIBC_UNGETC_SIZE == 4 -+typedef uint32_t __ungetc_t; - #endif - --#ifndef PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP --typedef uint16_t __ungetc_store_t; -+#if __PICOLIBC_UNGETC_SIZE == 2 - typedef uint16_t __ungetc_t; - #endif - - struct __file { -- __ungetc_store_t unget; /* ungetc() buffer */ -+ __ungetc_t unget; /* ungetc() buffer */ - uint8_t flags; /* flags, see below */ - #define __SRD 0x0001 /* OK to read */ - #define __SWR 0x0002 /* OK to write */ -diff --git a/newlib/libc/tinystdio/stdio_private.h b/newlib/libc/tinystdio/stdio_private.h -index b8ec66864..1a8b77dc9 100644 ---- a/newlib/libc/tinystdio/stdio_private.h -+++ b/newlib/libc/tinystdio/stdio_private.h -@@ -141,7 +141,7 @@ float - __atof_engine(uint32_t m10, int e10); - - static inline uint16_t --__non_atomic_exchange_ungetc(__ungetc_store_t *p, __ungetc_t v) -+__non_atomic_exchange_ungetc(__ungetc_t *p, __ungetc_t v) - { - __ungetc_t e = *p; - *p = v; -@@ -159,28 +159,38 @@ __non_atomic_compare_exchange_ungetc(__ungetc_t *p, __ungetc_t d, __ungetc_t v) - - #ifdef ATOMIC_UNGETC - -+#if __PICOLIBC_UNGETC_SIZE == 4 && defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) -+#define PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP -+#endif -+ -+#if __PICOLIBC_UNGETC_SIZE == 2 && defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2) -+#define PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP -+#endif -+ - #ifdef PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP - - /* Use built-in atomic functions if they exist */ - #include - static inline bool --__atomic_compare_exchange_ungetc(__ungetc_store_t *p, __ungetc_t d, __ungetc_t v) -+__atomic_compare_exchange_ungetc(__ungetc_t *p, __ungetc_t d, __ungetc_t v) - { -- return atomic_compare_exchange_weak(p, &d, v); -+ _Atomic __ungetc_t *pa = (_Atomic __ungetc_t *) p; -+ return atomic_compare_exchange_weak(pa, &d, v); - } - static inline __ungetc_t --__atomic_exchange_ungetc(__ungetc_store_t *p, __ungetc_t v) -+__atomic_exchange_ungetc(__ungetc_t *p, __ungetc_t v) - { -- return atomic_exchange_explicit(p, v, memory_order_relaxed); -+ _Atomic __ungetc_t *pa = (_Atomic __ungetc_t *) p; -+ return atomic_exchange_explicit(pa, v, memory_order_relaxed); - } - - #else - - bool --__atomic_compare_exchange_ungetc(__ungetc_store_t *p, __ungetc_t d, __ungetc_t v); -+__atomic_compare_exchange_ungetc(__ungetc_t *p, __ungetc_t d, __ungetc_t v); - - __ungetc_t --__atomic_exchange_ungetc(__ungetc_store_t *p, __ungetc_t v); -+__atomic_exchange_ungetc(__ungetc_t *p, __ungetc_t v); - - #endif /* PICOLIBC_HAVE_SYNC_COMPARE_AND_SWAP */ - --- -2.29.1 - diff --git a/packages/picolibc/1.4.7/0002-Add-ARM-exception-information-to-link-rules.patch b/packages/picolibc/1.4.7/0002-Add-ARM-exception-information-to-link-rules.patch deleted file mode 100644 index 7fd254d5..00000000 --- a/packages/picolibc/1.4.7/0002-Add-ARM-exception-information-to-link-rules.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 9c39c93d4897c9ee1659dd6df7433d097a84be4a Mon Sep 17 00:00:00 2001 -From: Keith Packard -Date: Wed, 4 Nov 2020 17:36:14 -0800 -Subject: [PATCH] Add ARM exception information to link rules - -Place any ARM exeception information in ROM for C++ support. - -Signed-off-by: Keith Packard ---- - picolibc.ld | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/picolibc.ld b/picolibc.ld -index 6d14b396f..ff60fe3a3 100644 ---- a/picolibc.ld -+++ b/picolibc.ld -@@ -94,6 +94,16 @@ SECTIONS - *(.got .got.*) - } >flash AT>flash :text - -+ .ARM.extab : { -+ *(.ARM.extab* .gnu.linkonce.armextab.*) -+ } >flash AT>flash :text -+ -+ PROVIDE (__exidx_start = .); -+ .ARM.exidx : { -+ *(.ARM.exidx*) -+ } >flash AT>flash :text -+ PROVIDE(__exidx_end = .); -+ - . = ALIGN(8); - - .preinit_array : { --- -2.28.0 - diff --git a/packages/picolibc/1.4.7/0002-Add-picolibc-include-directory-to-cc1plus-spec.patch b/packages/picolibc/1.4.7/0002-Add-picolibc-include-directory-to-cc1plus-spec.patch new file mode 100644 index 00000000..267e1b25 --- /dev/null +++ b/packages/picolibc/1.4.7/0002-Add-picolibc-include-directory-to-cc1plus-spec.patch @@ -0,0 +1,26 @@ +From 1f6b3ddcbba7432a5b2f1061f24297989d6ce791 Mon Sep 17 00:00:00 2001 +From: Keith Packard +Date: Mon, 9 Nov 2020 13:02:44 -0800 +Subject: [PATCH] Add picolibc include directory to cc1plus spec + +G++ doesn't use the cpp spec to add include directories, so we need to +add the picolibc include directory to the cc1plus spec element as well +as the cpp one. To make sure the libstdc++ headers can use +GCC-provided header directories, so use -idirafter instead of -isystem. + +Signed-off-by: Keith Packard +--- + picolibc.specs.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/picolibc.specs.in ++++ b/picolibc.specs.in +@@ -10,7 +10,7 @@ + @TLSMODEL@ %(picolibc_cc1) @CC1_SPEC@ + + *cc1plus: +-@TLSMODEL@ %(picolibc_cc1plus) @CC1_SPEC@ @CC1PLUS_SPEC@ ++-idirafter @INCLUDEDIR@ @TLSMODEL@ %(picolibc_cc1plus) @CC1_SPEC@ @CC1PLUS_SPEC@ + + *link: + @SPECS_PRINTF@ -L@LIBDIR@/%M -L@LIBDIR@ %{!T:-Tpicolibc.ld} %(picolibc_link) --gc-sections @LINK_SPEC@ diff --git a/packages/picolibc/1.4.7/0003-Add-picolibc-include-directory-to-cc1plus-spec.patch b/packages/picolibc/1.4.7/0003-Add-picolibc-include-directory-to-cc1plus-spec.patch deleted file mode 100644 index 885c0c7e..00000000 --- a/packages/picolibc/1.4.7/0003-Add-picolibc-include-directory-to-cc1plus-spec.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 1f6b3ddcbba7432a5b2f1061f24297989d6ce791 Mon Sep 17 00:00:00 2001 -From: Keith Packard -Date: Mon, 9 Nov 2020 13:02:44 -0800 -Subject: [PATCH] Add picolibc include directory to cc1plus spec - -G++ doesn't use the cpp spec to add include directories, so we need to -add the picolibc include directory to the cc1plus spec element as well -as the cpp one. To make sure the libstdc++ headers can use -GCC-provided header directories, so use -idirafter instead of -isystem. - -Signed-off-by: Keith Packard ---- - picolibc.specs.in | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/picolibc.specs.in b/picolibc.specs.in -index c1f916a6f..133e65db9 100644 ---- a/picolibc.specs.in -+++ b/picolibc.specs.in -@@ -10,7 +10,7 @@ - @TLSMODEL@ %(picolibc_cc1) @CC1_SPEC@ - - *cc1plus: --@TLSMODEL@ %(picolibc_cc1plus) @CC1_SPEC@ @CC1PLUS_SPEC@ -+-idirafter @INCLUDEDIR@ @TLSMODEL@ %(picolibc_cc1plus) @CC1_SPEC@ @CC1PLUS_SPEC@ - - *link: - @SPECS_PRINTF@ -L@LIBDIR@/%M -L@LIBDIR@ %{!T:-Tpicolibc.ld} %(picolibc_link) --gc-sections @LINK_SPEC@ --- -2.28.0 - diff --git a/packages/picolibc/1.5.1/0000-libc-Remove-include-sys-select.h-from-sys-types.h.patch b/packages/picolibc/1.5.1/0000-libc-Remove-include-sys-select.h-from-sys-types.h.patch new file mode 100644 index 00000000..658d2e4b --- /dev/null +++ b/packages/picolibc/1.5.1/0000-libc-Remove-include-sys-select.h-from-sys-types.h.patch @@ -0,0 +1,25 @@ +From 9d0640874425e9f3f265c9baff7a47139b25ea7d Mon Sep 17 00:00:00 2001 +From: Keith Packard +Date: Thu, 14 Jan 2021 17:54:22 -0800 +Subject: [PATCH 1/2] libc: Remove #include 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 +--- + newlib/libc/include/sys/types.h | 1 - + 1 file changed, 1 deletion(-) + +--- a/newlib/libc/include/sys/types.h ++++ b/newlib/libc/include/sys/types.h +@@ -75,7 +75,6 @@ + + #if __BSD_VISIBLE + #include +-#include + # define physadr physadr_t + # define quad quad_t + 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 deleted file mode 100644 index 5536cd43..00000000 --- a/packages/picolibc/1.5.1/0001-libc-Remove-include-sys-select.h-from-sys-types.h.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 9d0640874425e9f3f265c9baff7a47139b25ea7d Mon Sep 17 00:00:00 2001 -From: Keith Packard -Date: Thu, 14 Jan 2021 17:54:22 -0800 -Subject: [PATCH 1/2] libc: Remove #include 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 ---- - 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 --#include - # define physadr physadr_t - # define quad quad_t - --- -2.30.0 - diff --git a/packages/picolibc/1.5.1/0001-tinystdio-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch b/packages/picolibc/1.5.1/0001-tinystdio-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch new file mode 100644 index 00000000..911788ae --- /dev/null +++ b/packages/picolibc/1.5.1/0001-tinystdio-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch @@ -0,0 +1,70 @@ +From 9df2d784439720abbf67fa96c6515a5c4a9f230a Mon Sep 17 00:00:00 2001 +From: Keith Packard +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 +--- + newlib/libc/tinystdio/snprintf.c | 2 +- + test/printf_scanf.c | 31 +++++++++++++++++++++++++++++++ + 2 files changed, 32 insertions(+), 1 deletion(-) + +--- a/newlib/libc/tinystdio/snprintf.c ++++ b/newlib/libc/tinystdio/snprintf.c +@@ -56,7 +56,7 @@ + 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; +--- a/test/printf_scanf.c ++++ b/test/printf_scanf.c +@@ -96,6 +96,37 @@ + 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; diff --git a/packages/picolibc/1.5.1/0002-libc-Expose-wchar-stdio-prototypes-even-for-TINY_STD.patch b/packages/picolibc/1.5.1/0002-libc-Expose-wchar-stdio-prototypes-even-for-TINY_STD.patch new file mode 100644 index 00000000..a3e05447 --- /dev/null +++ b/packages/picolibc/1.5.1/0002-libc-Expose-wchar-stdio-prototypes-even-for-TINY_STD.patch @@ -0,0 +1,103 @@ +From f0c62653bbcf68291a7dd621db367a9fef666183 Mon Sep 17 00:00:00 2001 +From: Keith Packard +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 +--- + newlib/libc/include/wchar.h | 39 ++++++++++++++++++++------------------- + 1 file changed, 20 insertions(+), 19 deletions(-) + +--- a/newlib/libc/include/wchar.h ++++ b/newlib/libc/include/wchar.h +@@ -217,8 +217,6 @@ + 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 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_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 @@ + #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 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 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 @@ + #define putwchar_unlocked(wc) fputwc_unlocked((wc), stdout) + #endif + +-#endif /* !TINY_STDIO */ +- + _END_STD_C + + #if __SSP_FORTIFY_LEVEL > 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 deleted file mode 100644 index 754957e9..00000000 --- a/packages/picolibc/1.5.1/0002-tinystdio-Fix-snprintf-buf-0-.-to-not-smash-buffer.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 9df2d784439720abbf67fa96c6515a5c4a9f230a Mon Sep 17 00:00:00 2001 -From: Keith Packard -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 ---- - 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 deleted file mode 100644 index 5e1c5a85..00000000 --- a/packages/picolibc/1.5.1/0003-libc-Expose-wchar-stdio-prototypes-even-for-TINY_STD.patch +++ /dev/null @@ -1,108 +0,0 @@ -From f0c62653bbcf68291a7dd621db367a9fef666183 Mon Sep 17 00:00:00 2001 -From: Keith Packard -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 ---- - 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 - -- cgit v1.2.3