From 10989847b259547fcb2c03c4dd162deb89df7c10 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Mon, 29 Jul 2024 17:14:07 -0700 Subject: [PATCH 01/42] semihosting: reduce code duplication for calls with indirect arguments These functions make it easier to call the semihosting functions without having to declare a local struct in each caller. Since there is only one call with 4 indirect parameters, I did not add a sys_semihost4 wrapper. --- semihost/lseek.c | 10 +-------- semihost/semihost-private.h | 40 ++++++++++++++++++++++++++++++++++++ semihost/semihost.h | 2 +- semihost/sys_close.c | 7 +------ semihost/sys_exit.c | 9 +------- semihost/sys_exit_extended.c | 11 ++-------- semihost/sys_flen.c | 8 +------- semihost/sys_iserror.c | 7 +------ semihost/sys_istty.c | 7 +------ semihost/sys_open.c | 13 ++---------- semihost/sys_read.c | 12 +---------- semihost/sys_remove.c | 11 ++-------- semihost/sys_seek.c | 9 +------- semihost/sys_system.c | 9 +------- semihost/sys_tmpnam.c | 13 ++---------- semihost/sys_write.c | 15 +++----------- 16 files changed, 61 insertions(+), 122 deletions(-) diff --git a/semihost/lseek.c b/semihost/lseek.c index f6b61fea4c..d695307f12 100644 --- a/semihost/lseek.c +++ b/semihost/lseek.c @@ -60,15 +60,7 @@ off_t lseek(int fd, off_t offset, int whence) return (off_t) -1; } - struct { - sh_param_t field1; - sh_param_t field2; - } arg = { - .field1 = fd, - .field2 = offset - }; - - uintptr_t ret = sys_semihost(SYS_SEEK, (uintptr_t) &arg); + uintptr_t ret = sys_semihost2(SYS_SEEK, fd, offset); if (ret == 0) return offset; errno = sys_semihost_errno(); diff --git a/semihost/semihost-private.h b/semihost/semihost-private.h index 3d828fb671..7f50bbf1f5 100644 --- a/semihost/semihost-private.h +++ b/semihost/semihost-private.h @@ -77,5 +77,45 @@ typedef uintptr_t sh_param_t; uintptr_t sys_semihost(uintptr_t op, uintptr_t param); +/* Helper functions to simplify semihosting calls with indirect arguments. */ +static inline uintptr_t +sys_semihost1(long op, sh_param_t arg1) +{ + struct { + sh_param_t field1; + } indirect_args = { + .field1 = arg1, + }; + return sys_semihost(op, (uintptr_t)&indirect_args); +} + +static inline uintptr_t +sys_semihost2(long op, sh_param_t arg1, sh_param_t arg2) +{ + struct { + sh_param_t field1; + sh_param_t field2; + } indirect_args = { + .field1 = arg1, + .field2 = arg2, + }; + return sys_semihost(op, (uintptr_t)&indirect_args); +} + +static inline uintptr_t +sys_semihost3(long op, sh_param_t arg1, sh_param_t arg2, sh_param_t arg3) +{ + struct { + sh_param_t field1; + sh_param_t field2; + sh_param_t field3; + } indirect_args = { + .field1 = arg1, + .field2 = arg2, + .field3 = arg3, + }; + return sys_semihost(op, (uintptr_t)&indirect_args); +} + int _map_stdio(int fd); diff --git a/semihost/semihost.h b/semihost/semihost.h index 24d7ca1057..0e22b06c4e 100644 --- a/semihost/semihost.h +++ b/semihost/semihost.h @@ -155,7 +155,7 @@ int sys_semihost_tmpnam(char *pathname, int identifier, int maxpath); uintptr_t -sys_semihost_write(int fd, const void *buf, uintptr_t count); +sys_semihost_write(int fd, const void *buf, size_t count); void sys_semihost_write0(const char *string); diff --git a/semihost/sys_close.c b/semihost/sys_close.c index 92981c523f..f8a7d8f966 100644 --- a/semihost/sys_close.c +++ b/semihost/sys_close.c @@ -38,10 +38,5 @@ int sys_semihost_close(int fd) { - struct { - sh_param_t field1; - } arg = { - .field1 = fd - }; - return (int) sys_semihost(SYS_CLOSE, (uintptr_t) &arg); + return (int) sys_semihost1(SYS_CLOSE, fd); } diff --git a/semihost/sys_exit.c b/semihost/sys_exit.c index b751c6f3da..e9b7d65607 100644 --- a/semihost/sys_exit.c +++ b/semihost/sys_exit.c @@ -40,14 +40,7 @@ _Noreturn void sys_semihost_exit(uintptr_t exception, uintptr_t subcode) { if (sizeof(sh_param_t) == 8) { - struct { - sh_param_t field1; - sh_param_t field2; - } arg = { - .field1 = exception, - .field2 = subcode - }; - (void) sys_semihost(SYS_EXIT, (uintptr_t) &arg); + (void) sys_semihost2(SYS_EXIT, exception, subcode); } else (void) sys_semihost(SYS_EXIT, exception); diff --git a/semihost/sys_exit_extended.c b/semihost/sys_exit_extended.c index d87a99af4f..9cd48e83f7 100644 --- a/semihost/sys_exit_extended.c +++ b/semihost/sys_exit_extended.c @@ -39,13 +39,6 @@ _Noreturn void sys_semihost_exit_extended(uintptr_t code) { - struct { - sh_param_t field1; - sh_param_t field2; - } arg = { - .field1 = ADP_Stopped_ApplicationExit, - .field2 = code - }; - (void) sys_semihost(SYS_EXIT_EXTENDED, (uintptr_t) &arg); - __unreachable(); + (void)sys_semihost2(SYS_EXIT_EXTENDED, ADP_Stopped_ApplicationExit, code); + __unreachable(); } diff --git a/semihost/sys_flen.c b/semihost/sys_flen.c index cb39eb478d..05de6e6ffb 100644 --- a/semihost/sys_flen.c +++ b/semihost/sys_flen.c @@ -38,11 +38,5 @@ uintptr_t sys_semihost_flen(int fd) { - struct { - sh_param_t field1; - } arg = { - .field1 = (sh_param_t) fd, - }; - - return (uintptr_t) sys_semihost(SYS_FLEN, (uintptr_t) &arg); + return (uintptr_t)sys_semihost1(SYS_FLEN, fd); } diff --git a/semihost/sys_iserror.c b/semihost/sys_iserror.c index 055bbd0da1..a006ba1c33 100644 --- a/semihost/sys_iserror.c +++ b/semihost/sys_iserror.c @@ -38,10 +38,5 @@ int sys_semihost_iserror(intptr_t status) { - struct { - sh_param_t field1; - } arg = { - .field1 = status - }; - return (int) sys_semihost(SYS_ISERROR, (uintptr_t) &arg); + return (int)sys_semihost1(SYS_ISERROR, status); } diff --git a/semihost/sys_istty.c b/semihost/sys_istty.c index 21f2f7ce76..e92d512d06 100644 --- a/semihost/sys_istty.c +++ b/semihost/sys_istty.c @@ -38,10 +38,5 @@ int sys_semihost_istty(int fd) { - struct { - sh_param_t field1; - } arg = { - .field1 = fd - }; - return (int) sys_semihost(SYS_ISTTY, (uintptr_t) &arg); + return (int)sys_semihost1(SYS_ISTTY, fd); } diff --git a/semihost/sys_open.c b/semihost/sys_open.c index 512973a2aa..370224952c 100644 --- a/semihost/sys_open.c +++ b/semihost/sys_open.c @@ -39,15 +39,6 @@ int sys_semihost_open(const char *pathname, int semiflags) { - struct { - sh_param_t field1; - sh_param_t field2; - sh_param_t field3; - } arg = { - .field1 = (sh_param_t) (uintptr_t) pathname, - .field2 = semiflags, - .field3 = strlen(pathname) - }; - - return (int) sys_semihost(SYS_OPEN, (uintptr_t) &arg); + return (int)sys_semihost3(SYS_OPEN, (sh_param_t)(uintptr_t)pathname, + semiflags, strlen(pathname)); } diff --git a/semihost/sys_read.c b/semihost/sys_read.c index a3e02e3636..92bf8a2bb7 100644 --- a/semihost/sys_read.c +++ b/semihost/sys_read.c @@ -38,15 +38,5 @@ uintptr_t sys_semihost_read(int fd, void *buf, size_t count) { - struct { - sh_param_t field1; - sh_param_t field2; - sh_param_t field3; - } arg = { - .field1 = fd, - .field2 = (sh_param_t) (uintptr_t) buf, - .field3 = (sh_param_t) count - }; - - return sys_semihost(SYS_READ, (uintptr_t) &arg); + return sys_semihost3(SYS_READ, fd, (sh_param_t)(uintptr_t)buf, count); } diff --git a/semihost/sys_remove.c b/semihost/sys_remove.c index 31e33a7d25..9bd811d443 100644 --- a/semihost/sys_remove.c +++ b/semihost/sys_remove.c @@ -39,13 +39,6 @@ int sys_semihost_remove(const char *pathname) { - struct { - sh_param_t field1; - sh_param_t field2; - } arg = { - .field1 = (sh_param_t) (uintptr_t) pathname, - .field2 = strlen(pathname) - }; - - return (int) sys_semihost(SYS_REMOVE, (uintptr_t) &arg); + return (int)sys_semihost2(SYS_REMOVE, (sh_param_t)(uintptr_t)pathname, + strlen(pathname)); } diff --git a/semihost/sys_seek.c b/semihost/sys_seek.c index cd8795b644..f78893a80b 100644 --- a/semihost/sys_seek.c +++ b/semihost/sys_seek.c @@ -38,12 +38,5 @@ int sys_semihost_seek(int fd, uintptr_t pos) { - struct { - sh_param_t field1; - sh_param_t field2; - } arg = { - .field1 = fd, - .field2 = pos - }; - return (int) sys_semihost(SYS_SEEK, (uintptr_t) &arg); + return (int)sys_semihost2(SYS_SEEK, fd, pos); } diff --git a/semihost/sys_system.c b/semihost/sys_system.c index ade5f5a6fb..720cbf3f07 100644 --- a/semihost/sys_system.c +++ b/semihost/sys_system.c @@ -39,12 +39,5 @@ int sys_semihost_system(const char *command) { - struct { - sh_param_t field1; - sh_param_t field2; - } arg = { - .field1 = (uintptr_t) command, - .field2 = strlen(command) - }; - return (int) sys_semihost(SYS_SYSTEM, (uintptr_t) &arg); + return (int)sys_semihost2(SYS_SYSTEM, (uintptr_t)command, strlen(command)); } diff --git a/semihost/sys_tmpnam.c b/semihost/sys_tmpnam.c index 80ce5406fc..d76556fd3d 100644 --- a/semihost/sys_tmpnam.c +++ b/semihost/sys_tmpnam.c @@ -38,15 +38,6 @@ int sys_semihost_tmpnam(char *pathname, int identifier, int maxpath) { - struct { - sh_param_t field1; - sh_param_t field2; - sh_param_t field3; - } arg = { - .field1 = (sh_param_t) (uintptr_t) pathname, - .field2 = identifier, - .field3 = maxpath - }; - - return (int) sys_semihost(SYS_TMPNAM, (uintptr_t) &arg); + return (int)sys_semihost3(SYS_TMPNAM, (sh_param_t)(uintptr_t)pathname, + identifier, maxpath); } diff --git a/semihost/sys_write.c b/semihost/sys_write.c index de72bd3a4e..615e2d2f48 100644 --- a/semihost/sys_write.c +++ b/semihost/sys_write.c @@ -36,17 +36,8 @@ #include "semihost-private.h" uintptr_t -sys_semihost_write(int fd, const void *buf, uintptr_t count) +sys_semihost_write(int fd, const void *buf, size_t count) { - struct { - sh_param_t field1; - sh_param_t field2; - sh_param_t field3; - } arg = { - .field1 = fd, - .field2 = (sh_param_t) (uintptr_t) buf, - .field3 = (sh_param_t) count - }; - - return sys_semihost(SYS_WRITE, (uintptr_t) &arg); + return sys_semihost3(SYS_WRITE, fd, (sh_param_t)(uintptr_t)buf, + count); } From e71c602fb743e011e44525e5d6edbcd3d8e35478 Mon Sep 17 00:00:00 2001 From: Mohamed Moawad Date: Tue, 23 Jul 2024 09:43:15 +0200 Subject: [PATCH 02/42] strcmp optimization for riscv Optimize strcmp by calling orc.b (OR-Combine) instruction when Zbb extension is supported instead of 4 instructions to detect if zero byte is exist in word Signed-off-by: Mohamed Moawad --- newlib/libc/machine/riscv/strcmp.S | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/newlib/libc/machine/riscv/strcmp.S b/newlib/libc/machine/riscv/strcmp.S index a15bbc2c18..1a62951bd0 100644 --- a/newlib/libc/machine/riscv/strcmp.S +++ b/newlib/libc/machine/riscv/strcmp.S @@ -37,21 +37,25 @@ strcmp: and a4, a4, SZREG-1 bnez a4, .Lmisaligned +#ifndef __riscv_zbb #if SZREG == 4 li a5, 0x7f7f7f7f #else ld a5, mask +#endif #endif .macro check_one_word i n REG_L a2, \i*SZREG(a0) REG_L a3, \i*SZREG(a1) - +#ifdef __riscv_zbb + orc.b t0, a2 +#else and t0, a2, a5 or t1, a2, a5 add t0, t0, a5 or t0, t0, t1 - +#endif bne t0, t2, .Lnull\i .if \i+1-\n bne a2, a3, .Lmismatch @@ -189,7 +193,7 @@ strcmp: #endif .size strcmp, .-strcmp -#if SZREG == 8 +#if SZREG == 8 && !defined(__riscv_zbb) .section .srodata.cst8,"aM",@progbits,8 .align 3 mask: From 61560a1a4bfd78d0be3a36d0507cbeb795eebddb Mon Sep 17 00:00:00 2001 From: Mohamed Moawad Date: Sun, 28 Jul 2024 15:37:14 +0200 Subject: [PATCH 03/42] Enable zbb extension in CI configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable zbb extension in CI for RISC-V to test optimizations using bit manipulation instructions like `orc.b`.  This ensures that the strcmp optimization and other features using zbb are tested and validated Signed-off-by: Mohamed Moawad --- COPYING.picolibc | 2 +- ...{cross-rv32imac_zicsr.txt => cross-rv32imac_zicsr_zbb.txt} | 4 ++-- scripts/do-rv32imac-configure | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename scripts/{cross-rv32imac_zicsr.txt => cross-rv32imac_zicsr_zbb.txt} (92%) diff --git a/COPYING.picolibc b/COPYING.picolibc index 238ff42489..93c1153fa7 100644 --- a/COPYING.picolibc +++ b/COPYING.picolibc @@ -2845,7 +2845,7 @@ Files: .clang-format scripts/cross-riscv64-unknown-elf.txt scripts/cross-riscv64-zephyr-elf.txt scripts/cross-rv32imac.txt - scripts/cross-rv32imac_zicsr.txt + scripts/cross-rv32imac_zicsr_zbb.txt scripts/cross-sh-unknown-elf.txt scripts/cross-sparc-zephyr-elf.txt scripts/cross-sparc64-linux-gnu.txt diff --git a/scripts/cross-rv32imac_zicsr.txt b/scripts/cross-rv32imac_zicsr_zbb.txt similarity index 92% rename from scripts/cross-rv32imac_zicsr.txt rename to scripts/cross-rv32imac_zicsr_zbb.txt index ef1b2751ee..6e12ac283d 100644 --- a/scripts/cross-rv32imac_zicsr.txt +++ b/scripts/cross-rv32imac_zicsr_zbb.txt @@ -14,8 +14,8 @@ cpu = 'riscv32' endian = 'little' [properties] -c_args = ['-msave-restore', '-fshort-enums', '-march=rv32imac_zicsr', '-mabi=ilp32'] -c_link_args = ['-msave-restore', '-fshort-enums', '-march=rv32imac', '-mabi=ilp32'] +c_args = ['-msave-restore', '-fshort-enums', '-march=rv32imac_zicsr_zbb', '-mabi=ilp32'] +c_link_args = ['-msave-restore', '-fshort-enums', '-march=rv32imac_zicsr_zbb', '-mabi=ilp32'] skip_sanity_check = true default_flash_addr = '0x80000000' default_flash_size = '0x00200000' diff --git a/scripts/do-rv32imac-configure b/scripts/do-rv32imac-configure index 2275a83ea4..edd6b66fa3 100755 --- a/scripts/do-rv32imac-configure +++ b/scripts/do-rv32imac-configure @@ -40,7 +40,7 @@ case "$version" in arch=rv32imac ;; *) - arch=rv32imac_zicsr + arch=rv32imac_zicsr_zbb ;; esac exec "$(dirname "$0")"/do-configure "$arch" \ From 5252f4dd236e4eb1a9421103995e2983b39de7a3 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Thu, 30 May 2024 15:45:26 -0700 Subject: [PATCH 04/42] picocrt: Add an option to enable MMU (and caches) This is currently only implemented for Arm32 v7a where the CPU starts off with MMU disabled. This requires 8KB of page table memory, so there is an option to disable it if necessary. --- CMakeLists.txt | 3 + meson.build | 3 + meson_options.txt | 3 + picocrt/machine/arm/crt0.c | 168 ++++++++++++++++++++++++++++++++----- picolibc.h.in | 3 + 5 files changed, 159 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4227b8b391..0fa0163a5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,6 +229,9 @@ set(_HAVE_INITFINI_ARRAY 1) # Support _init() and _fini() functions set(_HAVE_INIT_FINI 1) +# Enable MMU in pico crt startup +set(_PICOCRT_ENABLE_MMU 1) + # Compiler has long double type picolibc_flag(_HAVE_LONG_DOUBLE) diff --git a/meson.build b/meson.build index 71b2aec992..bfed413d3a 100644 --- a/meson.build +++ b/meson.build @@ -1693,6 +1693,9 @@ endif # make sure to include semihost BEFORE picocrt! if enable_picocrt subdir('picocrt') + picocrt_enable_mmu = get_option('picocrt-enable-mmu') + conf_data.set('_PICOCRT_ENABLE_MMU', picocrt_enable_mmu, + description: 'Turn on mmu in picocrt startup code') endif subdir('newlib') diff --git a/meson_options.txt b/meson_options.txt index 383f6b7dc6..de9e479d06 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -62,6 +62,9 @@ option('picolib', type: 'boolean', value: true, option('picocrt', type: 'boolean', value: true, description: 'Include pico crt bits') +option('picocrt-enable-mmu', type: 'boolean', value: true, + description: 'Enable memory management unit in picocrt startup') + option('picocrt-lib', type: 'boolean', value: true, description: 'Include pico crt bits in lib form') diff --git a/picocrt/machine/arm/crt0.c b/picocrt/machine/arm/crt0.c index f18213c150..9417289f06 100644 --- a/picocrt/machine/arm/crt0.c +++ b/picocrt/machine/arm/crt0.c @@ -33,6 +33,7 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include "../../crt0.h" #if __ARM_ARCH_PROFILE == 'M' @@ -92,31 +93,92 @@ _start(void) __start(); } -#else +#else /* __ARM_ARCH_PROFILE == 'M' */ + +#ifdef _PICOCRT_ENABLE_MMU + +#if __ARM_ARCH >= 7 && __ARM_ARCH_PROFILE != 'R' + +/* + * We need 4096 1MB mappings to cover the usual Normal memory space, + * which runs from 0x00000000 to 0x7fffffff along with the usual + * Device space which runs from 0x80000000 to 0xffffffff. + */ +#define MMU_NORMAL_COUNT 2048 +#define MMU_DEVICE_COUNT 2048 +extern uint32_t __identity_page_table[MMU_NORMAL_COUNT + MMU_DEVICE_COUNT]; + +/* Bits within a short-form section PTE (1MB mapping) */ +#define MMU_NS_BIT 19 +#define MMU_NG_BIT 17 +#define MMU_S_BIT 16 +#define MMU_AP2_BIT 15 +#define MMU_TEX_BIT 12 +#define MMU_AP0_BIT 10 +#define MMU_XN_BIT 4 +#define MMU_BC_BIT 2 +#define MMU_PXN_BIT 0 + +#define MMU_TYPE_1MB (0x2 << 0) +#define MMU_RW (0x3 << MMU_AP0_BIT) + +/* Memory attributes when TEX[2] == 0 */ +#define MMU_STRONGLY_ORDERED ((0 << MMU_TEX_BIT) | (0 << MMU_BC_BIT)) +#define MMU_SHAREABLE_DEVICE ((0 << MMU_TEX_BIT) | (1 << MMU_BC_BIT)) +#define MMU_WT_NOWA ((0 << MMU_TEX_BIT) | (2 << MMU_BC_BIT)) +#define MMU_WB_NOWA ((0 << MMU_TEX_BIT) | (3 << MMU_BC_BIT)) +#define MMU_NON_CACHEABLE ((1 << MMU_TEX_BIT) | (0 << MMU_BC_BIT)) +#define MMU_WB_WA ((1 << MMU_TEX_BIT) | (3 << MMU_BC_BIT)) +#define MMU_NONSHAREABLE_DEVICE ((2 << MMU_TEX_BIT) | (0 << MMU_BC_BIT)) + +/* + * Memory attributes when TEX[2] == 1. In this mode + * TEX[1:0] define the outer cache attributes and + * C, B define the inner cache attributes + */ +#define MMU_MEM_ATTR(_O, _I) (((4 | (_O)) << MMU_TEX_BIT) | ((_I) << MMU_BC_BIT)) +#define MMU_MEM_ATTR_NC 0 +#define MMU_MEM_ATTR_WB_WA 1 +#define MMU_MEM_ATTR_WT_NOWA 2 +#define MMU_MEM_ATTR_WB_NOWA 3 + +#define MMU_SHAREABLE (1 << MMU_S_BIT) +#define MMU_NORMAL_MEMORY (MMU_MEM_ATTR(MMU_MEM_ATTR_WB_WA, MMU_MEM_ATTR_WB_WA) | MMU_SHAREABLE) +#define MMU_DEVICE_MEMORY (MMU_SHAREABLE_DEVICE) +#define MMU_NORMAL_FLAGS (MMU_TYPE_1MB | MMU_RW | MMU_NORMAL_MEMORY) +#define MMU_DEVICE_FLAGS (MMU_TYPE_1MB | MMU_RW | MMU_DEVICE_MEMORY) + +__asm__( + ".section .rodata\n" + ".global __identity_page_table\n" + ".balign 16384\n" + "__identity_page_table:\n" + ".set _i, 0\n" + ".rept " __XSTRING(MMU_NORMAL_COUNT) "\n" + " .4byte (_i << 20) |" __XSTRING(MMU_NORMAL_FLAGS) "\n" + " .set _i, _i + 1\n" + ".endr\n" + ".set _i, 0\n" + ".rept " __XSTRING(MMU_DEVICE_COUNT) "\n" + " .4byte (1 << 31) | (_i << 20) |" __XSTRING(MMU_DEVICE_FLAGS) "\n" + " .set _i, _i + 1\n" + ".endr\n" + ".size __identity_page_table, " __XSTRING((MMU_NORMAL_COUNT + MMU_DEVICE_COUNT) * 4) "\n" +); +#endif + +#endif /* _PICOCRT_ENABLE_MMU */ /* * Regular ARM has an 8-entry exception vector and starts without SP - * initialized, so start is a naked function + * initialized, so start is a naked function which sets up the stack + * and then branches here. */ static void __attribute__((used)) __section(".init") _cstart(void) { - __start(); -} - -extern char __stack[]; - -void __attribute__((naked)) __section(".init") __attribute__((used)) -_start(void) -{ - /* Generate a reference to __vector_table so we get one loaded */ - __asm__(".equ __my_vector_table, __vector_table"); - - /* Initialize stack pointer */ - __asm__("mov sp, %0" : : "r" (__stack)); - -#ifdef __thumb2__ +#if __thumb2__ && __ARM_ARCH_PROFILE != 'A' /* Make exceptions run in Thumb mode */ uint32_t sctlr; __asm__("mrc p15, 0, %0, c1, c0, 0" : "=r" (sctlr)); @@ -132,6 +194,71 @@ _start(void) __asm__("vmsr fpexc, %0" : : "r" (0x40000000)); #endif +#ifdef _PICOCRT_ENABLE_MMU + +#if __ARM_ARCH >= 7 && __ARM_ARCH_PROFILE != 'R' + +#define SCTLR_MMU (1 << 0) +#define SCTLR_DATA_L2 (1 << 2) +#define SCTLR_BRANCH_PRED (1 << 11) +#define SCTLR_ICACHE (1 << 12) +#define SCTLR_TRE (1 << 28) + + uint32_t mmfr0; + __asm__("mrc p15, 0, %0, c0, c1, 4" : "=r" (mmfr0)); + + /* Check to see if the processor supports VMSAv7 or better */ + if ((mmfr0 & 0xf) >= 3) + { + /* We have to set up an identity map and enable the MMU for caches. + * Additionally, all page table entries are set to Domain 0, so set up DACR + * so that Domain zero has permission checks enabled rather than "deny all". + */ + + /* Set DACR Domain 0 permissions checked */ + __asm__("mcr p15, 0, %0, c3, c0, 0\n" :: "r" (1)); + + /* + * Write TTBR + * + * No DSB since tables are statically initialized and dcache is off. + * We or __identity_page_table with 0x3 to set the cacheable flag bits. + */ + __asm__("mcr p15, 0, %0, c2, c0, 0\n" + :: "r" ((uintptr_t)__identity_page_table | 0x3)); + + /* Note: we assume Data+L2 cache has been invalidated by reset. */ + __asm__("mcr p15, 0, %0, c7, c5, 0\n" :: "r" (0)); /* ICIALLU: invalidate instruction cache */ + __asm__("mcr p15, 0, %0, c8, c7, 0\n" :: "r" (0)); /* TLBIALL: invalidate TLB */ + __asm__("mcr p15, 0, %0, c7, c5, 6\n" :: "r" (0)); /* BPIALL: invalidate branch predictor */ + __asm__("isb\n"); + + /* Enable caches, branch prediction and the MMU. Disable TRE */ + uint32_t sctlr; + __asm__("mrc p15, 0, %0, c1, c0, 0" : "=r" (sctlr)); + sctlr |= SCTLR_ICACHE | SCTLR_BRANCH_PRED | SCTLR_DATA_L2 | SCTLR_MMU; + sctlr &= ~SCTLR_TRE; + __asm__("mcr p15, 0, %0, c1, c0, 0\n" :: "r" (sctlr)); + __asm__("isb\n"); + } +#endif + +#endif /* _PICOCRT_ENABLE_MMU */ + + __start(); +} + +extern char __stack[]; + +void __attribute__((naked)) __section(".init") __attribute__((used)) +_start(void) +{ + /* Generate a reference to __vector_table so we get one loaded */ + __asm__(".equ __my_vector_table, __vector_table"); + + /* Initialize stack pointer */ + __asm__("mov sp, %0" : : "r" (__stack)); + /* Branch to C code */ __asm__("b _cstart"); } @@ -239,7 +366,7 @@ arm_usagefault_isr(void) __asm__("bl arm_fault"); } -#else +#else /* __ARM_ARCH_PROFILE == 'M' */ struct fault { unsigned int r[7]; @@ -304,7 +431,6 @@ arm_data_abort_vector(void) __asm__("bl arm_fault"); } -#endif - -#endif +#endif /* else __ARM_ARCH_PROFILE == 'M' */ +#endif /* CRT0_SEMIHOST */ diff --git a/picolibc.h.in b/picolibc.h.in index 95d5fba96f..22192669eb 100644 --- a/picolibc.h.in +++ b/picolibc.h.in @@ -23,6 +23,9 @@ /* use thread local storage */ #cmakedefine NEWLIB_TLS +/* Turn on mmu in picocrt startup code */ +#cmakedefine _PICOCRT_ENABLE_MMU + /* use thread local storage */ #cmakedefine PICOLIBC_TLS From b2d921a71ea011d4c1c7eb5ed5ad3454d9c8aa18 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 30 Jul 2024 00:18:05 -0700 Subject: [PATCH 05/42] arm: Initialize all of the shadow SPs for non-M targets Non-M processors have a wealth of stack pointers, one for each interrupt entry point. As the only thing we're using the other entry points for in the sample code is to catch errors, we'll just smash the same stack for every one. This allows us to stop setting the SP in the vectors themselves which trashed one of the saved register values. This is mixed in with code which uses ARM mode exception vectors on 'A' profile targets; attempting to set the TE bit on those doesn't seem to work on QEMU. Signed-off-by: Keith Packard --- newlib/libc/picolib/machine/arm/interrupt.c | 40 +++++++++---------- picocrt/machine/arm/crt0.c | 43 ++++++++++++++++++--- 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/newlib/libc/picolib/machine/arm/interrupt.c b/newlib/libc/picolib/machine/arm/interrupt.c index a6f8adaee3..a157152b27 100644 --- a/newlib/libc/picolib/machine/arm/interrupt.c +++ b/newlib/libc/picolib/machine/arm/interrupt.c @@ -135,29 +135,29 @@ __weak_vector_table(void) * Exception vector that lives at the * start of program text (usually 0x0) */ -#if __thumb2__ +#if __thumb2__ && __ARM_ARCH_PROFILE != 'A' /* Thumb 2 processors start in thumb mode */ - __asm__(".thumb"); - __asm__(".syntax unified"); - __asm__("b.w _start"); - __asm__("b.w arm_undef_vector"); - __asm__("b.w arm_svc_vector"); - __asm__("b.w arm_prefetch_abort_vector"); - __asm__("b.w arm_data_abort_vector"); - __asm__("b.w arm_not_used_vector"); - __asm__("b.w arm_irq_vector"); - __asm__("b.w arm_fiq_vector"); + __asm__(".thumb\n" + ".syntax unified\n" + "b.w _start\n" + "b.w arm_undef_vector\n" + "b.w arm_svc_vector\n" + "b.w arm_prefetch_abort_vector\n" + "b.w arm_data_abort_vector\n" + "b.w arm_not_used_vector\n" + "b.w arm_irq_vector\n" + "b.w arm_fiq_vector"); #else /* Thumb 1 and arm processors start in arm mode */ - __asm__(".arm"); - __asm__("b _start"); - __asm__("b arm_undef_vector"); - __asm__("b arm_svc_vector"); - __asm__("b arm_prefetch_abort_vector"); - __asm__("b arm_data_abort_vector"); - __asm__("b arm_not_used_vector"); - __asm__("b arm_irq_vector"); - __asm__("b arm_fiq_vector"); + __asm__(".arm\n" + "b _start\n" + "b arm_undef_vector\n" + "b arm_svc_vector\n" + "b arm_prefetch_abort_vector\n" + "b arm_data_abort_vector\n" + "b arm_not_used_vector\n" + "b arm_irq_vector\n" + "b arm_fiq_vector"); #endif } diff --git a/picocrt/machine/arm/crt0.c b/picocrt/machine/arm/crt0.c index 9417289f06..5f4ce38f9b 100644 --- a/picocrt/machine/arm/crt0.c +++ b/picocrt/machine/arm/crt0.c @@ -250,14 +250,47 @@ _cstart(void) extern char __stack[]; +#define MODE_USR (0x10) +#define MODE_FIQ (0x11) +#define MODE_IRQ (0x12) +#define MODE_SVC (0x13) +#define MODE_MON (0x16) +#define MODE_ABT (0x17) +#define MODE_HYP (0x1a) +#define MODE_UND (0x1b) +#define MODE_SYS (0x1f) +#define I_BIT (1 << 7) +#define F_BIT (1 << 6) + +/* + * Set up all of the shadow stack pointers. With Thumb 1 ISA we need + * to do this in ARM mode. + */ +#if __ARM_ARCH_ISA_THUMB == 1 +static __noinline __attribute__((target("arm"))) void +SET_SP(uint8_t mode) +{ + __asm__("mov r0, %0\nmsr cpsr_c, %0" :: "r" (mode | I_BIT | F_BIT): "r0"); + __asm__("mov sp, %0\n" : : "r" (__stack)); +} +#else +#define SET_SP(mode) \ + __asm__("mov r0, %0\nmsr cpsr_c, r0" :: "r" (mode | I_BIT | F_BIT): "r0"); \ + __asm__("mov sp, %0" : : "r" (__stack)) +#endif + void __attribute__((naked)) __section(".init") __attribute__((used)) _start(void) { /* Generate a reference to __vector_table so we get one loaded */ __asm__(".equ __my_vector_table, __vector_table"); - /* Initialize stack pointer */ - __asm__("mov sp, %0" : : "r" (__stack)); + SET_SP(MODE_IRQ); + SET_SP(MODE_ABT); + SET_SP(MODE_UND); + SET_SP(MODE_FIQ); + SET_SP(MODE_SVC); + SET_SP(MODE_SYS); /* Branch to C code */ __asm__("b _cstart"); @@ -401,10 +434,8 @@ arm_fault(struct fault *f, int reason) } #define VECTOR_COMMON \ - __asm__("mov r7, %0" : : "r" (__stack)); \ - __asm__("mov sp, r7"); \ - __asm__("push {lr}"); \ - __asm__("push {r0-r6}"); \ + __asm__("push {lr}"); \ + __asm__("push {r0-r6}"); \ __asm__("mov r0, sp") void __attribute__((naked)) __section(".init") From 2740e4fce4d8ad84ee444b375c10b98b997466c7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 30 Jul 2024 00:25:26 -0700 Subject: [PATCH 06/42] scripts: Split out non-'A' V7 arm targets in run-arm We need to distinguish between v7, v7-a and v7-r targets as the v7-r don't support the 32-bit ARM ISA and hence can't use ARM mode for exception handling, while the v7-a only seem to support ARM mode for exception handling. Signed-off-by: Keith Packard --- scripts/run-arm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/run-arm b/scripts/run-arm index 39042d440e..8724c64ef5 100755 --- a/scripts/run-arm +++ b/scripts/run-arm @@ -64,7 +64,7 @@ case "$cpu_arch"/"$cpu_profile" in v6S-M/Microcontroller) cpu=cortex-m0 ;; - v7/Application|v7/) + v7/Application) case "$fp_arch" in VFPv3) cpu=cortex-a9 @@ -72,11 +72,27 @@ case "$cpu_arch"/"$cpu_profile" in VFPv3-D16) cpu=cortex-a8 ;; + VFPv4) + cpu=cortex-a7 + ;; *) cpu=cortex-a7 ;; esac - ;; + ;; + v7/) + case "$fp_arch" in + VFPv3) + cpu=cortex-r5 + ;; + VFPv3-D16) + cpu=cortex-r5f + ;; + *) + cpu=cortex-r5 + ;; + esac + ;; v7/Microcontroller) cpu=cortex-m3 ;; From 06abb65a742e90d91150b586dcf7c7228bdf232f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 1 Aug 2024 13:54:22 -0700 Subject: [PATCH 07/42] arm: Use aeabi_memcpy-armv7a.S on aligned targets, memcpy-armv7a on unaligned This seems like it got scrambled when merging newlib updates from arm. Signed-off-by: Keith Packard --- newlib/libc/machine/arm/CMakeLists.txt | 1 - newlib/libc/machine/arm/aeabi_memcpy-armv7a.S | 14 ++++---------- newlib/libc/machine/arm/arm_asm.h | 10 ++++++++++ newlib/libc/machine/arm/memcpy-armv7a.S | 5 +++++ newlib/libc/machine/arm/memcpy-armv7m.S | 10 ---------- newlib/libc/machine/arm/memcpy.S | 4 ++-- newlib/libc/machine/arm/memcpy.c | 7 +++---- newlib/libc/machine/arm/meson.build | 1 - 8 files changed, 24 insertions(+), 28 deletions(-) diff --git a/newlib/libc/machine/arm/CMakeLists.txt b/newlib/libc/machine/arm/CMakeLists.txt index 5a9a53a678..5e502dc1c5 100644 --- a/newlib/libc/machine/arm/CMakeLists.txt +++ b/newlib/libc/machine/arm/CMakeLists.txt @@ -36,7 +36,6 @@ picolibc_sources_flags("-fno-builtin" setjmp.S strcmp.S strcpy.S - aeabi_memcpy-armv7a.S aeabi_memset.c bzero.c memchr.c diff --git a/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S b/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S index 8462433d80..6e53fe1a8f 100644 --- a/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S +++ b/newlib/libc/machine/arm/aeabi_memcpy-armv7a.S @@ -30,15 +30,11 @@ #include "arm_asm.h" -/* NOTE: This ifdef MUST match the one in aeabi_memcpy.c. */ -#if !(defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) && \ - defined (__ARM_ARCH_7A__) && defined (__ARM_FEATURE_UNALIGNED) && \ - (defined (__ARM_NEON__) || !defined (__SOFTFP__)) - .syntax unified - .global __aeabi_memcpy - .type __aeabi_memcpy, %function -__aeabi_memcpy: + .global memcpy + .type memcpy, %function + ASM_ALIAS __aeabi_memcpy, memcpy +memcpy: /* Assumes that n >= 0, and dst, src are valid pointers. If there is at least 8 bytes to copy, use LDRD/STRD. If src and dst are misaligned with different offsets, @@ -285,5 +281,3 @@ __aeabi_memcpy8: blt copy_less_than_64 /* if n + 8 < 64. */ bl two_word_aligned - -#endif diff --git a/newlib/libc/machine/arm/arm_asm.h b/newlib/libc/machine/arm/arm_asm.h index e15557c4ec..27ee42bbbd 100644 --- a/newlib/libc/machine/arm/arm_asm.h +++ b/newlib/libc/machine/arm/arm_asm.h @@ -499,6 +499,16 @@ .endif .endm +.macro ASM_ALIAS new old + .global \new + .type \new, %function +#if defined (__thumb__) + .thumb_set \new, \old +#else + .set \new, \old +#endif +.endm + #endif /* __ASSEMBLER__ */ #endif /* ARM_ASM__H */ diff --git a/newlib/libc/machine/arm/memcpy-armv7a.S b/newlib/libc/machine/arm/memcpy-armv7a.S index 6bf5cae727..2342748bbd 100644 --- a/newlib/libc/machine/arm/memcpy-armv7a.S +++ b/newlib/libc/machine/arm/memcpy-armv7a.S @@ -45,6 +45,8 @@ */ #include +#include "arm_asm.h" + .syntax unified /* This implementation requires ARM state. */ .arm @@ -155,6 +157,9 @@ .endm def_fn memcpy p2align=6 + ASM_ALIAS __aeabi_memcpy, memcpy + ASM_ALIAS __aeabi_memcpy4, memcpy + ASM_ALIAS __aeabi_memcpy8, memcpy mov dst, dstin /* Preserve dstin, we need to return it. */ cmp count, #64 diff --git a/newlib/libc/machine/arm/memcpy-armv7m.S b/newlib/libc/machine/arm/memcpy-armv7m.S index 97e82511c0..0c7b89e7e8 100644 --- a/newlib/libc/machine/arm/memcpy-armv7m.S +++ b/newlib/libc/machine/arm/memcpy-armv7m.S @@ -83,16 +83,6 @@ #define END_UNROLL .endr -.macro ASM_ALIAS new old - .global \new - .type \new, %function -#if defined (__thumb__) - .thumb_set \new, \old -#else - .set \new, \old -#endif -.endm - .syntax unified .text .align 2 diff --git a/newlib/libc/machine/arm/memcpy.S b/newlib/libc/machine/arm/memcpy.S index eed5d5017d..82f5cb09bc 100644 --- a/newlib/libc/machine/arm/memcpy.S +++ b/newlib/libc/machine/arm/memcpy.S @@ -39,10 +39,10 @@ #elif (__ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == 'A' \ && defined (__ARM_FEATURE_UNALIGNED)) #include "memcpy-armv7a.S" - #elif __ARM_ARCH_ISA_THUMB == 2 && !__ARM_ARCH_ISA_ARM #include "memcpy-armv7m.S" - +#elif defined (__ARM_ARCH_7A__) +#include "aeabi_memcpy-armv7a.S" #else /* Defined in memcpy-stub.c. */ diff --git a/newlib/libc/machine/arm/memcpy.c b/newlib/libc/machine/arm/memcpy.c index 4ce6d37cf9..8e2f2db090 100644 --- a/newlib/libc/machine/arm/memcpy.c +++ b/newlib/libc/machine/arm/memcpy.c @@ -35,11 +35,10 @@ #define MEMCPY_FALLBACK #elif (__ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == 'A' \ && defined (__ARM_FEATURE_UNALIGNED)) -/* Defined in memcpy.S. */ +/* Defined in memcpy-armv7a.S. */ #elif __ARM_ARCH_ISA_THUMB == 2 && !__ARM_ARCH_ISA_ARM -/* Defined in memcpy.S. */ -#elif defined (__ARM_ARCH_7A__) && defined (__ARM_FEATURE_UNALIGNED) && \ - (defined (__ARM_NEON__) || !defined (__SOFTFP__)) +/* Defined in memcpy-armv7m.S. */ +#elif defined (__ARM_ARCH_7A__) /* Defined in aeabi_memcpy-armv7a.S */ #else #define MEMCPY_FALLBACK diff --git a/newlib/libc/machine/arm/meson.build b/newlib/libc/machine/arm/meson.build index d1d1b1fd75..058aa715f6 100644 --- a/newlib/libc/machine/arm/meson.build +++ b/newlib/libc/machine/arm/meson.build @@ -36,7 +36,6 @@ srcs_machine = [ 'setjmp.S', 'strcmp.S', 'strcpy.S', - 'aeabi_memcpy-armv7a.S', 'aeabi_memset.c', 'bzero.c', 'memchr.c', From 64d0ff4c09752f7e0460738743cf23a4e910c82f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 1 Aug 2024 09:39:51 -0700 Subject: [PATCH 08/42] picocrt: Set correct reason value in non-M arm exception handlers copy-paste programming error left them all using REASON_UNDEF. Also switch instruction to 'movs', which makes clang happy. Signed-off-by: Keith Packard --- picocrt/machine/arm/crt0.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/picocrt/machine/arm/crt0.c b/picocrt/machine/arm/crt0.c index 5f4ce38f9b..a018e66960 100644 --- a/picocrt/machine/arm/crt0.c +++ b/picocrt/machine/arm/crt0.c @@ -442,7 +442,7 @@ void __attribute__((naked)) __section(".init") arm_undef_vector(void) { VECTOR_COMMON; - __asm__("mov r1, #" REASON(REASON_UNDEF)); + __asm__("movs r1, #" REASON(REASON_UNDEF)); __asm__("bl arm_fault"); } @@ -450,7 +450,7 @@ void __attribute__((naked)) __section(".init") arm_prefetch_abort_vector(void) { VECTOR_COMMON; - __asm__("mov r1, #" REASON(REASON_UNDEF)); + __asm__("movs r1, #" REASON(REASON_PREFETCH_ABORT)); __asm__("bl arm_fault"); } @@ -458,7 +458,7 @@ void __attribute__((naked)) __section(".init") arm_data_abort_vector(void) { VECTOR_COMMON; - __asm__("mov r1, #" REASON(REASON_UNDEF)); + __asm__("movs r1, #" REASON(REASON_DATA_ABORT)); __asm__("bl arm_fault"); } From dd711267309fbc3d13e0169b3af0ead7151e90ae Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 1 Aug 2024 09:40:50 -0700 Subject: [PATCH 09/42] picocrt: Call thumb-1 stack setting function from non-naked function Clang doesn't let us do any regular C code from a naked function, so move all of the Thumb-1 stack pointer setup into a single function and call that from _cstart instead of _start. Signed-off-by: Keith Packard --- picocrt/machine/arm/crt0.c | 86 +++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 38 deletions(-) diff --git a/picocrt/machine/arm/crt0.c b/picocrt/machine/arm/crt0.c index a018e66960..2ca9367241 100644 --- a/picocrt/machine/arm/crt0.c +++ b/picocrt/machine/arm/crt0.c @@ -169,6 +169,45 @@ __asm__( #endif /* _PICOCRT_ENABLE_MMU */ +/* + * Set up all of the shadow stack pointers. With Thumb 1 ISA we need + * to do this in ARM mode, hence the separate target("arm") function + */ + +extern char __stack[]; + +#define MODE_USR (0x10) +#define MODE_FIQ (0x11) +#define MODE_IRQ (0x12) +#define MODE_SVC (0x13) +#define MODE_MON (0x16) +#define MODE_ABT (0x17) +#define MODE_HYP (0x1a) +#define MODE_UND (0x1b) +#define MODE_SYS (0x1f) +#define I_BIT (1 << 7) +#define F_BIT (1 << 6) + +#define SET_SP(mode) \ + __asm__("mov r0, %0\nmsr cpsr_c, r0" :: "r" (mode | I_BIT | F_BIT): "r0"); \ + __asm__("mov sp, %0" : : "r" (__stack)) + +#define SET_SPS() \ + SET_SP(MODE_IRQ); \ + SET_SP(MODE_ABT); \ + SET_SP(MODE_UND); \ + SET_SP(MODE_FIQ); \ + SET_SP(MODE_SVC); \ + SET_SP(MODE_SYS); + +#if __ARM_ARCH_ISA_THUMB == 1 +static __noinline __attribute__((target("arm"))) void +_set_stacks(void) +{ + SET_SPS(); +} +#endif + /* * Regular ARM has an 8-entry exception vector and starts without SP * initialized, so start is a naked function which sets up the stack @@ -178,6 +217,10 @@ __asm__( static void __attribute__((used)) __section(".init") _cstart(void) { +#if __ARM_ARCH_ISA_THUMB == 1 + _set_stacks(); +#endif + #if __thumb2__ && __ARM_ARCH_PROFILE != 'A' /* Make exceptions run in Thumb mode */ uint32_t sctlr; @@ -248,50 +291,17 @@ _cstart(void) __start(); } -extern char __stack[]; - -#define MODE_USR (0x10) -#define MODE_FIQ (0x11) -#define MODE_IRQ (0x12) -#define MODE_SVC (0x13) -#define MODE_MON (0x16) -#define MODE_ABT (0x17) -#define MODE_HYP (0x1a) -#define MODE_UND (0x1b) -#define MODE_SYS (0x1f) -#define I_BIT (1 << 7) -#define F_BIT (1 << 6) - -/* - * Set up all of the shadow stack pointers. With Thumb 1 ISA we need - * to do this in ARM mode. - */ -#if __ARM_ARCH_ISA_THUMB == 1 -static __noinline __attribute__((target("arm"))) void -SET_SP(uint8_t mode) -{ - __asm__("mov r0, %0\nmsr cpsr_c, %0" :: "r" (mode | I_BIT | F_BIT): "r0"); - __asm__("mov sp, %0\n" : : "r" (__stack)); -} -#else -#define SET_SP(mode) \ - __asm__("mov r0, %0\nmsr cpsr_c, r0" :: "r" (mode | I_BIT | F_BIT): "r0"); \ - __asm__("mov sp, %0" : : "r" (__stack)) -#endif - void __attribute__((naked)) __section(".init") __attribute__((used)) _start(void) { /* Generate a reference to __vector_table so we get one loaded */ __asm__(".equ __my_vector_table, __vector_table"); - SET_SP(MODE_IRQ); - SET_SP(MODE_ABT); - SET_SP(MODE_UND); - SET_SP(MODE_FIQ); - SET_SP(MODE_SVC); - SET_SP(MODE_SYS); - +#if __ARM_ARCH_ISA_THUMB == 1 + __asm__("mov sp, %0" : : "r" (__stack)); +#else + SET_SPS(); +#endif /* Branch to C code */ __asm__("b _cstart"); } From e67e8b826ac2ae0185048c33f818105bdd183eb2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 1 Aug 2024 09:38:22 -0700 Subject: [PATCH 10/42] scripts: Use arm926 for v5T targets too clang sticks 'v5T' into the CPU_arch tag instead of 'v5TE', so check for that value. Signed-off-by: Keith Packard --- scripts/run-arm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run-arm b/scripts/run-arm index 8724c64ef5..90e6eadcdd 100755 --- a/scripts/run-arm +++ b/scripts/run-arm @@ -58,7 +58,7 @@ case "$cpu_arch"/"$cpu_profile" in v4T/) cpu=ti925t ;; - v5TE/) + v5TE/|v5T/) cpu=arm926 ;; v6S-M/Microcontroller) From 5a4193970266edec6a65819c5add8df989d5873f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 1 Aug 2024 09:43:08 -0700 Subject: [PATCH 11/42] scripts: Add clang arm v7a thumb v5 sample scripts Allow these architectures to be tested Signed-off-by: Keith Packard --- scripts/cross-clang-thumb-none-eabi.txt | 27 ++++++++++++++++ scripts/cross-clang-thumbv7-a-none-eabi.txt | 27 ++++++++++++++++ scripts/do-clang-thumb-configure | 36 +++++++++++++++++++++ scripts/do-clang-thumbv7-a-configure | 36 +++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 scripts/cross-clang-thumb-none-eabi.txt create mode 100644 scripts/cross-clang-thumbv7-a-none-eabi.txt create mode 100755 scripts/do-clang-thumb-configure create mode 100755 scripts/do-clang-thumbv7-a-configure diff --git a/scripts/cross-clang-thumb-none-eabi.txt b/scripts/cross-clang-thumb-none-eabi.txt new file mode 100644 index 0000000000..509a710d8d --- /dev/null +++ b/scripts/cross-clang-thumb-none-eabi.txt @@ -0,0 +1,27 @@ +[binaries] +# Meson 0.53.2 doesn't use any cflags when doing basic compiler tests, +# so we have to add -nostdlib to the compiler configuration itself or +# early compiler tests will fail. This can be removed when picolibc +# requires at least version 0.54.2 of meson. +c = ['clang', '-m32', '-target', 'arm-none-eabi', '-mthumb', '-march=armv5', '-mfloat-abi=soft', '-nostdlib'] +ar = 'arm-none-eabi-ar' +as = 'arm-none-eab-as' +nm = 'arm-none-eab-nm' +strip = 'arm-none-eabi-strip' +# only needed to run tests +exe_wrapper = ['sh', '-c', 'test -z "$PICOLIBC_TEST" || run-arm "$@"', 'run-arm'] + +[host_machine] +system = 'none' +cpu_family = 'arm' +cpu = 'arm' +endian = 'little' + +[properties] +c_args = ['-Werror=double-promotion', '-Wno-unsupported-floating-point-opt', '-fshort-enums'] +c_link_args = ['-L/usr/lib/gcc/arm-none-eabi/13.2.1/thumb/nofp/', '-Wl,-z,noexecstack', '-Wno-unused-command-line-argument'] +skip_sanity_check = true +default_flash_addr = '0x00000000' +default_flash_size = '0x00400000' +default_ram_addr = '0x20000000' +default_ram_size = '0x00200000' diff --git a/scripts/cross-clang-thumbv7-a-none-eabi.txt b/scripts/cross-clang-thumbv7-a-none-eabi.txt new file mode 100644 index 0000000000..5e6f700a34 --- /dev/null +++ b/scripts/cross-clang-thumbv7-a-none-eabi.txt @@ -0,0 +1,27 @@ +[binaries] +# Meson 0.53.2 doesn't use any cflags when doing basic compiler tests, +# so we have to add -nostdlib to the compiler configuration itself or +# early compiler tests will fail. This can be removed when picolibc +# requires at least version 0.54.2 of meson. +c = ['clang', '-m32', '-target', 'arm-none-eabihf', '-march=armv7-a', '-mfloat-abi=soft', '-nostdlib'] +ar = 'arm-none-eabi-ar' +as = 'arm-none-eab-as' +nm = 'arm-none-eab-nm' +strip = 'arm-none-eabi-strip' +# only needed to run tests +exe_wrapper = ['sh', '-c', 'test -z "$PICOLIBC_TEST" || run-arm "$@"', 'run-arm'] + +[host_machine] +system = 'none' +cpu_family = 'arm' +cpu = 'arm' +endian = 'little' + +[properties] +c_args = ['-Werror=double-promotion', '-Wno-unsupported-floating-point-opt', '-fshort-enums'] +c_link_args = ['-L/usr/lib/gcc/arm-none-eabi/13.2.1/thumb/v7-a/nofp/', '-Wl,-z,noexecstack', '-Wno-unused-command-line-argument'] +skip_sanity_check = true +default_flash_addr = '0x00000000' +default_flash_size = '0x00400000' +default_ram_addr = '0x20000000' +default_ram_size = '0x00200000' diff --git a/scripts/do-clang-thumb-configure b/scripts/do-clang-thumb-configure new file mode 100755 index 0000000000..9a68064af7 --- /dev/null +++ b/scripts/do-clang-thumb-configure @@ -0,0 +1,36 @@ +#!/bin/sh +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright © 2019 Keith Packard +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +# OF THE POSSIBILITY OF SUCH DAMAGE. +# +exec "$(dirname "$0")"/do-configure clang-thumb-none-eabi -Dtests=true -Dtests-enable-full-malloc-stress=false -Dmultilib=false "$@" diff --git a/scripts/do-clang-thumbv7-a-configure b/scripts/do-clang-thumbv7-a-configure new file mode 100755 index 0000000000..da50f3ee58 --- /dev/null +++ b/scripts/do-clang-thumbv7-a-configure @@ -0,0 +1,36 @@ +#!/bin/sh +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright © 2019 Keith Packard +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +# OF THE POSSIBILITY OF SUCH DAMAGE. +# +exec "$(dirname "$0")"/do-configure clang-thumbv7-a-none-eabi -Dtests=true -Dtests-enable-full-malloc-stress=false -Dmultilib=false "$@" From 8a9d58a7aba02ebb03927cab5348d3a5c1c228da Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 1 Aug 2024 10:46:49 -0700 Subject: [PATCH 12/42] .github: Disable testing on aarch64 targets for now These fail on current qemu which now checks memory access alignment when the MMU is disabled. Signed-off-by: Keith Packard --- .github/do-linux | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/do-linux b/.github/do-linux index b642baa586..58856ea029 100755 --- a/.github/do-linux +++ b/.github/do-linux @@ -7,13 +7,13 @@ HERE=`dirname "$0"` "$HERE"/do-test clang-thumbv7e+dp "$@" "$HERE"/do-test clang-thumbv7m "$@" "$HERE"/do-test clang-thumbv6m "$@" -"$HERE"/do-test clang-aarch64 "$@" +"$HERE"/do-build clang-aarch64 "$@" "$HERE"/do-build mips "$@" "$HERE"/do-build mips64 "$@" "$HERE"/do-build mipsel "$@" "$HERE"/do-test native "$@" "$HERE"/do-test native-m32 "$@" -"$HERE"/do-test aarch64 "$@" +"$HERE"/do-build aarch64 "$@" "$HERE"/do-build lx106 "$@" "$HERE"/do-test i386 "$@" "$HERE"/do-test m68k-unknown-elf "$@" From c8a2a97f18eba94aafec832d5ea05cd8b406dbca Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 1 Aug 2024 10:48:15 -0700 Subject: [PATCH 13/42] .github: Test clang on arm v7a and arm 5 in thumb mode Make sure these two architectures work when using clang. Signed-off-by: Keith Packard --- .github/do-linux | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/do-linux b/.github/do-linux index 58856ea029..31f0917632 100755 --- a/.github/do-linux +++ b/.github/do-linux @@ -2,6 +2,8 @@ set -e HERE=`dirname "$0"` "$HERE"/do-test arm "$@" +"$HERE"/do-test clang-thumbv7-a "$@" +"$HERE"/do-test clang-thumb "$@" "$HERE"/do-test cortex-a9 "$@" "$HERE"/do-test clang-thumbv7e+fp "$@" "$HERE"/do-test clang-thumbv7e+dp "$@" From 2ef817b8146b1ea692083d6fe1bc6176f2f779f5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 2 Aug 2024 16:42:19 -0700 Subject: [PATCH 14/42] math/aarch64: Fix lrint/lround in ilp32 mode In this mode, longs are only 32 bits, so we need to use the 32-bit form of the fcvtzs instruction instead of the 64-bit form. Signed-off-by: Keith Packard --- newlib/libm/machine/aarch64/s_lrint.c | 12 +++++++++--- newlib/libm/machine/aarch64/s_lround.c | 6 +++++- newlib/libm/machine/aarch64/sf_lrint.c | 12 +++++++++--- newlib/libm/machine/aarch64/sf_lround.c | 6 +++++- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/newlib/libm/machine/aarch64/s_lrint.c b/newlib/libm/machine/aarch64/s_lrint.c index 65e4ce2b97..172f86c37a 100644 --- a/newlib/libm/machine/aarch64/s_lrint.c +++ b/newlib/libm/machine/aarch64/s_lrint.c @@ -32,9 +32,15 @@ lrint (double x) { long int result; double temp; - __asm__("frintx\t%d1, %d2\n\t" - "fcvtzs\t%x0, %d1" - : "=r" (result), "=w" (temp) : "w" (x)); + if (sizeof (result) == 8) { + __asm__("frintx\t%d1, %d2\n\t" + "fcvtzs\t%x0, %d1" + : "=r" (result), "=w" (temp) : "w" (x)); + } else { + __asm__("frintx\t%d1, %d2\n\t" + "fcvtzs\t%w0, %d1" + : "=r" (result), "=w" (temp) : "w" (x)); + } return result; } diff --git a/newlib/libm/machine/aarch64/s_lround.c b/newlib/libm/machine/aarch64/s_lround.c index f8ca0da8d0..a789981967 100644 --- a/newlib/libm/machine/aarch64/s_lround.c +++ b/newlib/libm/machine/aarch64/s_lround.c @@ -31,7 +31,11 @@ long int lround (double x) { long int result; - __asm__("fcvtas\t%x0, %d1" : "=r" (result) : "w" (x)); + if (sizeof (result) == 8) { + __asm__("fcvtas\t%x0, %d1" : "=r" (result) : "w" (x)); + } else { + __asm__("fcvtas\t%w0, %d1" : "=r" (result) : "w" (x)); + } return result; } diff --git a/newlib/libm/machine/aarch64/sf_lrint.c b/newlib/libm/machine/aarch64/sf_lrint.c index 34949b54e6..f67974a421 100644 --- a/newlib/libm/machine/aarch64/sf_lrint.c +++ b/newlib/libm/machine/aarch64/sf_lrint.c @@ -32,9 +32,15 @@ lrintf (float x) { long int result; float temp; - __asm__("frintx\t%s1, %s2\n\t" - "fcvtzs\t%x0, %s1" - : "=r" (result), "=w" (temp) : "w" (x)); + if (sizeof (result) == 8) { + __asm__("frintx\t%s1, %s2\n\t" + "fcvtzs\t%x0, %s1" + : "=r" (result), "=w" (temp) : "w" (x)); + } else { + __asm__("frintx\t%s1, %s2\n\t" + "fcvtzs\t%w0, %s1" + : "=r" (result), "=w" (temp) : "w" (x)); + } return result; } #else diff --git a/newlib/libm/machine/aarch64/sf_lround.c b/newlib/libm/machine/aarch64/sf_lround.c index a14f29b4ae..41cf43e9d6 100644 --- a/newlib/libm/machine/aarch64/sf_lround.c +++ b/newlib/libm/machine/aarch64/sf_lround.c @@ -31,7 +31,11 @@ long int lroundf (float x) { long int result; - __asm__("fcvtas\t%x0, %s1" : "=r" (result) : "w" (x)); + if (sizeof (result) == 8) { + __asm__("fcvtas\t%x0, %s1" : "=r" (result) : "w" (x)); + } else { + __asm__("fcvtas\t%w0, %s1" : "=r" (result) : "w" (x)); + } return result; } From 8686449ba47dad0fe7243150b687ef4187ddbe8d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 2 Aug 2024 17:14:39 -0700 Subject: [PATCH 15/42] aarch64: Fix up strcmp for ilp32 The asm version was missing a check for LP64 causing it to also define the function. Signed-off-by: Keith Packard --- newlib/libc/machine/aarch64/strncmp.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/newlib/libc/machine/aarch64/strncmp.S b/newlib/libc/machine/aarch64/strncmp.S index 098b6f1a45..b2470a408c 100644 --- a/newlib/libc/machine/aarch64/strncmp.S +++ b/newlib/libc/machine/aarch64/strncmp.S @@ -26,7 +26,7 @@ #include -#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) +#if (defined (__OPTIMIZE_SIZE__) || defined (PREFER_SIZE_OVER_SPEED)) || !defined(__LP64__) /* See strncmp-stub.c */ #else From 343aead03ae245aa8b249404215d5c21736c2147 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 2 Aug 2024 15:29:54 -0700 Subject: [PATCH 16/42] picocrt/aarch64: Enable MMU We need to enable the MMU so that unaligned access to normal memory doesn't trap. On aarch64, that's not too bad as we can create level-1 block maps that cover 1GB apiece and then set up an 8GB virtual space. That means we only need 8 PTEs. Signed-off-by: Keith Packard --- picocrt/machine/aarch64/crt0.c | 147 ++++++++++++++++++++++++++++++++- 1 file changed, 146 insertions(+), 1 deletion(-) diff --git a/picocrt/machine/aarch64/crt0.c b/picocrt/machine/aarch64/crt0.c index 4e3efe5b71..8a42d1f02e 100644 --- a/picocrt/machine/aarch64/crt0.c +++ b/picocrt/machine/aarch64/crt0.c @@ -55,20 +55,165 @@ extern char __arm64_tls_tcb_offset; static inline void _set_tls(void *tls) { - __asm__ volatile("msr tpidr_el0, %0" : : "r" (tls - TP_OFFSET)); + __asm__ volatile("msr tpidr_el0, %x0" : : "r" (tls - TP_OFFSET)); } #include "../../crt0.h" +/* + * We need 4 1GB mappings to cover the usual Normal memory space, + * which runs from 0x00000000 to 0x7fffffff along with the usual + * Device space which runs from 0x80000000 to 0xffffffff. However, + * it looks like the smallest VA we can construct is 8GB, so we'll + * pad the space with invalid PTEs + */ +#define MMU_NORMAL_COUNT 2 +#define MMU_DEVICE_COUNT 2 +#define MMU_INVALID_COUNT 4 +extern uint64_t __identity_page_table[MMU_NORMAL_COUNT + MMU_DEVICE_COUNT + MMU_INVALID_COUNT]; + +#define MMU_DESCRIPTOR_VALID (1 << 0) +#define MMU_DESCRIPTOR_BLOCK (0 << 1) +#define MMU_DESCRIPTOR_TABLE (1 << 1) + +#define MMU_BLOCK_XN (1LL << 54) +#define MMU_BLOCK_PXN (1LL << 53) +#define MMU_BLOCK_CONTIG (1LL << 52) +#define MMU_BLOCK_DBM (1LL << 51) +#define MMU_BLOCK_GP (1LL << 50) + +#define MMU_BLOCK_NT (1 << 16) +#define MMU_BLOCK_OA_BIT 12 +#define MMU_BLOCK_NG (1 << 11) +#define MMU_BLOCK_AF (1 << 10) +#define MMU_BLOCK_SH_BIT 8 +#define MMU_BLOCK_SH_NS (0 << MMU_BLOCK_SH_BIT) +#define MMU_BLOCK_SH_OS (2 << MMU_BLOCK_SH_BIT) +#define MMU_BLOCK_SH_IS (3 << MMU_BLOCK_SH_BIT) +#define MMU_BLOCK_AP_BIT 6 +#define MMU_BLOCK_NS (1 << 5) +#define MMU_BLOCK_ATTR_BIT 2 + +#define MMU_NORMAL_FLAGS (MMU_DESCRIPTOR_VALID | \ + MMU_DESCRIPTOR_BLOCK | \ + MMU_BLOCK_AF | \ + MMU_BLOCK_SH_IS | \ + (0 << MMU_BLOCK_ATTR_BIT)) + +#define MMU_DEVICE_FLAGS (MMU_DESCRIPTOR_VALID | \ + MMU_DESCRIPTOR_BLOCK | \ + MMU_BLOCK_AF | \ + (1 << MMU_BLOCK_ATTR_BIT)) + +#define MMU_INVALID_FLAGS 0 + +__asm__( + ".section .rodata\n" + ".global __identity_page_table\n" + ".balign 65536\n" + "__identity_page_table:\n" + ".set _i, 0\n" + ".rept " __XSTRING(MMU_NORMAL_COUNT) "\n" + " .8byte (_i << 30) |" __XSTRING(MMU_NORMAL_FLAGS) "\n" + " .set _i, _i + 1\n" + ".endr\n" + ".set _i, 0\n" + ".rept " __XSTRING(MMU_DEVICE_COUNT) "\n" + " .8byte (1 << 31) | (_i << 30) |" __XSTRING(MMU_DEVICE_FLAGS) "\n" + " .set _i, _i + 1\n" + ".endr\n" + ".set _i, 0\n" + ".rept " __XSTRING(MMU_INVALID_COUNT) "\n" + " .8byte " __XSTRING(MMU_INVALID_FLAGS) "\n" + " .set _i, _i + 1\n" + ".endr\n" + ".size __identity_page_table, " __XSTRING((MMU_NORMAL_COUNT + MMU_DEVICE_COUNT + MMU_INVALID_COUNT) * 8) "\n" +); + +#define SCTLR_MMU (1 << 0) +#define SCTLR_A (1 << 1) +#define SCTLR_C (1 << 2) +#define SCTLR_ICACHE (1 << 12) +#define SCTLR_WXN (1 << 19) +#define TCR_T0SZ_BIT 0 +#define TCR_EPD0 (1 << 7) +#define TCR_IRGN0_BIT 8 +#define TCR_IRGN0_NC (0 << TCR_IRGN0_BIT) +#define TCR_IRGN0_WB_WA (1 << TCR_IRGN0_BIT) +#define TCR_IRGN0_WT (2 << TCR_IRGN0_BIT) +#define TCR_IRGN0_WB (3 << TCR_IRGN0_BIT) +#define TCR_ORGN0_BIT 10 +#define TCR_ORGN0_NC (0 << TCR_ORGN0_BIT) +#define TCR_ORGN0_WB_WA (1 << TCR_ORGN0_BIT) +#define TCR_ORGN0_WT (2 << TCR_ORGN0_BIT) +#define TCR_ORGN0_WB (3 << TCR_ORGN0_BIT) +#define TCR_SH0_BIT 12 +#define TCR_SH0_NS (0 << TCR_SH0_BIT) +#define TCR_SH0_OS (2 << TCR_SH0_BIT) +#define TCR_SH0_IS (3 << TCR_SH0_BIT) +#define TCR_TG0_BIT 14 +#define TCR_TG0_4KB (0 << TCR_TG0_BIT) +#define TCR_TG0_64KB (1 << TCR_TG0_BIT) +#define TCR_TG0_16KB (2 << TCR_TG0_BIT) +#define TCR_EPD1 (1 << 23) +#define TCR_IPS_BIT 32 +#define TCR_IPS_4GB (0LL << TCR_IPS_BIT) + static void __attribute((used)) _cstart(void) { + uint64_t sctlr_el1; + + /* Invalidate the cache */ + __asm__("ic iallu"); + __asm__("isb\n"); + + /* + * Set up the TCR register to provide a 33bit VA space using + * 4kB pages over 4GB of PA + */ + __asm__("msr tcr_el1, %x0" :: + "r" ((0x1f << TCR_T0SZ_BIT) | + TCR_IRGN0_WB_WA | + TCR_ORGN0_WB_WA | + TCR_SH0_IS | + TCR_TG0_4KB | + TCR_EPD1 | + TCR_IPS_4GB)); + + /* Load the page table base */ + __asm__("msr ttbr0_el1, %x0" :: "r" (__identity_page_table)); + + /* + * Set the memory attributions in the MAIR register: + * + * Region 0 is Normal memory + * Region 1 is Device memory + */ + __asm__("msr mair_el1, %x0" :: + "r" ((0xffLL << 0) | (0x00LL << 8))); + + /* + * Enable caches, and the MMU, disable alignment requirements + * and write-implies-XN + */ + __asm__("mrs %x0, sctlr_el1" : "=r" (sctlr_el1)); + sctlr_el1 |= SCTLR_ICACHE | SCTLR_C | SCTLR_MMU; + sctlr_el1 &= ~(SCTLR_A | SCTLR_WXN); + __asm__("msr sctlr_el1, %x0" :: "r" (sctlr_el1)); + __asm__("isb\n"); + + /* Set the vector base address register */ + __asm__("msr vbar_el1, %x0" :: "r" (__vector_table)); __start(); } void __section(".text.init.enter") _start(void) { + /* Switch to EL1 */ + __asm__("msr SPSel, #1"); + /* Initialize stack */ __asm__("adrp x1, __stack"); __asm__("add x1, x1, :lo12:__stack"); From 594d11d441856a8c6f93253f64cfd4bc1ad51ef4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 2 Aug 2024 16:23:59 -0700 Subject: [PATCH 17/42] picocrt/aarch64: Add sample interrupt vector This provides for override-able interrupt handling at the cost of wasting all of the room provided for these functions in the interrupt table. Signed-off-by: Keith Packard --- .../picolib/machine/aarch64/CMakeLists.txt | 42 ++++++++ .../libc/picolib/machine/aarch64/interrupt.c | 96 +++++++++++++++++++ .../libc/picolib/machine/aarch64/meson.build | 2 + 3 files changed, 140 insertions(+) create mode 100644 newlib/libc/picolib/machine/aarch64/CMakeLists.txt create mode 100644 newlib/libc/picolib/machine/aarch64/interrupt.c diff --git a/newlib/libc/picolib/machine/aarch64/CMakeLists.txt b/newlib/libc/picolib/machine/aarch64/CMakeLists.txt new file mode 100644 index 0000000000..1111044029 --- /dev/null +++ b/newlib/libc/picolib/machine/aarch64/CMakeLists.txt @@ -0,0 +1,42 @@ +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright © 2022 Keith Packard +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +# OF THE POSSIBILITY OF SUCH DAMAGE. +# + +picolibc_sources(interrupt.c) + +if(${_HAVE_PICOLIBC_TLS_API}) + picolibc_sources( + tls.c + ) +endif() diff --git a/newlib/libc/picolib/machine/aarch64/interrupt.c b/newlib/libc/picolib/machine/aarch64/interrupt.c new file mode 100644 index 0000000000..40a90ea785 --- /dev/null +++ b/newlib/libc/picolib/machine/aarch64/interrupt.c @@ -0,0 +1,96 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2019 Keith Packard + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +void aarch64_halt_vector(void); + +void __section(".init") +aarch64_halt_vector(void) +{ + /* Loop forever. */ + for(;;); +} + +void aarch64_ignore_vector(void); + +void __section(".init") +aarch64_ignore_vector(void) +{ + /* Ignore the interrupt by returning */ +} + +#define vector(name) \ + void aarch64_ ## name ## _vector(void) __attribute__ ((weak, alias("aarch64_ignore_vector"))) + +#define vector_halt(name) \ + void aarch64_ ## name ## _vector(void) __attribute__ ((weak, alias("aarch64_halt_vector"))) + +vector_halt(sync); +vector_halt(serror); +vector(irq); +vector(fiq); + +void +__weak_vector_table(void); + +void __section(".text.init.enter") __attribute__((aligned(1024))) +__weak_vector_table(void) +{ + /* + * Exception vector + */ + __asm__("SP_EL0:\n" + "b aarch64_sync_vector\n" + ". = SP_EL0 + 0x80\n" + "b aarch64_irq_vector\n" + ". = SP_EL0 + 0x100\n" + "b aarch64_fiq_vector\n" + ". = SP_EL0 + 0x180\n" + "b aarch64_serror_vector\n" + ". = SP_EL0 + 0x200\n" + "SP_ELx:\n" + "b aarch64_sync_vector\n" + ". = SP_ELx + 0x80\n" + "b aarch64_irq_vector\n" + ". = SP_ELx + 0x100\n" + "b aarch64_fiq_vector\n" + ". = SP_ELx + 0x180\n" + "b aarch64_serror_vector\n" + ". = SP_ELx + 0x200\n"); +} + +__weak_reference(__weak_vector_table, __vector_table); diff --git a/newlib/libc/picolib/machine/aarch64/meson.build b/newlib/libc/picolib/machine/aarch64/meson.build index 3111e10043..e2d5817281 100644 --- a/newlib/libc/picolib/machine/aarch64/meson.build +++ b/newlib/libc/picolib/machine/aarch64/meson.build @@ -33,6 +33,8 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # +src_picolib += files('interrupt.c') + if thread_local_storage src_picolib += files('tls.c') endif From a662ca1a917f9a4717e88f33ac053283a326382c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 2 Aug 2024 16:25:16 -0700 Subject: [PATCH 18/42] picocrt/aarch64: Trap exceptions in semihost mode Handle exceptions in semihost mode so that we'll get useful data. Signed-off-by: Keith Packard --- picocrt/machine/aarch64/crt0.c | 124 +++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/picocrt/machine/aarch64/crt0.c b/picocrt/machine/aarch64/crt0.c index 8a42d1f02e..98ffa564dc 100644 --- a/picocrt/machine/aarch64/crt0.c +++ b/picocrt/machine/aarch64/crt0.c @@ -159,6 +159,8 @@ __asm__( #define TCR_IPS_BIT 32 #define TCR_IPS_4GB (0LL << TCR_IPS_BIT) +extern const void *__vector_table[]; + static void __attribute((used)) _cstart(void) { @@ -226,3 +228,125 @@ _start(void) /* Jump into C code */ __asm__("bl _cstart"); } + +#ifdef CRT0_SEMIHOST + +/* + * Trap faults, print message and exit when running under semihost + */ + +#include +#include +#include + +#define _REASON(r) #r +#define REASON(r) _REASON(r) + +static void aarch64_fault_write_reg(const char *prefix, uint64_t reg) +{ + fputs(prefix, stdout); + + for (unsigned i = 0; i < 16; i++) { + unsigned digitval = 0xF & (reg >> (56 - 4*i)); + char digitchr = '0' + digitval + (digitval >= 10 ? 'a'-'0'-10 : 0); + putchar(digitchr); + } + + putchar('\n'); +} + +struct fault { + uint64_t x[31]; + uint64_t pc; +}; + +static const char *const reasons[] = { + "sync\n", + "irq\n", + "fiq\n", + "serror\n" +}; + +#define REASON_SYNC 0 +#define REASON_IRQ 1 +#define REASON_FIQ 2 +#define REASON_SERROR 3 + +static void __attribute__((used)) +aarch64_fault(struct fault *f, int reason) +{ + int r; + fputs("AARCH64 fault: ", stdout); + fputs(reasons[reason], stdout); + char prefix[] = "\tX##: 0x"; + for (r = 0; r <= 30; r++) { + prefix[2] = '0' + r / 10; /* overwrite # with register number */ + prefix[3] = '0' + r % 10; /* overwrite # with register number */ + aarch64_fault_write_reg(prefix, f->x[r]); + } + aarch64_fault_write_reg("\tPC: 0x", f->pc); + _exit(1); +} + +#define VECTOR_COMMON \ + __asm__("sub sp, sp, #256"); \ + __asm__("str x0, [sp, #0]"); \ + __asm__("str x1, [sp, #8]"); \ + __asm__("str x2, [sp, #16]"); \ + __asm__("str x3, [sp, #24]"); \ + __asm__("str x4, [sp, #32]"); \ + __asm__("str x5, [sp, #40]"); \ + __asm__("str x6, [sp, #48]"); \ + __asm__("str x7, [sp, #56]"); \ + __asm__("str x8, [sp, #64]"); \ + __asm__("str x9, [sp, #72]"); \ + __asm__("str x10, [sp, #80]"); \ + __asm__("str x11, [sp, #88]"); \ + __asm__("str x12, [sp, #96]"); \ + __asm__("str x13, [sp, #104]"); \ + __asm__("str x14, [sp, #112]"); \ + __asm__("str x15, [sp, #120]"); \ + __asm__("str x16, [sp, #128]"); \ + __asm__("str x17, [sp, #136]"); \ + __asm__("str x18, [sp, #144]"); \ + __asm__("str x19, [sp, #152]"); \ + __asm__("str x20, [sp, #160]"); \ + __asm__("str x21, [sp, #168]"); \ + __asm__("str x22, [sp, #176]"); \ + __asm__("str x23, [sp, #184]"); \ + __asm__("str x24, [sp, #192]"); \ + __asm__("str x25, [sp, #200]"); \ + __asm__("str x26, [sp, #208]"); \ + __asm__("str x27, [sp, #216]"); \ + __asm__("str x28, [sp, #224]"); \ + __asm__("str x29, [sp, #232]"); \ + __asm__("str x30, [sp, #240]"); \ + __asm__("mrs x0, ELR_EL1\n"); \ + __asm__("str x0, [sp, #248]"); \ + __asm__("mov x0, sp") + +void __section(".init") +aarch64_sync_vector(void) +{ + VECTOR_COMMON; + __asm__("mov x1, #" REASON(REASON_SYNC)); + __asm__("b aarch64_fault"); +} + +void __section(".init") +aarch64_irq_vector(void) +{ + VECTOR_COMMON; + __asm__("mov x1, #" REASON(REASON_IRQ)); + __asm__("b aarch64_fault"); +} + +void __section(".init") +aarch64_fiq_vector(void) +{ + VECTOR_COMMON; + __asm__("mov x1, #" REASON(REASON_FIQ)); + __asm__("b aarch64_fault"); +} + +#endif /* CRT0_SEMIHOST */ From b7bdbb822ed18b60cc6bccd079afcee0b07f29a5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 2 Aug 2024 16:26:05 -0700 Subject: [PATCH 19/42] test: Add invalid instruction for aarch64 to test-except Now that exceptions are trapped, make sure they work. Signed-off-by: Keith Packard --- test/test-except.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test-except.c b/test/test-except.c index 786b9e84c1..b07d7c3b5b 100644 --- a/test/test-except.c +++ b/test/test-except.c @@ -56,6 +56,10 @@ main(void) __asm__(".word 0x00000000"); +#elif defined(__aarch64__) + + __asm__(".word 0x00000000"); + #else #define NO_INVALID From 2dc75406c015ab7ba3c87c57273495dede55402a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 2 Aug 2024 16:43:26 -0700 Subject: [PATCH 20/42] scripts: Add aarch64-zephyr configuration script This uses the existing aarch64-zephyr cross compile file. Signed-off-by: Keith Packard --- scripts/do-aarch64-zephyr-configure | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 scripts/do-aarch64-zephyr-configure diff --git a/scripts/do-aarch64-zephyr-configure b/scripts/do-aarch64-zephyr-configure new file mode 100755 index 0000000000..ea00ec9c6d --- /dev/null +++ b/scripts/do-aarch64-zephyr-configure @@ -0,0 +1,36 @@ +#!/bin/sh +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright © 2019 Keith Packard +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +# OF THE POSSIBILITY OF SUCH DAMAGE. +# +exec "$(dirname "$0")"/do-configure aarch64-zephyr-elf -Dtests=true "$@" From 6b39d3470fa886a26977d7efbd082ce347a1cc78 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 2 Aug 2024 16:44:23 -0700 Subject: [PATCH 21/42] .github: Re-enable aarch64 testing with linux toolchain Now that the MMU is enabled, testing can be turned back on. Signed-off-by: Keith Packard --- .github/do-linux | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/do-linux b/.github/do-linux index 31f0917632..0346eed10a 100755 --- a/.github/do-linux +++ b/.github/do-linux @@ -9,13 +9,13 @@ HERE=`dirname "$0"` "$HERE"/do-test clang-thumbv7e+dp "$@" "$HERE"/do-test clang-thumbv7m "$@" "$HERE"/do-test clang-thumbv6m "$@" -"$HERE"/do-build clang-aarch64 "$@" +"$HERE"/do-test clang-aarch64 "$@" "$HERE"/do-build mips "$@" "$HERE"/do-build mips64 "$@" "$HERE"/do-build mipsel "$@" "$HERE"/do-test native "$@" "$HERE"/do-test native-m32 "$@" -"$HERE"/do-build aarch64 "$@" +"$HERE"/do-test aarch64 "$@" "$HERE"/do-build lx106 "$@" "$HERE"/do-test i386 "$@" "$HERE"/do-test m68k-unknown-elf "$@" From ee522879a05d7c50f029d21aeeeaf6f8aa478201 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 2 Aug 2024 16:44:53 -0700 Subject: [PATCH 22/42] .github: Test aarch64 using zephyr toolchain Update the Zephyr SDK and add aarch64 bits Signed-off-by: Keith Packard --- .github/do-zephyr | 1 + .github/zephyr-files.txt | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/do-zephyr b/.github/do-zephyr index e86b71eb7c..52aab873b3 100755 --- a/.github/do-zephyr +++ b/.github/do-zephyr @@ -1,6 +1,7 @@ #!/bin/sh set -e HERE=`dirname "$0"` +"$HERE"/do-zephyr-test aarch64-zephyr "$@" "$HERE"/do-zephyr-test arc "$@" "$HERE"/do-zephyr-test arc64 "$@" "$HERE"/do-zephyr-build microblazeel "$@" diff --git a/.github/zephyr-files.txt b/.github/zephyr-files.txt index aab77559f9..9e9c6cecee 100644 --- a/.github/zephyr-files.txt +++ b/.github/zephyr-files.txt @@ -1,16 +1,17 @@ -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_arc-zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_arc64-zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_microblazeel-zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_mips-zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_nios2-zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_sparc-zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_x86_64-zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_xtensa-espressif_esp32s2_zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_xtensa-espressif_esp32_zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_xtensa-intel_ace15_mtpm_zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_xtensa-intel_tgl_adsp_zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_xtensa-nxp_imx8m_adsp_zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_xtensa-nxp_imx_adsp_zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/toolchain_linux-x86_64_xtensa-sample_controller_zephyr-elf.tar.xz -https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/hosttools_linux-x86_64.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_aarch64-zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_arc-zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_arc64-zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_microblazeel-zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_mips-zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_nios2-zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_sparc-zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_x86_64-zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_xtensa-espressif_esp32s2_zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_xtensa-espressif_esp32_zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_xtensa-intel_ace15_mtpm_zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_xtensa-intel_tgl_adsp_zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_xtensa-nxp_imx8m_adsp_zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_xtensa-nxp_imx_adsp_zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/toolchain_linux-x86_64_xtensa-sample_controller_zephyr-elf.tar.xz +https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.8/hosttools_linux-x86_64.tar.xz https://maps.altusmetrum.org/qemu-nios2-2.tar.xz From eadb39ba1495bc28ff4fbc22a0221e49292b1a1c Mon Sep 17 00:00:00 2001 From: Abdallah Abdelhafeez Date: Sun, 28 Jul 2024 15:10:51 +0300 Subject: [PATCH 23/42] tinystdio: handling `"nan(n-sequence char)"` by `scanf()` family & `strtod()` Quoting from C standard part 7.19.6.2 > `a,e,f,g` Matches an optionally signed floating-point number, infinity, or NaN, whose format is the same as expected for the subject sequence of the `strtod` function. The corresponding argument shall be a pointer to floating. Regarding `strtod`, quoting from C standard part 7.20.1.3 > A character sequence `NAN` or `NAN(n-char-sequence)`, is interpreted as a quiet NaN, if supported in the return type, else like a subject sequence part that does not have the expected form; the meaning of the `n-char sequences` is implementation-defined. Signed-off-by: Abdallah Abdelhafeez (Abdallahs70) --- newlib/libc/tinystdio/conv_flt.c | 27 ++++++++++++++++++ test/libc-testsuite/sscanf.c | 47 ++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/newlib/libc/tinystdio/conv_flt.c b/newlib/libc/tinystdio/conv_flt.c index 1dd6bc8c5a..d70b8c0772 100644 --- a/newlib/libc/tinystdio/conv_flt.c +++ b/newlib/libc/tinystdio/conv_flt.c @@ -244,6 +244,33 @@ conv_flt (FLT_STREAM *stream, FLT_CONTEXT *context, width_t width, void *addr, u break; return 0; } + if (flt != flt) + { + if (CHECK_WIDTH()) { + if ((i = scanf_getc (stream, context)) == '(') + { + while(CHECK_WIDTH() && (i = scanf_getc (stream, context)) != ')') + { + if(isalnum(i) || i == '_' ) + { + continue; + } + else + { + break; + } + } + if(i != ')') + { + return 0; + } + } + else + { + scanf_ungetc (i, stream, context); + } + } + } } break; diff --git a/test/libc-testsuite/sscanf.c b/test/libc-testsuite/sscanf.c index 1273c0e7a2..bba64f6604 100644 --- a/test/libc-testsuite/sscanf.c +++ b/test/libc-testsuite/sscanf.c @@ -212,6 +212,53 @@ static int test_sscanf(void) /* legacy stdio fails this test */ TEST(i, sscanf("hello, world\n", "%8c%8c", a, b), 1, "%d fields, expected %d"); TEST_S(a, "hello, wX", ""); + + /* testing nan(n-seq-char) in the expected form */ + a[0] = '#'; + a[1] = '\0'; + TEST(i, sscanf(" Nan(98b)", "%lf%c", &d, a), 1, "got %d fields, expected %d"); + TEST(i, isnan(d), 1, "isnan %d expected %d"); + TEST_S(a, "#", ""); + + /* testing nan(n-seq-char) missing closing paren */ + a[0] = '#'; + a[1] = '\0'; + d = 1.0; + TEST(i, sscanf("NaN(abcdefg", "%lf%c", &d, a), -1, "got %d fields, expected %d"); + TEST(i, d, 1.0, "%d expected %lf"); + TEST_S(a, "#", ""); + + /* testing nan(n-seq-char) invalid character inside parens */ + a[0] = '#'; + a[1] = '\0'; + d = 1.0; + TEST(i, sscanf("NaN(12:b)", "%lf%c", &d, a), 0, "got %d fields, expected %d"); + TEST(i, d, 1.0, "%d expected %lf"); + TEST_S(a, "#", ""); + + /* testing nan(n-seq-char) overrunning a field width value */ + a[0] = '#'; + a[1] = '\0'; + d = 1.0; + TEST(i, sscanf("Nan(12345)", "%9lf%c", &d, a), 0, "got %d fields, expected %d"); + TEST(i, d, 1.0, "%d expected %lf"); + TEST_S(a, "#", ""); + + /* testing inf(n-seq-char) should 'inf' should be evaluated sperately */ + a[0] = '#'; + a[1] = '\0'; + d = 1.0; + TEST(i, sscanf("inf(12b)", "%lf%c", &d, a), 2, "got %d fields, expected %d"); + TEST(i, isinf(d), 1, "%d expected %d"); + TEST_S(a, "(", ""); + + /* testing infinity(n-seq-char) should 'infinity' should be evaluated sperately */ + a[0] = '#'; + a[1] = '\0'; + d = 1.0; + TEST(i, sscanf("infinity(abcd)", "%lf%c", &d, a), 2, "got %d fields, expected %d"); + TEST(i, isinf(d), 1, "%d expected %d"); + TEST_S(a, "(", ""); #endif TEST(i, sscanf("56789 0123 56a72", "%2d%d%*d %[0123456789]\n", &x, &y, a), 3, "only %d fields, expected %d"); From e434fa1f41a83a888d6498922ab7f140011933d1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 6 Aug 2024 21:30:57 -0700 Subject: [PATCH 24/42] tinystdio: Reformat conv_flt change Make the new code match the old format Signed-off-by: Keith Packard --- newlib/libc/tinystdio/conv_flt.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/newlib/libc/tinystdio/conv_flt.c b/newlib/libc/tinystdio/conv_flt.c index d70b8c0772..de16032b0d 100644 --- a/newlib/libc/tinystdio/conv_flt.c +++ b/newlib/libc/tinystdio/conv_flt.c @@ -244,29 +244,18 @@ conv_flt (FLT_STREAM *stream, FLT_CONTEXT *context, width_t width, void *addr, u break; return 0; } - if (flt != flt) - { + if (flt != flt) { if (CHECK_WIDTH()) { - if ((i = scanf_getc (stream, context)) == '(') - { - while(CHECK_WIDTH() && (i = scanf_getc (stream, context)) != ')') - { - if(isalnum(i) || i == '_' ) - { + if ((i = scanf_getc (stream, context)) == '(') { + while (CHECK_WIDTH() && (i = scanf_getc (stream, context)) != ')') { + if (isalnum(i) || i == '_' ) continue; - } else - { break; - } } - if(i != ')') - { + if (i != ')') return 0; - } - } - else - { + } else { scanf_ungetc (i, stream, context); } } From bf0b6936f068bdd44b3c1b68223163f65b6a2944 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 8 Aug 2024 13:41:57 -0700 Subject: [PATCH 25/42] test: Place libc in link_args consistently To avoid depending on a .specs file, we can't let meson insert the libraries relative to the link_args by itself as the link_args end up after the libs, which breaks the printf/scanf symbol definitions. Signed-off-by: Keith Packard --- newlib/libm/test/meson.build | 21 ++++++++++------ test/libc-testsuite/meson.build | 10 +++++--- test/libc-testsuite/string.c | 2 +- test/meson.build | 43 ++++++++++++--------------------- 4 files changed, 36 insertions(+), 40 deletions(-) diff --git a/newlib/libm/test/meson.build b/newlib/libm/test/meson.build index 0e23b3ea32..39a4ea0425 100644 --- a/newlib/libm/test/meson.build +++ b/newlib/libm/test/meson.build @@ -156,19 +156,25 @@ foreach target : targets value = get_variable('target_' + target) - libs = [get_variable('lib_c' + target)] + _libs = [get_variable('lib_c' + target)] if is_variable('lib_semihost' + target) - libs += [get_variable('lib_semihost' + target)] + _libs += [get_variable('lib_semihost' + target)] endif + if is_variable('crt0_hosted' + target) - objs = [get_variable('crt0_hosted'+ target)] + _objs = [get_variable('crt0_hosted'+ target)] else - objs = [] + _objs = [] endif + _lib_files=[] + foreach _lib : _libs + _lib_files += _lib.full_path() + endforeach + _c_args = value[1] + get_variable('test_c_args_' + target, test_c_args) - _link_args = value[1] + get_variable('test_link_args_' + target, test_link_args) - _link_depends = get_variable('test_link_depends_' + target, test_link_depends) + _link_args = value[1] + get_variable('test_link_args_' + target, test_link_args) + _lib_files + _link_depends = get_variable('test_link_depends_' + target, test_link_depends) + _libs _c_args = double_printf_compile_args + _c_args _link_args = double_printf_link_args + _link_args @@ -187,8 +193,7 @@ foreach target : targets test(test_name, executable(test_name, math_test_src, c_args: _c_args + ['-DTEST_PART=' + test_part], - objects: objs, - link_with: libs, + objects: _objs, link_args: _link_args, link_depends: _link_depends, include_directories: inc), diff --git a/test/libc-testsuite/meson.build b/test/libc-testsuite/meson.build index e2b5245b8a..0585e7ff9c 100644 --- a/test/libc-testsuite/meson.build +++ b/test/libc-testsuite/meson.build @@ -63,9 +63,14 @@ foreach target : targets _objs = [] endif + _lib_files=[] + foreach _lib : _libs + _lib_files += _lib.full_path() + endforeach + _c_args = value[1] + get_variable('test_c_args_' + target, test_c_args) - _link_args = value[1] + get_variable('test_link_args_' + target, test_link_args) - _link_depends = get_variable('test_link_depends_' + target, test_link_depends) + _link_args = value[1] + get_variable('test_link_args_' + target, test_link_args) + _lib_files + _link_depends = get_variable('test_link_depends_' + target, test_link_depends) + _libs foreach t1 : libc_tests_picolibc t1_src = t1 + '.c' @@ -86,7 +91,6 @@ foreach target : targets c_args: double_printf_compile_args + _c_args, link_args: double_printf_link_args + _link_args, objects: _objs, - link_with: _libs, link_depends: _link_depends, include_directories: inc), depends: bios_bin, diff --git a/test/libc-testsuite/string.c b/test/libc-testsuite/string.c index 084e46a83d..a17adc34c1 100644 --- a/test/libc-testsuite/string.c +++ b/test/libc-testsuite/string.c @@ -45,7 +45,7 @@ } while(0) #define TEST_S(s, x, m) do { \ - if (strcmp((s),(x)) != 0) { \ + if (s == NULL || strcmp((s),(x)) != 0) { \ printf(__FILE__ ":%d: [%s] != [%s] (%s)\n", __LINE__, s, x, m); \ err++; \ } \ diff --git a/test/meson.build b/test/meson.build index 8ddd9666a2..e37faabf54 100644 --- a/test/meson.build +++ b/test/meson.build @@ -133,8 +133,8 @@ foreach target : targets endif _c_args = value[1] + get_variable('test_c_args_' + target, test_c_args) - _link_args = value[1] + get_variable('test_link_args_' + target, test_link_args) - _link_depends = get_variable('test_link_depends_' + target, test_link_depends) + _link_args = value[1] + get_variable('test_link_args_' + target, test_link_args) + _lib_files + _link_depends = get_variable('test_link_depends_' + target, test_link_depends) + _libs if have_cplusplus _cpp_args = value[1] + get_variable('test_cpp_args_' + target, test_cpp_args) endif @@ -149,9 +149,9 @@ foreach target : targets test(t1_name, executable(t1_name, ['printf_scanf.c', 'lock-valid.c'], c_args: double_printf_compile_args + _c_args, - link_args: double_printf_link_args + _lib_files + _link_args, + link_args: double_printf_link_args + _link_args, objects: _objs, - link_depends: _link_depends + _libs, + link_depends: _link_depends, include_directories: inc), depends: bios_bin, env: test_env) @@ -166,7 +166,7 @@ foreach target : targets test(t1_name, executable(t1_name, ['printf_scanf.c', 'lock-valid.c'], c_args: float_printf_compile_args + _c_args, - link_args: float_printf_link_args + _lib_files + _link_args, + link_args: float_printf_link_args + _link_args, objects: _objs, link_depends: _link_depends + _libs, include_directories: inc), @@ -183,7 +183,7 @@ foreach target : targets test(t1_name, executable(t1_name, ['printf_scanf.c', 'lock-valid.c'], c_args: llong_printf_compile_args + _c_args, - link_args: llong_printf_link_args + _lib_files + _link_args, + link_args: llong_printf_link_args + _link_args, objects: _objs, link_depends: _link_depends + _libs, include_directories: inc), @@ -200,7 +200,7 @@ foreach target : targets test(t1_name, executable(t1_name, ['printf_scanf.c', 'lock-valid.c'], c_args: int_printf_compile_args + _c_args, - link_args: int_printf_link_args + _lib_files + _link_args, + link_args: int_printf_link_args + _link_args, objects: _objs, link_depends: _link_depends + _libs, include_directories: inc), @@ -217,7 +217,7 @@ foreach target : targets test(t1_name, executable(t1_name, ['printf_scanf.c', 'lock-valid.c'], c_args: min_printf_compile_args + _c_args, - link_args: min_printf_link_args + _lib_files + _link_args, + link_args: min_printf_link_args + _link_args, objects: _objs, link_depends: _link_depends + _libs, include_directories: inc), @@ -234,7 +234,7 @@ foreach target : targets test(t1_name, executable(t1_name, ['printf-tests.c', 'lock-valid.c'], c_args: double_printf_compile_args + _c_args, - link_args: double_printf_link_args + _lib_files + _link_args, + link_args: double_printf_link_args + _link_args, objects: _objs, link_depends: _libs, include_directories: inc), @@ -251,7 +251,7 @@ foreach target : targets test(t1_name, executable(t1_name, ['printf-tests.c', 'lock-valid.c'], c_args: float_printf_compile_args + _c_args, - link_args: float_printf_link_args + _lib_files + _link_args, + link_args: float_printf_link_args + _link_args, objects: _objs, link_depends: _libs, include_directories: inc), @@ -268,7 +268,7 @@ foreach target : targets test(t1_name, executable(t1_name, ['printf-tests.c', 'lock-valid.c'], c_args: int_printf_compile_args + _c_args, - link_args: int_printf_link_args + _lib_files + _link_args, + link_args: int_printf_link_args + _link_args, objects: _objs, link_depends: _libs, include_directories: inc), @@ -285,7 +285,7 @@ foreach target : targets test(t1_name, executable(t1_name, ['printf-tests.c', 'lock-valid.c'], c_args: min_printf_compile_args + _c_args, - link_args: min_printf_link_args + _lib_files + _link_args, + link_args: min_printf_link_args + _link_args, objects: _objs, link_depends: _libs, include_directories: inc), @@ -309,7 +309,7 @@ foreach target : targets test(t1_name, executable(t1_name, ['time-sprintf.c', 'lock-valid.c'], c_args: int_printf_compile_args + _c_args + ['-fno-builtin'], - link_args: int_printf_link_args + _lib_files + _link_args, + link_args: int_printf_link_args + _link_args, objects: _objs, link_depends: _libs, include_directories: inc), @@ -328,7 +328,6 @@ foreach target : targets c_args: _c_args, link_args: _link_args, objects: _objs, - link_with: _libs, include_directories: inc), depends: bios_bin, env: test_env) @@ -347,7 +346,6 @@ foreach target : targets c_args: _c_args, link_args: _link_args, objects: _objs, - link_with: _libs, include_directories: inc), depends: bios_bin, env: test_env) @@ -357,7 +355,6 @@ foreach target : targets c_args: _c_args + ['-DRETVAL=1'], link_args: _link_args, objects: _objs, - link_with: _libs, include_directories: inc), depends: bios_bin, env: test_env, @@ -376,7 +373,6 @@ foreach target : targets c_args: _c_args, link_args: _link_args, objects: _objs, - link_with: _libs, include_directories: inc), depends: bios_bin, env: test_env, @@ -401,7 +397,6 @@ foreach target : targets c_args: _c_args, link_args: _link_args, objects: _objs_minimal, - link_with: _libs, include_directories: inc), depends: bios_bin, env: test_env) @@ -419,7 +414,6 @@ foreach target : targets c_args: arg_fnobuiltin + _c_args, link_args: _link_args, objects: _objs, - link_with: _libs, include_directories: inc), depends: bios_bin, env: test_env) @@ -436,7 +430,6 @@ foreach target : targets c_args: arg_fnobuiltin + _c_args, link_args: _link_args, objects: _objs, - link_with: _libs, include_directories: inc), depends: bios_bin, env: test_env) @@ -454,7 +447,6 @@ foreach target : targets c_args: double_printf_compile_args + arg_fnobuiltin + _c_args, link_args: double_printf_link_args + _link_args, objects: _objs, - link_with: _libs, link_depends: _link_depends, include_directories: inc), depends: bios_bin, @@ -475,7 +467,6 @@ foreach target : targets c_args: double_printf_compile_args + _c_args, link_args: double_printf_link_args + _link_args, objects: _objs, - link_with: _libs, link_depends: _link_depends, include_directories: inc), depends: bios_bin, @@ -496,7 +487,6 @@ foreach target : targets c_args: _c_args, link_args: _link_args, objects: _objs, - link_with: _libs, link_depends: _link_depends, include_directories: inc) @@ -538,7 +528,6 @@ foreach target : targets c_args: c_sanitize_bounds_flags + _c_args + test_ubsan_flags, link_args: _link_args, objects: _objs, - link_with: _libs, link_depends: _link_depends, include_directories: inc), depends: bios_bin, @@ -557,7 +546,7 @@ foreach target : targets test(t1_name, executable(t1_name, ['test-long-long.c', 'lock-valid.c'], c_args: llong_printf_compile_args + _c_args, - link_args: llong_printf_link_args + _lib_files + _link_args, + link_args: llong_printf_link_args + _link_args, objects: _objs, link_depends: _link_depends + _libs, include_directories: inc), @@ -575,7 +564,7 @@ foreach target : targets test(t1_name, executable(t1_name, ['test-long-long.c', 'lock-valid.c'], c_args: double_printf_compile_args + _c_args, - link_args: double_printf_link_args + _lib_files + _link_args, + link_args: double_printf_link_args + _link_args, objects: _objs, link_depends: _link_depends + _libs, include_directories: inc), @@ -597,7 +586,6 @@ foreach target : targets c_args: double_printf_compile_args + test_file_name_arg + _c_args, link_args: double_printf_link_args + _link_args, objects: _objs, - link_with: _libs, link_depends: _link_depends, include_directories: inc), depends: bios_bin, @@ -618,7 +606,6 @@ foreach target : targets cpp_args: _cpp_args, link_args: _cpp_args + _link_args, objects: _objs, - link_with: _libs, link_depends: _link_depends, include_directories: inc)) endif From a88bcb7e09588a431c2a49ab32baa6c08d9df06b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 8 Aug 2024 10:36:21 -0700 Subject: [PATCH 26/42] Don't use specs files when building tests The generated specs files reference installed versions of the library files. If those are already present in the system, we may end up using them for things like #include_next. The existing compile and link args already provide all of the values which the .specs files want to add. Signed-off-by: Keith Packard --- meson.build | 35 +++++------------------------------ test.specs.in | 4 ---- 2 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 test.specs.in diff --git a/meson.build b/meson.build index bfed413d3a..8db5a52d67 100644 --- a/meson.build +++ b/meson.build @@ -1631,30 +1631,6 @@ endif test_env = environment({'PICOLIBC_TEST' : '1'}) test_env.prepend('PATH', meson.current_source_dir() / 'scripts') -# CompCert needs the '-WUl,' prefix to correctly pass the --spec parameters to the linker -specs_prefix = '' -if cc.get_id() == 'ccomp' - specs_prefix = '-WUl,' -endif - -if has_semihost - specs = picolibc_specs - specs_name = picolibc_specs_name -else - specs = configure_file(input: 'test.specs.in', - output: '@BASENAME@', - configuration: specs_data, - install: false) - specs_name = 'test.specs' -endif - -# Clang does not support spec files -specs_line = [] -if cc.get_id() != 'clang' - specs_line += [specs_prefix + '--specs', specs_prefix + meson.current_build_dir() / specs_name] -endif -test_c_args += specs_line - if has_semihost foreach target : ['default-target'] + targets if target == 'default-target' @@ -1676,18 +1652,17 @@ if has_semihost endif set_variable(test_link_args_variable, - ['-nostdlib', '-T', picolibc_ld_string, - lib_gcc] + additional_libs_list + specs_line) + ['-Wl,--gc-sections', '-nostdlib', '-T', picolibc_ld_string, + lib_gcc] + additional_libs_list) set_variable(test_linker_files_variable, [picolibc_ld_value]) # Make sure all of the tests get re-linked if the linker scripts change. - set_variable(test_link_depends_variable, [picolibc_ld_value, specs]) + set_variable(test_link_depends_variable, [picolibc_ld_value]) endforeach else - test_link_args = specs_line - test_linker_files = [specs] - test_link_depends = [specs] + test_link_args = ['-Wl,--gc-sections'] + test_link_depends = [] endif # make sure to include semihost BEFORE picocrt! diff --git a/test.specs.in b/test.specs.in deleted file mode 100644 index 3005c2697a..0000000000 --- a/test.specs.in +++ /dev/null @@ -1,4 +0,0 @@ -%rename link test_link - -*link: -@SPECS_PRINTF@ --gc-sections %(test_link) From 766eae15c76222e4a584d5ec61a60f63b71803ca Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 8 Aug 2024 13:41:13 -0700 Subject: [PATCH 27/42] posix: Disable analyzer bounds checks for computematchjumps I couldn't figure out why it got confused about the bounds checking for pmatches. Signed-off-by: Keith Packard --- newlib/libc/posix/regcomp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/newlib/libc/posix/regcomp.c b/newlib/libc/posix/regcomp.c index 5639dc18cd..45f9b05d3a 100644 --- a/newlib/libc/posix/regcomp.c +++ b/newlib/libc/posix/regcomp.c @@ -1888,6 +1888,12 @@ computejumps(struct parse *p, struct re_guts *g) g->charjump[(unsigned char) g->must[mindex]] = g->mlen - mindex - 1; } +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Wunknown-warning-option" +#pragma GCC diagnostic ignored "-Wanalyzer-out-of-bounds" +#endif + /* - computematchjumps - compute match jumps for BM scan == static void computematchjumps(struct parse *p, struct re_guts *g); From c4b55b01f6d8a238e25aa16d28be0f6fe52e0c43 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 6 Aug 2024 18:20:17 -0700 Subject: [PATCH 28/42] tinystdio: Remove public header includes from stdio.h Keep stdio.h from making other standard symbols visible Signed-off-by: Keith Packard --- newlib/libc/include/ssp/stdio.h | 10 +++--- newlib/libc/ssp/stack_protector.c | 1 + newlib/libc/tinystdio/stdio.h | 58 +++++++++++++++++-------------- newlib/libc/tinystdio/strtoi.h | 1 + 4 files changed, 40 insertions(+), 30 deletions(-) diff --git a/newlib/libc/include/ssp/stdio.h b/newlib/libc/include/ssp/stdio.h index 5e1b2123be..81cce8383f 100644 --- a/newlib/libc/include/ssp/stdio.h +++ b/newlib/libc/include/ssp/stdio.h @@ -33,20 +33,20 @@ #include -__BEGIN_DECLS +_BEGIN_STD_C + int __sprintf_chk(char *__restrict, int, size_t, const char *__restrict, ...) __printflike(4, 5); int __vsprintf_chk(char *__restrict, int, size_t, const char *__restrict, - va_list) + __gnuc_va_list) __printflike(4, 0); int __snprintf_chk(char *__restrict, size_t, int, size_t, const char *__restrict, ...) __printflike(5, 6); int __vsnprintf_chk(char *__restrict, size_t, int, size_t, - const char *__restrict, va_list) + const char *__restrict, __gnuc_va_list) __printflike(5, 0); char *__gets_chk(char *, size_t); -__END_DECLS #if __SSP_FORTIFY_LEVEL > 0 @@ -98,4 +98,6 @@ __ssp_decl(size_t, fread_unlocked, (void *__restrict __ptr, size_t __size, size_ #endif /* __SSP_FORTIFY_LEVEL > 0 */ +_END_STD_C + #endif /* _SSP_STDIO_H_ */ diff --git a/newlib/libc/ssp/stack_protector.c b/newlib/libc/ssp/stack_protector.c index 61542f15c1..4d91f4e22a 100644 --- a/newlib/libc/ssp/stack_protector.c +++ b/newlib/libc/ssp/stack_protector.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include diff --git a/newlib/libc/tinystdio/stdio.h b/newlib/libc/tinystdio/stdio.h index 0b2c92e2db..994567da2f 100644 --- a/newlib/libc/tinystdio/stdio.h +++ b/newlib/libc/tinystdio/stdio.h @@ -43,10 +43,12 @@ #define __need_NULL #define __need_size_t #include -#include +#define __need___va_list #include #include +_BEGIN_STD_C + /* * This is an internal structure of the library that is subject to be * changed without warnings at any time. Please do *never* reference @@ -70,16 +72,16 @@ #endif #if __PICOLIBC_UNGETC_SIZE == 4 -typedef uint32_t __ungetc_t; +typedef __uint32_t __ungetc_t; #endif #if __PICOLIBC_UNGETC_SIZE == 2 -typedef uint16_t __ungetc_t; +typedef __uint16_t __ungetc_t; #endif struct __file { __ungetc_t unget; /* ungetc() buffer */ - uint8_t flags; /* flags, see below */ + __uint8_t flags; /* flags, see below */ #define __SRD 0x0001 /* OK to read */ #define __SWR 0x0002 /* OK to write */ #define __SERR 0x0004 /* found error */ @@ -128,7 +130,7 @@ struct __file_ext { */ #ifndef ___FILE_DECLARED typedef struct __file __FILE; -# define __FILE_defined +# define __FILE_DECLARED #endif #ifndef _FILE_DECLARED @@ -193,10 +195,6 @@ extern FILE *const stderr; .flush = (fl), \ } -#ifdef __cplusplus -extern "C" { -#endif - FILE *fdevopen(int (*__put)(char, FILE*), int (*__get)(FILE*), int(*__flush)(FILE *)); int fclose(FILE *__stream); int fflush(FILE *stream); @@ -225,14 +223,14 @@ int putchar(int __c); int printf(const char *__fmt, ...) __PRINTF_ATTRIBUTE__(1, 2); int fprintf(FILE *__stream, const char *__fmt, ...) __PRINTF_ATTRIBUTE__(2, 3); -int vprintf(const char *__fmt, va_list __ap) __PRINTF_ATTRIBUTE__(1, 0); -int vfprintf(FILE *__stream, const char *__fmt, va_list __ap) __PRINTF_ATTRIBUTE__(2, 0); +int vprintf(const char *__fmt, __gnuc_va_list __ap) __PRINTF_ATTRIBUTE__(1, 0); +int vfprintf(FILE *__stream, const char *__fmt, __gnuc_va_list __ap) __PRINTF_ATTRIBUTE__(2, 0); int sprintf(char *__s, const char *__fmt, ...) __PRINTF_ATTRIBUTE__(2, 3); int snprintf(char *__s, size_t __n, const char *__fmt, ...) __PRINTF_ATTRIBUTE__(3, 4); -int vsprintf(char *__s, const char *__fmt, va_list ap) __PRINTF_ATTRIBUTE__(2, 0); -int vsnprintf(char *__s, size_t __n, const char *__fmt, va_list ap) __PRINTF_ATTRIBUTE__(3, 0); +int vsprintf(char *__s, const char *__fmt, __gnuc_va_list ap) __PRINTF_ATTRIBUTE__(2, 0); +int vsnprintf(char *__s, size_t __n, const char *__fmt, __gnuc_va_list ap) __PRINTF_ATTRIBUTE__(3, 0); int asprintf(char **strp, const char *fmt, ...) __PRINTF_ATTRIBUTE__(2,3); -int vasprintf(char **strp, const char *fmt, va_list ap) __PRINTF_ATTRIBUTE__(2,0); +int vasprintf(char **strp, const char *fmt, __gnuc_va_list ap) __PRINTF_ATTRIBUTE__(2,0); int fputs(const char *__str, FILE *__stream); int puts(const char *__str); @@ -248,10 +246,10 @@ int ungetc(int __c, FILE *__stream); int scanf(const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 1, 2); int fscanf(FILE *__stream, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 2, 3); -int vscanf(const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(scanf, 1, 0); -int vfscanf(FILE *__stream, const char *__fmt, va_list __ap) __FORMAT_ATTRIBUTE__(scanf, 2, 0); +int vscanf(const char *__fmt, __gnuc_va_list __ap) __FORMAT_ATTRIBUTE__(scanf, 1, 0); +int vfscanf(FILE *__stream, const char *__fmt, __gnuc_va_list __ap) __FORMAT_ATTRIBUTE__(scanf, 2, 0); int sscanf(const char *__buf, const char *__fmt, ...) __FORMAT_ATTRIBUTE__(scanf, 2, 3); -int vsscanf(const char *__buf, const char *__fmt, va_list ap) __FORMAT_ATTRIBUTE__(scanf, 2, 0); +int vsscanf(const char *__buf, const char *__fmt, __gnuc_va_list ap) __FORMAT_ATTRIBUTE__(scanf, 2, 0); char *fgets(char *__str, int __size, FILE *__stream); char *gets(char *__str); @@ -309,18 +307,26 @@ typedef _fpos_t fpos_t; #if __POSIX_VISIBLE /* * Declare required additional POSIX types. - * - * va_list comes from stdarg.h (included above) */ # ifndef _OFF_T_DECLARED typedef __off_t off_t; /* file offset */ -# define _OFF_T_DECLARED +# define _OFF_T_DECLARED # endif # ifndef _SSIZE_T_DECLARED typedef _ssize_t ssize_t; -# define _SSIZE_T_DECLARED +# define _SSIZE_T_DECLARED +# endif + +/* This needs to agree with */ +# ifdef __GNUC__ +# ifndef _VA_LIST_DEFINED +typedef __gnuc_va_list va_list; +# define _VA_LIST_DEFINED +# endif +# else +# include # endif #endif @@ -389,20 +395,18 @@ int putchar_unlocked (int); * We don't have any way of knowing any underlying POSIX limits, * so just use a reasonably small value here */ +#ifndef TMP_MAX #define TMP_MAX 32 - -#ifdef __cplusplus -} #endif /*@}*/ -static __inline uint32_t +static __inline __uint32_t __printf_float(float f) { union { float f; - uint32_t u; + __uint32_t u; } u = { .f = f }; return u.u; } @@ -488,6 +492,8 @@ __printf_float(float f) # endif #endif +_END_STD_C + #if __SSP_FORTIFY_LEVEL > 0 #include #endif diff --git a/newlib/libc/tinystdio/strtoi.h b/newlib/libc/tinystdio/strtoi.h index 43877c0301..6d29cbd810 100644 --- a/newlib/libc/tinystdio/strtoi.h +++ b/newlib/libc/tinystdio/strtoi.h @@ -31,6 +31,7 @@ */ #include "stdio_private.h" +#include #if defined(_HAVE_BUILTIN_MUL_OVERFLOW) && defined(_HAVE_BUILTIN_ADD_OVERFLOW) && !defined(strtoi_signed) #define USE_OVERFLOW From 37f520a6d99c552e576cc546c901a0b8fe2f4303 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 6 Aug 2024 18:24:07 -0700 Subject: [PATCH 29/42] signal: Remove sys/signal.h, clean up signal.h Follow POSIX requirements for visible symbols by placing them all in signal.h and then cleaning that up to stop making other symbols visible. Signed-off-by: Keith Packard --- newlib/libc/include/signal.h | 243 ++++++++++++++- newlib/libc/include/sys/CMakeLists.txt | 2 +- newlib/libc/include/sys/_select.h | 84 ++++++ newlib/libc/include/sys/_timespec.h | 4 +- newlib/libc/include/sys/_timeval.h | 2 - newlib/libc/include/sys/meson.build | 2 +- newlib/libc/include/sys/sched.h | 1 + newlib/libc/include/sys/select.h | 72 +---- newlib/libc/include/sys/signal.h | 397 ------------------------- newlib/libc/include/sys/syslimits.h | 4 + newlib/libc/include/sys/time.h | 78 ++--- newlib/libc/include/time.h | 5 +- newlib/libc/signal/sig2str.c | 2 +- newlib/libc/signal/signal.c | 15 +- 14 files changed, 370 insertions(+), 541 deletions(-) create mode 100644 newlib/libc/include/sys/_select.h delete mode 100644 newlib/libc/include/sys/signal.h diff --git a/newlib/libc/include/signal.h b/newlib/libc/include/signal.h index 24712cbb8f..5f774b77ff 100644 --- a/newlib/libc/include/signal.h +++ b/newlib/libc/include/signal.h @@ -35,28 +35,253 @@ SUCH DAMAGE. #define _SIGNAL_H_ #include -#include +#define __need_size_t +#include +#include +#include +#include _BEGIN_STD_C typedef int sig_atomic_t; /* Atomic entity type (ANSI) */ + +typedef void (*_sig_func_ptr)(int); + +#define SIG_DFL ((_sig_func_ptr)0) /* Default action */ +#define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */ +#define SIG_ERR ((_sig_func_ptr)-1) /* Error return */ + +#if __POSIX_VISIBLE + +#ifndef _UID_T_DECLARED +typedef __uid_t uid_t; /* user id */ +#define _UID_T_DECLARED +#endif + +#if !defined(_SIGSET_T_DECLARED) +#define _SIGSET_T_DECLARED +typedef __sigset_t sigset_t; +#endif + +union sigval { + int sival_int; /* Integer signal value */ + void *sival_ptr; /* Pointer signal value */ +}; + +/* Signal Actions, P1003.1b-1993, p. 64 */ +/* si_code values, p. 66 */ + +#define SI_USER 1 /* Sent by a user. kill(), abort(), etc */ +#define SI_QUEUE 2 /* Sent by sigqueue() */ +#define SI_TIMER 3 /* Sent by expiration of a timer_settime() timer */ +#define SI_ASYNCIO 4 /* Indicates completion of asycnhronous IO */ +#define SI_MESGQ 5 /* Indicates arrival of a message at an empty queue */ + +typedef struct { + int si_signo; /* Signal number */ + int si_code; /* Cause of the signal */ + int si_errno; /* If non-zero, the errno */ + __pid_t si_pid; /* Sending process ID */ + uid_t si_uid; /* Real UID of sending process */ + void *si_addr; /* Address of faulting instruction */ + int si_status; /* Exit value or signal */ + union sigval si_value; /* Signal value */ +} siginfo_t; + +/* + * Possible values for sa_flags in sigaction below. + */ + +#define SA_NOCLDSTOP (1 << 0) +#define SA_ONSTACK (1 << 1) +#define SA_RESETHAND (1 << 2) +#define SA_RESTART (1 << 3) +#define SA_SIGINFO (1 << 4) +#define SA_NOCLDWAIT (1 << 5) +#define SA_NODEFER (1 << 6) + +struct sigaction { + union { + void (*sa_handler)(int); + void (*sa_sigaction)(int, siginfo_t *, void *); + }; + sigset_t sa_mask; + int sa_flags; +}; + +/* + * Possible values for ss_flags in stack_t below. + */ +#define SS_ONSTACK 0x1 +#define SS_DISABLE 0x2 + +/* + * Structure used in sigaltstack call. + */ +typedef struct sigaltstack { + void *ss_sp; /* Stack base or pointer. */ + int ss_flags; /* Flags. */ + size_t ss_size; /* Stack size. */ +} stack_t; + +#define SIG_SETMASK 0 /* set mask with sigprocmask() */ +#define SIG_BLOCK 1 /* set of signals to block */ +#define SIG_UNBLOCK 2 /* set of signals to unblock */ + +#endif /* __POSIX_VISIBLE */ + +#if defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 + +/* sigev_notify values + NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */ + +#define SIGEV_NONE 1 /* No asynchronous notification shall be delivered */ + /* when the event of interest occurs. */ +#define SIGEV_SIGNAL 2 /* A queued signal, with an application defined */ + /* value, shall be delivered when the event of */ + /* interest occurs. */ +#define SIGEV_THREAD 3 /* A notification function shall be called to */ + /* perform notification. */ + +/* Signal Generation and Delivery, P1003.1b-1993, p. 63 + NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and + sigev_notify_attributes to the sigevent structure. */ + +struct sigevent { + int sigev_notify; /* Notification type */ + int sigev_signo; /* Signal number */ + union sigval sigev_value; /* Signal value */ + void (*sigev_notify_function)( union sigval ); + /* Notification function */ + void *sigev_notify_attributes; /* Notification Attributes */ +}; +#endif /* defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 */ + + +#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 + +/* + * Minimum and default signal stack constants. Allow for target overrides + * from . + */ +#ifndef MINSIGSTKSZ +#define MINSIGSTKSZ 2048 +#endif +#ifndef SIGSTKSZ +#define SIGSTKSZ 8192 +#endif + +#endif + +#define SIGHUP 1 /* hangup */ +#define SIGINT 2 /* interrupt */ +#define SIGQUIT 3 /* quit */ +#define SIGILL 4 /* illegal instruction (not reset when caught) */ +#define SIGTRAP 5 /* trace trap (not reset when caught) */ +#define SIGIOT 6 /* IOT instruction */ +#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ +#define SIGEMT 7 /* EMT instruction */ +#define SIGFPE 8 /* floating point exception */ +#define SIGKILL 9 /* kill (cannot be caught or ignored) */ +#define SIGBUS 10 /* bus error */ +#define SIGSEGV 11 /* segmentation violation */ +#define SIGSYS 12 /* bad argument to system call */ +#define SIGPIPE 13 /* write on a pipe with no one to read it */ +#define SIGALRM 14 /* alarm clock */ +#define SIGTERM 15 /* software termination signal from kill */ +#define SIGURG 16 /* urgent condition on IO channel */ +#define SIGSTOP 17 /* sendable stop signal not from tty */ +#define SIGTSTP 18 /* stop signal from tty */ +#define SIGCONT 19 /* continue a stopped process */ +#define SIGCHLD 20 /* to parent on child stop or exit */ +#define SIGCLD 20 /* System V name for SIGCHLD */ +#define SIGTTIN 21 /* to readers pgrp upon background tty read */ +#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ +#define SIGIO 23 /* input/output possible signal */ +#define SIGPOLL SIGIO /* System V name for SIGIO */ +#define SIGXCPU 24 /* exceeded CPU time limit */ +#define SIGXFSZ 25 /* exceeded file size limit */ +#define SIGVTALRM 26 /* virtual time alarm */ +#define SIGPROF 27 /* profiling time alarm */ +#define SIGWINCH 28 /* window changed */ +#define SIGLOST 29 /* resource lost (eg, record-lock lost) */ +#define SIGUSR1 30 /* user defined signal 1 */ +#define SIGUSR2 31 /* user defined signal 2 */ +#define _NSIG 32 + +/* Using __MISC_VISIBLE until POSIX Issue 8 is officially released */ +#if __MISC_VISIBLE +#if __SIZEOF_INT__ >= 4 +#define SIG2STR_MAX 17 /* (sizeof("RTMAX+") + sizeof("4294967295") - 1) */ +#else +#define SIG2STR_MAX 12 /* (sizeof("RTMAX+") + sizeof("65535") - 1) */ +#endif +#endif + #if __BSD_VISIBLE typedef _sig_func_ptr sig_t; /* BSD naming */ #endif + #if __GNU_VISIBLE typedef _sig_func_ptr sighandler_t; /* glibc naming */ #endif -#define SIG_DFL ((_sig_func_ptr)0) /* Default action */ -#define SIG_IGN ((_sig_func_ptr)1) /* Ignore action */ -#define SIG_ERR ((_sig_func_ptr)-1) /* Error return */ - -_sig_func_ptr signal (int, _sig_func_ptr); -int raise (int); +#if __POSIX_VISIBLE +int kill(__pid_t pid, int sig); +#endif +#if __XSI_VISIBLE >= 500 +int killpg(__pid_t pid, int sig); +#endif +#if __POSIX_VISIBLE >= 200809L +void psiginfo(const siginfo_t *, const char *); +#endif +#if __BSD_VISIBLE || __SVID_VISIBLE void psignal (int, const char *); - +#endif +int raise (int); +#if __MISC_VISIBLE +int sig2str(int, char *); +#endif +#if __POSIX_VISIBLE +int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict); +int sigaddset (sigset_t *, const int); +#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0) +#endif +#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 +int sigaltstack (const stack_t *__restrict, stack_t *__restrict); +#endif +#if __POSIX_VISIBLE +int sigdelset (sigset_t *, const int); +#define sigdelset(what,sig) (*(what) &= ~((sigset_t)1<<(sig)), 0) +int sigemptyset (sigset_t *); +#define sigemptyset(what) (*(what) = (sigset_t) 0, 0) +int sigfillset (sigset_t *); +#define sigfillset(what) (*(what) = ~((sigset_t)0), 0) +int sigismember (const sigset_t *, int); +#define sigismember(what,sig) (((*(what)) & ((sigset_t) 1<<(sig))) != 0) +#endif +_sig_func_ptr signal (int, _sig_func_ptr); +#if __POSIX_VISIBLE +int sigpending (sigset_t *); +int sigprocmask (int, const sigset_t *, sigset_t *); +#endif +#if __POSIX_VISIBLE >= 199309L +int sigqueue (__pid_t, int, const union sigval); +#endif #if __POSIX_VISIBLE -int kill(__pid_t pid, int sig); +int sigsuspend (const sigset_t *); +#endif +#if __POSIX_VISIBLE >= 199309L +int sigtimedwait (const sigset_t *, siginfo_t *, const struct timespec *); +#endif +#if __POSIX_VISIBLE >= 199506L +int sigwait (const sigset_t *, int *); +#endif +#if __POSIX_VISIBLE >= 199309L +int sigwaitinfo (const sigset_t *, siginfo_t *); +#endif +#if __MISC_VISIBLE +int str2sig(const char *__restrict, int *__restrict); #endif _END_STD_C diff --git a/newlib/libc/include/sys/CMakeLists.txt b/newlib/libc/include/sys/CMakeLists.txt index 973b8edfc7..e45aaca9e0 100644 --- a/newlib/libc/include/sys/CMakeLists.txt +++ b/newlib/libc/include/sys/CMakeLists.txt @@ -55,7 +55,7 @@ picolibc_headers(sys resource.h sched.h select.h - signal.h + _select.h _sigset.h stat.h _stdint.h diff --git a/newlib/libc/include/sys/_select.h b/newlib/libc/include/sys/_select.h new file mode 100644 index 0000000000..4d1e13e9d0 --- /dev/null +++ b/newlib/libc/include/sys/_select.h @@ -0,0 +1,84 @@ +/* +Copyright (c) 1982, 1986, 1993 +The Regents of the University of California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +3. Neither the name of the University nor the names of its contributors +may be used to endorse or promote products derived from this software +without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + */ + +#ifndef _SYS__SELECT_H +#define _SYS__SELECT_H + +_BEGIN_STD_C + +# define _SYS_TYPES_FD_SET +/* + * Select uses bit masks of file descriptors in longs. + * These macros manipulate such bit fields (the filesystem macros use chars). + * FD_SETSIZE may be defined by the user, but the default here + * should be enough for most uses. + */ +#ifndef FD_SETSIZE +# if defined(__rtems__) +# define FD_SETSIZE 256 +# else +# define FD_SETSIZE 64 +# endif +#endif + +typedef unsigned long __fd_mask; +#if __BSD_VISIBLE +typedef __fd_mask fd_mask; +#endif + +#define __NFDBITS ((int)sizeof(__fd_mask) * 8) /* bits per mask */ +#define __FD_ARRAY_SIZE ((FD_SETSIZE + __NFDBITS - 1) / __NFDBITS) +#if __BSD_VISIBLE +#define NFDBITS __NFDBITS +#endif + +typedef struct fd_set { + __fd_mask __fds_bits[__FD_ARRAY_SIZE]; +} fd_set; + +#define __fdset_mask(n) ((__fd_mask)1 << ((n) % __NFDBITS)) +#define FD_CLR(n, p) ((p)->__fds_bits[(n)/__NFDBITS] &= ~__fdset_mask(n)) +#if __BSD_VISIBLE +#define FD_COPY(f, t) (void)(*(t) = *(f)) +#endif +#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/__NFDBITS] & __fdset_mask(n)) != 0) +#define FD_SET(n, p) ((p)->__fds_bits[(n)/__NFDBITS] |= __fdset_mask(n)) +#define FD_ZERO(p) do { \ + fd_set *__p = (p); \ + __size_t __i; \ + for (__i = 0; __i < __FD_ARRAY_SIZE; i++) \ + __p->__fds_bits[__i] = 0; \ + } while (0) + +int select (int __n, fd_set *__readfds, fd_set *__writefds, + fd_set *__exceptfds, struct timeval *__timeout); + +_END_STD_C + +#endif /* sys/_select.h */ diff --git a/newlib/libc/include/sys/_timespec.h b/newlib/libc/include/sys/_timespec.h index 3a4c7221d8..036bd29863 100644 --- a/newlib/libc/include/sys/_timespec.h +++ b/newlib/libc/include/sys/_timespec.h @@ -36,10 +36,8 @@ #ifndef _SYS__TIMESPEC_H_ #define _SYS__TIMESPEC_H_ -#include - #ifndef _TIME_T_DECLARED -typedef _TIME_T_ time_t; +typedef __time_t time_t; #define _TIME_T_DECLARED #endif diff --git a/newlib/libc/include/sys/_timeval.h b/newlib/libc/include/sys/_timeval.h index 97abeae8e7..a68e5a81b9 100644 --- a/newlib/libc/include/sys/_timeval.h +++ b/newlib/libc/include/sys/_timeval.h @@ -31,8 +31,6 @@ #ifndef _SYS__TIMEVAL_H_ #define _SYS__TIMEVAL_H_ -#include - #ifndef _SUSECONDS_T_DECLARED typedef __suseconds_t suseconds_t; #define _SUSECONDS_T_DECLARED diff --git a/newlib/libc/include/sys/meson.build b/newlib/libc/include/sys/meson.build index 125c927242..1cfc7482a9 100644 --- a/newlib/libc/include/sys/meson.build +++ b/newlib/libc/include/sys/meson.build @@ -55,7 +55,7 @@ inc_sys_headers_all = [ 'resource.h', 'sched.h', 'select.h', - 'signal.h', + '_select.h', '_sigset.h', 'stat.h', '_stdint.h', diff --git a/newlib/libc/include/sys/sched.h b/newlib/libc/include/sys/sched.h index 494cd2cafc..667aa370c0 100644 --- a/newlib/libc/include/sys/sched.h +++ b/newlib/libc/include/sys/sched.h @@ -22,6 +22,7 @@ #define _SYS_SCHED_H_ #include +#include #include _BEGIN_STD_C diff --git a/newlib/libc/include/sys/select.h b/newlib/libc/include/sys/select.h index 39299de54a..586a1d2c1c 100644 --- a/newlib/libc/include/sys/select.h +++ b/newlib/libc/include/sys/select.h @@ -30,84 +30,20 @@ SUCH DAMAGE. #ifndef _SYS_SELECT_H #define _SYS_SELECT_H -/* We don't define fd_set and friends if we are compiling POSIX - source, or if we have included (or may include as indicated - by __USE_W32_SOCKETS) the W32api winsock[2].h header which - defines Windows versions of them. Note that a program which - includes the W32api winsock[2].h header must know what it is doing; - it must not call the Cygwin select function. -*/ -# if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS)) - #include +#include #include #include #include +#include #if !defined(_SIGSET_T_DECLARED) #define _SIGSET_T_DECLARED typedef __sigset_t sigset_t; #endif -# define _SYS_TYPES_FD_SET -/* - * Select uses bit masks of file descriptors in longs. - * These macros manipulate such bit fields (the filesystem macros use chars). - * FD_SETSIZE may be defined by the user, but the default here - * should be enough for most uses. - */ -#ifndef FD_SETSIZE -# if defined(__rtems__) -# define FD_SETSIZE 256 -# else -# define FD_SETSIZE 64 -# endif -#endif - -typedef unsigned long __fd_mask; -#if __BSD_VISIBLE -typedef __fd_mask fd_mask; -#endif - -#define _NFDBITS ((int)sizeof(__fd_mask) * 8) /* bits per mask */ -#if __BSD_VISIBLE -#define NFDBITS _NFDBITS -#endif - -#ifndef _howmany -#define _howmany(x,y) (((x) + ((y) - 1)) / (y)) -#endif - -typedef struct fd_set { - __fd_mask __fds_bits[_howmany(FD_SETSIZE, _NFDBITS)]; -} fd_set; -#if __BSD_VISIBLE -#define fds_bits __fds_bits -#endif - -#define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS)) -#define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n)) -#if __BSD_VISIBLE -#define FD_COPY(f, t) (void)(*(t) = *(f)) -#endif -#define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0) -#define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n)) -#define FD_ZERO(p) do { \ - fd_set *_p; \ - __size_t _n; \ - \ - _p = (p); \ - _n = _howmany(FD_SETSIZE, _NFDBITS); \ - while (_n > 0) \ - _p->__fds_bits[--_n] = 0; \ -} while (0) - -#if !defined (__INSIDE_CYGWIN_NET__) - __BEGIN_DECLS -int select __P ((int __n, fd_set *__readfds, fd_set *__writefds, - fd_set *__exceptfds, struct timeval *__timeout)); #if __POSIX_VISIBLE >= 200112 int pselect __P ((int __n, fd_set *__readfds, fd_set *__writefds, fd_set *__exceptfds, const struct timespec *__timeout, @@ -116,8 +52,4 @@ int pselect __P ((int __n, fd_set *__readfds, fd_set *__writefds, __END_DECLS -#endif /* !__INSIDE_CYGWIN_NET__ */ - -#endif /* !(_WINSOCK_H || _WINSOCKAPI_ || __USE_W32_SOCKETS) */ - #endif /* sys/select.h */ diff --git a/newlib/libc/include/sys/signal.h b/newlib/libc/include/sys/signal.h deleted file mode 100644 index ac60fb19e0..0000000000 --- a/newlib/libc/include/sys/signal.h +++ /dev/null @@ -1,397 +0,0 @@ -/* -Copyright (c) 1982, 1986, 1993 -The Regents of the University of California. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. -3. Neither the name of the University nor the names of its contributors -may be used to endorse or promote products derived from this software -without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - */ -/* sys/signal.h */ - -#ifndef _SYS_SIGNAL_H -#define _SYS_SIGNAL_H -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include - -#if !defined(_SIGSET_T_DECLARED) -#define _SIGSET_T_DECLARED -typedef __sigset_t sigset_t; -#endif - - -#if defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 - -/* sigev_notify values - NOTE: P1003.1c/D10, p. 34 adds SIGEV_THREAD. */ - -#define SIGEV_NONE 1 /* No asynchronous notification shall be delivered */ - /* when the event of interest occurs. */ -#define SIGEV_SIGNAL 2 /* A queued signal, with an application defined */ - /* value, shall be delivered when the event of */ - /* interest occurs. */ -#define SIGEV_THREAD 3 /* A notification function shall be called to */ - /* perform notification. */ - -/* Signal Generation and Delivery, P1003.1b-1993, p. 63 - NOTE: P1003.1c/D10, p. 34 adds sigev_notify_function and - sigev_notify_attributes to the sigevent structure. */ - -union sigval { - int sival_int; /* Integer signal value */ - void *sival_ptr; /* Pointer signal value */ -}; - -struct sigevent { - int sigev_notify; /* Notification type */ - int sigev_signo; /* Signal number */ - union sigval sigev_value; /* Signal value */ -#if defined(_POSIX_THREADS) - void (*sigev_notify_function)( union sigval ); - /* Notification function */ - pthread_attr_t *sigev_notify_attributes; /* Notification Attributes */ -#endif -}; - -/* Signal Actions, P1003.1b-1993, p. 64 */ -/* si_code values, p. 66 */ - -#define SI_USER 1 /* Sent by a user. kill(), abort(), etc */ -#define SI_QUEUE 2 /* Sent by sigqueue() */ -#define SI_TIMER 3 /* Sent by expiration of a timer_settime() timer */ -#define SI_ASYNCIO 4 /* Indicates completion of asycnhronous IO */ -#define SI_MESGQ 5 /* Indicates arrival of a message at an empty queue */ - -typedef struct { - int si_signo; /* Signal number */ - int si_code; /* Cause of the signal */ - union sigval si_value; /* Signal value */ -} siginfo_t; -#endif /* defined(_POSIX_REALTIME_SIGNALS) || __POSIX_VISIBLE >= 199309 */ - -#if defined(__rtems__) - -/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 */ - -#define SA_NOCLDSTOP 0x1 /* Do not generate SIGCHLD when children stop */ -#define SA_SIGINFO 0x2 /* Invoke the signal catching function with */ - /* three arguments instead of one. */ -#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 -#define SA_ONSTACK 0x4 /* Signal delivery will be on a separate stack. */ -#endif - -/* struct sigaction notes from POSIX: - * - * (1) Routines stored in sa_handler should take a single int as - * their argument although the POSIX standard does not require this. - * This is not longer true since at least POSIX.1-2008 - * (2) The fields sa_handler and sa_sigaction may overlap, and a conforming - * application should not use both simultaneously. - */ - -typedef void (*_sig_func_ptr)(int); - -struct sigaction { - int sa_flags; /* Special flags to affect behavior of signal */ - sigset_t sa_mask; /* Additional set of signals to be blocked */ - /* during execution of signal-catching */ - /* function. */ - union { - _sig_func_ptr _handler; /* SIG_DFL, SIG_IGN, or pointer to a function */ -#if defined(_POSIX_REALTIME_SIGNALS) - void (*_sigaction)( int, siginfo_t *, void * ); -#endif - } _signal_handlers; -}; - -#define sa_handler _signal_handlers._handler -#if defined(_POSIX_REALTIME_SIGNALS) -#define sa_sigaction _signal_handlers._sigaction -#endif - -#else /* defined(__rtems__) */ - -#define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */ - -typedef void (*_sig_func_ptr)(int); - -struct sigaction -{ - _sig_func_ptr sa_handler; - sigset_t sa_mask; - int sa_flags; -}; -#endif /* defined(__rtems__) */ - -#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 -/* - * Minimum and default signal stack constants. Allow for target overrides - * from . - */ -#ifndef MINSIGSTKSZ -#define MINSIGSTKSZ 2048 -#endif -#ifndef SIGSTKSZ -#define SIGSTKSZ 8192 -#endif - -/* - * Possible values for ss_flags in stack_t below. - */ -#define SS_ONSTACK 0x1 -#define SS_DISABLE 0x2 - -#endif - -/* - * Structure used in sigaltstack call. - */ -typedef struct sigaltstack { - void *ss_sp; /* Stack base or pointer. */ - int ss_flags; /* Flags. */ - size_t ss_size; /* Stack size. */ -} stack_t; - -#if __POSIX_VISIBLE -#define SIG_SETMASK 0 /* set mask with sigprocmask() */ -#define SIG_BLOCK 1 /* set of signals to block */ -#define SIG_UNBLOCK 2 /* set of signals to, well, unblock */ - -int sigprocmask (int, const sigset_t *, sigset_t *); -#endif - -#if __POSIX_VISIBLE >= 199506 -int pthread_sigmask (int, const sigset_t *, sigset_t *); -#endif - -#if __POSIX_VISIBLE -int kill (pid_t, int); -#endif - -#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 -int killpg (pid_t, int); -#endif -#if __POSIX_VISIBLE -int sigaction (int, const struct sigaction *, struct sigaction *); -int sigaddset (sigset_t *, const int); -int sigdelset (sigset_t *, const int); -int sigismember (const sigset_t *, int); -int sigfillset (sigset_t *); -int sigemptyset (sigset_t *); -int sigpending (sigset_t *); -int sigsuspend (const sigset_t *); -int sigwait (const sigset_t *, int *); - -#if !defined(__CYGWIN__) && !defined(__rtems__) -/* These depend upon the type of sigset_t, which right now - is always a long.. They're in the POSIX namespace, but - are not ANSI. */ -#define sigaddset(what,sig) (*(what) |= (1<<(sig)), 0) -#define sigdelset(what,sig) (*(what) &= ~(1<<(sig)), 0) -#define sigemptyset(what) (*(what) = 0, 0) -#define sigfillset(what) (*(what) = ~(0), 0) -#define sigismember(what,sig) (((*(what)) & (1<<(sig))) != 0) -#endif /* !__CYGWIN__ && !__rtems__ */ -#endif /* __POSIX_VISIBLE */ - -/* There are two common sigpause variants, both of which take an int argument. - If you request _XOPEN_SOURCE or _GNU_SOURCE, you get the System V version, - which removes the given signal from the process's signal mask; otherwise - you get the BSD version, which sets the process's signal mask to the given - value. */ -#if __XSI_VISIBLE && !defined(__INSIDE_CYGWIN__) -# ifdef __GNUC__ -int sigpause (int) __asm__ (__ASMNAME ("__xpg_sigpause")); -# else -int __xpg_sigpause (int); -# define sigpause __xpg_sigpause -# endif -#elif __BSD_VISIBLE -int sigpause (int); -#endif - -#if __BSD_VISIBLE || __XSI_VISIBLE >= 4 || __POSIX_VISIBLE >= 200809 -int sigaltstack (const stack_t *__restrict, stack_t *__restrict); -#endif - -#if __POSIX_VISIBLE >= 199309 - -/* 3.3.8 Synchronously Accept a Signal, P1003.1b-1993, p. 76 - NOTE: P1003.1c/D10, p. 39 adds sigwait(). */ - -int sigwaitinfo (const sigset_t *, siginfo_t *); -int sigtimedwait (const sigset_t *, siginfo_t *, const struct timespec *); -/* 3.3.9 Queue a Signal to a Process, P1003.1b-1993, p. 78 */ -int sigqueue (pid_t, int, const union sigval); - -#endif /* __POSIX_VISIBLE >= 199309 */ - -/* Using __MISC_VISIBLE until POSIX Issue 8 is officially released */ -#if __MISC_VISIBLE - -/* POSIX Issue 8 adds sig2str() and str2sig() */ - -#if __SIZEOF_INT__ >= 4 -#define SIG2STR_MAX 17 /* (sizeof("RTMAX+") + sizeof("4294967295") - 1) */ -#else -#define SIG2STR_MAX 12 /* (sizeof("RTMAX+") + sizeof("65535") - 1) */ -#endif - -int sig2str(int, char *); -int str2sig(const char *__restrict, int *__restrict); - -#endif /* __MISC_VISIBLE */ - -#if defined(___AM29K__) -/* These all need to be defined for ANSI C, but I don't think they are - meaningful. */ -#define SIGABRT 1 -#define SIGFPE 1 -#define SIGILL 1 -#define SIGINT 1 -#define SIGSEGV 1 -#define SIGTERM 1 -/* These need to be defined for POSIX, and some others do too. */ -#define SIGHUP 1 -#define SIGQUIT 1 -#define NSIG 2 -#elif defined(__GO32__) -#define SIGINT 1 -#define SIGKILL 2 -#define SIGPIPE 3 -#define SIGFPE 4 -#define SIGHUP 5 -#define SIGTERM 6 -#define SIGSEGV 7 -#define SIGTSTP 8 -#define SIGQUIT 9 -#define SIGTRAP 10 -#define SIGILL 11 -#define SIGEMT 12 -#define SIGALRM 13 -#define SIGBUS 14 -#define SIGLOST 15 -#define SIGSTOP 16 -#define SIGABRT 17 -#define SIGUSR1 18 -#define SIGUSR2 19 -#define NSIG 20 -#elif !defined(SIGTRAP) -#define SIGHUP 1 /* hangup */ -#define SIGINT 2 /* interrupt */ -#define SIGQUIT 3 /* quit */ -#define SIGILL 4 /* illegal instruction (not reset when caught) */ -#define SIGTRAP 5 /* trace trap (not reset when caught) */ -#define SIGIOT 6 /* IOT instruction */ -#define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ -#define SIGEMT 7 /* EMT instruction */ -#define SIGFPE 8 /* floating point exception */ -#define SIGKILL 9 /* kill (cannot be caught or ignored) */ -#define SIGBUS 10 /* bus error */ -#define SIGSEGV 11 /* segmentation violation */ -#define SIGSYS 12 /* bad argument to system call */ -#define SIGPIPE 13 /* write on a pipe with no one to read it */ -#define SIGALRM 14 /* alarm clock */ -#define SIGTERM 15 /* software termination signal from kill */ - -#if defined(__rtems__) -#define SIGURG 16 /* urgent condition on IO channel */ -#define SIGSTOP 17 /* sendable stop signal not from tty */ -#define SIGTSTP 18 /* stop signal from tty */ -#define SIGCONT 19 /* continue a stopped process */ -#define SIGCHLD 20 /* to parent on child stop or exit */ -#define SIGCLD 20 /* System V name for SIGCHLD */ -#define SIGTTIN 21 /* to readers pgrp upon background tty read */ -#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ -#define SIGIO 23 /* input/output possible signal */ -#define SIGPOLL SIGIO /* System V name for SIGIO */ -#define SIGWINCH 24 /* window changed */ -#define SIGUSR1 25 /* user defined signal 1 */ -#define SIGUSR2 26 /* user defined signal 2 */ - -/* Real-Time Signals Range, P1003.1b-1993, p. 61 - NOTE: By P1003.1b-1993, this should be at least RTSIG_MAX - (which is a minimum of 8) signals. - */ -#define SIGRTMIN 27 -#define SIGRTMAX 31 -#define __SIGFIRSTNOTRT SIGHUP -#define __SIGLASTNOTRT SIGUSR2 - -#define NSIG 32 /* signal 0 implied */ - -#elif defined(__svr4__) -/* svr4 specifics. different signals above 15, and sigaction. */ -#define SIGUSR1 16 -#define SIGUSR2 17 -#define SIGCLD 18 -#define SIGPWR 19 -#define SIGWINCH 20 -#define SIGPOLL 22 /* 20 for x.out binaries!!!! */ -#define SIGSTOP 23 /* sendable stop signal not from tty */ -#define SIGTSTP 24 /* stop signal from tty */ -#define SIGCONT 25 /* continue a stopped process */ -#define SIGTTIN 26 /* to readers pgrp upon background tty read */ -#define SIGTTOU 27 /* like TTIN for output if (tp->t_local<OSTOP) */ -#define NSIG 28 -#else -#define SIGURG 16 /* urgent condition on IO channel */ -#define SIGSTOP 17 /* sendable stop signal not from tty */ -#define SIGTSTP 18 /* stop signal from tty */ -#define SIGCONT 19 /* continue a stopped process */ -#define SIGCHLD 20 /* to parent on child stop or exit */ -#define SIGCLD 20 /* System V name for SIGCHLD */ -#define SIGTTIN 21 /* to readers pgrp upon background tty read */ -#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ -#define SIGIO 23 /* input/output possible signal */ -#define SIGPOLL SIGIO /* System V name for SIGIO */ -#define SIGXCPU 24 /* exceeded CPU time limit */ -#define SIGXFSZ 25 /* exceeded file size limit */ -#define SIGVTALRM 26 /* virtual time alarm */ -#define SIGPROF 27 /* profiling time alarm */ -#define SIGWINCH 28 /* window changed */ -#define SIGLOST 29 /* resource lost (eg, record-lock lost) */ -#define SIGUSR1 30 /* user defined signal 1 */ -#define SIGUSR2 31 /* user defined signal 2 */ -#define NSIG 32 /* signal 0 implied */ -#endif -#endif - -#ifdef __cplusplus -} -#endif - - -#ifndef _SIGNAL_H_ -/* Some applications take advantage of the fact that - * and are equivalent in glibc. Allow for that here. */ -#include -#endif -#endif /* _SYS_SIGNAL_H */ diff --git a/newlib/libc/include/sys/syslimits.h b/newlib/libc/include/sys/syslimits.h index 7d524e0665..db575cdec2 100644 --- a/newlib/libc/include/sys/syslimits.h +++ b/newlib/libc/include/sys/syslimits.h @@ -60,4 +60,8 @@ #define LINE_MAX 2048 /* max bytes in an input line */ #define RE_DUP_MAX 255 /* max RE's in interval notation */ +#if __POSIX_VISIBLE +#define NSIG_MAX __LONG_WIDTH__ /* max signal number */ +#endif + #endif diff --git a/newlib/libc/include/sys/time.h b/newlib/libc/include/sys/time.h index bf5d6ff565..1dfbb0bffa 100644 --- a/newlib/libc/include/sys/time.h +++ b/newlib/libc/include/sys/time.h @@ -40,15 +40,15 @@ #define _SYS_TIME_H_ #include -#include #include +#include #include -#include +#include _BEGIN_STD_C #ifndef _TIME_T_DECLARED -typedef _TIME_T_ time_t; +typedef __time_t time_t; #define _TIME_T_DECLARED #endif @@ -57,10 +57,38 @@ typedef __suseconds_t suseconds_t; #define _SUSECONDS_T_DECLARED #endif +/* + * Names of the interval timers, and structure + * defining a timer setting. + */ +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 + +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +int getitimer (int __which, struct itimerval *__value); +int gettimeofday (struct timeval *__restrict __p, + void *__restrict __tz); +int setitimer (int __which, const struct itimerval *__restrict __value, + struct itimerval *__restrict __ovalue); +int utimes (const char *, const struct timeval [2]); + +#if __BSD_VISIBLE + struct timezone { int tz_minuteswest; /* minutes west of Greenwich */ int tz_dsttime; /* type of dst correction */ }; + +int adjtime (const struct timeval *, struct timeval *); +int futimes (int, const struct timeval [2]); +int lutimes (const char *, const struct timeval [2]); +int settimeofday (const struct timeval *, const struct timezone *); + #define DST_NONE 0 /* not on dst */ #define DST_USA 1 /* USA style dst */ #define DST_AUST 2 /* Australian style dst */ @@ -69,8 +97,6 @@ struct timezone { #define DST_EET 5 /* Eastern European dst */ #define DST_CAN 6 /* Canada */ -#if __BSD_VISIBLE - #ifndef _SBINTIME_T_DECLARED typedef __int64_t sbintime_t; #define _SBINTIME_T_DECLARED @@ -382,8 +408,6 @@ tvtosbt(struct timeval _tv) } \ } while (0) -#ifndef _KERNEL /* NetBSD/OpenBSD compatible interfaces */ - #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) #define timercmp(tvp, uvp, cmp) \ @@ -408,51 +432,13 @@ tvtosbt(struct timeval _tv) (vvp)->tv_usec += 1000000; \ } \ } while (0) -#endif -#endif /* __BSD_VISIBLE */ - -/* - * Names of the interval timers, and structure - * defining a timer setting. - */ -#define ITIMER_REAL 0 -#define ITIMER_VIRTUAL 1 -#define ITIMER_PROF 2 - -struct itimerval { - struct timeval it_interval; /* timer interval */ - struct timeval it_value; /* current value */ -}; - -#ifndef _KERNEL - -int utimes (const char *, const struct timeval [2]); -#if __BSD_VISIBLE -int adjtime (const struct timeval *, struct timeval *); -int futimes (int, const struct timeval [2]); -int lutimes (const char *, const struct timeval [2]); -int settimeofday (const struct timeval *, const struct timezone *); -#endif - -#if __MISC_VISIBLE || __XSI_VISIBLE -int getitimer (int __which, struct itimerval *__value); -int setitimer (int __which, const struct itimerval *__restrict __value, - struct itimerval *__restrict __ovalue); -#endif - -int gettimeofday (struct timeval *__restrict __p, - void *__restrict __tz); +#endif /* __BSD_VISIBLE */ #if __GNU_VISIBLE int futimesat (int, const char *, const struct timeval [2]); #endif -#ifdef _LIBC -int _gettimeofday (struct timeval *__p, void *__tz); -#endif - -#endif /* !_KERNEL */ #include _END_STD_C diff --git a/newlib/libc/include/time.h b/newlib/libc/include/time.h index ec86ded7a3..fb4f6c543b 100644 --- a/newlib/libc/include/time.h +++ b/newlib/libc/include/time.h @@ -45,12 +45,11 @@ SUCH DAMAGE. #define __need_size_t #define __need_NULL #include +#include +#include _BEGIN_STD_C -/* Get time_t and struct timespec */ -#include - #ifndef _CLOCKS_PER_SEC_ #define _CLOCKS_PER_SEC_ 1000000 #endif diff --git a/newlib/libc/signal/sig2str.c b/newlib/libc/signal/sig2str.c index 96e8ad5535..c35d574607 100644 --- a/newlib/libc/signal/sig2str.c +++ b/newlib/libc/signal/sig2str.c @@ -293,7 +293,7 @@ str2sig(const char *__restrict str, int *__restrict pnum) /* If str is a representation of a decimal value, save its integer value * in pnum. */ if (1 <= is_valid_decimal && - is_valid_decimal <= (NSIG - 1)) { + is_valid_decimal <= (_NSIG - 1)) { *pnum = is_valid_decimal; return 0; } diff --git a/newlib/libc/signal/signal.c b/newlib/libc/signal/signal.c index 77c27e3016..7af81ea292 100644 --- a/newlib/libc/signal/signal.c +++ b/newlib/libc/signal/signal.c @@ -105,23 +105,22 @@ without an operating system that can actually raise exceptions. #ifdef _USE_ATOMIC_SIGNAL #include -static _Atomic uintptr_t _sig_func[NSIG]; +static _Atomic _sig_func_ptr _sig_func[_NSIG]; #else -static _sig_func_ptr _sig_func[NSIG]; +static _sig_func_ptr _sig_func[_NSIG]; #endif _sig_func_ptr signal (int sig, _sig_func_ptr func) { - if (sig < 0 || sig >= NSIG) + if (sig < 0 || sig >= _NSIG) { errno = EINVAL; return SIG_ERR; } #ifdef _USE_ATOMIC_SIGNAL - uintptr_t ifunc = (uintptr_t) func; - return (_sig_func_ptr) atomic_exchange(&_sig_func[sig], ifunc); + return (_sig_func_ptr) atomic_exchange(&_sig_func[sig], func); #else _sig_func_ptr old = _sig_func[sig]; _sig_func[sig] = func; @@ -132,7 +131,7 @@ signal (int sig, _sig_func_ptr func) int raise (int sig) { - if (sig < 0 || sig >= NSIG) + if (sig < 0 || sig >= _NSIG) { errno = EINVAL; return -1; @@ -152,8 +151,8 @@ raise (int sig) #ifdef _USE_ATOMIC_SIGNAL /* make sure it hasn't changed in the meantime */ if (!atomic_compare_exchange_strong(&_sig_func[sig], - (uintptr_t *) &func, - (uintptr_t) SIG_DFL)) + &func, + SIG_DFL)) continue; #else _sig_func[sig] = SIG_DFL; From 4759097da370ab0b8d9d4356c04752a8ff4e191e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 6 Aug 2024 18:25:35 -0700 Subject: [PATCH 30/42] string: Remove sys/features from string.h sys/cdefs already includes this Signed-off-by: Keith Packard --- newlib/libc/include/string.h | 1 - 1 file changed, 1 deletion(-) diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h index d459f06bae..77b61ccd2c 100644 --- a/newlib/libc/include/string.h +++ b/newlib/libc/include/string.h @@ -41,7 +41,6 @@ SUCH DAMAGE. #define _STRING_H_ #include -#include #define __need_size_t #define __need_NULL From 2f56cbdc936e15eb81603148342dfd61922a9bcd Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 7 Aug 2024 11:35:59 -0700 Subject: [PATCH 31/42] include: Clean up errno.h (and sys/errno.h) move 'error_t' to argz.h and envz.h where it belongs. Get rid of __LINUX_ERRNO_EXTENSIONS__ -- C allows the library to define as many errno values as it likes. Signed-off-by: Keith Packard --- newlib/libc/include/argz.h | 9 +++++++-- newlib/libc/include/envz.h | 19 +++++++++++++++++-- newlib/libc/include/errno.h | 5 ----- newlib/libc/include/sys/errno.h | 28 ---------------------------- newlib/libc/search/hash.c | 15 ++++----------- newlib/libc/search/hash_page.c | 21 ++++++--------------- 6 files changed, 34 insertions(+), 63 deletions(-) diff --git a/newlib/libc/include/argz.h b/newlib/libc/include/argz.h index 6c84836b5c..321bd0570d 100644 --- a/newlib/libc/include/argz.h +++ b/newlib/libc/include/argz.h @@ -8,11 +8,16 @@ #define _ARGZ_H_ #include -#include -#include +#define __need_size_t +#include _BEGIN_STD_C +#ifndef _ERROR_T_DECLARED +typedef int error_t; +#define _ERROR_T_DECLARED +#endif + /* The newlib implementation of these functions assumes that sizeof(char) == 1. */ error_t argz_create (char *const argv[], char **argz, size_t *argz_len); error_t argz_create_sep (const char *string, int sep, char **argz, size_t *argz_len); diff --git a/newlib/libc/include/envz.h b/newlib/libc/include/envz.h index e6a31c31d6..9e451eef49 100644 --- a/newlib/libc/include/envz.h +++ b/newlib/libc/include/envz.h @@ -4,8 +4,19 @@ * is freely granted, provided that this notice is preserved. */ -#include -#include +#ifndef _ENVZ_H_ +#define _ENVZ_H_ + +#include +#define __need_size_t +#include + +_BEGIN_STD_C + +#ifndef _ERROR_T_DECLARED +typedef int error_t; +#define _ERROR_T_DECLARED +#endif /* The newlib implementation of these functions assumes that sizeof(char) == 1. */ char * envz_entry (const char *envz, size_t envz_len, const char *name); @@ -14,3 +25,7 @@ error_t envz_add (char **envz, size_t *envz_len, const char *name, const char *v error_t envz_merge (char **envz, size_t *envz_len, const char *envz2, size_t envz2_len, int override); void envz_remove(char **envz, size_t *envz_len, const char *name); void envz_strip (char **envz, size_t *envz_len); + +_END_STD_C + +#endif /* _ENVZ_H_ */ diff --git a/newlib/libc/include/errno.h b/newlib/libc/include/errno.h index d52446d122..cf73f0460c 100644 --- a/newlib/libc/include/errno.h +++ b/newlib/libc/include/errno.h @@ -36,11 +36,6 @@ SUCH DAMAGE. #include -#ifndef __error_t_defined -typedef int error_t; -#define __error_t_defined 1 -#endif - #include #endif /* !__ERRNO_H__ */ diff --git a/newlib/libc/include/sys/errno.h b/newlib/libc/include/sys/errno.h index 7b0d8d33a9..638abb9f16 100644 --- a/newlib/libc/include/sys/errno.h +++ b/newlib/libc/include/sys/errno.h @@ -75,9 +75,7 @@ extern NEWLIB_THREAD_LOCAL_ERRNO int errno; #define ENOMEM 12 /* Not enough space */ #define EACCES 13 /* Permission denied */ #define EFAULT 14 /* Bad address */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define ENOTBLK 15 /* Block device required */ -#endif #define EBUSY 16 /* Device or resource busy */ #define EEXIST 17 /* File exists */ #define EXDEV 18 /* Cross-device link */ @@ -99,7 +97,6 @@ extern NEWLIB_THREAD_LOCAL_ERRNO int errno; #define ERANGE 34 /* Result too large */ #define ENOMSG 35 /* No message of desired type */ #define EIDRM 36 /* Identifier removed */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define ECHRNG 37 /* Channel number out of range */ #define EL2NSYNC 38 /* Level 2 not synchronized */ #define EL3HLT 39 /* Level 3 halted */ @@ -108,10 +105,8 @@ extern NEWLIB_THREAD_LOCAL_ERRNO int errno; #define EUNATCH 42 /* Protocol driver not attached */ #define ENOCSI 43 /* No CSI structure available */ #define EL2HLT 44 /* Level 2 halted */ -#endif #define EDEADLK 45 /* Deadlock */ #define ENOLCK 46 /* No lock */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define EBADE 50 /* Invalid exchange */ #define EBADR 51 /* Invalid request descriptor */ #define EXFULL 52 /* Exchange full */ @@ -120,30 +115,22 @@ extern NEWLIB_THREAD_LOCAL_ERRNO int errno; #define EBADSLT 55 /* Invalid slot */ #define EDEADLOCK 56 /* File locking deadlock error */ #define EBFONT 57 /* Bad font file fmt */ -#endif #define ENOSTR 60 /* Not a stream */ #define ENODATA 61 /* No data (for no delay io) */ #define ETIME 62 /* Stream ioctl timeout */ #define ENOSR 63 /* No stream resources */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */ #define EREMOTE 66 /* The object is remote */ -#endif #define ENOLINK 67 /* Virtual circuit is gone */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define EADV 68 /* Advertise error */ #define ESRMNT 69 /* Srmount error */ #define ECOMM 70 /* Communication error on send */ -#endif #define EPROTO 71 /* Protocol error */ #define EMULTIHOP 74 /* Multihop attempted */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define ELBIN 75 /* Inode is remote (not really error) */ #define EDOTDOT 76 /* Cross mount point (not really error) */ -#endif #define EBADMSG 77 /* Bad message */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define EFTYPE 79 /* Inappropriate file type or format */ #define ENOTUNIQ 80 /* Given log. name not unique */ #define EBADFD 81 /* File descriptor in bad state */ @@ -153,70 +140,55 @@ extern NEWLIB_THREAD_LOCAL_ERRNO int errno; #define ELIBSCN 85 /* .lib section in a.out corrupted */ #define ELIBMAX 86 /* Attempting to link in too many libs */ #define ELIBEXEC 87 /* Attempting to exec a shared library */ -#endif #define ENOSYS 88 /* Function not implemented */ #define ENOTEMPTY 90 /* Directory not empty */ #define ENAMETOOLONG 91 /* File or path name too long */ #define ELOOP 92 /* Too many symbolic links */ #define EOPNOTSUPP 95 /* Operation not supported on socket */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define EPFNOSUPPORT 96 /* Protocol family not supported */ -#endif #define ECONNRESET 104 /* Connection reset by peer */ #define ENOBUFS 105 /* No buffer space available */ #define EAFNOSUPPORT 106 /* Address family not supported by protocol family */ #define EPROTOTYPE 107 /* Protocol wrong type for socket */ #define ENOTSOCK 108 /* Socket operation on non-socket */ #define ENOPROTOOPT 109 /* Protocol not available */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define ESHUTDOWN 110 /* Can't send after socket shutdown */ -#endif #define ECONNREFUSED 111 /* Connection refused */ #define EADDRINUSE 112 /* Address already in use */ #define ECONNABORTED 113 /* Software caused connection abort */ #define ENETUNREACH 114 /* Network is unreachable */ #define ENETDOWN 115 /* Network interface is not configured */ #define ETIMEDOUT 116 /* Connection timed out */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define EHOSTDOWN 117 /* Host is down */ -#endif #define EHOSTUNREACH 118 /* Host is unreachable */ #define EINPROGRESS 119 /* Connection already in progress */ #define EALREADY 120 /* Socket already connected */ #define EDESTADDRREQ 121 /* Destination address required */ #define EMSGSIZE 122 /* Message too long */ #define EPROTONOSUPPORT 123 /* Unknown protocol */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define ESOCKTNOSUPPORT 124 /* Socket type not supported */ -#endif #define EADDRNOTAVAIL 125 /* Address not available */ #define ENETRESET 126 /* Connection aborted by network */ #define EISCONN 127 /* Socket is already connected */ #define ENOTCONN 128 /* Socket is not connected */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define ETOOMANYREFS 129 /* Too many references: cannot splice */ #define EPROCLIM 130 /* Too many processes */ #define EUSERS 131 /* Too many users */ -#endif #define EDQUOT 132 /* Reserved */ #define ESTALE 133 /* Reserved */ #define ENOTSUP 134 /* Not supported */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define ENOMEDIUM 135 /* No medium found */ -#endif #define EILSEQ 138 /* Illegal byte sequence */ #define EOVERFLOW 139 /* Value too large for defined data type */ #define ECANCELED 140 /* Operation canceled */ #define ENOTRECOVERABLE 141 /* State not recoverable */ #define EOWNERDEAD 142 /* Previous owner died */ -#ifdef __LINUX_ERRNO_EXTENSIONS__ #define ESTRPIPE 143 /* Streams pipe error */ #define EHWPOISON 144 /* Memory page has hardware error */ #define EISNAM 145 /* Is a named type file */ #define EKEYEXPIRED 146 /* Key has expired */ #define EKEYREJECTED 147 /* Key was rejected by service */ #define EKEYREVOKED 148 /* Key has been revoked */ -#endif #define EWOULDBLOCK EAGAIN /* Operation would block */ #define __ELASTERROR 2000 /* Users can add values starting here */ diff --git a/newlib/libc/search/hash.c b/newlib/libc/search/hash.c index 04fbce0840..93f8346851 100644 --- a/newlib/libc/search/hash.c +++ b/newlib/libc/search/hash.c @@ -31,25 +31,19 @@ */ #define _DEFAULT_SOURCE -#define __LINUX_ERRNO_EXTENSIONS__ -#include -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash.c 8.9 (Berkeley) 6/16/94"; -#endif /* LIBC_SCCS and not lint */ #include #include - #include - #include #include #include #include #include #include -#ifdef DEBUG -#include +#ifndef DEBUG +#define NDEBUG #endif +#include #define __DBINTERFACE_PRIVATE /* activate prototypes from db_local.h */ #include "db_local.h" @@ -795,10 +789,9 @@ hash_seq(const DB *dbp, } else bp = (__uint16_t *)hashp->cpage->page; -#ifdef DEBUG assert(bp); assert(bufp); -#endif + while (bp[hashp->cndx + 1] == OVFLPAGE) { bufp = hashp->cpage = __get_buf(hashp, bp[hashp->cndx], bufp, 0); diff --git a/newlib/libc/search/hash_page.c b/newlib/libc/search/hash_page.c index d67a5857cb..da0e18f2eb 100644 --- a/newlib/libc/search/hash_page.c +++ b/newlib/libc/search/hash_page.c @@ -30,14 +30,6 @@ * SUCH DAMAGE. */ -#define _DEFAULT_SOURCE -#define __LINUX_ERRNO_EXTENSIONS__ -#include -#if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94"; -#endif /* LIBC_SCCS and not lint */ -#include - /* * PACKAGE: hashing * @@ -54,8 +46,9 @@ static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94"; * open_temp */ +#define _DEFAULT_SOURCE +#include #include - #include #include #include @@ -63,9 +56,10 @@ static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94"; #include #include #include -#ifdef DEBUG -#include +#ifndef DEBUG +#define NDEBUG #endif +#include #include "db_local.h" #include "hash.h" @@ -826,15 +820,12 @@ __free_ovflpage(HTAB *hashp, BUFHEAD *obufp) if (!(freep = hashp->mapp[free_page])) freep = fetch_bitmap(hashp, free_page); -#ifdef DEBUG /* * This had better never happen. It means we tried to read a bitmap * that has already had overflow pages allocated off it, and we * failed to read it from the file. */ - if (!freep) - assert(0); -#endif + assert(freep); CLRBIT(freep, free_bit); #ifdef DEBUG2 (void)fprintf(stderr, "FREE_OVFLPAGE: ADDR: %d BIT: %d PAGE %d\n", From e9aeef532eac690ab3fa2909c67c2ce5a721eddc Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 7 Aug 2024 11:37:14 -0700 Subject: [PATCH 32/42] include: Clean up complex.h Move sys/cdefs include to the top of the file. Signed-off-by: Keith Packard --- newlib/libc/include/complex.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/newlib/libc/include/complex.h b/newlib/libc/include/complex.h index f4d6067a42..5f5217d251 100644 --- a/newlib/libc/include/complex.h +++ b/newlib/libc/include/complex.h @@ -8,12 +8,12 @@ #ifndef _COMPLEX_H #define _COMPLEX_H +#include + #define complex _Complex #define _Complex_I 1.0fi #define I _Complex_I -#include - _BEGIN_STD_C /* 7.3.5 Trigonometric functions */ From 3eac89777cb73ecd8ef77670e7de13499983792d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 7 Aug 2024 11:54:46 -0700 Subject: [PATCH 33/42] include: Remove unnecessary sys/config.h includes sys/config.h is included by sys/cdefs.h, which is included by every public header. Signed-off-by: Keith Packard --- newlib/libc/include/fenv.h | 1 - newlib/libc/include/limits.h | 2 -- newlib/libc/include/machine/_endian.h | 2 -- newlib/libc/include/sys/_types.h | 1 - newlib/libc/include/sys/errno.h | 1 - newlib/libc/search/db_local.h | 3 --- newlib/libc/stdio/vfieeefp.h | 2 -- newlib/libc/stdlib/mprec.h | 1 - newlib/libc/stdlib/nano-malloc.h | 1 - newlib/libc/time/strftime.c | 1 - 10 files changed, 15 deletions(-) diff --git a/newlib/libc/include/fenv.h b/newlib/libc/include/fenv.h index 45d8c21500..45b4d031c0 100644 --- a/newlib/libc/include/fenv.h +++ b/newlib/libc/include/fenv.h @@ -13,7 +13,6 @@ #define _FENV_H #include -#include _BEGIN_STD_C diff --git a/newlib/libc/include/limits.h b/newlib/libc/include/limits.h index a517ba084c..f663eeb9a1 100644 --- a/newlib/libc/include/limits.h +++ b/newlib/libc/include/limits.h @@ -26,8 +26,6 @@ # ifndef _LIMITS_H # define _LIMITS_H 1 -# include - /* Number of bits in a `char'. */ # undef CHAR_BIT # define CHAR_BIT 8 diff --git a/newlib/libc/include/machine/_endian.h b/newlib/libc/include/machine/_endian.h index 0b6ea13ee5..96c072472d 100644 --- a/newlib/libc/include/machine/_endian.h +++ b/newlib/libc/include/machine/_endian.h @@ -3,8 +3,6 @@ #error "must be included via " #endif /* !__MACHINE_ENDIAN_H__ */ -#include - #ifdef __PPC__ /* Get rid of GCC builtin defines on PowerPC */ #ifdef _BIG_ENDIAN diff --git a/newlib/libc/include/sys/_types.h b/newlib/libc/include/sys/_types.h index c38b7d1e60..9dce1e7b39 100644 --- a/newlib/libc/include/sys/_types.h +++ b/newlib/libc/include/sys/_types.h @@ -58,7 +58,6 @@ SUCH DAMAGE. typedef __WINT_TYPE__ wint_t; #endif -#include #include #ifndef __machine_blkcnt_t_defined diff --git a/newlib/libc/include/sys/errno.h b/newlib/libc/include/sys/errno.h index 638abb9f16..826d482ed5 100644 --- a/newlib/libc/include/sys/errno.h +++ b/newlib/libc/include/sys/errno.h @@ -34,7 +34,6 @@ SUCH DAMAGE. #define _SYS_ERRNO_H_ #include -#include _BEGIN_STD_C diff --git a/newlib/libc/search/db_local.h b/newlib/libc/search/db_local.h index 8167953e82..ab84f396e7 100644 --- a/newlib/libc/search/db_local.h +++ b/newlib/libc/search/db_local.h @@ -34,9 +34,6 @@ #define _DB_H_ #include -#include -#include - #include #define RET_ERROR -1 /* Return values. */ diff --git a/newlib/libc/stdio/vfieeefp.h b/newlib/libc/stdio/vfieeefp.h index ee5a418025..5529a046cb 100644 --- a/newlib/libc/stdio/vfieeefp.h +++ b/newlib/libc/stdio/vfieeefp.h @@ -32,8 +32,6 @@ #include #include #include -#include -#include #ifdef __IEEE_LITTLE_ENDIAN #define IEEE_8087 diff --git a/newlib/libc/stdlib/mprec.h b/newlib/libc/stdlib/mprec.h index ab71c5e55a..fae164e931 100644 --- a/newlib/libc/stdlib/mprec.h +++ b/newlib/libc/stdlib/mprec.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include "../locale/setlocale.h" diff --git a/newlib/libc/stdlib/nano-malloc.h b/newlib/libc/stdlib/nano-malloc.h index 2b8eb207c9..696eefc935 100644 --- a/newlib/libc/stdlib/nano-malloc.h +++ b/newlib/libc/stdlib/nano-malloc.h @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include diff --git a/newlib/libc/time/strftime.c b/newlib/libc/time/strftime.c index 1edd4842c2..1475565223 100644 --- a/newlib/libc/time/strftime.c +++ b/newlib/libc/time/strftime.c @@ -279,7 +279,6 @@ locale, hard-coding the "C" locale settings. */ #define _GNU_SOURCE -#include #include #include #include From ea86a2794bdf1a13831f0f5b0b5aac6f28cd3012 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 7 Aug 2024 12:18:22 -0700 Subject: [PATCH 34/42] Remove internal source references to sys/cdefs.h This will be included by any public header, so the internal source files don't need to also include it. Signed-off-by: Keith Packard --- dummyhost/iob.c | 1 - newlib/libc/argz/argz_count.c | 1 - newlib/libc/argz/argz_stringify.c | 1 - newlib/libc/ctype/isdigit_l.c | 1 - newlib/libc/ctype/islower_l.c | 1 - newlib/libc/ctype/iswalnum_l.c | 1 - newlib/libc/ctype/iswalpha_l.c | 1 - newlib/libc/ctype/iswblank_l.c | 1 - newlib/libc/ctype/iswcntrl_l.c | 1 - newlib/libc/ctype/iswctype_l.c | 1 - newlib/libc/ctype/iswdigit.c | 1 - newlib/libc/ctype/iswdigit_l.c | 1 - newlib/libc/ctype/iswlower_l.c | 1 - newlib/libc/ctype/iswprint_l.c | 1 - newlib/libc/ctype/iswpunct_l.c | 1 - newlib/libc/ctype/iswspace_l.c | 1 - newlib/libc/ctype/iswupper_l.c | 1 - newlib/libc/ctype/iswxdigit.c | 1 - newlib/libc/ctype/iswxdigit_l.c | 1 - newlib/libc/ctype/jp2uc.c | 1 - newlib/libc/ctype/toascii.c | 1 - newlib/libc/ctype/toascii_l.c | 1 - newlib/libc/ctype/towctrans.c | 1 - newlib/libc/ctype/towctrans_l.c | 1 - newlib/libc/ctype/towlower.c | 1 - newlib/libc/ctype/towlower_l.c | 1 - newlib/libc/ctype/towupper.c | 1 - newlib/libc/ctype/towupper_l.c | 1 - newlib/libc/ctype/wctrans.c | 1 - newlib/libc/ctype/wctrans_l.c | 1 - newlib/libc/ctype/wctype_l.c | 1 - newlib/libc/iconv/ccs/big5.c | 1 - newlib/libc/iconv/ccs/ccs.h | 2 +- newlib/libc/iconv/ccs/ccsbi.c | 1 - newlib/libc/iconv/ccs/ccsbi.h | 2 -- newlib/libc/iconv/ccs/cns11643_plane1.c | 1 - newlib/libc/iconv/ccs/cns11643_plane14.c | 1 - newlib/libc/iconv/ccs/cns11643_plane2.c | 1 - newlib/libc/iconv/ccs/cp775.c | 1 - newlib/libc/iconv/ccs/cp850.c | 1 - newlib/libc/iconv/ccs/cp852.c | 1 - newlib/libc/iconv/ccs/cp855.c | 1 - newlib/libc/iconv/ccs/cp866.c | 1 - newlib/libc/iconv/ccs/iso_8859_1.c | 1 - newlib/libc/iconv/ccs/iso_8859_10.c | 1 - newlib/libc/iconv/ccs/iso_8859_11.c | 1 - newlib/libc/iconv/ccs/iso_8859_13.c | 1 - newlib/libc/iconv/ccs/iso_8859_14.c | 1 - newlib/libc/iconv/ccs/iso_8859_15.c | 1 - newlib/libc/iconv/ccs/iso_8859_2.c | 1 - newlib/libc/iconv/ccs/iso_8859_3.c | 1 - newlib/libc/iconv/ccs/iso_8859_4.c | 1 - newlib/libc/iconv/ccs/iso_8859_5.c | 1 - newlib/libc/iconv/ccs/iso_8859_6.c | 1 - newlib/libc/iconv/ccs/iso_8859_7.c | 1 - newlib/libc/iconv/ccs/iso_8859_8.c | 1 - newlib/libc/iconv/ccs/iso_8859_9.c | 1 - newlib/libc/iconv/ccs/iso_ir_111.c | 1 - newlib/libc/iconv/ccs/jis_x0201_1976.c | 1 - newlib/libc/iconv/ccs/jis_x0208_1990.c | 1 - newlib/libc/iconv/ccs/jis_x0212_1990.c | 1 - newlib/libc/iconv/ccs/koi8_r.c | 1 - newlib/libc/iconv/ccs/koi8_ru.c | 1 - newlib/libc/iconv/ccs/koi8_u.c | 1 - newlib/libc/iconv/ccs/koi8_uni.c | 1 - newlib/libc/iconv/ccs/ksx1001.c | 1 - newlib/libc/iconv/ccs/mktbl.pl | 1 - newlib/libc/iconv/ccs/win_1250.c | 1 - newlib/libc/iconv/ccs/win_1251.c | 1 - newlib/libc/iconv/ccs/win_1252.c | 1 - newlib/libc/iconv/ccs/win_1253.c | 1 - newlib/libc/iconv/ccs/win_1254.c | 1 - newlib/libc/iconv/ccs/win_1255.c | 1 - newlib/libc/iconv/ccs/win_1256.c | 1 - newlib/libc/iconv/ccs/win_1257.c | 1 - newlib/libc/iconv/ccs/win_1258.c | 1 - newlib/libc/iconv/ces/cesbi.h | 1 - newlib/libc/iconv/ces/mkdeps.pl | 5 ----- newlib/libc/iconv/ces/table-pcs.c | 1 - newlib/libc/iconv/ces/ucs-2-internal.c | 1 - newlib/libc/iconv/ces/ucs-2.c | 1 - newlib/libc/iconv/ces/ucs-4-internal.c | 1 - newlib/libc/iconv/ces/ucs-4.c | 1 - newlib/libc/iconv/ces/us-ascii.c | 1 - newlib/libc/iconv/ces/utf-16.c | 1 - newlib/libc/iconv/ces/utf-8.c | 1 - newlib/libc/iconv/lib/aliasesbi.c | 2 +- newlib/libc/iconv/lib/aliasesi.c | 1 - newlib/libc/iconv/lib/conv.h | 1 - newlib/libc/iconv/lib/iconv.c | 1 - newlib/libc/iconv/lib/iconvnls.c | 1 - newlib/libc/iconv/lib/local.h | 1 - newlib/libc/iconv/lib/nullconv.c | 1 - newlib/libc/iconv/lib/ucsconv.c | 1 - newlib/libc/iconv/lib/ucsconv.h | 1 - newlib/libc/include/sys/cdefs.h | 20 ------------------- newlib/libc/locale/setlocale.h | 1 - newlib/libc/machine/aarch64/sys/fenv.h | 1 - newlib/libc/machine/arm/aeabi_memset.c | 1 - newlib/libc/machine/arm/memset.c | 1 - newlib/libc/machine/arm/strlen.c | 1 - newlib/libc/machine/arm/sys/fenv.h | 1 - newlib/libc/machine/cris/sys/fcntl.h | 1 - newlib/libc/machine/cris/sys/signal.h | 1 - newlib/libc/machine/m68k/sys/fenv.h | 1 - newlib/libc/machine/microblaze/strlen.c | 1 - newlib/libc/machine/mips/sys/fenv.h | 1 - newlib/libc/machine/powerpc/sys/fenv.h | 1 - newlib/libc/machine/riscv/sys/fenv.h | 1 - newlib/libc/machine/sh/sys/fenv.h | 1 - newlib/libc/machine/sparc/sys/fenv.h | 1 - newlib/libc/machine/spu/fclose.c | 1 - newlib/libc/machine/spu/fopen.c | 1 - newlib/libc/machine/spu/fputc.c | 1 - newlib/libc/machine/spu/fputs.c | 1 - newlib/libc/machine/spu/fread.c | 1 - newlib/libc/machine/spu/freopen.c | 1 - newlib/libc/machine/spu/fseek.c | 1 - newlib/libc/machine/spu/fsetpos.c | 1 - newlib/libc/machine/spu/fwrite.c | 1 - newlib/libc/machine/spu/putc.c | 1 - newlib/libc/machine/spu/rename.c | 1 - newlib/libc/machine/spu/setbuf.c | 1 - newlib/libc/machine/spu/setvbuf.c | 1 - newlib/libc/machine/spu/ungetc.c | 1 - newlib/libc/machine/spu/vfprintf.c | 1 - newlib/libc/machine/spu/vfscanf.c | 1 - newlib/libc/machine/spu/vprintf.c | 1 - newlib/libc/machine/spu/vscanf.c | 1 - newlib/libc/machine/spu/vsnprintf.c | 1 - newlib/libc/machine/spu/vsprintf.c | 1 - newlib/libc/machine/spu/vsscanf.c | 1 - newlib/libc/machine/x86/sys/fenv.h | 1 - newlib/libc/machine/xtensa/sys/fenv.h | 1 - newlib/libc/misc/__dprintf.c | 1 - newlib/libc/misc/unctrl.c | 1 - newlib/libc/picolib/getauxval.c | 1 - .../libc/picolib/machine/aarch64/interrupt.c | 1 - newlib/libc/picolib/machine/arm/interrupt.c | 1 - newlib/libc/picolib/machine/m68k/interrupt.c | 1 - newlib/libc/posix/collate.c | 14 +------------ newlib/libc/posix/collate.h | 1 - newlib/libc/posix/collcmp.c | 1 - newlib/libc/posix/engine.c | 1 - newlib/libc/posix/regerror.c | 1 - newlib/libc/posix/regexec.c | 1 - newlib/libc/posix/regfree.c | 1 - newlib/libc/posix/runetype.h | 1 - newlib/libc/search/hash.c | 1 - newlib/libc/search/hash_bigkey.c | 1 - newlib/libc/search/hash_buf.c | 1 - newlib/libc/search/hash_func.c | 1 - newlib/libc/search/hash_log2.c | 1 - newlib/libc/search/hash_page.c | 1 - newlib/libc/search/hcreate.c | 2 -- newlib/libc/search/hcreate_r.c | 2 -- newlib/libc/search/ndbm.c | 2 -- newlib/libc/search/qsort.c | 1 - newlib/libc/search/tdelete.c | 2 -- newlib/libc/search/tdestroy.c | 2 -- newlib/libc/search/tfind.c | 2 -- newlib/libc/search/tsearch.c | 2 -- newlib/libc/search/twalk.c | 2 -- newlib/libc/signal/psignal.c | 1 - newlib/libc/ssp/gets_chk.c | 2 -- newlib/libc/ssp/memcpy_chk.c | 2 -- newlib/libc/ssp/memmove_chk.c | 2 -- newlib/libc/ssp/mempcpy_chk.c | 1 - newlib/libc/ssp/memset_chk.c | 2 -- newlib/libc/ssp/snprintf_chk.c | 2 -- newlib/libc/ssp/sprintf_chk.c | 2 -- newlib/libc/ssp/stack_protector.c | 1 - newlib/libc/ssp/stpcpy_chk.c | 2 -- newlib/libc/ssp/stpncpy_chk.c | 2 -- newlib/libc/ssp/strcat_chk.c | 2 -- newlib/libc/ssp/strcpy_chk.c | 2 -- newlib/libc/ssp/strncat_chk.c | 2 -- newlib/libc/ssp/strncpy_chk.c | 2 -- newlib/libc/ssp/vsnprintf_chk.c | 2 -- newlib/libc/ssp/vsprintf_chk.c | 2 -- newlib/libc/stdio/asiprintf.c | 1 - newlib/libc/stdio/asniprintf.c | 1 - newlib/libc/stdio/asnprintf.c | 1 - newlib/libc/stdio/asprintf.c | 1 - newlib/libc/stdio/clearerr.c | 1 - newlib/libc/stdio/clearerr_u.c | 1 - newlib/libc/stdio/diprintf.c | 1 - newlib/libc/stdio/dprintf.c | 1 - newlib/libc/stdio/fclose.c | 1 - newlib/libc/stdio/fcloseall.c | 1 - newlib/libc/stdio/fdopen.c | 1 - newlib/libc/stdio/ferror.c | 1 - newlib/libc/stdio/ferror_u.c | 1 - newlib/libc/stdio/fflush.c | 1 - newlib/libc/stdio/fgetc.c | 1 - newlib/libc/stdio/fgetc_u.c | 1 - newlib/libc/stdio/fgetpos.c | 1 - newlib/libc/stdio/fgets.c | 1 - newlib/libc/stdio/fgetwc.c | 1 - newlib/libc/stdio/fgetwc_u.c | 1 - newlib/libc/stdio/fgetws.c | 1 - newlib/libc/stdio/fileno.c | 1 - newlib/libc/stdio/fileno_u.c | 1 - newlib/libc/stdio/findfp.c | 1 - newlib/libc/stdio/fiprintf.c | 1 - newlib/libc/stdio/fiscanf.c | 1 - newlib/libc/stdio/flags.c | 1 - newlib/libc/stdio/fopen.c | 1 - newlib/libc/stdio/fprintf.c | 1 - newlib/libc/stdio/fpurge.c | 1 - newlib/libc/stdio/fputc.c | 1 - newlib/libc/stdio/fputc_u.c | 1 - newlib/libc/stdio/fputs.c | 1 - newlib/libc/stdio/fputwc.c | 1 - newlib/libc/stdio/fputwc_u.c | 1 - newlib/libc/stdio/fputws.c | 1 - newlib/libc/stdio/fread.c | 1 - newlib/libc/stdio/freopen.c | 1 - newlib/libc/stdio/fscanf.c | 1 - newlib/libc/stdio/fseek.c | 1 - newlib/libc/stdio/fseeko.c | 1 - newlib/libc/stdio/fsetlocking.c | 1 - newlib/libc/stdio/fsetpos.c | 1 - newlib/libc/stdio/ftell.c | 1 - newlib/libc/stdio/ftello.c | 1 - newlib/libc/stdio/fvwrite.c | 1 - newlib/libc/stdio/fvwrite.h | 3 --- newlib/libc/stdio/fwalk.c | 1 - newlib/libc/stdio/fwide.c | 1 - newlib/libc/stdio/fwprintf.c | 1 - newlib/libc/stdio/fwrite.c | 1 - newlib/libc/stdio/fwscanf.c | 1 - newlib/libc/stdio/getc.c | 1 - newlib/libc/stdio/getc_u.c | 1 - newlib/libc/stdio/getchar.c | 1 - newlib/libc/stdio/getchar_u.c | 1 - newlib/libc/stdio/getdelim.c | 1 - newlib/libc/stdio/getline.c | 1 - newlib/libc/stdio/gets.c | 1 - newlib/libc/stdio/getw.c | 1 - newlib/libc/stdio/getwc.c | 1 - newlib/libc/stdio/getwc_u.c | 1 - newlib/libc/stdio/getwchar.c | 1 - newlib/libc/stdio/getwchar_u.c | 1 - newlib/libc/stdio/iprintf.c | 1 - newlib/libc/stdio/iscanf.c | 1 - newlib/libc/stdio/local.h | 1 - newlib/libc/stdio/makebuf.c | 1 - newlib/libc/stdio/mktemp.c | 1 - newlib/libc/stdio/nano-vfprintf.c | 1 - newlib/libc/stdio/nano-vfprintf_float.c | 1 - newlib/libc/stdio/nano-vfprintf_i.c | 1 - newlib/libc/stdio/nano-vfscanf.c | 1 - newlib/libc/stdio/nano-vfscanf_float.c | 1 - newlib/libc/stdio/nano-vfscanf_i.c | 1 - newlib/libc/stdio/perror.c | 1 - newlib/libc/stdio/printf.c | 1 - newlib/libc/stdio/putc.c | 1 - newlib/libc/stdio/putc_u.c | 1 - newlib/libc/stdio/putchar.c | 1 - newlib/libc/stdio/putchar_u.c | 1 - newlib/libc/stdio/puts.c | 1 - newlib/libc/stdio/putwc.c | 1 - newlib/libc/stdio/putwc_u.c | 1 - newlib/libc/stdio/putwchar.c | 1 - newlib/libc/stdio/putwchar_u.c | 1 - newlib/libc/stdio/refill.c | 1 - newlib/libc/stdio/remove.c | 1 - newlib/libc/stdio/rename.c | 1 - newlib/libc/stdio/rewind.c | 1 - newlib/libc/stdio/rget.c | 1 - newlib/libc/stdio/scanf.c | 1 - newlib/libc/stdio/sccl.c | 1 - newlib/libc/stdio/setbuf.c | 1 - newlib/libc/stdio/setbuffer.c | 1 - newlib/libc/stdio/setlinebuf.c | 1 - newlib/libc/stdio/setvbuf.c | 1 - newlib/libc/stdio/siprintf.c | 1 - newlib/libc/stdio/siscanf.c | 1 - newlib/libc/stdio/sniprintf.c | 1 - newlib/libc/stdio/snprintf.c | 1 - newlib/libc/stdio/sprintf.c | 1 - newlib/libc/stdio/sscanf.c | 1 - newlib/libc/stdio/stdio.c | 1 - newlib/libc/stdio/stdio_ext.c | 1 - newlib/libc/stdio/stdio_ext.h | 5 ----- newlib/libc/stdio/swprintf.c | 1 - newlib/libc/stdio/swscanf.c | 1 - newlib/libc/stdio/tmpfile.c | 1 - newlib/libc/stdio/tmpnam.c | 1 - newlib/libc/stdio/ungetc.c | 1 - newlib/libc/stdio/ungetwc.c | 1 - newlib/libc/stdio/vasiprintf.c | 1 - newlib/libc/stdio/vasniprintf.c | 1 - newlib/libc/stdio/vasnprintf.c | 1 - newlib/libc/stdio/vasprintf.c | 1 - newlib/libc/stdio/vdiprintf.c | 1 - newlib/libc/stdio/vdprintf.c | 1 - newlib/libc/stdio/vfprintf.c | 1 - newlib/libc/stdio/vfscanf.c | 1 - newlib/libc/stdio/vfwprintf.c | 1 - newlib/libc/stdio/vfwscanf.c | 1 - newlib/libc/stdio/viprintf.c | 1 - newlib/libc/stdio/viscanf.c | 1 - newlib/libc/stdio/vprintf.c | 1 - newlib/libc/stdio/vscanf.c | 1 - newlib/libc/stdio/vsiprintf.c | 1 - newlib/libc/stdio/vsiscanf.c | 1 - newlib/libc/stdio/vsniprintf.c | 1 - newlib/libc/stdio/vsnprintf.c | 1 - newlib/libc/stdio/vsprintf.c | 1 - newlib/libc/stdio/vsscanf.c | 1 - newlib/libc/stdio/vswprintf.c | 1 - newlib/libc/stdio/vswscanf.c | 1 - newlib/libc/stdio/vwprintf.c | 1 - newlib/libc/stdio/vwscanf.c | 1 - newlib/libc/stdio/wbuf.c | 1 - newlib/libc/stdio/wbufw.c | 1 - newlib/libc/stdio/wprintf.c | 1 - newlib/libc/stdio/wscanf.c | 1 - newlib/libc/stdio/wsetup.c | 1 - newlib/libc/stdlib/a64l.c | 1 - newlib/libc/stdlib/atof.c | 1 - newlib/libc/stdlib/atoff.c | 1 - newlib/libc/stdlib/atoi.c | 1 - newlib/libc/stdlib/atol.c | 1 - newlib/libc/stdlib/div.c | 1 - newlib/libc/stdlib/dtoa.c | 1 - newlib/libc/stdlib/ecvtbuf.c | 1 - newlib/libc/stdlib/efgcvt.c | 1 - newlib/libc/stdlib/gdtoa-gethex.c | 1 - newlib/libc/stdlib/gdtoa-hexnan.c | 1 - newlib/libc/stdlib/getsubopt.c | 1 - newlib/libc/stdlib/imaxabs.c | 2 -- newlib/libc/stdlib/imaxdiv.c | 2 -- newlib/libc/stdlib/l64a.c | 1 - newlib/libc/stdlib/ldiv.c | 1 - newlib/libc/stdlib/ldtoa.c | 1 - newlib/libc/stdlib/mprec.c | 1 - newlib/libc/stdlib/mstats.c | 1 - newlib/libc/stdlib/reallocarray.c | 1 - newlib/libc/stdlib/reallocf.c | 1 - newlib/libc/stdlib/rpmatch.c | 1 - newlib/libc/stdlib/strtod.c | 1 - newlib/libc/stdlib/strtodg.c | 1 - newlib/libc/stdlib/strtoimax.c | 2 -- newlib/libc/stdlib/strtol.c | 1 - newlib/libc/stdlib/strtoll.c | 1 - newlib/libc/stdlib/strtorx.c | 1 - newlib/libc/stdlib/strtoul.c | 1 - newlib/libc/stdlib/strtoull.c | 1 - newlib/libc/stdlib/strtoumax.c | 2 -- newlib/libc/stdlib/system.c | 1 - newlib/libc/stdlib/wcstod.c | 1 - newlib/libc/stdlib/wcstoimax.c | 3 --- newlib/libc/stdlib/wcstol.c | 1 - newlib/libc/stdlib/wcstoll.c | 1 - newlib/libc/stdlib/wcstoul.c | 1 - newlib/libc/stdlib/wcstoull.c | 1 - newlib/libc/stdlib/wcstoumax.c | 3 --- newlib/libc/string/memccpy.c | 1 - newlib/libc/string/memchr.c | 1 - newlib/libc/string/memcpy.c | 1 - newlib/libc/string/memmove.c | 1 - newlib/libc/string/mempcpy.c | 1 - newlib/libc/string/memrchr.c | 1 - newlib/libc/string/rawmemchr.c | 1 - newlib/libc/string/str-two-way.h | 1 - newlib/libc/string/strcasestr.c | 1 - newlib/libc/string/strlen.c | 1 - newlib/libc/string/strndup.c | 1 - newlib/libc/string/strnlen.c | 1 - newlib/libc/string/strsep.c | 1 - newlib/libc/string/strtok.c | 1 - newlib/libc/string/wcpcpy.c | 1 - newlib/libc/string/wcpncpy.c | 1 - newlib/libc/string/wcscat.c | 1 - newlib/libc/string/wcschr.c | 1 - newlib/libc/string/wcscmp.c | 1 - newlib/libc/string/wcscoll.c | 1 - newlib/libc/string/wcscoll_l.c | 1 - newlib/libc/string/wcscpy.c | 1 - newlib/libc/string/wcscspn.c | 1 - newlib/libc/string/wcslen.c | 1 - newlib/libc/string/wcsncat.c | 1 - newlib/libc/string/wcsncmp.c | 1 - newlib/libc/string/wcsncpy.c | 1 - newlib/libc/string/wcsnlen.c | 1 - newlib/libc/string/wcspbrk.c | 1 - newlib/libc/string/wcsrchr.c | 1 - newlib/libc/string/wcsspn.c | 1 - newlib/libc/string/wcsstr.c | 1 - newlib/libc/string/wcswidth.c | 1 - newlib/libc/string/wcsxfrm.c | 1 - newlib/libc/string/wcsxfrm_l.c | 1 - newlib/libc/string/wcwidth.c | 1 - newlib/libc/string/wmemchr.c | 1 - newlib/libc/string/wmemcmp.c | 1 - newlib/libc/string/wmemcpy.c | 1 - newlib/libc/string/wmemmove.c | 1 - newlib/libc/string/wmempcpy.c | 1 - newlib/libc/string/wmemset.c | 1 - newlib/libc/sys/amdgcn/include/sys/lock.h | 1 - newlib/libc/sys/rtems/include/sys/poll.h | 1 - newlib/libc/time/asctime.c | 1 - newlib/libc/time/local.h | 1 - newlib/libc/time/tzset.c | 1 - newlib/libc/xdr/xdr_private.h | 1 - newlib/libm/common/fma_inc.h | 1 - newlib/libm/complex/conjl.c | 2 -- newlib/libm/complex/cproj.c | 2 -- newlib/libm/complex/cprojf.c | 2 -- newlib/libm/complex/cprojl.c | 2 -- newlib/libm/complex/csqrtl.c | 1 - newlib/libm/ld/common/e_acosl.c | 1 - newlib/libm/ld/common/e_asinl.c | 1 - newlib/libm/ld/common/e_atan2l.c | 1 - newlib/libm/ld/common/e_remainderl.c | 1 - newlib/libm/ld/common/e_sqrtl.c | 1 - newlib/libm/ld/common/k_rem_pio2.c | 1 - newlib/libm/ld/common/s_atanl.c | 1 - newlib/libm/ld/common/s_cbrtl.c | 1 - newlib/libm/ld/common/s_cosl.c | 1 - newlib/libm/ld/common/s_fdiml.c | 1 - newlib/libm/ld/common/s_fmaxl.c | 1 - newlib/libm/ld/common/s_fminl.c | 1 - newlib/libm/ld/common/s_ilogbl.c | 1 - newlib/libm/ld/common/s_llrintl.c | 1 - newlib/libm/ld/common/s_lroundl.c | 1 - newlib/libm/ld/common/s_rintl.c | 1 - newlib/libm/ld/common/s_roundl.c | 1 - newlib/libm/ld/common/s_scalbl.c | 1 - newlib/libm/ld/common/s_scalbln.c | 1 - newlib/libm/ld/common/s_tanl.c | 1 - newlib/libm/ld/ld128/e_rem_pio2l.h | 1 - newlib/libm/ld/ld128/invtrig.c | 1 - newlib/libm/ld/ld128/k_cosl.c | 1 - newlib/libm/ld/ld128/k_sinl.c | 1 - newlib/libm/ld/ld128/k_tanl.c | 1 - newlib/libm/ld/ld128/s_exp2l.c | 1 - newlib/libm/ld/ld80/e_rem_pio2l.h | 1 - newlib/libm/ld/ld80/invtrig.c | 1 - newlib/libm/ld/ld80/k_cosl.c | 1 - newlib/libm/ld/ld80/k_sinl.c | 1 - newlib/libm/ld/ld80/k_tanl.c | 1 - newlib/libm/ld/ld80/s_exp2l.c | 1 - newlib/libm/machine/x86/f_math.h | 1 - newlib/testsuite/newlib.search/hsearchtest.c | 9 --------- 448 files changed, 3 insertions(+), 532 deletions(-) diff --git a/dummyhost/iob.c b/dummyhost/iob.c index 85f643ad68..81d60e4794 100644 --- a/dummyhost/iob.c +++ b/dummyhost/iob.c @@ -34,7 +34,6 @@ */ #include -#include /* * Dummy stdio hooks. This allows programs to link without requiring diff --git a/newlib/libc/argz/argz_count.c b/newlib/libc/argz/argz_count.c index 650fc64aef..7c89c0f8be 100644 --- a/newlib/libc/argz/argz_count.c +++ b/newlib/libc/argz/argz_count.c @@ -4,7 +4,6 @@ * is freely granted, provided that this notice is preserved. */ -#include #include #include #include diff --git a/newlib/libc/argz/argz_stringify.c b/newlib/libc/argz/argz_stringify.c index 30ec3989f2..8c2ed8d902 100644 --- a/newlib/libc/argz/argz_stringify.c +++ b/newlib/libc/argz/argz_stringify.c @@ -4,7 +4,6 @@ * is freely granted, provided that this notice is preserved. */ -#include #include #include #include diff --git a/newlib/libc/ctype/isdigit_l.c b/newlib/libc/ctype/isdigit_l.c index ec956b527b..161925e349 100644 --- a/newlib/libc/ctype/isdigit_l.c +++ b/newlib/libc/ctype/isdigit_l.c @@ -3,7 +3,6 @@ Copyright (c) 2016 Corinna Vinschen Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #undef isdigit_l diff --git a/newlib/libc/ctype/islower_l.c b/newlib/libc/ctype/islower_l.c index d160b301c7..0fb4919fcb 100644 --- a/newlib/libc/ctype/islower_l.c +++ b/newlib/libc/ctype/islower_l.c @@ -3,7 +3,6 @@ Copyright (c) 2016 Corinna Vinschen Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #undef islower_l diff --git a/newlib/libc/ctype/iswalnum_l.c b/newlib/libc/ctype/iswalnum_l.c index 817b5a1d7b..98af63e9f0 100644 --- a/newlib/libc/ctype/iswalnum_l.c +++ b/newlib/libc/ctype/iswalnum_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/ctype/iswalpha_l.c b/newlib/libc/ctype/iswalpha_l.c index 3652585671..1185cb6ab0 100644 --- a/newlib/libc/ctype/iswalpha_l.c +++ b/newlib/libc/ctype/iswalpha_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/ctype/iswblank_l.c b/newlib/libc/ctype/iswblank_l.c index 13fbfea16b..b714eb3c68 100644 --- a/newlib/libc/ctype/iswblank_l.c +++ b/newlib/libc/ctype/iswblank_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/ctype/iswcntrl_l.c b/newlib/libc/ctype/iswcntrl_l.c index 1f5f29166d..aa3d902074 100644 --- a/newlib/libc/ctype/iswcntrl_l.c +++ b/newlib/libc/ctype/iswcntrl_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/ctype/iswctype_l.c b/newlib/libc/ctype/iswctype_l.c index 4365ae949e..3642758653 100644 --- a/newlib/libc/ctype/iswctype_l.c +++ b/newlib/libc/ctype/iswctype_l.c @@ -1,7 +1,6 @@ /* Copyright (c) 2016 Corinna Vinschen */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/ctype/iswdigit.c b/newlib/libc/ctype/iswdigit.c index 2bab28d507..85c5f4df57 100644 --- a/newlib/libc/ctype/iswdigit.c +++ b/newlib/libc/ctype/iswdigit.c @@ -62,7 +62,6 @@ PORTABILITY No supporting OS subroutines are required. */ -#include #include int diff --git a/newlib/libc/ctype/iswdigit_l.c b/newlib/libc/ctype/iswdigit_l.c index acf2bc0a13..025b5c0d68 100644 --- a/newlib/libc/ctype/iswdigit_l.c +++ b/newlib/libc/ctype/iswdigit_l.c @@ -3,7 +3,6 @@ Copyright (c) 2016 Corinna Vinschen Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include int diff --git a/newlib/libc/ctype/iswlower_l.c b/newlib/libc/ctype/iswlower_l.c index 1af8dfdf6d..bc1d377261 100644 --- a/newlib/libc/ctype/iswlower_l.c +++ b/newlib/libc/ctype/iswlower_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/ctype/iswprint_l.c b/newlib/libc/ctype/iswprint_l.c index 20dc54405b..40b883ae65 100644 --- a/newlib/libc/ctype/iswprint_l.c +++ b/newlib/libc/ctype/iswprint_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/ctype/iswpunct_l.c b/newlib/libc/ctype/iswpunct_l.c index 4b39c48428..0d98568bce 100644 --- a/newlib/libc/ctype/iswpunct_l.c +++ b/newlib/libc/ctype/iswpunct_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/ctype/iswspace_l.c b/newlib/libc/ctype/iswspace_l.c index 7ea81c30ea..bba8d3ee1a 100644 --- a/newlib/libc/ctype/iswspace_l.c +++ b/newlib/libc/ctype/iswspace_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/ctype/iswupper_l.c b/newlib/libc/ctype/iswupper_l.c index b3e0fc35f3..dff44b6be6 100644 --- a/newlib/libc/ctype/iswupper_l.c +++ b/newlib/libc/ctype/iswupper_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/ctype/iswxdigit.c b/newlib/libc/ctype/iswxdigit.c index 4551f4f3f5..fa1aec3996 100644 --- a/newlib/libc/ctype/iswxdigit.c +++ b/newlib/libc/ctype/iswxdigit.c @@ -62,7 +62,6 @@ PORTABILITY No supporting OS subroutines are required. */ -#include #include int diff --git a/newlib/libc/ctype/iswxdigit_l.c b/newlib/libc/ctype/iswxdigit_l.c index e6da0caaef..786a896cb6 100644 --- a/newlib/libc/ctype/iswxdigit_l.c +++ b/newlib/libc/ctype/iswxdigit_l.c @@ -3,7 +3,6 @@ Copyright (c) 2016 Corinna Vinschen Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include int diff --git a/newlib/libc/ctype/jp2uc.c b/newlib/libc/ctype/jp2uc.c index 987335fa72..bafb34586f 100644 --- a/newlib/libc/ctype/jp2uc.c +++ b/newlib/libc/ctype/jp2uc.c @@ -36,7 +36,6 @@ /* Under Cygwin, the incoming wide character is already given in UTF due to the requirements of the underlying OS. */ -#include #include #include #include "local.h" diff --git a/newlib/libc/ctype/toascii.c b/newlib/libc/ctype/toascii.c index 6494933eea..5f5ead83ee 100644 --- a/newlib/libc/ctype/toascii.c +++ b/newlib/libc/ctype/toascii.c @@ -65,7 +65,6 @@ No supporting OS subroutines are required. */ #define _GNU_SOURCE -#include #include #undef toascii diff --git a/newlib/libc/ctype/toascii_l.c b/newlib/libc/ctype/toascii_l.c index e1c9319548..5558f73016 100644 --- a/newlib/libc/ctype/toascii_l.c +++ b/newlib/libc/ctype/toascii_l.c @@ -3,7 +3,6 @@ Copyright (c) 2016 Corinna Vinschen Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #undef toascii_l diff --git a/newlib/libc/ctype/towctrans.c b/newlib/libc/ctype/towctrans.c index 858e997f01..f7e0b93187 100644 --- a/newlib/libc/ctype/towctrans.c +++ b/newlib/libc/ctype/towctrans.c @@ -70,7 +70,6 @@ No supporting OS subroutines are required. */ #define _DEFAULT_SOURCE -#include #include //#include #include "local.h" diff --git a/newlib/libc/ctype/towctrans_l.c b/newlib/libc/ctype/towctrans_l.c index fb73a6e25e..3ae07c3601 100644 --- a/newlib/libc/ctype/towctrans_l.c +++ b/newlib/libc/ctype/towctrans_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include //#include diff --git a/newlib/libc/ctype/towlower.c b/newlib/libc/ctype/towlower.c index 413c3e9cf7..6a55902da5 100644 --- a/newlib/libc/ctype/towlower.c +++ b/newlib/libc/ctype/towlower.c @@ -65,7 +65,6 @@ PORTABILITY No supporting OS subroutines are required. */ -#include #include #include #include "local.h" diff --git a/newlib/libc/ctype/towlower_l.c b/newlib/libc/ctype/towlower_l.c index d6c1331dfc..43396f4f15 100644 --- a/newlib/libc/ctype/towlower_l.c +++ b/newlib/libc/ctype/towlower_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/ctype/towupper.c b/newlib/libc/ctype/towupper.c index 0352369d93..ad677dfa42 100644 --- a/newlib/libc/ctype/towupper.c +++ b/newlib/libc/ctype/towupper.c @@ -65,7 +65,6 @@ PORTABILITY No supporting OS subroutines are required. */ -#include #include #include #include diff --git a/newlib/libc/ctype/towupper_l.c b/newlib/libc/ctype/towupper_l.c index 69eb4bb701..73668a295e 100644 --- a/newlib/libc/ctype/towupper_l.c +++ b/newlib/libc/ctype/towupper_l.c @@ -4,7 +4,6 @@ Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/ctype/wctrans.c b/newlib/libc/ctype/wctrans.c index c0f8018eb3..bd7211efea 100644 --- a/newlib/libc/ctype/wctrans.c +++ b/newlib/libc/ctype/wctrans.c @@ -67,7 +67,6 @@ PORTABILITY No supporting OS subroutines are required. */ -#include #include #include #include diff --git a/newlib/libc/ctype/wctrans_l.c b/newlib/libc/ctype/wctrans_l.c index 725d872531..4323cc3be5 100644 --- a/newlib/libc/ctype/wctrans_l.c +++ b/newlib/libc/ctype/wctrans_l.c @@ -3,7 +3,6 @@ Copyright (c) 2016 Corinna Vinschen Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include wctrans_t diff --git a/newlib/libc/ctype/wctype_l.c b/newlib/libc/ctype/wctype_l.c index 8a499f1c41..e98f18ca6a 100644 --- a/newlib/libc/ctype/wctype_l.c +++ b/newlib/libc/ctype/wctype_l.c @@ -3,7 +3,6 @@ Copyright (c) 2016 Corinna Vinschen Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #define _DEFAULT_SOURCE -#include #include wctype_t diff --git a/newlib/libc/iconv/ccs/big5.c b/newlib/libc/iconv/ccs/big5.c index f0d5bc9f5a..852a27f3a4 100644 --- a/newlib/libc/iconv/ccs/big5.c +++ b/newlib/libc/iconv/ccs/big5.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_BIG5) \ || defined (ICONV_FROM_UCS_CCS_BIG5) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/ccs.h b/newlib/libc/iconv/ccs/ccs.h index 183286f096..21d531b866 100644 --- a/newlib/libc/iconv/ccs/ccs.h +++ b/newlib/libc/iconv/ccs/ccs.h @@ -25,9 +25,9 @@ #ifndef __CCS_H__ #define __CCS_H__ -#include #include #include +#include /* * Size-optimized tables will be linked instead of speed-optimized if diff --git a/newlib/libc/iconv/ccs/ccsbi.c b/newlib/libc/iconv/ccs/ccsbi.c index ece45279ff..33e06eecc9 100644 --- a/newlib/libc/iconv/ccs/ccsbi.c +++ b/newlib/libc/iconv/ccs/ccsbi.c @@ -2,7 +2,6 @@ * This file was automatically generated mkdeps.pl script. Don't edit. */ -#include #include "ccsbi.h" /* diff --git a/newlib/libc/iconv/ccs/ccsbi.h b/newlib/libc/iconv/ccs/ccsbi.h index 4e3890e08a..5a83de1d90 100644 --- a/newlib/libc/iconv/ccs/ccsbi.h +++ b/newlib/libc/iconv/ccs/ccsbi.h @@ -5,8 +5,6 @@ #ifndef __CCSBI_H__ #define __CCSBI_H__ -#include -#include #include "ccs.h" /* diff --git a/newlib/libc/iconv/ccs/cns11643_plane1.c b/newlib/libc/iconv/ccs/cns11643_plane1.c index 8e3efba9ee..8f45962e72 100644 --- a/newlib/libc/iconv/ccs/cns11643_plane1.c +++ b/newlib/libc/iconv/ccs/cns11643_plane1.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_CNS11643_PLANE1) \ || defined (ICONV_FROM_UCS_CCS_CNS11643_PLANE1) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/cns11643_plane14.c b/newlib/libc/iconv/ccs/cns11643_plane14.c index a31677d23d..4aa7748283 100644 --- a/newlib/libc/iconv/ccs/cns11643_plane14.c +++ b/newlib/libc/iconv/ccs/cns11643_plane14.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_CNS11643_PLANE14) \ || defined (ICONV_FROM_UCS_CCS_CNS11643_PLANE14) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/cns11643_plane2.c b/newlib/libc/iconv/ccs/cns11643_plane2.c index facacd019e..cfb2fb553c 100644 --- a/newlib/libc/iconv/ccs/cns11643_plane2.c +++ b/newlib/libc/iconv/ccs/cns11643_plane2.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_CNS11643_PLANE2) \ || defined (ICONV_FROM_UCS_CCS_CNS11643_PLANE2) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/cp775.c b/newlib/libc/iconv/ccs/cp775.c index 03ab02fe84..cbb50a80a8 100644 --- a/newlib/libc/iconv/ccs/cp775.c +++ b/newlib/libc/iconv/ccs/cp775.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_CP775) \ || defined (ICONV_FROM_UCS_CCS_CP775) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/cp850.c b/newlib/libc/iconv/ccs/cp850.c index 85925a326e..3bb37ec943 100644 --- a/newlib/libc/iconv/ccs/cp850.c +++ b/newlib/libc/iconv/ccs/cp850.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_CP850) \ || defined (ICONV_FROM_UCS_CCS_CP850) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/cp852.c b/newlib/libc/iconv/ccs/cp852.c index e670845c85..140b8b2aa0 100644 --- a/newlib/libc/iconv/ccs/cp852.c +++ b/newlib/libc/iconv/ccs/cp852.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_CP852) \ || defined (ICONV_FROM_UCS_CCS_CP852) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/cp855.c b/newlib/libc/iconv/ccs/cp855.c index 5ed43a5b03..5b00ee20cf 100644 --- a/newlib/libc/iconv/ccs/cp855.c +++ b/newlib/libc/iconv/ccs/cp855.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_CP855) \ || defined (ICONV_FROM_UCS_CCS_CP855) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/cp866.c b/newlib/libc/iconv/ccs/cp866.c index 8de71fd3cf..133aad7345 100644 --- a/newlib/libc/iconv/ccs/cp866.c +++ b/newlib/libc/iconv/ccs/cp866.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_CP866) \ || defined (ICONV_FROM_UCS_CCS_CP866) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_1.c b/newlib/libc/iconv/ccs/iso_8859_1.c index 2dd680225f..a1539eb53a 100644 --- a/newlib/libc/iconv/ccs/iso_8859_1.c +++ b/newlib/libc/iconv/ccs/iso_8859_1.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_1) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_1) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_10.c b/newlib/libc/iconv/ccs/iso_8859_10.c index 07456df66e..fe4c3f1d50 100644 --- a/newlib/libc/iconv/ccs/iso_8859_10.c +++ b/newlib/libc/iconv/ccs/iso_8859_10.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_10) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_10) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_11.c b/newlib/libc/iconv/ccs/iso_8859_11.c index 3053e0acf8..b3fc381d00 100644 --- a/newlib/libc/iconv/ccs/iso_8859_11.c +++ b/newlib/libc/iconv/ccs/iso_8859_11.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_11) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_11) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_13.c b/newlib/libc/iconv/ccs/iso_8859_13.c index 53451b473c..11f260f003 100644 --- a/newlib/libc/iconv/ccs/iso_8859_13.c +++ b/newlib/libc/iconv/ccs/iso_8859_13.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_13) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_13) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_14.c b/newlib/libc/iconv/ccs/iso_8859_14.c index c29b56c035..de1d9dd9be 100644 --- a/newlib/libc/iconv/ccs/iso_8859_14.c +++ b/newlib/libc/iconv/ccs/iso_8859_14.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_14) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_14) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_15.c b/newlib/libc/iconv/ccs/iso_8859_15.c index bc2037f6cc..900e91e33e 100644 --- a/newlib/libc/iconv/ccs/iso_8859_15.c +++ b/newlib/libc/iconv/ccs/iso_8859_15.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_15) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_15) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_2.c b/newlib/libc/iconv/ccs/iso_8859_2.c index e69df7bcca..e466591657 100644 --- a/newlib/libc/iconv/ccs/iso_8859_2.c +++ b/newlib/libc/iconv/ccs/iso_8859_2.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_2) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_2) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_3.c b/newlib/libc/iconv/ccs/iso_8859_3.c index 679b93f06c..7449bd78e1 100644 --- a/newlib/libc/iconv/ccs/iso_8859_3.c +++ b/newlib/libc/iconv/ccs/iso_8859_3.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_3) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_3) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_4.c b/newlib/libc/iconv/ccs/iso_8859_4.c index d86258c705..89f5ea6063 100644 --- a/newlib/libc/iconv/ccs/iso_8859_4.c +++ b/newlib/libc/iconv/ccs/iso_8859_4.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_4) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_4) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_5.c b/newlib/libc/iconv/ccs/iso_8859_5.c index 788c9b1eba..cc57e028f1 100644 --- a/newlib/libc/iconv/ccs/iso_8859_5.c +++ b/newlib/libc/iconv/ccs/iso_8859_5.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_5) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_5) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_6.c b/newlib/libc/iconv/ccs/iso_8859_6.c index c5b4227f89..06363fd2cb 100644 --- a/newlib/libc/iconv/ccs/iso_8859_6.c +++ b/newlib/libc/iconv/ccs/iso_8859_6.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_6) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_6) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_7.c b/newlib/libc/iconv/ccs/iso_8859_7.c index e06375de1c..76ee7d1932 100644 --- a/newlib/libc/iconv/ccs/iso_8859_7.c +++ b/newlib/libc/iconv/ccs/iso_8859_7.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_7) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_7) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_8.c b/newlib/libc/iconv/ccs/iso_8859_8.c index 2221cc2154..8f48ac7b6f 100644 --- a/newlib/libc/iconv/ccs/iso_8859_8.c +++ b/newlib/libc/iconv/ccs/iso_8859_8.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_8) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_8) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_8859_9.c b/newlib/libc/iconv/ccs/iso_8859_9.c index cbc20cd202..dd6a68922e 100644 --- a/newlib/libc/iconv/ccs/iso_8859_9.c +++ b/newlib/libc/iconv/ccs/iso_8859_9.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_8859_9) \ || defined (ICONV_FROM_UCS_CCS_ISO_8859_9) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/iso_ir_111.c b/newlib/libc/iconv/ccs/iso_ir_111.c index 34988c466d..d6a6252469 100644 --- a/newlib/libc/iconv/ccs/iso_ir_111.c +++ b/newlib/libc/iconv/ccs/iso_ir_111.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_ISO_IR_111) \ || defined (ICONV_FROM_UCS_CCS_ISO_IR_111) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/jis_x0201_1976.c b/newlib/libc/iconv/ccs/jis_x0201_1976.c index 1a2907efac..da0bf131a1 100644 --- a/newlib/libc/iconv/ccs/jis_x0201_1976.c +++ b/newlib/libc/iconv/ccs/jis_x0201_1976.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_JIS_X0201_1976) \ || defined (ICONV_FROM_UCS_CCS_JIS_X0201_1976) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/jis_x0208_1990.c b/newlib/libc/iconv/ccs/jis_x0208_1990.c index 08e1275215..e459aa7b30 100644 --- a/newlib/libc/iconv/ccs/jis_x0208_1990.c +++ b/newlib/libc/iconv/ccs/jis_x0208_1990.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_JIS_X0208_1990) \ || defined (ICONV_FROM_UCS_CCS_JIS_X0208_1990) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/jis_x0212_1990.c b/newlib/libc/iconv/ccs/jis_x0212_1990.c index eef2fbc86f..b8aeffcdde 100644 --- a/newlib/libc/iconv/ccs/jis_x0212_1990.c +++ b/newlib/libc/iconv/ccs/jis_x0212_1990.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_JIS_X0212_1990) \ || defined (ICONV_FROM_UCS_CCS_JIS_X0212_1990) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/koi8_r.c b/newlib/libc/iconv/ccs/koi8_r.c index ca88a1a73e..4f315fbeb3 100644 --- a/newlib/libc/iconv/ccs/koi8_r.c +++ b/newlib/libc/iconv/ccs/koi8_r.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_KOI8_R) \ || defined (ICONV_FROM_UCS_CCS_KOI8_R) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/koi8_ru.c b/newlib/libc/iconv/ccs/koi8_ru.c index f013d99b2a..05f543c907 100644 --- a/newlib/libc/iconv/ccs/koi8_ru.c +++ b/newlib/libc/iconv/ccs/koi8_ru.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_KOI8_RU) \ || defined (ICONV_FROM_UCS_CCS_KOI8_RU) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/koi8_u.c b/newlib/libc/iconv/ccs/koi8_u.c index 620a9b0a97..22d6ee3982 100644 --- a/newlib/libc/iconv/ccs/koi8_u.c +++ b/newlib/libc/iconv/ccs/koi8_u.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_KOI8_U) \ || defined (ICONV_FROM_UCS_CCS_KOI8_U) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/koi8_uni.c b/newlib/libc/iconv/ccs/koi8_uni.c index fec002dcc1..d3df9f056f 100644 --- a/newlib/libc/iconv/ccs/koi8_uni.c +++ b/newlib/libc/iconv/ccs/koi8_uni.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_KOI8_UNI) \ || defined (ICONV_FROM_UCS_CCS_KOI8_UNI) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/ksx1001.c b/newlib/libc/iconv/ccs/ksx1001.c index 056e833d01..f139795440 100644 --- a/newlib/libc/iconv/ccs/ksx1001.c +++ b/newlib/libc/iconv/ccs/ksx1001.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_KSX1001) \ || defined (ICONV_FROM_UCS_CCS_KSX1001) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/mktbl.pl b/newlib/libc/iconv/ccs/mktbl.pl index 16dc51750f..12daaaef47 100755 --- a/newlib/libc/iconv/ccs/mktbl.pl +++ b/newlib/libc/iconv/ccs/mktbl.pl @@ -290,7 +290,6 @@ #if defined ($GuardToUCS) \\ || defined ($GuardFromUCS) -#include #include #include #include \"ccs.h\" diff --git a/newlib/libc/iconv/ccs/win_1250.c b/newlib/libc/iconv/ccs/win_1250.c index cb2d4aba3b..bd297104c6 100644 --- a/newlib/libc/iconv/ccs/win_1250.c +++ b/newlib/libc/iconv/ccs/win_1250.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_WIN_1250) \ || defined (ICONV_FROM_UCS_CCS_WIN_1250) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/win_1251.c b/newlib/libc/iconv/ccs/win_1251.c index 16cd1a6302..04580bca11 100644 --- a/newlib/libc/iconv/ccs/win_1251.c +++ b/newlib/libc/iconv/ccs/win_1251.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_WIN_1251) \ || defined (ICONV_FROM_UCS_CCS_WIN_1251) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/win_1252.c b/newlib/libc/iconv/ccs/win_1252.c index 6fa02385e4..32a40d14b4 100644 --- a/newlib/libc/iconv/ccs/win_1252.c +++ b/newlib/libc/iconv/ccs/win_1252.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_WIN_1252) \ || defined (ICONV_FROM_UCS_CCS_WIN_1252) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/win_1253.c b/newlib/libc/iconv/ccs/win_1253.c index 6d8157cc52..8cdf032dda 100644 --- a/newlib/libc/iconv/ccs/win_1253.c +++ b/newlib/libc/iconv/ccs/win_1253.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_WIN_1253) \ || defined (ICONV_FROM_UCS_CCS_WIN_1253) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/win_1254.c b/newlib/libc/iconv/ccs/win_1254.c index 05ef1c5be1..40d91a8a5c 100644 --- a/newlib/libc/iconv/ccs/win_1254.c +++ b/newlib/libc/iconv/ccs/win_1254.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_WIN_1254) \ || defined (ICONV_FROM_UCS_CCS_WIN_1254) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/win_1255.c b/newlib/libc/iconv/ccs/win_1255.c index 7a7cfa7232..469e2b1c54 100644 --- a/newlib/libc/iconv/ccs/win_1255.c +++ b/newlib/libc/iconv/ccs/win_1255.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_WIN_1255) \ || defined (ICONV_FROM_UCS_CCS_WIN_1255) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/win_1256.c b/newlib/libc/iconv/ccs/win_1256.c index a8f7227ef9..8109ba3051 100644 --- a/newlib/libc/iconv/ccs/win_1256.c +++ b/newlib/libc/iconv/ccs/win_1256.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_WIN_1256) \ || defined (ICONV_FROM_UCS_CCS_WIN_1256) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/win_1257.c b/newlib/libc/iconv/ccs/win_1257.c index 3512067bea..8fe4e4b787 100644 --- a/newlib/libc/iconv/ccs/win_1257.c +++ b/newlib/libc/iconv/ccs/win_1257.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_WIN_1257) \ || defined (ICONV_FROM_UCS_CCS_WIN_1257) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ccs/win_1258.c b/newlib/libc/iconv/ccs/win_1258.c index 8491a5a390..b112c7875b 100644 --- a/newlib/libc/iconv/ccs/win_1258.c +++ b/newlib/libc/iconv/ccs/win_1258.c @@ -8,7 +8,6 @@ #if defined (ICONV_TO_UCS_CCS_WIN_1258) \ || defined (ICONV_FROM_UCS_CCS_WIN_1258) -#include #include #include #include "ccs.h" diff --git a/newlib/libc/iconv/ces/cesbi.h b/newlib/libc/iconv/ces/cesbi.h index 59daadbb02..881f252ee0 100644 --- a/newlib/libc/iconv/ces/cesbi.h +++ b/newlib/libc/iconv/ces/cesbi.h @@ -5,7 +5,6 @@ #ifndef __CESBI_H__ #define __CESBI_H__ -#include #include "../lib/encnames.h" #include "../lib/ucsconv.h" diff --git a/newlib/libc/iconv/ces/mkdeps.pl b/newlib/libc/iconv/ces/mkdeps.pl index 5bcc7c3033..8b596ecf42 100755 --- a/newlib/libc/iconv/ces/mkdeps.pl +++ b/newlib/libc/iconv/ces/mkdeps.pl @@ -472,7 +472,6 @@ ($$) print CESBI_H "$comment_automatic\n\n"; print CESBI_H "#ifndef __CESBI_H__\n"; print CESBI_H "#define __CESBI_H__\n\n"; - print CESBI_H "#include \n"; print CESBI_H "#include \"../lib/encnames.h\"\n"; print CESBI_H "#include \"../lib/ucsconv.h\"\n\n"; print CESBI_H "/*\n"; @@ -584,7 +583,6 @@ ($) or err "Can't create \"../lib/aliasesbi.c\" file for writing.\nSystem error message: $!.\n"; print ALIASESBI_C "$comment_automatic\n\n"; - print ALIASESBI_C "#include \n"; print ALIASESBI_C "#include \"encnames.h\"\n\n"; print ALIASESBI_C "const char\n"; print ALIASESBI_C "$var_aliases\[\] =\n"; @@ -706,7 +704,6 @@ ($) print CCSBI_H "$comment_automatic\n\n"; print CCSBI_H "#ifndef __CCSBI_H__\n"; print CCSBI_H "#define __CCSBI_H__\n\n"; - print CCSBI_H "#include \n"; print CCSBI_H "#include \"ccs.h\"\n\n"; print CCSBI_H "/*\n"; print CCSBI_H " * Enable CCS tables if encoding needs them.\n"; @@ -778,7 +775,6 @@ ($) or err "Can't create \"cesbi.c\" file for writing.\nSystem error message: $!.\n"; print CESBI_C "$comment_automatic\n\n"; - print CESBI_C "#include \n"; print CESBI_C "#include \"../lib/ucsconv.h\"\n"; print CESBI_C "#include \"cesbi.h\"\n\n"; print CESBI_C "/*\n"; @@ -860,7 +856,6 @@ ($) or err "Can't create \"../ccs/ccsbi.c\" file for writing.\nSystem error message: $!.\n"; print CESBI_C "$comment_automatic\n\n"; - print CESBI_C "#include \n"; print CESBI_C "#include \"ccsbi.h\"\n\n"; print CESBI_C "/*\n"; print CESBI_C " * The following array contains the list of built-in CCS tables.\n"; diff --git a/newlib/libc/iconv/ces/table-pcs.c b/newlib/libc/iconv/ces/table-pcs.c index 1565ddde0e..b052954293 100644 --- a/newlib/libc/iconv/ces/table-pcs.c +++ b/newlib/libc/iconv/ces/table-pcs.c @@ -32,7 +32,6 @@ #if defined (ICONV_TO_UCS_CES_TABLE_PCS) \ || defined (ICONV_FROM_UCS_CES_TABLE_PCS) -#include #include #include "../lib/local.h" #include "../lib/ucsconv.h" diff --git a/newlib/libc/iconv/ces/ucs-2-internal.c b/newlib/libc/iconv/ces/ucs-2-internal.c index 65a16dfc4c..720e7cf1c2 100644 --- a/newlib/libc/iconv/ces/ucs-2-internal.c +++ b/newlib/libc/iconv/ces/ucs-2-internal.c @@ -28,7 +28,6 @@ #if defined (ICONV_TO_UCS_CES_UCS_2_INTERNAL) \ || defined (ICONV_FROM_UCS_CES_UCS_2_INTERNAL) -#include #include #include #include diff --git a/newlib/libc/iconv/ces/ucs-2.c b/newlib/libc/iconv/ces/ucs-2.c index 8286df7e10..06d428648b 100644 --- a/newlib/libc/iconv/ces/ucs-2.c +++ b/newlib/libc/iconv/ces/ucs-2.c @@ -28,7 +28,6 @@ #if defined (ICONV_TO_UCS_CES_UCS_2) \ || defined (ICONV_FROM_UCS_CES_UCS_2) -#include #include #include #include diff --git a/newlib/libc/iconv/ces/ucs-4-internal.c b/newlib/libc/iconv/ces/ucs-4-internal.c index 5caaf14e02..68fc72c522 100644 --- a/newlib/libc/iconv/ces/ucs-4-internal.c +++ b/newlib/libc/iconv/ces/ucs-4-internal.c @@ -28,7 +28,6 @@ #if defined (ICONV_TO_UCS_CES_UCS_4_INTERNAL) \ || defined (ICONV_FROM_UCS_CES_UCS_4_INTERNAL) -#include #include #include #include diff --git a/newlib/libc/iconv/ces/ucs-4.c b/newlib/libc/iconv/ces/ucs-4.c index 07d0619d73..d8f06326cc 100644 --- a/newlib/libc/iconv/ces/ucs-4.c +++ b/newlib/libc/iconv/ces/ucs-4.c @@ -28,7 +28,6 @@ #if defined (ICONV_TO_UCS_CES_UCS_4) \ || defined (ICONV_FROM_UCS_CES_UCS_4) -#include #include #include #include diff --git a/newlib/libc/iconv/ces/us-ascii.c b/newlib/libc/iconv/ces/us-ascii.c index 32904e58ff..1cf61b534a 100644 --- a/newlib/libc/iconv/ces/us-ascii.c +++ b/newlib/libc/iconv/ces/us-ascii.c @@ -27,7 +27,6 @@ #if defined (ICONV_TO_UCS_CES_US_ASCII) \ || defined (ICONV_FROM_UCS_CES_US_ASCII) -#include #include #include "../lib/local.h" #include "../lib/ucsconv.h" diff --git a/newlib/libc/iconv/ces/utf-16.c b/newlib/libc/iconv/ces/utf-16.c index cb47170be0..f480ba5674 100644 --- a/newlib/libc/iconv/ces/utf-16.c +++ b/newlib/libc/iconv/ces/utf-16.c @@ -28,7 +28,6 @@ #if defined (ICONV_TO_UCS_CES_UTF_16) \ || defined (ICONV_FROM_UCS_CES_UTF_16) -#include #include #include #include diff --git a/newlib/libc/iconv/ces/utf-8.c b/newlib/libc/iconv/ces/utf-8.c index 339c940ea5..7cc03c406b 100644 --- a/newlib/libc/iconv/ces/utf-8.c +++ b/newlib/libc/iconv/ces/utf-8.c @@ -28,7 +28,6 @@ #if defined (ICONV_TO_UCS_CES_UTF_8) \ || defined (ICONV_FROM_UCS_CES_UTF_8) -#include #include #include "../lib/local.h" #include "../lib/ucsconv.h" diff --git a/newlib/libc/iconv/lib/aliasesbi.c b/newlib/libc/iconv/lib/aliasesbi.c index f27b6afdf7..43591ddd14 100644 --- a/newlib/libc/iconv/lib/aliasesbi.c +++ b/newlib/libc/iconv/lib/aliasesbi.c @@ -2,7 +2,7 @@ * This file was automatically generated mkdeps.pl script. Don't edit. */ -#include +#include #include "encnames.h" const char diff --git a/newlib/libc/iconv/lib/aliasesi.c b/newlib/libc/iconv/lib/aliasesi.c index 841688f9b6..e6306673e5 100644 --- a/newlib/libc/iconv/lib/aliasesi.c +++ b/newlib/libc/iconv/lib/aliasesi.c @@ -23,7 +23,6 @@ * SUCH DAMAGE. */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/iconv/lib/conv.h b/newlib/libc/iconv/lib/conv.h index 13b73abdbc..9dfa0ce121 100644 --- a/newlib/libc/iconv/lib/conv.h +++ b/newlib/libc/iconv/lib/conv.h @@ -26,7 +26,6 @@ #ifndef __ICONV_CONVERSION_H__ #define __ICONV_CONVERSION_H__ -#include #include #include diff --git a/newlib/libc/iconv/lib/iconv.c b/newlib/libc/iconv/lib/iconv.c index 011d15bbed..72e0e4b507 100644 --- a/newlib/libc/iconv/lib/iconv.c +++ b/newlib/libc/iconv/lib/iconv.c @@ -83,7 +83,6 @@ by the Single Unix specification. No supporting OS subroutine calls are required. */ -#include #include #include #include diff --git a/newlib/libc/iconv/lib/iconvnls.c b/newlib/libc/iconv/lib/iconvnls.c index 52c0a386d0..63500c945f 100644 --- a/newlib/libc/iconv/lib/iconvnls.c +++ b/newlib/libc/iconv/lib/iconvnls.c @@ -22,7 +22,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include #include #include #include diff --git a/newlib/libc/iconv/lib/local.h b/newlib/libc/iconv/lib/local.h index 0cac25fcec..d7eb72faac 100644 --- a/newlib/libc/iconv/lib/local.h +++ b/newlib/libc/iconv/lib/local.h @@ -25,7 +25,6 @@ #ifndef __ICONV_LIB_LOCAL_H__ #define __ICONV_LIB_LOCAL_H__ -#include #include #include diff --git a/newlib/libc/iconv/lib/nullconv.c b/newlib/libc/iconv/lib/nullconv.c index 5095fbf8ef..0702569c73 100644 --- a/newlib/libc/iconv/lib/nullconv.c +++ b/newlib/libc/iconv/lib/nullconv.c @@ -23,7 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include #include #include #include diff --git a/newlib/libc/iconv/lib/ucsconv.c b/newlib/libc/iconv/lib/ucsconv.c index 9b0c0613f2..46930169ef 100644 --- a/newlib/libc/iconv/lib/ucsconv.c +++ b/newlib/libc/iconv/lib/ucsconv.c @@ -23,7 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include #include #include #include diff --git a/newlib/libc/iconv/lib/ucsconv.h b/newlib/libc/iconv/lib/ucsconv.h index d0e9cf5fed..11d15eec23 100644 --- a/newlib/libc/iconv/lib/ucsconv.h +++ b/newlib/libc/iconv/lib/ucsconv.h @@ -26,7 +26,6 @@ #ifndef __ICONV_UCS_CONVERSION_H__ #define __ICONV_UCS_CONVERSION_H__ -#include #include #include #include "local.h" diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h index 26366e7577..28875f00e5 100644 --- a/newlib/libc/include/sys/cdefs.h +++ b/newlib/libc/include/sys/cdefs.h @@ -674,26 +674,6 @@ #endif /* __GNUC__ */ -#ifndef __FBSDID -#define __FBSDID(s) struct __hack -#endif - -#ifndef __RCSID -#define __RCSID(s) struct __hack -#endif - -#ifndef __RCSID_SOURCE -#define __RCSID_SOURCE(s) struct __hack -#endif - -#ifndef __SCCSID -#define __SCCSID(s) struct __hack -#endif - -#ifndef __COPYRIGHT -#define __COPYRIGHT(s) struct __hack -#endif - #ifndef __DECONST #define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var)) #endif diff --git a/newlib/libc/locale/setlocale.h b/newlib/libc/locale/setlocale.h index c3c9d09cdd..fded7d00f5 100644 --- a/newlib/libc/locale/setlocale.h +++ b/newlib/libc/locale/setlocale.h @@ -29,7 +29,6 @@ #ifndef _SETLOCALE_H_ #define _SETLOCALE_H_ -#include #include #include #include diff --git a/newlib/libc/machine/aarch64/sys/fenv.h b/newlib/libc/machine/aarch64/sys/fenv.h index 06d5994ced..4deef4d3d8 100644 --- a/newlib/libc/machine/aarch64/sys/fenv.h +++ b/newlib/libc/machine/aarch64/sys/fenv.h @@ -29,7 +29,6 @@ #ifndef _FENV_H_ #define _FENV_H_ -#include #include #ifdef __cplusplus diff --git a/newlib/libc/machine/arm/aeabi_memset.c b/newlib/libc/machine/arm/aeabi_memset.c index 22d6c5a6a4..960d2ad204 100644 --- a/newlib/libc/machine/arm/aeabi_memset.c +++ b/newlib/libc/machine/arm/aeabi_memset.c @@ -30,7 +30,6 @@ #include #include -#include /* Support the alias for the __aeabi_memset which may assume memory alignment. */ diff --git a/newlib/libc/machine/arm/memset.c b/newlib/libc/machine/arm/memset.c index 1c786c29c9..8f5a991d32 100644 --- a/newlib/libc/machine/arm/memset.c +++ b/newlib/libc/machine/arm/memset.c @@ -30,7 +30,6 @@ #include #include -#include /* According to the run-time ABI for the ARM Architecture, this function is allowed to corrupt only the integer core register diff --git a/newlib/libc/machine/arm/strlen.c b/newlib/libc/machine/arm/strlen.c index fa076e2c39..3727d15f3d 100644 --- a/newlib/libc/machine/arm/strlen.c +++ b/newlib/libc/machine/arm/strlen.c @@ -29,7 +29,6 @@ #include #include "arm_asm.h" -#include #include #include diff --git a/newlib/libc/machine/arm/sys/fenv.h b/newlib/libc/machine/arm/sys/fenv.h index 51d24f3391..5179d64441 100644 --- a/newlib/libc/machine/arm/sys/fenv.h +++ b/newlib/libc/machine/arm/sys/fenv.h @@ -31,7 +31,6 @@ #ifndef _SYS_FENV_H_ #define _SYS_FENV_H_ 1 -#include _BEGIN_STD_C diff --git a/newlib/libc/machine/cris/sys/fcntl.h b/newlib/libc/machine/cris/sys/fcntl.h index fac0f10da6..14d5e708df 100644 --- a/newlib/libc/machine/cris/sys/fcntl.h +++ b/newlib/libc/machine/cris/sys/fcntl.h @@ -35,7 +35,6 @@ POSSIBILITY OF SUCH DAMAGE. extern "C" { #endif #define _FCNTL_ -#include #define _FOPEN (-1) /* from sys/file.h, kernel use only */ #define _FREAD 0x0001 /* read enabled */ #define _FWRITE 0x0002 /* write enabled */ diff --git a/newlib/libc/machine/cris/sys/signal.h b/newlib/libc/machine/cris/sys/signal.h index 26c33da00d..6335c811ed 100644 --- a/newlib/libc/machine/cris/sys/signal.h +++ b/newlib/libc/machine/cris/sys/signal.h @@ -39,7 +39,6 @@ POSSIBILITY OF SUCH DAMAGE. extern "C" { #endif -#include #include #include diff --git a/newlib/libc/machine/m68k/sys/fenv.h b/newlib/libc/machine/m68k/sys/fenv.h index 13857c47e6..aeb917e923 100644 --- a/newlib/libc/machine/m68k/sys/fenv.h +++ b/newlib/libc/machine/m68k/sys/fenv.h @@ -36,7 +36,6 @@ #ifndef _SYS_FENV_H_ #define _SYS_FENV_H_ -#include #ifdef __cplusplus extern "C" { diff --git a/newlib/libc/machine/microblaze/strlen.c b/newlib/libc/machine/microblaze/strlen.c index 1bef4029d1..15c4a2fbc1 100644 --- a/newlib/libc/machine/microblaze/strlen.c +++ b/newlib/libc/machine/microblaze/strlen.c @@ -57,7 +57,6 @@ QUICKREF #include -#include #include #include diff --git a/newlib/libc/machine/mips/sys/fenv.h b/newlib/libc/machine/mips/sys/fenv.h index da9e05e991..f1017a726a 100644 --- a/newlib/libc/machine/mips/sys/fenv.h +++ b/newlib/libc/machine/mips/sys/fenv.h @@ -31,7 +31,6 @@ #ifndef _SYS_FENV_H_ #define _SYS_FENV_H_ -#include #if !defined(__mips_soft_float) && !defined(__mips_hard_float) #error compiler didnt set soft/hard float macros diff --git a/newlib/libc/machine/powerpc/sys/fenv.h b/newlib/libc/machine/powerpc/sys/fenv.h index 34daad9107..8523b89f7f 100644 --- a/newlib/libc/machine/powerpc/sys/fenv.h +++ b/newlib/libc/machine/powerpc/sys/fenv.h @@ -31,7 +31,6 @@ #ifndef _SYS_FENV_H_ #define _SYS_FENV_H_ -#include #ifdef __cplusplus extern "C" { diff --git a/newlib/libc/machine/riscv/sys/fenv.h b/newlib/libc/machine/riscv/sys/fenv.h index 9f29b40566..48bd0420a3 100644 --- a/newlib/libc/machine/riscv/sys/fenv.h +++ b/newlib/libc/machine/riscv/sys/fenv.h @@ -12,7 +12,6 @@ #ifndef _SYS_FENV_H #define _SYS_FENV_H -#include #include #if defined(__riscv_flen) || defined(__riscv_zfinx) diff --git a/newlib/libc/machine/sh/sys/fenv.h b/newlib/libc/machine/sh/sys/fenv.h index 4bff929a14..ae95eda7e9 100644 --- a/newlib/libc/machine/sh/sys/fenv.h +++ b/newlib/libc/machine/sh/sys/fenv.h @@ -31,7 +31,6 @@ #ifndef _SYS_FENV_H_ #define _SYS_FENV_H_ 1 -#include #include _BEGIN_STD_C diff --git a/newlib/libc/machine/sparc/sys/fenv.h b/newlib/libc/machine/sparc/sys/fenv.h index e9de297db9..7d17b7205a 100644 --- a/newlib/libc/machine/sparc/sys/fenv.h +++ b/newlib/libc/machine/sparc/sys/fenv.h @@ -31,7 +31,6 @@ #ifndef _SYS_FENV_H_ #define _SYS_FENV_H_ -#include _BEGIN_STD_C diff --git a/newlib/libc/machine/spu/fclose.c b/newlib/libc/machine/spu/fclose.c index c2504d4c51..8ae3078e9c 100644 --- a/newlib/libc/machine/spu/fclose.c +++ b/newlib/libc/machine/spu/fclose.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/fopen.c b/newlib/libc/machine/spu/fopen.c index 06295240f0..ef53e43de0 100644 --- a/newlib/libc/machine/spu/fopen.c +++ b/newlib/libc/machine/spu/fopen.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/fputc.c b/newlib/libc/machine/spu/fputc.c index 12bb9e8ec8..a483d8eeef 100644 --- a/newlib/libc/machine/spu/fputc.c +++ b/newlib/libc/machine/spu/fputc.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/fputs.c b/newlib/libc/machine/spu/fputs.c index cc974c1f53..e9172b4e35 100644 --- a/newlib/libc/machine/spu/fputs.c +++ b/newlib/libc/machine/spu/fputs.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/fread.c b/newlib/libc/machine/spu/fread.c index 9d311287bf..13cfe97f7f 100644 --- a/newlib/libc/machine/spu/fread.c +++ b/newlib/libc/machine/spu/fread.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/freopen.c b/newlib/libc/machine/spu/freopen.c index 3d07798235..64d3221425 100644 --- a/newlib/libc/machine/spu/freopen.c +++ b/newlib/libc/machine/spu/freopen.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/fseek.c b/newlib/libc/machine/spu/fseek.c index 3292af1284..e95e624d56 100644 --- a/newlib/libc/machine/spu/fseek.c +++ b/newlib/libc/machine/spu/fseek.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/fsetpos.c b/newlib/libc/machine/spu/fsetpos.c index e5a3dc0977..e1b94f0a19 100644 --- a/newlib/libc/machine/spu/fsetpos.c +++ b/newlib/libc/machine/spu/fsetpos.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/fwrite.c b/newlib/libc/machine/spu/fwrite.c index 6d94328ab8..b4bd5bf415 100644 --- a/newlib/libc/machine/spu/fwrite.c +++ b/newlib/libc/machine/spu/fwrite.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/putc.c b/newlib/libc/machine/spu/putc.c index aef4f76fee..49d8f5c889 100644 --- a/newlib/libc/machine/spu/putc.c +++ b/newlib/libc/machine/spu/putc.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/rename.c b/newlib/libc/machine/spu/rename.c index cf627cb962..38ec6b0a8f 100644 --- a/newlib/libc/machine/spu/rename.c +++ b/newlib/libc/machine/spu/rename.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/setbuf.c b/newlib/libc/machine/spu/setbuf.c index 6c6e45d3a4..fc30eb65fc 100644 --- a/newlib/libc/machine/spu/setbuf.c +++ b/newlib/libc/machine/spu/setbuf.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/setvbuf.c b/newlib/libc/machine/spu/setvbuf.c index 7c354d5adb..6aaf596488 100644 --- a/newlib/libc/machine/spu/setvbuf.c +++ b/newlib/libc/machine/spu/setvbuf.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/ungetc.c b/newlib/libc/machine/spu/ungetc.c index 630c9c9fd3..0bdf9e6ecf 100644 --- a/newlib/libc/machine/spu/ungetc.c +++ b/newlib/libc/machine/spu/ungetc.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/vfprintf.c b/newlib/libc/machine/spu/vfprintf.c index c8ab60d5db..481433ff53 100644 --- a/newlib/libc/machine/spu/vfprintf.c +++ b/newlib/libc/machine/spu/vfprintf.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/vfscanf.c b/newlib/libc/machine/spu/vfscanf.c index 2d0750cca5..3bceda4aa9 100644 --- a/newlib/libc/machine/spu/vfscanf.c +++ b/newlib/libc/machine/spu/vfscanf.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/vprintf.c b/newlib/libc/machine/spu/vprintf.c index 0302d480b2..44b05e03e1 100644 --- a/newlib/libc/machine/spu/vprintf.c +++ b/newlib/libc/machine/spu/vprintf.c @@ -29,7 +29,6 @@ POSSIBILITY OF SUCH DAMAGE. */ #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/vscanf.c b/newlib/libc/machine/spu/vscanf.c index e7957564c8..ccb2a7b99d 100644 --- a/newlib/libc/machine/spu/vscanf.c +++ b/newlib/libc/machine/spu/vscanf.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/vsnprintf.c b/newlib/libc/machine/spu/vsnprintf.c index 98d6b1b5ab..803f701b74 100644 --- a/newlib/libc/machine/spu/vsnprintf.c +++ b/newlib/libc/machine/spu/vsnprintf.c @@ -29,7 +29,6 @@ POSSIBILITY OF SUCH DAMAGE. */ #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/vsprintf.c b/newlib/libc/machine/spu/vsprintf.c index 04d427966f..e1fd68f86a 100644 --- a/newlib/libc/machine/spu/vsprintf.c +++ b/newlib/libc/machine/spu/vsprintf.c @@ -30,7 +30,6 @@ POSSIBILITY OF SUCH DAMAGE. #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/spu/vsscanf.c b/newlib/libc/machine/spu/vsscanf.c index 077fd6ca02..7450fb63c4 100644 --- a/newlib/libc/machine/spu/vsscanf.c +++ b/newlib/libc/machine/spu/vsscanf.c @@ -32,7 +32,6 @@ Author: Joel Schopp #include -#include #include #include "c99ppe.h" diff --git a/newlib/libc/machine/x86/sys/fenv.h b/newlib/libc/machine/x86/sys/fenv.h index 3885e50dec..3df0e302c1 100644 --- a/newlib/libc/machine/x86/sys/fenv.h +++ b/newlib/libc/machine/x86/sys/fenv.h @@ -29,7 +29,6 @@ #ifndef _SYS_FENV_H #define _SYS_FENV_H 1 -#include #ifdef __cplusplus extern "C" { diff --git a/newlib/libc/machine/xtensa/sys/fenv.h b/newlib/libc/machine/xtensa/sys/fenv.h index a7586181eb..f634543016 100644 --- a/newlib/libc/machine/xtensa/sys/fenv.h +++ b/newlib/libc/machine/xtensa/sys/fenv.h @@ -29,7 +29,6 @@ #ifndef _SYS_FENV_H #define _SYS_FENV_H -#include #ifdef __cplusplus extern "C" { diff --git a/newlib/libc/misc/__dprintf.c b/newlib/libc/misc/__dprintf.c index 1828c2b899..8cbf154a91 100644 --- a/newlib/libc/misc/__dprintf.c +++ b/newlib/libc/misc/__dprintf.c @@ -32,7 +32,6 @@ We do assume _write_r is working. */ -#include #include #include #include "ctype.h" diff --git a/newlib/libc/misc/unctrl.c b/newlib/libc/misc/unctrl.c index d9e447e57f..f406d9cc1b 100644 --- a/newlib/libc/misc/unctrl.c +++ b/newlib/libc/misc/unctrl.c @@ -59,7 +59,6 @@ No supporting OS subroutines are required. * SUCH DAMAGE. */ -#include #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)unctrl.c 8.1 (Berkeley) 6/4/93"; diff --git a/newlib/libc/picolib/getauxval.c b/newlib/libc/picolib/getauxval.c index f6536df59e..30c44836f4 100644 --- a/newlib/libc/picolib/getauxval.c +++ b/newlib/libc/picolib/getauxval.c @@ -35,7 +35,6 @@ #include #include -#include unsigned long getauxval(unsigned long type) { diff --git a/newlib/libc/picolib/machine/aarch64/interrupt.c b/newlib/libc/picolib/machine/aarch64/interrupt.c index 40a90ea785..66cf102cb9 100644 --- a/newlib/libc/picolib/machine/aarch64/interrupt.c +++ b/newlib/libc/picolib/machine/aarch64/interrupt.c @@ -33,7 +33,6 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include void aarch64_halt_vector(void); diff --git a/newlib/libc/picolib/machine/arm/interrupt.c b/newlib/libc/picolib/machine/arm/interrupt.c index a157152b27..75866dcc7c 100644 --- a/newlib/libc/picolib/machine/arm/interrupt.c +++ b/newlib/libc/picolib/machine/arm/interrupt.c @@ -33,7 +33,6 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include #if __ARM_ARCH_PROFILE == 'M' diff --git a/newlib/libc/picolib/machine/m68k/interrupt.c b/newlib/libc/picolib/machine/m68k/interrupt.c index 381c90ab3a..be35fb4dba 100644 --- a/newlib/libc/picolib/machine/m68k/interrupt.c +++ b/newlib/libc/picolib/machine/m68k/interrupt.c @@ -33,7 +33,6 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include #include static void diff --git a/newlib/libc/posix/collate.c b/newlib/libc/posix/collate.c index 22b2ca1da4..9e19980aec 100644 --- a/newlib/libc/posix/collate.c +++ b/newlib/libc/posix/collate.c @@ -26,9 +26,7 @@ */ #define _GNU_SOURCE -#include -#include "namespace.h" #include "rune.h" #include #include @@ -36,7 +34,6 @@ #include #include #include "sysexits.h" -#include "un-namespace.h" #include "collate.h" @@ -178,16 +175,7 @@ __collate_strdup(u_char *s) void __collate_err(int ex, const char *f) { - const char *s; - int serrno = errno; - - /* Be careful to change write counts if you change the strings */ - write(STDERR_FILENO, "collate_error: ", 15); - write(STDERR_FILENO, f, strlen(f)); - write(STDERR_FILENO, ": ", 2); - s = strerror(serrno); - write(STDERR_FILENO, s, strlen(s)); - write(STDERR_FILENO, "\n", 1); + fprintf(stderr, "collate_error: %s: %s\n", f, strerror(errno)); exit(ex); } diff --git a/newlib/libc/posix/collate.h b/newlib/libc/posix/collate.h index 2e045188ac..06a4b1ea07 100644 --- a/newlib/libc/posix/collate.h +++ b/newlib/libc/posix/collate.h @@ -30,7 +30,6 @@ #ifndef _COLLATE_H_ #define _COLLATE_H_ -#include #include #include diff --git a/newlib/libc/posix/collcmp.c b/newlib/libc/posix/collcmp.c index 24c947080a..67cacb7cf0 100644 --- a/newlib/libc/posix/collcmp.c +++ b/newlib/libc/posix/collcmp.c @@ -25,7 +25,6 @@ */ #define _GNU_SOURCE -#include #define ASCII_COMPATIBLE_COLLATE /* see share/colldef */ diff --git a/newlib/libc/posix/engine.c b/newlib/libc/posix/engine.c index 3bcd7c262f..34fed00e14 100644 --- a/newlib/libc/posix/engine.c +++ b/newlib/libc/posix/engine.c @@ -33,7 +33,6 @@ * @(#)engine.c 8.5 (Berkeley) 3/20/94 */ -#include /* * The matching engine and friends. This file is #included by regexec.c diff --git a/newlib/libc/posix/regerror.c b/newlib/libc/posix/regerror.c index bd2023a925..a4db4a3eb0 100644 --- a/newlib/libc/posix/regerror.c +++ b/newlib/libc/posix/regerror.c @@ -38,7 +38,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94"; #endif /* LIBC_SCCS and not lint */ -#include #include #include diff --git a/newlib/libc/posix/regexec.c b/newlib/libc/posix/regexec.c index fab295f0df..70a2e8d733 100644 --- a/newlib/libc/posix/regexec.c +++ b/newlib/libc/posix/regexec.c @@ -38,7 +38,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94"; #endif /* LIBC_SCCS and not lint */ -#include /* * the outer shell of regexec() diff --git a/newlib/libc/posix/regfree.c b/newlib/libc/posix/regfree.c index 020c785151..232dc90e99 100644 --- a/newlib/libc/posix/regfree.c +++ b/newlib/libc/posix/regfree.c @@ -38,7 +38,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94"; #endif /* LIBC_SCCS and not lint */ -#include #include #include diff --git a/newlib/libc/posix/runetype.h b/newlib/libc/posix/runetype.h index 4562521b9f..f09a14eea4 100644 --- a/newlib/libc/posix/runetype.h +++ b/newlib/libc/posix/runetype.h @@ -37,7 +37,6 @@ #define _RUNETYPE_H_ #include -#include #include #ifdef _BSD_RUNE_T_ diff --git a/newlib/libc/search/hash.c b/newlib/libc/search/hash.c index 93f8346851..4172b88644 100644 --- a/newlib/libc/search/hash.c +++ b/newlib/libc/search/hash.c @@ -31,7 +31,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/search/hash_bigkey.c b/newlib/libc/search/hash_bigkey.c index 757fd319f2..79f8cb39f7 100644 --- a/newlib/libc/search/hash_bigkey.c +++ b/newlib/libc/search/hash_bigkey.c @@ -35,7 +35,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94"; #endif /* LIBC_SCCS and not lint */ -#include /* * PACKAGE: hash diff --git a/newlib/libc/search/hash_buf.c b/newlib/libc/search/hash_buf.c index 4810c63954..86bed03fcb 100644 --- a/newlib/libc/search/hash_buf.c +++ b/newlib/libc/search/hash_buf.c @@ -35,7 +35,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)hash_buf.c 8.5 (Berkeley) 7/15/94"; #endif /* LIBC_SCCS and not lint */ -#include /* * PACKAGE: hash diff --git a/newlib/libc/search/hash_func.c b/newlib/libc/search/hash_func.c index 91b92c1a50..8ca5a0b437 100644 --- a/newlib/libc/search/hash_func.c +++ b/newlib/libc/search/hash_func.c @@ -34,7 +34,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)hash_func.c 8.2 (Berkeley) 2/21/94"; #endif /* LIBC_SCCS and not lint */ -#include #include #include "db_local.h" diff --git a/newlib/libc/search/hash_log2.c b/newlib/libc/search/hash_log2.c index 9eebaae3e0..8e98a85d62 100644 --- a/newlib/libc/search/hash_log2.c +++ b/newlib/libc/search/hash_log2.c @@ -34,7 +34,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)hash_log2.c 8.2 (Berkeley) 5/31/94"; #endif /* LIBC_SCCS and not lint */ -#include #include diff --git a/newlib/libc/search/hash_page.c b/newlib/libc/search/hash_page.c index da0e18f2eb..0f2c43e9ca 100644 --- a/newlib/libc/search/hash_page.c +++ b/newlib/libc/search/hash_page.c @@ -47,7 +47,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/search/hcreate.c b/newlib/libc/search/hcreate.c index 7664353cc2..a93aa7adab 100644 --- a/newlib/libc/search/hcreate.c +++ b/newlib/libc/search/hcreate.c @@ -41,10 +41,8 @@ * nobody had a copy in the office, so... */ -#include #if 0 #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: hcreate.c,v 1.2 2001/02/19 21:26:04 ross Exp $"); #endif /* LIBC_SCCS and not lint */ #endif diff --git a/newlib/libc/search/hcreate_r.c b/newlib/libc/search/hcreate_r.c index 7072453a9d..dab0e0c4e2 100644 --- a/newlib/libc/search/hcreate_r.c +++ b/newlib/libc/search/hcreate_r.c @@ -42,10 +42,8 @@ */ #define _DEFAULT_SOURCE -#include #if 0 #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: hcreate.c,v 1.2 2001/02/19 21:26:04 ross Exp $"); #endif /* LIBC_SCCS and not lint */ #endif diff --git a/newlib/libc/search/ndbm.c b/newlib/libc/search/ndbm.c index 7f32960784..589eb79bad 100644 --- a/newlib/libc/search/ndbm.c +++ b/newlib/libc/search/ndbm.c @@ -35,8 +35,6 @@ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)ndbm.c 8.4 (Berkeley) 7/21/94"; #endif /* LIBC_SCCS and not lint */ -#include -__FBSDID("$FreeBSD$ : src/lib/libc/db/hash/ndbm.c Nov 20 19:49:47 2017 UTC by pfg - SVN Revision 326025"); /* * This package provides a dbm compatible interface to the new hashing diff --git a/newlib/libc/search/qsort.c b/newlib/libc/search/qsort.c index f8331ee903..216557ac43 100644 --- a/newlib/libc/search/qsort.c +++ b/newlib/libc/search/qsort.c @@ -67,7 +67,6 @@ PORTABILITY #else #define _DEFAULT_SOURCE #endif -#include #include #include diff --git a/newlib/libc/search/tdelete.c b/newlib/libc/search/tdelete.c index 311596511c..1a6ca5a981 100644 --- a/newlib/libc/search/tdelete.c +++ b/newlib/libc/search/tdelete.c @@ -39,10 +39,8 @@ SUCH DAMAGE. * Totally public domain. */ -#include #if 0 #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $"); #endif /* LIBC_SCCS and not lint */ #endif diff --git a/newlib/libc/search/tdestroy.c b/newlib/libc/search/tdestroy.c index d837941c24..cd0fa5ae19 100644 --- a/newlib/libc/search/tdestroy.c +++ b/newlib/libc/search/tdestroy.c @@ -39,10 +39,8 @@ SUCH DAMAGE. * Totally public domain. */ -#include #if 0 #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: tdelete.c,v 1.2 1999/09/16 11:45:37 lukem Exp $"); #endif /* LIBC_SCCS and not lint */ #endif diff --git a/newlib/libc/search/tfind.c b/newlib/libc/search/tfind.c index f0e8358008..826697701c 100644 --- a/newlib/libc/search/tfind.c +++ b/newlib/libc/search/tfind.c @@ -39,10 +39,8 @@ SUCH DAMAGE. * Totally public domain. */ -#include #if 0 #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: tfind.c,v 1.2 1999/09/16 11:45:37 lukem Exp $"); #endif /* LIBC_SCCS and not lint */ #endif diff --git a/newlib/libc/search/tsearch.c b/newlib/libc/search/tsearch.c index d7c869e4df..5a8d29ce90 100644 --- a/newlib/libc/search/tsearch.c +++ b/newlib/libc/search/tsearch.c @@ -39,10 +39,8 @@ SUCH DAMAGE. * Totally public domain. */ -#include #if 0 #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: tsearch.c,v 1.3 1999/09/16 11:45:37 lukem Exp $"); #endif /* LIBC_SCCS and not lint */ #endif diff --git a/newlib/libc/search/twalk.c b/newlib/libc/search/twalk.c index 68dc503879..92e4cc123e 100644 --- a/newlib/libc/search/twalk.c +++ b/newlib/libc/search/twalk.c @@ -39,10 +39,8 @@ SUCH DAMAGE. * Totally public domain. */ -#include #if 0 #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: twalk.c,v 1.1 1999/02/22 10:33:16 christos Exp $"); #endif /* LIBC_SCCS and not lint */ #endif diff --git a/newlib/libc/signal/psignal.c b/newlib/libc/signal/psignal.c index 9763d2f31d..4cfa8306df 100644 --- a/newlib/libc/signal/psignal.c +++ b/newlib/libc/signal/psignal.c @@ -30,7 +30,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/ssp/gets_chk.c b/newlib/libc/ssp/gets_chk.c index 7eaf829996..76baea89a6 100644 --- a/newlib/libc/ssp/gets_chk.c +++ b/newlib/libc/ssp/gets_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: gets_chk.c,v 1.7 2013/10/04 20:49:16 christos Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/memcpy_chk.c b/newlib/libc/ssp/memcpy_chk.c index 63f536dc59..0c4d5b7def 100644 --- a/newlib/libc/ssp/memcpy_chk.c +++ b/newlib/libc/ssp/memcpy_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: memcpy_chk.c,v 1.7 2015/05/13 19:57:16 joerg Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/memmove_chk.c b/newlib/libc/ssp/memmove_chk.c index 3fe2dd5382..f1e3911856 100644 --- a/newlib/libc/ssp/memmove_chk.c +++ b/newlib/libc/ssp/memmove_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: memmove_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/mempcpy_chk.c b/newlib/libc/ssp/mempcpy_chk.c index d141acf332..1f02fabb24 100644 --- a/newlib/libc/ssp/mempcpy_chk.c +++ b/newlib/libc/ssp/mempcpy_chk.c @@ -24,7 +24,6 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #define _GNU_SOURCE -#include #include #include diff --git a/newlib/libc/ssp/memset_chk.c b/newlib/libc/ssp/memset_chk.c index 0e303b9eba..2f70bd1e83 100644 --- a/newlib/libc/ssp/memset_chk.c +++ b/newlib/libc/ssp/memset_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: memset_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/snprintf_chk.c b/newlib/libc/ssp/snprintf_chk.c index 4f52b9c265..78de3f1681 100644 --- a/newlib/libc/ssp/snprintf_chk.c +++ b/newlib/libc/ssp/snprintf_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: snprintf_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/sprintf_chk.c b/newlib/libc/ssp/sprintf_chk.c index 83d964575d..1ecdb3e1f2 100644 --- a/newlib/libc/ssp/sprintf_chk.c +++ b/newlib/libc/ssp/sprintf_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: sprintf_chk.c,v 1.6 2009/02/05 05:40:36 lukem Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/stack_protector.c b/newlib/libc/ssp/stack_protector.c index 4d91f4e22a..05bbbfe0c4 100644 --- a/newlib/libc/ssp/stack_protector.c +++ b/newlib/libc/ssp/stack_protector.c @@ -1,5 +1,4 @@ /* Copyright (c) 2017 Yaakov Selkowitz */ -#include #include #include #include diff --git a/newlib/libc/ssp/stpcpy_chk.c b/newlib/libc/ssp/stpcpy_chk.c index 7785874666..07dad20d0a 100644 --- a/newlib/libc/ssp/stpcpy_chk.c +++ b/newlib/libc/ssp/stpcpy_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: stpcpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/stpncpy_chk.c b/newlib/libc/ssp/stpncpy_chk.c index 6e66a510b4..48e2024bd0 100644 --- a/newlib/libc/ssp/stpncpy_chk.c +++ b/newlib/libc/ssp/stpncpy_chk.c @@ -29,8 +29,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ #define _DEFAULT_SOURCE -#include -__RCSID("$NetBSD: stpncpy_chk.c,v 1.3 2015/05/09 15:42:21 christos Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/strcat_chk.c b/newlib/libc/ssp/strcat_chk.c index d57f9559b5..d8ebc7b0c7 100644 --- a/newlib/libc/ssp/strcat_chk.c +++ b/newlib/libc/ssp/strcat_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: strcat_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/strcpy_chk.c b/newlib/libc/ssp/strcpy_chk.c index cef160a628..d240c0fe45 100644 --- a/newlib/libc/ssp/strcpy_chk.c +++ b/newlib/libc/ssp/strcpy_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: strcpy_chk.c,v 1.8 2015/05/09 15:42:21 christos Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/strncat_chk.c b/newlib/libc/ssp/strncat_chk.c index 5ce5a9ef60..09c26acf01 100644 --- a/newlib/libc/ssp/strncat_chk.c +++ b/newlib/libc/ssp/strncat_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: strncat_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/strncpy_chk.c b/newlib/libc/ssp/strncpy_chk.c index 591157a252..4159ffd5c2 100644 --- a/newlib/libc/ssp/strncpy_chk.c +++ b/newlib/libc/ssp/strncpy_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: strncpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/vsnprintf_chk.c b/newlib/libc/ssp/vsnprintf_chk.c index 8f170f0c5e..934d61c6cf 100644 --- a/newlib/libc/ssp/vsnprintf_chk.c +++ b/newlib/libc/ssp/vsnprintf_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: vsnprintf_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/ssp/vsprintf_chk.c b/newlib/libc/ssp/vsprintf_chk.c index a4344e5e73..e17ac84dd9 100644 --- a/newlib/libc/ssp/vsprintf_chk.c +++ b/newlib/libc/ssp/vsprintf_chk.c @@ -28,8 +28,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: vsprintf_chk.c,v 1.6 2009/02/05 05:39:38 lukem Exp $"); /*LINTLIBRARY*/ diff --git a/newlib/libc/stdio/asiprintf.c b/newlib/libc/stdio/asiprintf.c index 98c5afddbc..2d084b7d9a 100644 --- a/newlib/libc/stdio/asiprintf.c +++ b/newlib/libc/stdio/asiprintf.c @@ -18,7 +18,6 @@ /* doc in siprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/asniprintf.c b/newlib/libc/stdio/asniprintf.c index f0182c389f..02707369d0 100644 --- a/newlib/libc/stdio/asniprintf.c +++ b/newlib/libc/stdio/asniprintf.c @@ -6,7 +6,6 @@ /* doc in siprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/asnprintf.c b/newlib/libc/stdio/asnprintf.c index e1a49548c2..5a732e35f1 100644 --- a/newlib/libc/stdio/asnprintf.c +++ b/newlib/libc/stdio/asnprintf.c @@ -6,7 +6,6 @@ /* doc in sprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/asprintf.c b/newlib/libc/stdio/asprintf.c index 3bcec9fc21..5bba9b4bc2 100644 --- a/newlib/libc/stdio/asprintf.c +++ b/newlib/libc/stdio/asprintf.c @@ -18,7 +18,6 @@ /* doc in sprintf.c */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/clearerr.c b/newlib/libc/stdio/clearerr.c index 039388153b..80314b5b1e 100644 --- a/newlib/libc/stdio/clearerr.c +++ b/newlib/libc/stdio/clearerr.c @@ -64,7 +64,6 @@ No supporting OS subroutines are required. */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/clearerr_u.c b/newlib/libc/stdio/clearerr_u.c index 39c9a77b34..9a07cb4b16 100644 --- a/newlib/libc/stdio/clearerr_u.c +++ b/newlib/libc/stdio/clearerr_u.c @@ -25,7 +25,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/diprintf.c b/newlib/libc/stdio/diprintf.c index 1799d7d4ad..f5c82d0ef3 100644 --- a/newlib/libc/stdio/diprintf.c +++ b/newlib/libc/stdio/diprintf.c @@ -43,7 +43,6 @@ Supporting OS subroutines required: <>, <>. */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/dprintf.c b/newlib/libc/stdio/dprintf.c index 3b9d73a2f2..093d1d10bc 100644 --- a/newlib/libc/stdio/dprintf.c +++ b/newlib/libc/stdio/dprintf.c @@ -46,7 +46,6 @@ Supporting OS subroutines required: <>, <>. */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c index 44655b5cbf..695a2ccd1a 100644 --- a/newlib/libc/stdio/fclose.c +++ b/newlib/libc/stdio/fclose.c @@ -49,7 +49,6 @@ Required OS subroutines: <>, <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fcloseall.c b/newlib/libc/stdio/fcloseall.c index fe4f03c220..9d4780aa15 100644 --- a/newlib/libc/stdio/fcloseall.c +++ b/newlib/libc/stdio/fcloseall.c @@ -50,7 +50,6 @@ Required OS subroutines: <>, <>, <>, <>, /* This file based upon fwalk.c. */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fdopen.c b/newlib/libc/stdio/fdopen.c index da21bfa49d..d4ea877b56 100644 --- a/newlib/libc/stdio/fdopen.c +++ b/newlib/libc/stdio/fdopen.c @@ -44,7 +44,6 @@ PORTABILITY */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/ferror.c b/newlib/libc/stdio/ferror.c index 6c453ab761..7e0704c40d 100644 --- a/newlib/libc/stdio/ferror.c +++ b/newlib/libc/stdio/ferror.c @@ -66,7 +66,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/ferror_u.c b/newlib/libc/stdio/ferror_u.c index c4ad9f7e02..cc6f7e47fa 100644 --- a/newlib/libc/stdio/ferror_u.c +++ b/newlib/libc/stdio/ferror_u.c @@ -25,7 +25,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/fflush.c b/newlib/libc/stdio/fflush.c index 964e90ba6a..d788e4c16e 100644 --- a/newlib/libc/stdio/fflush.c +++ b/newlib/libc/stdio/fflush.c @@ -85,7 +85,6 @@ No supporting OS subroutines are required. */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/fgetc.c b/newlib/libc/stdio/fgetc.c index d369d2e39c..cce3683d04 100644 --- a/newlib/libc/stdio/fgetc.c +++ b/newlib/libc/stdio/fgetc.c @@ -81,7 +81,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/fgetc_u.c b/newlib/libc/stdio/fgetc_u.c index 38cd4cd1be..d66e4528e4 100644 --- a/newlib/libc/stdio/fgetc_u.c +++ b/newlib/libc/stdio/fgetc_u.c @@ -25,7 +25,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/fgetpos.c b/newlib/libc/stdio/fgetpos.c index 7b15aecc7b..e2f22b73ed 100644 --- a/newlib/libc/stdio/fgetpos.c +++ b/newlib/libc/stdio/fgetpos.c @@ -61,7 +61,6 @@ No supporting OS subroutines are required. */ #define _DEFAULT_SOURCE -#include #include int diff --git a/newlib/libc/stdio/fgets.c b/newlib/libc/stdio/fgets.c index 7ad8bacefe..4fdc741d6d 100644 --- a/newlib/libc/stdio/fgets.c +++ b/newlib/libc/stdio/fgets.c @@ -78,7 +78,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _GNU_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/fgetwc.c b/newlib/libc/stdio/fgetwc.c index 917c7db308..51c6f4e50f 100644 --- a/newlib/libc/stdio/fgetwc.c +++ b/newlib/libc/stdio/fgetwc.c @@ -117,7 +117,6 @@ PORTABILITY */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fgetwc_u.c b/newlib/libc/stdio/fgetwc_u.c index 501d3ba7af..37a13f0d67 100644 --- a/newlib/libc/stdio/fgetwc_u.c +++ b/newlib/libc/stdio/fgetwc_u.c @@ -25,7 +25,6 @@ */ #define _GNU_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/fgetws.c b/newlib/libc/stdio/fgetws.c index 13560e8b68..ab6ed5137f 100644 --- a/newlib/libc/stdio/fgetws.c +++ b/newlib/libc/stdio/fgetws.c @@ -86,7 +86,6 @@ PORTABILITY */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fileno.c b/newlib/libc/stdio/fileno.c index 3d02ee0502..9f8f48900f 100644 --- a/newlib/libc/stdio/fileno.c +++ b/newlib/libc/stdio/fileno.c @@ -58,7 +58,6 @@ Supporting OS subroutines required: none. */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/fileno_u.c b/newlib/libc/stdio/fileno_u.c index bf4fc43db4..4dac5c1ea1 100644 --- a/newlib/libc/stdio/fileno_u.c +++ b/newlib/libc/stdio/fileno_u.c @@ -25,7 +25,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/findfp.c b/newlib/libc/stdio/findfp.c index ff4f2cd919..f8fadcbec6 100644 --- a/newlib/libc/stdio/findfp.c +++ b/newlib/libc/stdio/findfp.c @@ -17,7 +17,6 @@ /* No user fns here. Pesch 15apr92. */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fiprintf.c b/newlib/libc/stdio/fiprintf.c index af169015b1..7944d87325 100644 --- a/newlib/libc/stdio/fiprintf.c +++ b/newlib/libc/stdio/fiprintf.c @@ -17,7 +17,6 @@ /* doc in siprintf.c */ #define _DEFAULT_SOURCE -#include #include #include diff --git a/newlib/libc/stdio/fiscanf.c b/newlib/libc/stdio/fiscanf.c index 979e3eba7f..66ff0d8a13 100644 --- a/newlib/libc/stdio/fiscanf.c +++ b/newlib/libc/stdio/fiscanf.c @@ -16,7 +16,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/flags.c b/newlib/libc/stdio/flags.c index 4311f0eb37..24f8388696 100644 --- a/newlib/libc/stdio/flags.c +++ b/newlib/libc/stdio/flags.c @@ -17,7 +17,6 @@ /* No user fns here. Pesch 15apr92 */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fopen.c b/newlib/libc/stdio/fopen.c index e85e6fdae3..702c35a12a 100644 --- a/newlib/libc/stdio/fopen.c +++ b/newlib/libc/stdio/fopen.c @@ -103,7 +103,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fprintf.c b/newlib/libc/stdio/fprintf.c index 2e88bc5efd..e0f966a48c 100644 --- a/newlib/libc/stdio/fprintf.c +++ b/newlib/libc/stdio/fprintf.c @@ -17,7 +17,6 @@ /* doc in sprintf.c */ #define _DEFAULT_SOURCE -#include #include #include diff --git a/newlib/libc/stdio/fpurge.c b/newlib/libc/stdio/fpurge.c index 68a98d7488..0ac04bab0e 100644 --- a/newlib/libc/stdio/fpurge.c +++ b/newlib/libc/stdio/fpurge.c @@ -50,7 +50,6 @@ No supporting OS subroutines are required. */ #define _DEFAULT_SOURCE -#include #include #ifndef __rtems__ #include diff --git a/newlib/libc/stdio/fputc.c b/newlib/libc/stdio/fputc.c index a7d0575f84..df4cf75ecf 100644 --- a/newlib/libc/stdio/fputc.c +++ b/newlib/libc/stdio/fputc.c @@ -83,7 +83,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/fputc_u.c b/newlib/libc/stdio/fputc_u.c index 7e4efc13e7..46ee790cf4 100644 --- a/newlib/libc/stdio/fputc_u.c +++ b/newlib/libc/stdio/fputc_u.c @@ -25,7 +25,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/fputs.c b/newlib/libc/stdio/fputs.c index 5fc29ec22c..0f8cf100bd 100644 --- a/newlib/libc/stdio/fputs.c +++ b/newlib/libc/stdio/fputs.c @@ -72,7 +72,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _GNU_SOURCE -#include #include #include #include "fvwrite.h" diff --git a/newlib/libc/stdio/fputwc.c b/newlib/libc/stdio/fputwc.c index 502cb3b368..be4d042544 100644 --- a/newlib/libc/stdio/fputwc.c +++ b/newlib/libc/stdio/fputwc.c @@ -119,7 +119,6 @@ PORTABILITY */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fputwc_u.c b/newlib/libc/stdio/fputwc_u.c index 6f9b339351..65f72019f0 100644 --- a/newlib/libc/stdio/fputwc_u.c +++ b/newlib/libc/stdio/fputwc_u.c @@ -25,7 +25,6 @@ */ #define _GNU_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/fputws.c b/newlib/libc/stdio/fputws.c index f5a5e28ea4..4ea1ae462d 100644 --- a/newlib/libc/stdio/fputws.c +++ b/newlib/libc/stdio/fputws.c @@ -80,7 +80,6 @@ PORTABILITY */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c index 930cc20dd5..a36ac447f9 100644 --- a/newlib/libc/stdio/fread.c +++ b/newlib/libc/stdio/fread.c @@ -81,7 +81,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/freopen.c b/newlib/libc/stdio/freopen.c index 3c2faea5b7..8f943bb487 100644 --- a/newlib/libc/stdio/freopen.c +++ b/newlib/libc/stdio/freopen.c @@ -60,7 +60,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fscanf.c b/newlib/libc/stdio/fscanf.c index 5b452acb01..f5b93ad528 100644 --- a/newlib/libc/stdio/fscanf.c +++ b/newlib/libc/stdio/fscanf.c @@ -16,7 +16,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/fseek.c b/newlib/libc/stdio/fseek.c index 608c0778eb..a4861e6823 100644 --- a/newlib/libc/stdio/fseek.c +++ b/newlib/libc/stdio/fseek.c @@ -75,7 +75,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/fseeko.c b/newlib/libc/stdio/fseeko.c index 60a79f280d..e1f1984049 100644 --- a/newlib/libc/stdio/fseeko.c +++ b/newlib/libc/stdio/fseeko.c @@ -75,7 +75,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fsetlocking.c b/newlib/libc/stdio/fsetlocking.c index 712754df44..29bb18cad0 100644 --- a/newlib/libc/stdio/fsetlocking.c +++ b/newlib/libc/stdio/fsetlocking.c @@ -60,7 +60,6 @@ No supporting OS subroutines are required. #ifndef __rtems__ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/fsetpos.c b/newlib/libc/stdio/fsetpos.c index dee9d4be7f..df4d93b22d 100644 --- a/newlib/libc/stdio/fsetpos.c +++ b/newlib/libc/stdio/fsetpos.c @@ -55,7 +55,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include int diff --git a/newlib/libc/stdio/ftell.c b/newlib/libc/stdio/ftell.c index bbba2d3f15..0c2c3d6386 100644 --- a/newlib/libc/stdio/ftell.c +++ b/newlib/libc/stdio/ftell.c @@ -77,7 +77,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/ftello.c b/newlib/libc/stdio/ftello.c index 72d1ff6718..2a779ba755 100644 --- a/newlib/libc/stdio/ftello.c +++ b/newlib/libc/stdio/ftello.c @@ -77,7 +77,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/fvwrite.c b/newlib/libc/stdio/fvwrite.c index 82d6d91ec4..addf4a1e1c 100644 --- a/newlib/libc/stdio/fvwrite.c +++ b/newlib/libc/stdio/fvwrite.c @@ -17,7 +17,6 @@ /* No user fns here. Pesch 15apr92. */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fvwrite.h b/newlib/libc/stdio/fvwrite.h index 74106c03f6..5d567fc1cb 100644 --- a/newlib/libc/stdio/fvwrite.h +++ b/newlib/libc/stdio/fvwrite.h @@ -18,9 +18,6 @@ #ifndef _FVWRITE_H_ #define _FVWRITE_H_ -/* %W% (Berkeley) %G% */ -#include - /* * I/O descriptors for __sfvwrite_r(). */ diff --git a/newlib/libc/stdio/fwalk.c b/newlib/libc/stdio/fwalk.c index 1990032e59..1545829b58 100644 --- a/newlib/libc/stdio/fwalk.c +++ b/newlib/libc/stdio/fwalk.c @@ -21,7 +21,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fwide.c b/newlib/libc/stdio/fwide.c index a504b19c9d..ae0c82a084 100644 --- a/newlib/libc/stdio/fwide.c +++ b/newlib/libc/stdio/fwide.c @@ -69,7 +69,6 @@ C99, POSIX.1-2001. */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/fwprintf.c b/newlib/libc/stdio/fwprintf.c index 7358d57c65..237921fdc5 100644 --- a/newlib/libc/stdio/fwprintf.c +++ b/newlib/libc/stdio/fwprintf.c @@ -17,7 +17,6 @@ /* doc in swprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/fwrite.c b/newlib/libc/stdio/fwrite.c index 10633b17d6..3b379ae48b 100644 --- a/newlib/libc/stdio/fwrite.c +++ b/newlib/libc/stdio/fwrite.c @@ -87,7 +87,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #if 0 diff --git a/newlib/libc/stdio/fwscanf.c b/newlib/libc/stdio/fwscanf.c index 862295640a..9ec326aa4d 100644 --- a/newlib/libc/stdio/fwscanf.c +++ b/newlib/libc/stdio/fwscanf.c @@ -17,7 +17,6 @@ /* Doc in swscanf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/getc.c b/newlib/libc/stdio/getc.c index 127980f2ce..529997a8a0 100644 --- a/newlib/libc/stdio/getc.c +++ b/newlib/libc/stdio/getc.c @@ -66,7 +66,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/getc_u.c b/newlib/libc/stdio/getc_u.c index e990fb880b..51319e9703 100644 --- a/newlib/libc/stdio/getc_u.c +++ b/newlib/libc/stdio/getc_u.c @@ -60,7 +60,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include /* diff --git a/newlib/libc/stdio/getchar.c b/newlib/libc/stdio/getchar.c index 46503d6d4e..846b267da1 100644 --- a/newlib/libc/stdio/getchar.c +++ b/newlib/libc/stdio/getchar.c @@ -65,7 +65,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/getchar_u.c b/newlib/libc/stdio/getchar_u.c index 811946f763..9a3f6051e4 100644 --- a/newlib/libc/stdio/getchar_u.c +++ b/newlib/libc/stdio/getchar_u.c @@ -64,7 +64,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; */ #define _DEFAULT_SOURCE -#include #include #undef getchar_unlocked diff --git a/newlib/libc/stdio/getdelim.c b/newlib/libc/stdio/getdelim.c index b15e638e57..52e9520a5e 100644 --- a/newlib/libc/stdio/getdelim.c +++ b/newlib/libc/stdio/getdelim.c @@ -32,7 +32,6 @@ No supporting OS subroutines are directly required. #define _DEFAULT_SOURCE #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/getline.c b/newlib/libc/stdio/getline.c index 3cb1907b62..c2b9409d51 100644 --- a/newlib/libc/stdio/getline.c +++ b/newlib/libc/stdio/getline.c @@ -32,7 +32,6 @@ No supporting OS subroutines are directly required. */ #define _DEFAULT_SOURCE -#include #include extern ssize_t __getdelim (char **, size_t *, int, FILE *); diff --git a/newlib/libc/stdio/gets.c b/newlib/libc/stdio/gets.c index 6a8e5e306a..8d1b0180b5 100644 --- a/newlib/libc/stdio/gets.c +++ b/newlib/libc/stdio/gets.c @@ -58,7 +58,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/getw.c b/newlib/libc/stdio/getw.c index 21bb59ef31..40387ecb24 100644 --- a/newlib/libc/stdio/getw.c +++ b/newlib/libc/stdio/getw.c @@ -51,7 +51,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include int diff --git a/newlib/libc/stdio/getwc.c b/newlib/libc/stdio/getwc.c index be26d0ec0c..e43cf3b185 100644 --- a/newlib/libc/stdio/getwc.c +++ b/newlib/libc/stdio/getwc.c @@ -25,7 +25,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/getwc_u.c b/newlib/libc/stdio/getwc_u.c index 9cca2dd899..837a569217 100644 --- a/newlib/libc/stdio/getwc_u.c +++ b/newlib/libc/stdio/getwc_u.c @@ -26,7 +26,6 @@ #define _GNU_SOURCE #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/getwchar.c b/newlib/libc/stdio/getwchar.c index bd111fa643..c42e069b7a 100644 --- a/newlib/libc/stdio/getwchar.c +++ b/newlib/libc/stdio/getwchar.c @@ -85,7 +85,6 @@ PORTABILITY */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/getwchar_u.c b/newlib/libc/stdio/getwchar_u.c index 66da1dcca8..9fe8b57ea2 100644 --- a/newlib/libc/stdio/getwchar_u.c +++ b/newlib/libc/stdio/getwchar_u.c @@ -25,7 +25,6 @@ */ #define _GNU_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/iprintf.c b/newlib/libc/stdio/iprintf.c index 7e78b3a78f..0bb314d22b 100644 --- a/newlib/libc/stdio/iprintf.c +++ b/newlib/libc/stdio/iprintf.c @@ -17,7 +17,6 @@ /* doc in siprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/iscanf.c b/newlib/libc/stdio/iscanf.c index 4b66e85512..057ff3a6a5 100644 --- a/newlib/libc/stdio/iscanf.c +++ b/newlib/libc/stdio/iscanf.c @@ -16,7 +16,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/local.h b/newlib/libc/stdio/local.h index 248ef32c3d..f5a2d4240e 100644 --- a/newlib/libc/stdio/local.h +++ b/newlib/libc/stdio/local.h @@ -22,7 +22,6 @@ * in particular, macros and private variables. */ -#include #include #include #include diff --git a/newlib/libc/stdio/makebuf.c b/newlib/libc/stdio/makebuf.c index 371d58c608..cfdcee0024 100644 --- a/newlib/libc/stdio/makebuf.c +++ b/newlib/libc/stdio/makebuf.c @@ -17,7 +17,6 @@ /* No user fns here. Pesch 15apr92. */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/mktemp.c b/newlib/libc/stdio/mktemp.c index 7ca8085bcc..9768bdeb77 100644 --- a/newlib/libc/stdio/mktemp.c +++ b/newlib/libc/stdio/mktemp.c @@ -128,7 +128,6 @@ Supporting OS subroutines required: <>, <>, <>, <>. */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/nano-vfprintf.c b/newlib/libc/stdio/nano-vfprintf.c index 1a5772d652..dcb30d8aaf 100644 --- a/newlib/libc/stdio/nano-vfprintf.c +++ b/newlib/libc/stdio/nano-vfprintf.c @@ -151,7 +151,6 @@ static char *rcsid = "$Id$"; #endif #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/nano-vfprintf_float.c b/newlib/libc/stdio/nano-vfprintf_float.c index e20d19c880..a88c7b0724 100644 --- a/newlib/libc/stdio/nano-vfprintf_float.c +++ b/newlib/libc/stdio/nano-vfprintf_float.c @@ -32,7 +32,6 @@ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/nano-vfprintf_i.c b/newlib/libc/stdio/nano-vfprintf_i.c index 085b3d025f..5d6738b4c8 100644 --- a/newlib/libc/stdio/nano-vfprintf_i.c +++ b/newlib/libc/stdio/nano-vfprintf_i.c @@ -28,7 +28,6 @@ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/nano-vfscanf.c b/newlib/libc/stdio/nano-vfscanf.c index 269caa16c1..5f6fda6f50 100644 --- a/newlib/libc/stdio/nano-vfscanf.c +++ b/newlib/libc/stdio/nano-vfscanf.c @@ -103,7 +103,6 @@ Supporting OS subroutines required: */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/nano-vfscanf_float.c b/newlib/libc/stdio/nano-vfscanf_float.c index 37e0fc979d..167dc409df 100644 --- a/newlib/libc/stdio/nano-vfscanf_float.c +++ b/newlib/libc/stdio/nano-vfscanf_float.c @@ -16,7 +16,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/nano-vfscanf_i.c b/newlib/libc/stdio/nano-vfscanf_i.c index 33c5b0f4e1..627e43ec9d 100644 --- a/newlib/libc/stdio/nano-vfscanf_i.c +++ b/newlib/libc/stdio/nano-vfscanf_i.c @@ -27,7 +27,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/perror.c b/newlib/libc/stdio/perror.c index 8fb2de2157..0300a3fb50 100644 --- a/newlib/libc/stdio/perror.c +++ b/newlib/libc/stdio/perror.c @@ -54,7 +54,6 @@ Supporting OS subroutines required: <>, <>, <>, #define _DEFAULT_SOURCE #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/printf.c b/newlib/libc/stdio/printf.c index eaef66b9e5..e64acfab85 100644 --- a/newlib/libc/stdio/printf.c +++ b/newlib/libc/stdio/printf.c @@ -17,7 +17,6 @@ /* doc in sprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/putc.c b/newlib/libc/stdio/putc.c index a97ed72de5..3a56f5e451 100644 --- a/newlib/libc/stdio/putc.c +++ b/newlib/libc/stdio/putc.c @@ -68,7 +68,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/putc_u.c b/newlib/libc/stdio/putc_u.c index 43a246795a..ef2377241b 100644 --- a/newlib/libc/stdio/putc_u.c +++ b/newlib/libc/stdio/putc_u.c @@ -61,7 +61,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include /* diff --git a/newlib/libc/stdio/putchar.c b/newlib/libc/stdio/putchar.c index 67e77193c1..5c5b0aed55 100644 --- a/newlib/libc/stdio/putchar.c +++ b/newlib/libc/stdio/putchar.c @@ -60,7 +60,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/putchar_u.c b/newlib/libc/stdio/putchar_u.c index 7021fcaeab..93b6c35f1a 100644 --- a/newlib/libc/stdio/putchar_u.c +++ b/newlib/libc/stdio/putchar_u.c @@ -56,7 +56,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #define _DEFAULT_SOURCE #define _DEFAULT_SOURCE -#include #include #undef putchar_unlocked diff --git a/newlib/libc/stdio/puts.c b/newlib/libc/stdio/puts.c index b1684106ac..1ad9c88539 100644 --- a/newlib/libc/stdio/puts.c +++ b/newlib/libc/stdio/puts.c @@ -54,7 +54,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include "fvwrite.h" diff --git a/newlib/libc/stdio/putwc.c b/newlib/libc/stdio/putwc.c index eaed6ad1d7..ac91bb2398 100644 --- a/newlib/libc/stdio/putwc.c +++ b/newlib/libc/stdio/putwc.c @@ -25,7 +25,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/putwc_u.c b/newlib/libc/stdio/putwc_u.c index 4c63bae1ae..58671bc056 100644 --- a/newlib/libc/stdio/putwc_u.c +++ b/newlib/libc/stdio/putwc_u.c @@ -26,7 +26,6 @@ #define _GNU_SOURCE #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/putwchar.c b/newlib/libc/stdio/putwchar.c index 2650c2f840..4aa0cd1531 100644 --- a/newlib/libc/stdio/putwchar.c +++ b/newlib/libc/stdio/putwchar.c @@ -79,7 +79,6 @@ PORTABILITY */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/putwchar_u.c b/newlib/libc/stdio/putwchar_u.c index 9875a0725b..74bf214a2c 100644 --- a/newlib/libc/stdio/putwchar_u.c +++ b/newlib/libc/stdio/putwchar_u.c @@ -26,7 +26,6 @@ #define _GNU_SOURCE #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c index b80a854059..4341f70b18 100644 --- a/newlib/libc/stdio/refill.c +++ b/newlib/libc/stdio/refill.c @@ -17,7 +17,6 @@ /* No user fns here. Pesch 15apr92. */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/remove.c b/newlib/libc/stdio/remove.c index 8eadcae1b6..76564a15b6 100644 --- a/newlib/libc/stdio/remove.c +++ b/newlib/libc/stdio/remove.c @@ -55,7 +55,6 @@ Supporting OS subroutine required: <>. */ #define _DEFAULT_SOURCE -#include #include #include diff --git a/newlib/libc/stdio/rename.c b/newlib/libc/stdio/rename.c index 0edf4d8551..871d31253d 100644 --- a/newlib/libc/stdio/rename.c +++ b/newlib/libc/stdio/rename.c @@ -47,7 +47,6 @@ Supporting OS subroutines required: <>, <>, or <>. */ #define _DEFAULT_SOURCE -#include #include #include diff --git a/newlib/libc/stdio/rewind.c b/newlib/libc/stdio/rewind.c index d250ae45bb..49e6434704 100644 --- a/newlib/libc/stdio/rewind.c +++ b/newlib/libc/stdio/rewind.c @@ -48,7 +48,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include void diff --git a/newlib/libc/stdio/rget.c b/newlib/libc/stdio/rget.c index ef30cab3d0..a7330477b3 100644 --- a/newlib/libc/stdio/rget.c +++ b/newlib/libc/stdio/rget.c @@ -21,7 +21,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/scanf.c b/newlib/libc/stdio/scanf.c index a5ca2c9a7c..cffc4ce7bc 100644 --- a/newlib/libc/stdio/scanf.c +++ b/newlib/libc/stdio/scanf.c @@ -16,7 +16,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/sccl.c b/newlib/libc/stdio/sccl.c index 858cb22c66..7019fdcc7b 100644 --- a/newlib/libc/stdio/sccl.c +++ b/newlib/libc/stdio/sccl.c @@ -18,7 +18,6 @@ /* Split from vfscanf.c */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/setbuf.c b/newlib/libc/stdio/setbuf.c index 3fd0dde58e..3dfa5e0fcc 100644 --- a/newlib/libc/stdio/setbuf.c +++ b/newlib/libc/stdio/setbuf.c @@ -61,7 +61,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/setbuffer.c b/newlib/libc/stdio/setbuffer.c index e498651f4a..53c8f12fa0 100644 --- a/newlib/libc/stdio/setbuffer.c +++ b/newlib/libc/stdio/setbuffer.c @@ -61,7 +61,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/setlinebuf.c b/newlib/libc/stdio/setlinebuf.c index e14c2e76b1..1ab19d2735 100644 --- a/newlib/libc/stdio/setlinebuf.c +++ b/newlib/libc/stdio/setlinebuf.c @@ -52,7 +52,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include "local.h" diff --git a/newlib/libc/stdio/setvbuf.c b/newlib/libc/stdio/setvbuf.c index d1823ae537..cda24aa74d 100644 --- a/newlib/libc/stdio/setvbuf.c +++ b/newlib/libc/stdio/setvbuf.c @@ -79,7 +79,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/siprintf.c b/newlib/libc/stdio/siprintf.c index eea0d721f6..78725e326e 100644 --- a/newlib/libc/stdio/siprintf.c +++ b/newlib/libc/stdio/siprintf.c @@ -92,7 +92,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/siscanf.c b/newlib/libc/stdio/siscanf.c index 24011d4a70..333f4846c5 100644 --- a/newlib/libc/stdio/siscanf.c +++ b/newlib/libc/stdio/siscanf.c @@ -73,7 +73,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/sniprintf.c b/newlib/libc/stdio/sniprintf.c index e0bbfc1010..45ab3274a6 100644 --- a/newlib/libc/stdio/sniprintf.c +++ b/newlib/libc/stdio/sniprintf.c @@ -19,7 +19,6 @@ /* doc in siprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/snprintf.c b/newlib/libc/stdio/snprintf.c index 920d94c302..78a027daff 100644 --- a/newlib/libc/stdio/snprintf.c +++ b/newlib/libc/stdio/snprintf.c @@ -18,7 +18,6 @@ /* This code created by modifying sprintf.c so copyright inherited. */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/sprintf.c b/newlib/libc/stdio/sprintf.c index b81c7c2268..cae8675641 100644 --- a/newlib/libc/stdio/sprintf.c +++ b/newlib/libc/stdio/sprintf.c @@ -568,7 +568,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/sscanf.c b/newlib/libc/stdio/sscanf.c index 887f4aaf56..7dae93e305 100644 --- a/newlib/libc/stdio/sscanf.c +++ b/newlib/libc/stdio/sscanf.c @@ -412,7 +412,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/stdio.c b/newlib/libc/stdio/stdio.c index 74a6a9ca2a..13b6035bf2 100644 --- a/newlib/libc/stdio/stdio.c +++ b/newlib/libc/stdio/stdio.c @@ -17,7 +17,6 @@ /* No user fns here. Pesch 15apr92. */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/stdio_ext.c b/newlib/libc/stdio/stdio_ext.c index 286047a1a0..3ca6e03356 100644 --- a/newlib/libc/stdio/stdio_ext.c +++ b/newlib/libc/stdio/stdio_ext.c @@ -60,7 +60,6 @@ No supporting OS subroutines are required. #ifndef __rtems__ #define _DEFAULT_SOURCE -#include #include #include diff --git a/newlib/libc/stdio/stdio_ext.h b/newlib/libc/stdio/stdio_ext.h index 26563bbb6c..a448b4875b 100644 --- a/newlib/libc/stdio/stdio_ext.h +++ b/newlib/libc/stdio/stdio_ext.h @@ -8,12 +8,7 @@ #ifndef _STDIO_EXT_H_ #define _STDIO_EXT_H_ -#ifdef __rtems__ -#error " not supported" -#endif - #include -#include #define FSETLOCKING_QUERY 0 #define FSETLOCKING_INTERNAL 1 diff --git a/newlib/libc/stdio/swprintf.c b/newlib/libc/stdio/swprintf.c index 0449ba92c0..f2c5b28350 100644 --- a/newlib/libc/stdio/swprintf.c +++ b/newlib/libc/stdio/swprintf.c @@ -540,7 +540,6 @@ Supporting OS subroutines required: <>, <>, <>, #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/swscanf.c b/newlib/libc/stdio/swscanf.c index 8f0c2c335d..7a5d75793f 100644 --- a/newlib/libc/stdio/swscanf.c +++ b/newlib/libc/stdio/swscanf.c @@ -406,7 +406,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/tmpfile.c b/newlib/libc/stdio/tmpfile.c index 96b2c6b961..f9bcc02f37 100644 --- a/newlib/libc/stdio/tmpfile.c +++ b/newlib/libc/stdio/tmpfile.c @@ -55,7 +55,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/tmpnam.c b/newlib/libc/stdio/tmpnam.c index 6353ee97d2..27a0e88403 100644 --- a/newlib/libc/stdio/tmpnam.c +++ b/newlib/libc/stdio/tmpnam.c @@ -91,7 +91,6 @@ The global pointer <> is also required. #define _DEFAULT_SOURCE #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c index 7058fff371..01a99fb979 100644 --- a/newlib/libc/stdio/ungetc.c +++ b/newlib/libc/stdio/ungetc.c @@ -62,7 +62,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/ungetwc.c b/newlib/libc/stdio/ungetwc.c index 8dc8e27056..015c34eaad 100644 --- a/newlib/libc/stdio/ungetwc.c +++ b/newlib/libc/stdio/ungetwc.c @@ -65,7 +65,6 @@ C99 */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vasiprintf.c b/newlib/libc/stdio/vasiprintf.c index c56b894580..b195031463 100644 --- a/newlib/libc/stdio/vasiprintf.c +++ b/newlib/libc/stdio/vasiprintf.c @@ -22,7 +22,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vasniprintf.c b/newlib/libc/stdio/vasniprintf.c index 6aa2005866..2736032d8c 100644 --- a/newlib/libc/stdio/vasniprintf.c +++ b/newlib/libc/stdio/vasniprintf.c @@ -6,7 +6,6 @@ /* doc in viprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vasnprintf.c b/newlib/libc/stdio/vasnprintf.c index 4c84b6793d..2762015d96 100644 --- a/newlib/libc/stdio/vasnprintf.c +++ b/newlib/libc/stdio/vasnprintf.c @@ -6,7 +6,6 @@ /* doc in vfprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vasprintf.c b/newlib/libc/stdio/vasprintf.c index 736499fb5f..936a7d15ca 100644 --- a/newlib/libc/stdio/vasprintf.c +++ b/newlib/libc/stdio/vasprintf.c @@ -18,7 +18,6 @@ /* doc in vfprintf.c */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vdiprintf.c b/newlib/libc/stdio/vdiprintf.c index 4549b0ce6e..cc779926e2 100644 --- a/newlib/libc/stdio/vdiprintf.c +++ b/newlib/libc/stdio/vdiprintf.c @@ -5,7 +5,6 @@ /* doc in diprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vdprintf.c b/newlib/libc/stdio/vdprintf.c index 812e533acb..5bdeceffd2 100644 --- a/newlib/libc/stdio/vdprintf.c +++ b/newlib/libc/stdio/vdprintf.c @@ -5,7 +5,6 @@ /* doc in dprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index c88bfce733..5530642b0d 100644 --- a/newlib/libc/stdio/vfprintf.c +++ b/newlib/libc/stdio/vfprintf.c @@ -143,7 +143,6 @@ static char *rcsid = "$Id$"; #endif #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vfscanf.c b/newlib/libc/stdio/vfscanf.c index c98bc3a72c..172acf6818 100644 --- a/newlib/libc/stdio/vfscanf.c +++ b/newlib/libc/stdio/vfscanf.c @@ -75,7 +75,6 @@ Supporting OS subroutines required: */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c index d54e01f8db..86543483b1 100644 --- a/newlib/libc/stdio/vfwprintf.c +++ b/newlib/libc/stdio/vfwprintf.c @@ -108,7 +108,6 @@ SEEALSO #endif #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vfwscanf.c b/newlib/libc/stdio/vfwscanf.c index fb66666dc6..4ddee481ca 100644 --- a/newlib/libc/stdio/vfwscanf.c +++ b/newlib/libc/stdio/vfwscanf.c @@ -75,7 +75,6 @@ C99, POSIX-1.2008 */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/viprintf.c b/newlib/libc/stdio/viprintf.c index 364fc6e0a0..aef0b991cc 100644 --- a/newlib/libc/stdio/viprintf.c +++ b/newlib/libc/stdio/viprintf.c @@ -93,7 +93,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/viscanf.c b/newlib/libc/stdio/viscanf.c index 0df1c8e21a..d4f8f88c28 100644 --- a/newlib/libc/stdio/viscanf.c +++ b/newlib/libc/stdio/viscanf.c @@ -77,7 +77,6 @@ Supporting OS subroutines required: */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/vprintf.c b/newlib/libc/stdio/vprintf.c index d800fad89a..861ffee6f2 100644 --- a/newlib/libc/stdio/vprintf.c +++ b/newlib/libc/stdio/vprintf.c @@ -17,7 +17,6 @@ /* doc in vfprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/vscanf.c b/newlib/libc/stdio/vscanf.c index 0bf967e2f3..e2e5e35ee8 100644 --- a/newlib/libc/stdio/vscanf.c +++ b/newlib/libc/stdio/vscanf.c @@ -18,7 +18,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/vsiprintf.c b/newlib/libc/stdio/vsiprintf.c index e30efd2189..98c1b51f9a 100644 --- a/newlib/libc/stdio/vsiprintf.c +++ b/newlib/libc/stdio/vsiprintf.c @@ -21,7 +21,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vsiscanf.c b/newlib/libc/stdio/vsiscanf.c index 5ff744df5b..170faefeb4 100644 --- a/newlib/libc/stdio/vsiscanf.c +++ b/newlib/libc/stdio/vsiscanf.c @@ -18,7 +18,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vsniprintf.c b/newlib/libc/stdio/vsniprintf.c index d5f1f92cc5..01baaf6488 100644 --- a/newlib/libc/stdio/vsniprintf.c +++ b/newlib/libc/stdio/vsniprintf.c @@ -21,7 +21,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vsnprintf.c b/newlib/libc/stdio/vsnprintf.c index c89901918a..39b4c26548 100644 --- a/newlib/libc/stdio/vsnprintf.c +++ b/newlib/libc/stdio/vsnprintf.c @@ -21,7 +21,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vsprintf.c b/newlib/libc/stdio/vsprintf.c index 34b9d16295..77e41ea026 100644 --- a/newlib/libc/stdio/vsprintf.c +++ b/newlib/libc/stdio/vsprintf.c @@ -21,7 +21,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vsscanf.c b/newlib/libc/stdio/vsscanf.c index 78833342f1..fc16db25f7 100644 --- a/newlib/libc/stdio/vsscanf.c +++ b/newlib/libc/stdio/vsscanf.c @@ -18,7 +18,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vswprintf.c b/newlib/libc/stdio/vswprintf.c index b8c55290a8..68206fcb35 100644 --- a/newlib/libc/stdio/vswprintf.c +++ b/newlib/libc/stdio/vswprintf.c @@ -21,7 +21,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vswscanf.c b/newlib/libc/stdio/vswscanf.c index ff8a85fb42..025708173e 100644 --- a/newlib/libc/stdio/vswscanf.c +++ b/newlib/libc/stdio/vswscanf.c @@ -19,7 +19,6 @@ /* Doc in vfwscanf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vwprintf.c b/newlib/libc/stdio/vwprintf.c index f6bfffb8f8..2a614dfce7 100644 --- a/newlib/libc/stdio/vwprintf.c +++ b/newlib/libc/stdio/vwprintf.c @@ -17,7 +17,6 @@ /* doc in vfwprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/vwscanf.c b/newlib/libc/stdio/vwscanf.c index 6dcbe3ff3e..0efcbf5cc2 100644 --- a/newlib/libc/stdio/vwscanf.c +++ b/newlib/libc/stdio/vwscanf.c @@ -19,7 +19,6 @@ /* Doc in vfwscanf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/wbuf.c b/newlib/libc/stdio/wbuf.c index c6c5a176df..ebbe7bc4aa 100644 --- a/newlib/libc/stdio/wbuf.c +++ b/newlib/libc/stdio/wbuf.c @@ -21,7 +21,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/wbufw.c b/newlib/libc/stdio/wbufw.c index 9c87795957..960b4746d0 100644 --- a/newlib/libc/stdio/wbufw.c +++ b/newlib/libc/stdio/wbufw.c @@ -20,7 +20,6 @@ static char sccsid[] = "%W% (Berkeley) %G%"; #endif /* LIBC_SCCS and not lint */ -#include #include #include #include "local.h" diff --git a/newlib/libc/stdio/wprintf.c b/newlib/libc/stdio/wprintf.c index 368d9535b3..45e7a4f439 100644 --- a/newlib/libc/stdio/wprintf.c +++ b/newlib/libc/stdio/wprintf.c @@ -17,7 +17,6 @@ /* doc in swprintf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/wscanf.c b/newlib/libc/stdio/wscanf.c index 2e8c1b0b4a..816b287c92 100644 --- a/newlib/libc/stdio/wscanf.c +++ b/newlib/libc/stdio/wscanf.c @@ -17,7 +17,6 @@ /* Doc in swscanf.c */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdio/wsetup.c b/newlib/libc/stdio/wsetup.c index 3dcd021d00..8f6f9bd1ea 100644 --- a/newlib/libc/stdio/wsetup.c +++ b/newlib/libc/stdio/wsetup.c @@ -18,7 +18,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/a64l.c b/newlib/libc/stdlib/a64l.c index 4433330b2e..ecda2d95b0 100644 --- a/newlib/libc/stdlib/a64l.c +++ b/newlib/libc/stdlib/a64l.c @@ -53,7 +53,6 @@ Supporting OS subroutines required: None. */ #define _DEFAULT_SOURCE -#include #include #include diff --git a/newlib/libc/stdlib/atof.c b/newlib/libc/stdlib/atof.c index 5423f94b89..1bd42de10a 100644 --- a/newlib/libc/stdlib/atof.c +++ b/newlib/libc/stdlib/atof.c @@ -58,7 +58,6 @@ Supporting OS subroutines required: <>, <>, <>, #include -#include double atof (const char *s) diff --git a/newlib/libc/stdlib/atoff.c b/newlib/libc/stdlib/atoff.c index 3cf5ac1e21..049615ac16 100644 --- a/newlib/libc/stdlib/atoff.c +++ b/newlib/libc/stdlib/atoff.c @@ -4,7 +4,6 @@ All rights reserved. */ #define _DEFAULT_SOURCE #include -#include float atoff (const char *s) diff --git a/newlib/libc/stdlib/atoi.c b/newlib/libc/stdlib/atoi.c index 46e6e94b57..56cae9c027 100644 --- a/newlib/libc/stdlib/atoi.c +++ b/newlib/libc/stdlib/atoi.c @@ -47,7 +47,6 @@ No supporting OS subroutines are required. */ #include -#include #ifndef _REENT_ONLY int diff --git a/newlib/libc/stdlib/atol.c b/newlib/libc/stdlib/atol.c index db03e5dd6c..e73e4c6315 100644 --- a/newlib/libc/stdlib/atol.c +++ b/newlib/libc/stdlib/atol.c @@ -7,7 +7,6 @@ All rights reserved. */ #include -#include #ifndef _REENT_ONLY long diff --git a/newlib/libc/stdlib/div.c b/newlib/libc/stdlib/div.c index a40a8e2e55..2a19caeac8 100644 --- a/newlib/libc/stdlib/div.c +++ b/newlib/libc/stdlib/div.c @@ -73,7 +73,6 @@ No supporting OS subroutines are required. * SUCH DAMAGE. */ -#include #include /* div_t */ div_t diff --git a/newlib/libc/stdlib/dtoa.c b/newlib/libc/stdlib/dtoa.c index 17921cda00..0d12d02205 100644 --- a/newlib/libc/stdlib/dtoa.c +++ b/newlib/libc/stdlib/dtoa.c @@ -27,7 +27,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include "mprec.h" diff --git a/newlib/libc/stdlib/ecvtbuf.c b/newlib/libc/stdlib/ecvtbuf.c index 142ef643f4..26b3a9dd5b 100644 --- a/newlib/libc/stdlib/ecvtbuf.c +++ b/newlib/libc/stdlib/ecvtbuf.c @@ -55,7 +55,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _GNU_SOURCE -#include #include #include #include "mprec.h" diff --git a/newlib/libc/stdlib/efgcvt.c b/newlib/libc/stdlib/efgcvt.c index 92094071fb..8448c3685d 100644 --- a/newlib/libc/stdlib/efgcvt.c +++ b/newlib/libc/stdlib/efgcvt.c @@ -100,7 +100,6 @@ Supporting OS subroutines required: <>, <>, <>, #define _XOPEN_SOURCE #define _XOPEN_SOURCE_EXTENDED -#include #include #include #include "local.h" diff --git a/newlib/libc/stdlib/gdtoa-gethex.c b/newlib/libc/stdlib/gdtoa-gethex.c index 5e3e805607..926de93631 100644 --- a/newlib/libc/stdlib/gdtoa-gethex.c +++ b/newlib/libc/stdlib/gdtoa-gethex.c @@ -30,7 +30,6 @@ THIS SOFTWARE. * with " at " changed at "@" and " dot " changed to "."). */ #define _DEFAULT_SOURCE -#include #include #include #include "mprec.h" diff --git a/newlib/libc/stdlib/gdtoa-hexnan.c b/newlib/libc/stdlib/gdtoa-hexnan.c index ab04148d85..8b62d2ba63 100644 --- a/newlib/libc/stdlib/gdtoa-hexnan.c +++ b/newlib/libc/stdlib/gdtoa-hexnan.c @@ -38,7 +38,6 @@ THIS SOFTWARE. /* Modified 06-21-2006 by Jeff Johnston to work with newlib. */ #define _DEFAULT_SOURCE -#include #include #include "mprec.h" #include "gdtoa.h" diff --git a/newlib/libc/stdlib/getsubopt.c b/newlib/libc/stdlib/getsubopt.c index 644b1b5175..48cb6556a4 100644 --- a/newlib/libc/stdlib/getsubopt.c +++ b/newlib/libc/stdlib/getsubopt.c @@ -28,7 +28,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/imaxabs.c b/newlib/libc/stdlib/imaxabs.c index e438646064..954355a2e4 100644 --- a/newlib/libc/stdlib/imaxabs.c +++ b/newlib/libc/stdlib/imaxabs.c @@ -24,8 +24,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD: head/lib/libc/stdlib/imaxabs.c 86368 2001-11-15 02:05:03Z mike $"); #include #include diff --git a/newlib/libc/stdlib/imaxdiv.c b/newlib/libc/stdlib/imaxdiv.c index eb3e99ad62..869e1a8cb0 100644 --- a/newlib/libc/stdlib/imaxdiv.c +++ b/newlib/libc/stdlib/imaxdiv.c @@ -24,8 +24,6 @@ * SUCH DAMAGE. */ -#include -__FBSDID("$FreeBSD: head/lib/libc/stdlib/imaxdiv.c 301115 2016-06-01 10:14:25Z ache $"); #include #include diff --git a/newlib/libc/stdlib/l64a.c b/newlib/libc/stdlib/l64a.c index 365f444d90..54305d8f99 100644 --- a/newlib/libc/stdlib/l64a.c +++ b/newlib/libc/stdlib/l64a.c @@ -22,7 +22,6 @@ */ #define _DEFAULT_SOURCE -#include #include static const char R64_ARRAY[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; diff --git a/newlib/libc/stdlib/ldiv.c b/newlib/libc/stdlib/ldiv.c index 7b07d340d8..0d8ae32ee1 100644 --- a/newlib/libc/stdlib/ldiv.c +++ b/newlib/libc/stdlib/ldiv.c @@ -74,7 +74,6 @@ No supporting OS subroutines are required. * SUCH DAMAGE. */ -#include #include /* ldiv_t */ ldiv_t diff --git a/newlib/libc/stdlib/ldtoa.c b/newlib/libc/stdlib/ldtoa.c index 35b8e9d36f..0d31669c4c 100644 --- a/newlib/libc/stdlib/ldtoa.c +++ b/newlib/libc/stdlib/ldtoa.c @@ -13,7 +13,6 @@ #endif #define _DEFAULT_SOURCE -#include #ifndef _USE_GDTOA #include diff --git a/newlib/libc/stdlib/mprec.c b/newlib/libc/stdlib/mprec.c index 137ed9df2a..237bd53181 100644 --- a/newlib/libc/stdlib/mprec.c +++ b/newlib/libc/stdlib/mprec.c @@ -91,7 +91,6 @@ #endif #define _DEFAULT_SOURCE -#include #include #include #include "mprec.h" diff --git a/newlib/libc/stdlib/mstats.c b/newlib/libc/stdlib/mstats.c index caa7ca170a..4a8f82c100 100644 --- a/newlib/libc/stdlib/mstats.c +++ b/newlib/libc/stdlib/mstats.c @@ -79,7 +79,6 @@ not portable. */ -#include #include #include #include diff --git a/newlib/libc/stdlib/reallocarray.c b/newlib/libc/stdlib/reallocarray.c index 24a793687f..e7aa39509d 100644 --- a/newlib/libc/stdlib/reallocarray.c +++ b/newlib/libc/stdlib/reallocarray.c @@ -16,7 +16,6 @@ */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/reallocf.c b/newlib/libc/stdlib/reallocf.c index 266ebf444a..814a027f24 100644 --- a/newlib/libc/stdlib/reallocf.c +++ b/newlib/libc/stdlib/reallocf.c @@ -27,7 +27,6 @@ /* Documented in malloc.c. */ #define _DEFAULT_SOURCE -#include #include #ifndef _REENT_ONLY diff --git a/newlib/libc/stdlib/rpmatch.c b/newlib/libc/stdlib/rpmatch.c index 277f1b2982..57edc5688e 100644 --- a/newlib/libc/stdlib/rpmatch.c +++ b/newlib/libc/stdlib/rpmatch.c @@ -52,7 +52,6 @@ No supporting OS subroutines are required. */ #define _DEFAULT_SOURCE -#include #include #include diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c index 6e3c05f542..8ba207c5d4 100644 --- a/newlib/libc/stdlib/strtod.c +++ b/newlib/libc/stdlib/strtod.c @@ -131,7 +131,6 @@ THIS SOFTWARE. /* Original file gdtoa-strtod.c Modified 06-21-2006 by Jeff Johnston to work within newlib. */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/strtodg.c b/newlib/libc/stdlib/strtodg.c index 1848a9ddf7..d76fa2d40e 100644 --- a/newlib/libc/stdlib/strtodg.c +++ b/newlib/libc/stdlib/strtodg.c @@ -30,7 +30,6 @@ THIS SOFTWARE. * with " at " changed at "@" and " dot " changed to "."). */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/strtoimax.c b/newlib/libc/stdlib/strtoimax.c index 7b457141ce..51450b578b 100644 --- a/newlib/libc/stdlib/strtoimax.c +++ b/newlib/libc/stdlib/strtoimax.c @@ -36,8 +36,6 @@ static char sccsid[] = "from @(#)strtol.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include -__FBSDID("$FreeBSD: head/lib/libc/stdlib/strtoimax.c 251672 2013-06-13 00:19:30Z emaste $"); #include #include diff --git a/newlib/libc/stdlib/strtol.c b/newlib/libc/stdlib/strtol.c index 2faaa48aaa..65402d5e50 100644 --- a/newlib/libc/stdlib/strtol.c +++ b/newlib/libc/stdlib/strtol.c @@ -109,7 +109,6 @@ No supporting OS subroutines are required. */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/strtoll.c b/newlib/libc/stdlib/strtoll.c index 746d3ba1a0..5148197717 100644 --- a/newlib/libc/stdlib/strtoll.c +++ b/newlib/libc/stdlib/strtoll.c @@ -117,7 +117,6 @@ No supporting OS subroutines are required. */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/strtorx.c b/newlib/libc/stdlib/strtorx.c index 8d321abab2..983690aa7e 100644 --- a/newlib/libc/stdlib/strtorx.c +++ b/newlib/libc/stdlib/strtorx.c @@ -30,7 +30,6 @@ THIS SOFTWARE. * with " at " changed at "@" and " dot " changed to "."). */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/strtoul.c b/newlib/libc/stdlib/strtoul.c index 2cc33503ac..5f6fcfd687 100644 --- a/newlib/libc/stdlib/strtoul.c +++ b/newlib/libc/stdlib/strtoul.c @@ -115,7 +115,6 @@ PORTABILITY */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/strtoull.c b/newlib/libc/stdlib/strtoull.c index 690ce882dc..744c90f9b1 100644 --- a/newlib/libc/stdlib/strtoull.c +++ b/newlib/libc/stdlib/strtoull.c @@ -113,7 +113,6 @@ PORTABILITY */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/strtoumax.c b/newlib/libc/stdlib/strtoumax.c index 34b4da7575..b7a54fd22e 100644 --- a/newlib/libc/stdlib/strtoumax.c +++ b/newlib/libc/stdlib/strtoumax.c @@ -36,8 +36,6 @@ static char sccsid[] = "from @(#)strtoul.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #define _DEFAULT_SOURCE -#include -__FBSDID("$FreeBSD: head/lib/libc/stdlib/strtoumax.c 251672 2013-06-13 00:19:30Z emaste $"); #include #include diff --git a/newlib/libc/stdlib/system.c b/newlib/libc/stdlib/system.c index f98b3b1323..5089ce97a1 100644 --- a/newlib/libc/stdlib/system.c +++ b/newlib/libc/stdlib/system.c @@ -48,7 +48,6 @@ Supporting OS subroutines required: <<_exit>>, <<_execve>>, <<_fork_r>>, <<_wait_r>>. */ -#include #include #include #include diff --git a/newlib/libc/stdlib/wcstod.c b/newlib/libc/stdlib/wcstod.c index 1fd2b0cdd4..1ce10cc668 100644 --- a/newlib/libc/stdlib/wcstod.c +++ b/newlib/libc/stdlib/wcstod.c @@ -132,7 +132,6 @@ Supporting OS subroutines required: <>, <>, <>, */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/wcstoimax.c b/newlib/libc/stdlib/wcstoimax.c index 3bf3f9f0f8..b6f1806d0e 100644 --- a/newlib/libc/stdlib/wcstoimax.c +++ b/newlib/libc/stdlib/wcstoimax.c @@ -33,14 +33,11 @@ */ #define _DEFAULT_SOURCE -#include #if 0 #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "from @(#)strtol.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ -__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoimax.c,v 1.8 2002/09/06 11:23:59 tjr Exp "); #endif -__FBSDID("$FreeBSD: head/lib/libc/locale/wcstoimax.c 314436 2017-02-28 23:42:47Z imp $"); #include #include diff --git a/newlib/libc/stdlib/wcstol.c b/newlib/libc/stdlib/wcstol.c index ae7f1327df..f2a227a8f5 100644 --- a/newlib/libc/stdlib/wcstol.c +++ b/newlib/libc/stdlib/wcstol.c @@ -117,7 +117,6 @@ No supporting OS subroutines are required. #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/wcstoll.c b/newlib/libc/stdlib/wcstoll.c index 23a8a742dd..2f82875448 100644 --- a/newlib/libc/stdlib/wcstoll.c +++ b/newlib/libc/stdlib/wcstoll.c @@ -116,7 +116,6 @@ No supporting OS subroutines are required. */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/wcstoul.c b/newlib/libc/stdlib/wcstoul.c index f2339d7e77..6c98e4edaf 100644 --- a/newlib/libc/stdlib/wcstoul.c +++ b/newlib/libc/stdlib/wcstoul.c @@ -116,7 +116,6 @@ PORTABILITY */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/wcstoull.c b/newlib/libc/stdlib/wcstoull.c index db6ca0008b..0da83ae9de 100644 --- a/newlib/libc/stdlib/wcstoull.c +++ b/newlib/libc/stdlib/wcstoull.c @@ -122,7 +122,6 @@ PORTABILITY */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/stdlib/wcstoumax.c b/newlib/libc/stdlib/wcstoumax.c index 60e89b7777..50a31aea02 100644 --- a/newlib/libc/stdlib/wcstoumax.c +++ b/newlib/libc/stdlib/wcstoumax.c @@ -33,14 +33,11 @@ */ #define _DEFAULT_SOURCE -#include #if 0 #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "from @(#)strtoul.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ -__FBSDID("FreeBSD: src/lib/libc/stdlib/strtoumax.c,v 1.8 2002/09/06 11:23:59 tjr Exp "); #endif -__FBSDID("$FreeBSD: head/lib/libc/locale/wcstoumax.c 314436 2017-02-28 23:42:47Z imp $"); #include #include diff --git a/newlib/libc/string/memccpy.c b/newlib/libc/string/memccpy.c index e4372a27ba..d69dc329fe 100644 --- a/newlib/libc/string/memccpy.c +++ b/newlib/libc/string/memccpy.c @@ -29,7 +29,6 @@ PORTABILITY */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/string/memchr.c b/newlib/libc/string/memchr.c index 4421a7aec6..44e9b25fa6 100644 --- a/newlib/libc/string/memchr.c +++ b/newlib/libc/string/memchr.c @@ -45,7 +45,6 @@ QUICKREF memchr ansi pure */ -#include #include #include #include diff --git a/newlib/libc/string/memcpy.c b/newlib/libc/string/memcpy.c index c49c5dd41b..a116b05ee9 100644 --- a/newlib/libc/string/memcpy.c +++ b/newlib/libc/string/memcpy.c @@ -43,7 +43,6 @@ QUICKREF memcpy ansi pure */ -#include #include #include "local.h" #include diff --git a/newlib/libc/string/memmove.c b/newlib/libc/string/memmove.c index 1ee8610c8d..27c272a37b 100644 --- a/newlib/libc/string/memmove.c +++ b/newlib/libc/string/memmove.c @@ -45,7 +45,6 @@ QUICKREF */ #include -#include #include #include #include diff --git a/newlib/libc/string/mempcpy.c b/newlib/libc/string/mempcpy.c index 7e7572e628..f4a50a7583 100644 --- a/newlib/libc/string/mempcpy.c +++ b/newlib/libc/string/mempcpy.c @@ -28,7 +28,6 @@ PORTABILITY */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/string/memrchr.c b/newlib/libc/string/memrchr.c index 9bd58c0020..ae67d59ffb 100644 --- a/newlib/libc/string/memrchr.c +++ b/newlib/libc/string/memrchr.c @@ -31,7 +31,6 @@ QUICKREF */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/string/rawmemchr.c b/newlib/libc/string/rawmemchr.c index aab7a9ea12..3b5bd5e988 100644 --- a/newlib/libc/string/rawmemchr.c +++ b/newlib/libc/string/rawmemchr.c @@ -30,7 +30,6 @@ QUICKREF */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libc/string/str-two-way.h b/newlib/libc/string/str-two-way.h index aeebbc8ab6..a7a8a568a4 100644 --- a/newlib/libc/string/str-two-way.h +++ b/newlib/libc/string/str-two-way.h @@ -31,7 +31,6 @@ #include #include -#include /* We use the Two-Way string matching algorithm, which guarantees linear complexity with constant space. Additionally, for long diff --git a/newlib/libc/string/strcasestr.c b/newlib/libc/string/strcasestr.c index 71cd9f1fcd..ae6fb3e63b 100644 --- a/newlib/libc/string/strcasestr.c +++ b/newlib/libc/string/strcasestr.c @@ -67,7 +67,6 @@ QUICKREF */ #define _GNU_SOURCE -#include #include #include diff --git a/newlib/libc/string/strlen.c b/newlib/libc/string/strlen.c index 04d035b2de..42882e3161 100644 --- a/newlib/libc/string/strlen.c +++ b/newlib/libc/string/strlen.c @@ -42,7 +42,6 @@ QUICKREF strlen ansi pure */ -#include #include #include #include diff --git a/newlib/libc/string/strndup.c b/newlib/libc/string/strndup.c index 32f617cedb..c1e4f20a42 100644 --- a/newlib/libc/string/strndup.c +++ b/newlib/libc/string/strndup.c @@ -3,7 +3,6 @@ Copyright (c) 2002 Jeff Johnston */ #define _DEFAULT_SOURCE -#include #include #include diff --git a/newlib/libc/string/strnlen.c b/newlib/libc/string/strnlen.c index 618c00880a..f81fdf8a0e 100644 --- a/newlib/libc/string/strnlen.c +++ b/newlib/libc/string/strnlen.c @@ -27,7 +27,6 @@ PORTABILITY */ #undef __STRICT_ANSI__ -#include #include size_t diff --git a/newlib/libc/string/strsep.c b/newlib/libc/string/strsep.c index 1879a06e28..8ff4ce45da 100644 --- a/newlib/libc/string/strsep.c +++ b/newlib/libc/string/strsep.c @@ -4,7 +4,6 @@ #define _DEFAULT_SOURCE #include -#include #include "strtok_r.h" char * diff --git a/newlib/libc/string/strtok.c b/newlib/libc/string/strtok.c index 5431089c39..6d2506106b 100644 --- a/newlib/libc/string/strtok.c +++ b/newlib/libc/string/strtok.c @@ -87,7 +87,6 @@ QUICKREF #undef __STRICT_ANSI__ #include #include -#include #ifndef _REENT_ONLY diff --git a/newlib/libc/string/wcpcpy.c b/newlib/libc/string/wcpcpy.c index 6e6dc784c2..a3cc0d811a 100644 --- a/newlib/libc/string/wcpcpy.c +++ b/newlib/libc/string/wcpcpy.c @@ -24,7 +24,6 @@ No supporting OS subroutines are required. */ #define _DEFAULT_SOURCE -#include #include wchar_t * diff --git a/newlib/libc/string/wcpncpy.c b/newlib/libc/string/wcpncpy.c index eab45bc184..351f8ff3b5 100644 --- a/newlib/libc/string/wcpncpy.c +++ b/newlib/libc/string/wcpncpy.c @@ -31,7 +31,6 @@ No supporting OS subroutines are required. */ #define _DEFAULT_SOURCE -#include #include wchar_t * diff --git a/newlib/libc/string/wcscat.c b/newlib/libc/string/wcscat.c index 2e01e08208..f39fc81528 100644 --- a/newlib/libc/string/wcscat.c +++ b/newlib/libc/string/wcscat.c @@ -57,7 +57,6 @@ No supporting OS subroutines are required. * citrus Id: wcscat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp */ -#include #include wchar_t * diff --git a/newlib/libc/string/wcschr.c b/newlib/libc/string/wcschr.c index 7e483ae694..6a266d5245 100644 --- a/newlib/libc/string/wcschr.c +++ b/newlib/libc/string/wcschr.c @@ -53,7 +53,6 @@ No supporting OS subroutines are required. * citrus Id: wcschr.c,v 1.2 2000/12/21 05:07:25 itojun Exp */ -#include #include #include diff --git a/newlib/libc/string/wcscmp.c b/newlib/libc/string/wcscmp.c index 69319377ae..bf3d2ba4f1 100644 --- a/newlib/libc/string/wcscmp.c +++ b/newlib/libc/string/wcscmp.c @@ -60,7 +60,6 @@ No supporting OS subroutines are required. * SUCH DAMAGE. */ -#include #include /* diff --git a/newlib/libc/string/wcscoll.c b/newlib/libc/string/wcscoll.c index 67fdf9e750..0771522ad3 100644 --- a/newlib/libc/string/wcscoll.c +++ b/newlib/libc/string/wcscoll.c @@ -30,7 +30,6 @@ PORTABILITY <> is ISO/IEC 9899/AMD1:1995 (ISO C). */ -#include #include int diff --git a/newlib/libc/string/wcscoll_l.c b/newlib/libc/string/wcscoll_l.c index 90b39480e7..f7102b97b1 100644 --- a/newlib/libc/string/wcscoll_l.c +++ b/newlib/libc/string/wcscoll_l.c @@ -37,7 +37,6 @@ PORTABILITY */ #define _DEFAULT_SOURCE -#include #include int diff --git a/newlib/libc/string/wcscpy.c b/newlib/libc/string/wcscpy.c index e396aba482..dd4ce721fc 100644 --- a/newlib/libc/string/wcscpy.c +++ b/newlib/libc/string/wcscpy.c @@ -53,7 +53,6 @@ No supporting OS subroutines are required. * citrus Id: wcscpy.c,v 1.2 2000/12/21 04:51:09 itojun Exp */ -#include #include wchar_t * diff --git a/newlib/libc/string/wcscspn.c b/newlib/libc/string/wcscspn.c index a570123b2d..d4993176b7 100644 --- a/newlib/libc/string/wcscspn.c +++ b/newlib/libc/string/wcscspn.c @@ -52,7 +52,6 @@ No supporting OS subroutines are required. * citrus Id: wcscspn.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp */ -#include #include size_t diff --git a/newlib/libc/string/wcslen.c b/newlib/libc/string/wcslen.c index a109bcc392..7ad03a4839 100644 --- a/newlib/libc/string/wcslen.c +++ b/newlib/libc/string/wcslen.c @@ -51,7 +51,6 @@ No supporting OS subroutines are required. * citrus Id: wcslen.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp */ -#include #include size_t diff --git a/newlib/libc/string/wcsncat.c b/newlib/libc/string/wcsncat.c index cba49cbdde..fda72992f5 100644 --- a/newlib/libc/string/wcsncat.c +++ b/newlib/libc/string/wcsncat.c @@ -58,7 +58,6 @@ No supporting OS subroutines are required. * citrus Id: wcsncat.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp */ -#include #include wchar_t * diff --git a/newlib/libc/string/wcsncmp.c b/newlib/libc/string/wcsncmp.c index 0b619c940c..e22b8ca486 100644 --- a/newlib/libc/string/wcsncmp.c +++ b/newlib/libc/string/wcsncmp.c @@ -59,7 +59,6 @@ No supporting OS subroutines are required. * SUCH DAMAGE. */ -#include #include int diff --git a/newlib/libc/string/wcsncpy.c b/newlib/libc/string/wcsncpy.c index 6ab6099123..61f7f92193 100644 --- a/newlib/libc/string/wcsncpy.c +++ b/newlib/libc/string/wcsncpy.c @@ -56,7 +56,6 @@ ISO/IEC 9899; POSIX.1. No supporting OS subroutines are required. */ -#include #include wchar_t * diff --git a/newlib/libc/string/wcsnlen.c b/newlib/libc/string/wcsnlen.c index 8331348df8..5313a0c7cb 100644 --- a/newlib/libc/string/wcsnlen.c +++ b/newlib/libc/string/wcsnlen.c @@ -48,7 +48,6 @@ PORTABILITY */ #define _DEFAULT_SOURCE -#include #include #include diff --git a/newlib/libc/string/wcspbrk.c b/newlib/libc/string/wcspbrk.c index 5dbe99543d..ae0f3c77ec 100644 --- a/newlib/libc/string/wcspbrk.c +++ b/newlib/libc/string/wcspbrk.c @@ -52,7 +52,6 @@ No supporting OS subroutines are required. * citrus Id: wcspbrk.c,v 1.2 2000/12/21 05:07:25 itojun Exp */ -#include #include #include diff --git a/newlib/libc/string/wcsrchr.c b/newlib/libc/string/wcsrchr.c index 8405c68e3a..a17dd33733 100644 --- a/newlib/libc/string/wcsrchr.c +++ b/newlib/libc/string/wcsrchr.c @@ -55,7 +55,6 @@ No supporting OS subroutines are required. * citrus Id: wcsrchr.c,v 1.2 2000/12/21 05:07:25 itojun Exp */ -#include #include #include diff --git a/newlib/libc/string/wcsspn.c b/newlib/libc/string/wcsspn.c index 6535c9ffd6..5f73801844 100644 --- a/newlib/libc/string/wcsspn.c +++ b/newlib/libc/string/wcsspn.c @@ -52,7 +52,6 @@ No supporting OS subroutines are required. * citrus Id: wcsspn.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp */ -#include #include size_t diff --git a/newlib/libc/string/wcsstr.c b/newlib/libc/string/wcsstr.c index 99c259fe3f..364d0b60a7 100644 --- a/newlib/libc/string/wcsstr.c +++ b/newlib/libc/string/wcsstr.c @@ -56,7 +56,6 @@ PORTABILITY * citrus Id: wcsstr.c,v 1.2 2000/12/21 05:07:25 itojun Exp */ -#include #include #include diff --git a/newlib/libc/string/wcswidth.c b/newlib/libc/string/wcswidth.c index 4a04208c12..9551744863 100644 --- a/newlib/libc/string/wcswidth.c +++ b/newlib/libc/string/wcswidth.c @@ -33,7 +33,6 @@ PORTABILITY */ #define _XOPEN_SOURCE -#include #include #include #include "local.h" diff --git a/newlib/libc/string/wcsxfrm.c b/newlib/libc/string/wcsxfrm.c index e8f9943ada..dc4e0bbec0 100644 --- a/newlib/libc/string/wcsxfrm.c +++ b/newlib/libc/string/wcsxfrm.c @@ -34,7 +34,6 @@ PORTABILITY */ #define _GNU_SOURCE -#include #include size_t diff --git a/newlib/libc/string/wcsxfrm_l.c b/newlib/libc/string/wcsxfrm_l.c index 93609ed63e..00f88e0b82 100644 --- a/newlib/libc/string/wcsxfrm_l.c +++ b/newlib/libc/string/wcsxfrm_l.c @@ -40,7 +40,6 @@ PORTABILITY */ #define _DEFAULT_SOURCE -#include #include size_t diff --git a/newlib/libc/string/wcwidth.c b/newlib/libc/string/wcwidth.c index 18bd4b7679..071c0d3c65 100644 --- a/newlib/libc/string/wcwidth.c +++ b/newlib/libc/string/wcwidth.c @@ -90,7 +90,6 @@ PORTABILITY */ #define _XOPEN_SOURCE -#include #include #include #ifndef _MB_CAPABLE diff --git a/newlib/libc/string/wmemchr.c b/newlib/libc/string/wmemchr.c index 7738e0cba9..82dd01eecd 100644 --- a/newlib/libc/string/wmemchr.c +++ b/newlib/libc/string/wmemchr.c @@ -59,7 +59,6 @@ No supporting OS subroutines are required. */ -#include #include wchar_t * diff --git a/newlib/libc/string/wmemcmp.c b/newlib/libc/string/wmemcmp.c index c359000e34..491c2eabfa 100644 --- a/newlib/libc/string/wmemcmp.c +++ b/newlib/libc/string/wmemcmp.c @@ -58,7 +58,6 @@ No supporting OS subroutines are required. * citrus Id: wmemcmp.c,v 1.2 2000/12/20 14:08:31 itojun Exp */ -#include #include int diff --git a/newlib/libc/string/wmemcpy.c b/newlib/libc/string/wmemcpy.c index 0cca33e9b9..a5bbe130ae 100644 --- a/newlib/libc/string/wmemcpy.c +++ b/newlib/libc/string/wmemcpy.c @@ -56,7 +56,6 @@ No supporting OS subroutines are required. * citrus Id: wmemcpy.c,v 1.2 2000/12/20 14:08:31 itojun Exp */ -#include #include #include diff --git a/newlib/libc/string/wmemmove.c b/newlib/libc/string/wmemmove.c index b79c10c9ec..f3da5aef8e 100644 --- a/newlib/libc/string/wmemmove.c +++ b/newlib/libc/string/wmemmove.c @@ -61,7 +61,6 @@ No supporting OS subroutines are required. * citrus Id: wmemmove.c,v 1.2 2000/12/20 14:08:31 itojun Exp */ -#include #include #include diff --git a/newlib/libc/string/wmempcpy.c b/newlib/libc/string/wmempcpy.c index f384d5eaaf..b787332b55 100644 --- a/newlib/libc/string/wmempcpy.c +++ b/newlib/libc/string/wmempcpy.c @@ -30,7 +30,6 @@ No supporting OS subroutines are required. */ #define _GNU_SOURCE -#include #include #include diff --git a/newlib/libc/string/wmemset.c b/newlib/libc/string/wmemset.c index 08846f1675..6d606f237f 100644 --- a/newlib/libc/string/wmemset.c +++ b/newlib/libc/string/wmemset.c @@ -55,7 +55,6 @@ No supporting OS subroutines are required. * citrus Id: wmemset.c,v 1.2 2000/12/20 14:08:31 itojun Exp */ -#include #include wchar_t * diff --git a/newlib/libc/sys/amdgcn/include/sys/lock.h b/newlib/libc/sys/amdgcn/include/sys/lock.h index 67374c0831..b40a700f28 100644 --- a/newlib/libc/sys/amdgcn/include/sys/lock.h +++ b/newlib/libc/sys/amdgcn/include/sys/lock.h @@ -1,7 +1,6 @@ #ifndef __SYS_LOCK_H__ #define __SYS_LOCK_H__ -#include typedef unsigned int _LOCK_T; typedef unsigned int _LOCK_RECURSIVE_T; diff --git a/newlib/libc/sys/rtems/include/sys/poll.h b/newlib/libc/sys/rtems/include/sys/poll.h index cc6ad49db0..ae3e3e3ada 100644 --- a/newlib/libc/sys/rtems/include/sys/poll.h +++ b/newlib/libc/sys/rtems/include/sys/poll.h @@ -33,7 +33,6 @@ #ifndef _SYS_POLL_H_ #define _SYS_POLL_H_ -#include /* * This file is intended to be compatible with the traditional poll.h. diff --git a/newlib/libc/time/asctime.c b/newlib/libc/time/asctime.c index 5d30cbda55..a9fc4720da 100644 --- a/newlib/libc/time/asctime.c +++ b/newlib/libc/time/asctime.c @@ -56,7 +56,6 @@ ANSI C requires <>. */ #define _DEFAULT_SOURCE -#include #include static NEWLIB_THREAD_LOCAL char _asctime_buf[__ASCTIME_SIZE]; diff --git a/newlib/libc/time/local.h b/newlib/libc/time/local.h index e354134f6f..379704540d 100644 --- a/newlib/libc/time/local.h +++ b/newlib/libc/time/local.h @@ -3,7 +3,6 @@ #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE #endif -#include #include #include #include diff --git a/newlib/libc/time/tzset.c b/newlib/libc/time/tzset.c index 35d81d0e44..3be6f889ba 100644 --- a/newlib/libc/time/tzset.c +++ b/newlib/libc/time/tzset.c @@ -99,7 +99,6 @@ Supporting OS subroutine required: None */ #define _DEFAULT_SOURCE -#include #include #include #include diff --git a/newlib/libc/xdr/xdr_private.h b/newlib/libc/xdr/xdr_private.h index fafe8e5429..033cafe3bb 100644 --- a/newlib/libc/xdr/xdr_private.h +++ b/newlib/libc/xdr/xdr_private.h @@ -23,7 +23,6 @@ #ifndef _XDR_PRIVATE_H #define _XDR_PRIVATE_H -#include #include #include #include diff --git a/newlib/libm/common/fma_inc.h b/newlib/libm/common/fma_inc.h index e2b7540469..7a0954ea46 100644 --- a/newlib/libm/common/fma_inc.h +++ b/newlib/libm/common/fma_inc.h @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_fmal.c,v 1.7 2011/10/21 06:30:43 das Exp $"); /* * Denorms usually have an exponent biased by 1 so that they flow diff --git a/newlib/libm/complex/conjl.c b/newlib/libm/complex/conjl.c index 35094ce893..77c288ff4d 100644 --- a/newlib/libm/complex/conjl.c +++ b/newlib/libm/complex/conjl.c @@ -25,8 +25,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: conjl.c,v 1.4 2010/09/20 16:55:20 christos Exp $"); #include #include "../common/fdlibm.h" diff --git a/newlib/libm/complex/cproj.c b/newlib/libm/complex/cproj.c index 9ea7281a47..175a07b0b8 100644 --- a/newlib/libm/complex/cproj.c +++ b/newlib/libm/complex/cproj.c @@ -68,8 +68,6 @@ QUICKREF */ -#include -/*__RCSID("$NetBSD: cproj.c,v 1.3 2010/09/20 17:51:38 christos Exp $"); */ #include #include diff --git a/newlib/libm/complex/cprojf.c b/newlib/libm/complex/cprojf.c index 1310170b6a..373f9e041e 100644 --- a/newlib/libm/complex/cprojf.c +++ b/newlib/libm/complex/cprojf.c @@ -29,8 +29,6 @@ * Marco Atzeri */ -#include -/*__RCSID("$NetBSD: cprojf.c,v 1.3 2010/09/20 17:51:38 christos Exp $"); */ #include #include diff --git a/newlib/libm/complex/cprojl.c b/newlib/libm/complex/cprojl.c index fdd2950954..44bb180cfc 100644 --- a/newlib/libm/complex/cprojl.c +++ b/newlib/libm/complex/cprojl.c @@ -25,8 +25,6 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ -#include -__RCSID("$NetBSD: cprojl.c,v 1.7 2014/10/10 00:48:18 christos Exp $"); #include #include diff --git a/newlib/libm/complex/csqrtl.c b/newlib/libm/complex/csqrtl.c index 5f4c3ca85f..bc62e9151f 100644 --- a/newlib/libm/complex/csqrtl.c +++ b/newlib/libm/complex/csqrtl.c @@ -25,7 +25,6 @@ */ #define _GNU_SOURCE -#include #include #include #include diff --git a/newlib/libm/ld/common/e_acosl.c b/newlib/libm/ld/common/e_acosl.c index e132ec31bb..e8787ec861 100644 --- a/newlib/libm/ld/common/e_acosl.c +++ b/newlib/libm/ld/common/e_acosl.c @@ -12,7 +12,6 @@ * ==================================================== */ -//__FBSDID("$FreeBSD: src/lib/msun/src/e_acosl.c,v 1.2 2008/08/02 03:56:22 das Exp $"); /* * See comments in e_acos.c. diff --git a/newlib/libm/ld/common/e_asinl.c b/newlib/libm/ld/common/e_asinl.c index e92bedfb62..cd77c19a78 100644 --- a/newlib/libm/ld/common/e_asinl.c +++ b/newlib/libm/ld/common/e_asinl.c @@ -12,7 +12,6 @@ * ==================================================== */ -//__FBSDID("$FreeBSD: src/lib/msun/src/e_asinl.c,v 1.2 2008/08/03 17:49:05 das Exp $"); /* * See comments in e_asin.c. diff --git a/newlib/libm/ld/common/e_atan2l.c b/newlib/libm/ld/common/e_atan2l.c index 2a1649272c..123ac1914c 100644 --- a/newlib/libm/ld/common/e_atan2l.c +++ b/newlib/libm/ld/common/e_atan2l.c @@ -13,7 +13,6 @@ * */ -//__FBSDID("$FreeBSD: src/lib/msun/src/e_atan2l.c,v 1.3 2008/08/02 19:17:00 das Exp $"); /* * See comments in e_atan2.c. diff --git a/newlib/libm/ld/common/e_remainderl.c b/newlib/libm/ld/common/e_remainderl.c index 11082b197e..9d02511e06 100644 --- a/newlib/libm/ld/common/e_remainderl.c +++ b/newlib/libm/ld/common/e_remainderl.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/e_remainderl.c,v 1.1 2008/03/30 20:47:42 das Exp $"); long double diff --git a/newlib/libm/ld/common/e_sqrtl.c b/newlib/libm/ld/common/e_sqrtl.c index c1f0f8edc0..99e15bf100 100644 --- a/newlib/libm/ld/common/e_sqrtl.c +++ b/newlib/libm/ld/common/e_sqrtl.c @@ -24,7 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/e_sqrtl.c,v 1.1 2008/03/02 01:47:58 das Exp $"); #ifndef _DOUBLE_DOUBLE_FLOAT /* Return (x + ulp) for normal positive x. Assumes no overflow. */ diff --git a/newlib/libm/ld/common/k_rem_pio2.c b/newlib/libm/ld/common/k_rem_pio2.c index 60c1055b75..553be6112c 100644 --- a/newlib/libm/ld/common/k_rem_pio2.c +++ b/newlib/libm/ld/common/k_rem_pio2.c @@ -11,7 +11,6 @@ * ==================================================== */ -//__FBSDID("$FreeBSD: src/lib/msun/src/k_rem_pio2.c,v 1.11 2008/02/25 11:43:20 bde Exp $"); /* * __kernel_rem_pio2(x,y,e0,nx,prec) diff --git a/newlib/libm/ld/common/s_atanl.c b/newlib/libm/ld/common/s_atanl.c index e41fd7981b..9d53d27fed 100644 --- a/newlib/libm/ld/common/s_atanl.c +++ b/newlib/libm/ld/common/s_atanl.c @@ -11,7 +11,6 @@ * ==================================================== */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_atanl.c,v 1.1 2008/07/31 22:41:26 das Exp $"); /* * See comments in s_atan.c. diff --git a/newlib/libm/ld/common/s_cbrtl.c b/newlib/libm/ld/common/s_cbrtl.c index e51dc0d3b1..52e6f69055 100644 --- a/newlib/libm/ld/common/s_cbrtl.c +++ b/newlib/libm/ld/common/s_cbrtl.c @@ -14,7 +14,6 @@ * and David A. Schultz. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_cbrtl.c,v 1.1 2011/03/12 19:37:35 kargl Exp $"); #define BIAS (LDBL_MAX_EXP - 1) diff --git a/newlib/libm/ld/common/s_cosl.c b/newlib/libm/ld/common/s_cosl.c index 4f9b219ed6..285ed8a751 100644 --- a/newlib/libm/ld/common/s_cosl.c +++ b/newlib/libm/ld/common/s_cosl.c @@ -24,7 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_cosl.c,v 1.3 2011/05/30 19:41:28 kargl Exp $"); /* * Limited testing on pseudorandom numbers drawn within [-2e8:4e8] shows diff --git a/newlib/libm/ld/common/s_fdiml.c b/newlib/libm/ld/common/s_fdiml.c index ca1210559d..738d89d67a 100644 --- a/newlib/libm/ld/common/s_fdiml.c +++ b/newlib/libm/ld/common/s_fdiml.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_fdim.c,v 1.1 2004/06/30 07:04:01 das Exp $"); long double diff --git a/newlib/libm/ld/common/s_fmaxl.c b/newlib/libm/ld/common/s_fmaxl.c index 337c332db0..9ad9052547 100644 --- a/newlib/libm/ld/common/s_fmaxl.c +++ b/newlib/libm/ld/common/s_fmaxl.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_fmaxl.c,v 1.1 2004/06/30 07:04:01 das Exp $"); long double diff --git a/newlib/libm/ld/common/s_fminl.c b/newlib/libm/ld/common/s_fminl.c index 7601e3cea1..5b8032c1b0 100644 --- a/newlib/libm/ld/common/s_fminl.c +++ b/newlib/libm/ld/common/s_fminl.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_fminl.c,v 1.1 2004/06/30 07:04:01 das Exp $"); long double diff --git a/newlib/libm/ld/common/s_ilogbl.c b/newlib/libm/ld/common/s_ilogbl.c index e7450bf86f..d2d3ae272d 100644 --- a/newlib/libm/ld/common/s_ilogbl.c +++ b/newlib/libm/ld/common/s_ilogbl.c @@ -10,7 +10,6 @@ * ==================================================== */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_ilogbl.c,v 1.2 2008/02/22 02:30:35 das Exp $"); #include diff --git a/newlib/libm/ld/common/s_llrintl.c b/newlib/libm/ld/common/s_llrintl.c index ab225c8f07..feeb03f400 100644 --- a/newlib/libm/ld/common/s_llrintl.c +++ b/newlib/libm/ld/common/s_llrintl.c @@ -1,4 +1,3 @@ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_llrintl.c,v 1.1 2008/01/14 02:12:06 das Exp $"); #define dtype long long #define DTYPE_MIN LLONG_MIN diff --git a/newlib/libm/ld/common/s_lroundl.c b/newlib/libm/ld/common/s_lroundl.c index d437804aca..8b13789179 100644 --- a/newlib/libm/ld/common/s_lroundl.c +++ b/newlib/libm/ld/common/s_lroundl.c @@ -1,2 +1 @@ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_lroundl.c,v 1.1 2005/04/08 01:24:08 das Exp $"); diff --git a/newlib/libm/ld/common/s_rintl.c b/newlib/libm/ld/common/s_rintl.c index ffbad67b55..028fa26460 100644 --- a/newlib/libm/ld/common/s_rintl.c +++ b/newlib/libm/ld/common/s_rintl.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_rintl.c,v 1.5 2008/02/22 11:59:05 bde Exp $"); #if LDBL_MAX_EXP != 0x4000 diff --git a/newlib/libm/ld/common/s_roundl.c b/newlib/libm/ld/common/s_roundl.c index 61a941d598..e8589257a9 100644 --- a/newlib/libm/ld/common/s_roundl.c +++ b/newlib/libm/ld/common/s_roundl.c @@ -24,7 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_roundl.c,v 1.2 2005/12/02 13:45:06 bde Exp $"); #include "../math_ld.h" diff --git a/newlib/libm/ld/common/s_scalbl.c b/newlib/libm/ld/common/s_scalbl.c index 71db2fe902..af68c13bc6 100644 --- a/newlib/libm/ld/common/s_scalbl.c +++ b/newlib/libm/ld/common/s_scalbl.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_scalbln.c,v 1.2 2005/03/07 04:57:50 das Exp $"); #include diff --git a/newlib/libm/ld/common/s_scalbln.c b/newlib/libm/ld/common/s_scalbln.c index 0684661b8b..eee5332daa 100644 --- a/newlib/libm/ld/common/s_scalbln.c +++ b/newlib/libm/ld/common/s_scalbln.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_scalbln.c,v 1.2 2005/03/07 04:57:50 das Exp $"); #include diff --git a/newlib/libm/ld/common/s_tanl.c b/newlib/libm/ld/common/s_tanl.c index 26e895992e..9e32cc9af2 100644 --- a/newlib/libm/ld/common/s_tanl.c +++ b/newlib/libm/ld/common/s_tanl.c @@ -24,7 +24,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/src/s_tanl.c,v 1.3 2011/05/30 19:41:28 kargl Exp $"); /* * Limited testing on pseudorandom numbers drawn within [0:4e8] shows diff --git a/newlib/libm/ld/ld128/e_rem_pio2l.h b/newlib/libm/ld/ld128/e_rem_pio2l.h index b1e62a8193..fb75371519 100644 --- a/newlib/libm/ld/ld128/e_rem_pio2l.h +++ b/newlib/libm/ld/ld128/e_rem_pio2l.h @@ -13,7 +13,6 @@ * Optimized by Bruce D. Evans. */ -//__FBSDID("$FreeBSD: src/lib/msun/ld128/e_rem_pio2l.h,v 1.2 2011/05/30 19:41:28 kargl Exp $"); /* ld128 version of __ieee754_rem_pio2l(x,y) * diff --git a/newlib/libm/ld/ld128/invtrig.c b/newlib/libm/ld/ld128/invtrig.c index f609f597d7..4616c9f9eb 100644 --- a/newlib/libm/ld/ld128/invtrig.c +++ b/newlib/libm/ld/ld128/invtrig.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/ld128/invtrig.c,v 1.1 2008/07/31 22:41:26 das Exp $"); #include "invtrig.h" diff --git a/newlib/libm/ld/ld128/k_cosl.c b/newlib/libm/ld/ld128/k_cosl.c index 866e00d532..b22ff44129 100644 --- a/newlib/libm/ld/ld128/k_cosl.c +++ b/newlib/libm/ld/ld128/k_cosl.c @@ -11,7 +11,6 @@ * ==================================================== */ -//__FBSDID("$FreeBSD: src/lib/msun/ld128/k_cosl.c,v 1.1 2008/02/17 07:32:31 das Exp $"); /* * ld128 version of k_cos.c. See ../src/k_cos.c for most comments. diff --git a/newlib/libm/ld/ld128/k_sinl.c b/newlib/libm/ld/ld128/k_sinl.c index 1b9c1148fa..679696ef84 100644 --- a/newlib/libm/ld/ld128/k_sinl.c +++ b/newlib/libm/ld/ld128/k_sinl.c @@ -11,7 +11,6 @@ * ==================================================== */ -//__FBSDID("$FreeBSD: src/lib/msun/ld128/k_sinl.c,v 1.1 2008/02/17 07:32:31 das Exp $"); /* * ld128 version of k_sin.c. See ../src/k_sin.c for most comments. diff --git a/newlib/libm/ld/ld128/k_tanl.c b/newlib/libm/ld/ld128/k_tanl.c index 7168c63914..2fdc17ac19 100644 --- a/newlib/libm/ld/ld128/k_tanl.c +++ b/newlib/libm/ld/ld128/k_tanl.c @@ -11,7 +11,6 @@ * ==================================================== */ -//__FBSDID("$FreeBSD: src/lib/msun/ld128/k_tanl.c,v 1.1 2008/02/17 07:32:31 das Exp $"); /* * ld128 version of k_tan.c. See ../src/k_tan.c for most comments. diff --git a/newlib/libm/ld/ld128/s_exp2l.c b/newlib/libm/ld/ld128/s_exp2l.c index 592a64362d..f0128734bc 100644 --- a/newlib/libm/ld/ld128/s_exp2l.c +++ b/newlib/libm/ld/ld128/s_exp2l.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/ld128/s_exp2l.c,v 1.3 2008/02/13 10:44:44 bde Exp $"); diff --git a/newlib/libm/ld/ld80/e_rem_pio2l.h b/newlib/libm/ld/ld80/e_rem_pio2l.h index ad6b87279e..4ad7b9ded0 100644 --- a/newlib/libm/ld/ld80/e_rem_pio2l.h +++ b/newlib/libm/ld/ld80/e_rem_pio2l.h @@ -13,7 +13,6 @@ * Optimized by Bruce D. Evans. */ -//__FBSDID("$FreeBSD: src/lib/msun/ld80/e_rem_pio2l.h,v 1.3 2011/06/18 13:56:33 benl Exp $"); /* ld80 version of __ieee754_rem_pio2l(x,y) * diff --git a/newlib/libm/ld/ld80/invtrig.c b/newlib/libm/ld/ld80/invtrig.c index c2020bfd45..45eb49fd98 100644 --- a/newlib/libm/ld/ld80/invtrig.c +++ b/newlib/libm/ld/ld80/invtrig.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/ld80/invtrig.c,v 1.1 2008/07/31 22:41:26 das Exp $"); #include "invtrig.h" diff --git a/newlib/libm/ld/ld80/k_cosl.c b/newlib/libm/ld/ld80/k_cosl.c index d29043c500..d2e67dd344 100644 --- a/newlib/libm/ld/ld80/k_cosl.c +++ b/newlib/libm/ld/ld80/k_cosl.c @@ -11,7 +11,6 @@ * ==================================================== */ -//__FBSDID("$FreeBSD: src/lib/msun/ld80/k_cosl.c,v 1.1 2008/02/17 07:32:14 das Exp $"); /* * ld80 version of k_cos.c. See ../src/k_cos.c for most comments. diff --git a/newlib/libm/ld/ld80/k_sinl.c b/newlib/libm/ld/ld80/k_sinl.c index 04d8f69801..4405940679 100644 --- a/newlib/libm/ld/ld80/k_sinl.c +++ b/newlib/libm/ld/ld80/k_sinl.c @@ -11,7 +11,6 @@ * ==================================================== */ -//__FBSDID("$FreeBSD: src/lib/msun/ld80/k_sinl.c,v 1.1 2008/02/17 07:32:14 das Exp $"); /* * ld80 version of k_sin.c. See ../src/k_sin.c for most comments. diff --git a/newlib/libm/ld/ld80/k_tanl.c b/newlib/libm/ld/ld80/k_tanl.c index d74571bb9c..898c47d533 100644 --- a/newlib/libm/ld/ld80/k_tanl.c +++ b/newlib/libm/ld/ld80/k_tanl.c @@ -11,7 +11,6 @@ * ==================================================== */ -//__FBSDID("$FreeBSD: src/lib/msun/ld80/k_tanl.c,v 1.3 2008/02/18 15:39:52 bde Exp $"); /* * ld80 version of k_tan.c. See ../src/k_tan.c for most comments. diff --git a/newlib/libm/ld/ld80/s_exp2l.c b/newlib/libm/ld/ld80/s_exp2l.c index 9a0a2cfc7c..2eeb8ba314 100644 --- a/newlib/libm/ld/ld80/s_exp2l.c +++ b/newlib/libm/ld/ld80/s_exp2l.c @@ -24,7 +24,6 @@ * SUCH DAMAGE. */ -//__FBSDID("$FreeBSD: src/lib/msun/ld80/s_exp2l.c,v 1.3 2008/02/13 10:44:44 bde Exp $"); #define TBLBITS 7 diff --git a/newlib/libm/machine/x86/f_math.h b/newlib/libm/machine/x86/f_math.h index 207e1458a0..997379ebcd 100644 --- a/newlib/libm/machine/x86/f_math.h +++ b/newlib/libm/machine/x86/f_math.h @@ -8,7 +8,6 @@ is preserved. #ifndef __F_MATH_H__ #define __F_MATH_H__ -#include #include "fdlibm.h" __inline__ diff --git a/newlib/testsuite/newlib.search/hsearchtest.c b/newlib/testsuite/newlib.search/hsearchtest.c index 902d46c786..2aef9a712b 100644 --- a/newlib/testsuite/newlib.search/hsearchtest.c +++ b/newlib/testsuite/newlib.search/hsearchtest.c @@ -33,15 +33,6 @@ * Test program for hsearch() et al. */ -#include -#if 0 -#if !defined(lint) -__RCSID("$NetBSD: hsearchtest.c,v 1.4 2002/02/21 07:38:15 itojun Exp $"); -__COPYRIGHT( -"@(#) Copyright (c) 2001 Christopher G. Demetriou. All rights reserved.\n"); -#endif /* not lint */ -#endif - #include #include #include From a78577209e03573b297c9e178af9e528106bd46c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 7 Aug 2024 12:28:07 -0700 Subject: [PATCH 35/42] posix: Remove the entirely unused LC_COLLATE file support Not even newlib still supports any of this mechanism. Remove the collate.c file and eliminate all internal usage of __collate_load_error. Signed-off-by: Keith Packard --- newlib/libc/posix/CMakeLists.txt | 1 - newlib/libc/posix/collate.c | 202 ------------------------------- newlib/libc/posix/collate.h | 31 +---- newlib/libc/posix/collcmp.c | 38 +----- newlib/libc/posix/fnmatch.c | 4 +- newlib/libc/posix/meson.build | 1 - newlib/libc/posix/namespace.h | 153 ----------------------- newlib/libc/posix/regcomp.c | 26 ++-- newlib/libc/posix/un-namespace.h | 140 --------------------- 9 files changed, 17 insertions(+), 579 deletions(-) delete mode 100644 newlib/libc/posix/collate.c delete mode 100644 newlib/libc/posix/namespace.h delete mode 100644 newlib/libc/posix/un-namespace.h diff --git a/newlib/libc/posix/CMakeLists.txt b/newlib/libc/posix/CMakeLists.txt index cd3e589e5c..f8581d1eab 100644 --- a/newlib/libc/posix/CMakeLists.txt +++ b/newlib/libc/posix/CMakeLists.txt @@ -44,7 +44,6 @@ picolibc_sources( if(__HAVE_LOCALE_INFO__) picolibc_sources( - collate.c collcmp.c ) endif() diff --git a/newlib/libc/posix/collate.c b/newlib/libc/posix/collate.c deleted file mode 100644 index 9e19980aec..0000000000 --- a/newlib/libc/posix/collate.c +++ /dev/null @@ -1,202 +0,0 @@ -/*- - * Copyright (c) 1995 Alex Tatmanjants - * at Electronni Visti IA, Kiev, Ukraine. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#define _GNU_SOURCE - -#include "rune.h" -#include -#include -#include -#include -#include -#include "sysexits.h" - -#include "collate.h" - -extern char *_PathLocale; -int __collate_load_error = 1; -int __collate_substitute_nontrivial; -char __collate_version[STR_LEN]; -u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN]; -struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1]; -struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE]; - -#define FREAD(a, b, c, d) \ - do { \ - if (fread(a, b, c, d) != c) { \ - fclose(d); \ - return -1; \ - } \ - } while(0) - -void __collate_err(int ex, const char *f); - -int -__collate_load_tables(char *encoding) -{ - char buf[PATH_MAX]; - FILE *fp; - int i, save_load_error; - - save_load_error = __collate_load_error; - __collate_load_error = 1; - if (!encoding) { - __collate_load_error = save_load_error; - return -1; - } - if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) - return 0; - if (!_PathLocale) { - __collate_load_error = save_load_error; - return -1; - } - /* Range checking not needed, encoding has fixed size */ - (void) strcpy(buf, _PathLocale); - (void) strcat(buf, "/"); - (void) strcat(buf, encoding); - (void) strcat(buf, "/LC_COLLATE"); - if ((fp = fopen(buf, "r")) == NULL) { - __collate_load_error = save_load_error; - return -1; - } - FREAD(__collate_version, sizeof(__collate_version), 1, fp); - if (strcmp(__collate_version, COLLATE_VERSION) != 0) { - fclose(fp); - return -1; - } - FREAD(__collate_substitute_table, sizeof(__collate_substitute_table), - 1, fp); - FREAD(__collate_char_pri_table, sizeof(__collate_char_pri_table), 1, - fp); - FREAD(__collate_chain_pri_table, sizeof(__collate_chain_pri_table), 1, - fp); - fclose(fp); - __collate_load_error = 0; - - __collate_substitute_nontrivial = 0; - for (i = 0; i < UCHAR_MAX + 1; i++) { - if (__collate_substitute_table[i][0] != i || - __collate_substitute_table[i][1] != 0) { - __collate_substitute_nontrivial = 1; - break; - } - } - - return 0; -} - -u_char * -__collate_substitute(const u_char *s) -{ - int dest_len, len, nlen; - int delta; - u_char *dest_str = NULL; - - if(s == NULL || *s == '\0') - return __collate_strdup((u_char *) ""); - delta = strlen((const char *) s); - delta += delta / 8; - dest_str = (u_char *) malloc(dest_len = delta); - if(dest_str == NULL) - __collate_err(EX_OSERR, __FUNCTION__); - len = 0; - while(*s) { - nlen = len + strlen((const char *) - __collate_substitute_table[*s]); - if (dest_len <= nlen) { - dest_str = reallocf(dest_str, dest_len = nlen + delta); - if(dest_str == NULL) - __collate_err(EX_OSERR, __FUNCTION__); - } - strcpy((char *) dest_str + len, - (const char *) __collate_substitute_table[*s++]); - len = nlen; - } - return dest_str; -} - -void -__collate_lookup(const u_char *t, - int *len, - int *prim, - int *sec) -{ - struct __collate_st_chain_pri *p2; - - *len = 1; - *prim = *sec = 0; - for(p2 = __collate_chain_pri_table; p2->str[0]; p2++) { - if(strncmp((const char *) t, (const char *) p2->str, - strlen((const char *) p2->str)) == 0) { - *len = strlen((const char *) p2->str); - *prim = p2->prim; - *sec = p2->sec; - return; - } - } - *prim = __collate_char_pri_table[*t].prim; - *sec = __collate_char_pri_table[*t].sec; -} - -u_char * -__collate_strdup(u_char *s) -{ - u_char *t = (u_char *) strdup((const char *) s); - - if (t == NULL) - __collate_err(EX_OSERR, __FUNCTION__); - return t; -} - -void -__collate_err(int ex, const char *f) -{ - fprintf(stderr, "collate_error: %s: %s\n", f, strerror(errno)); - exit(ex); -} - -#ifdef COLLATE_DEBUG -void -__collate_print_tables() -{ - int i; - struct __collate_st_chain_pri *p2; - - printf("Substitute table:\n"); - for (i = 0; i < UCHAR_MAX + 1; i++) - if (i != *__collate_substitute_table[i]) - printf("\t'%c' --> \"%s\"\n", i, - __collate_substitute_table[i]); - printf("Chain priority table:\n"); - for (p2 = __collate_chain_pri_table; p2->str[0]; p2++) - printf("\t\"%s\" : %d %d\n\n", p2->str, p2->prim, p2->sec); - printf("Char priority table:\n"); - for (i = 0; i < UCHAR_MAX + 1; i++) - printf("\t'%c' : %d %d\n", i, __collate_char_pri_table[i].prim, - __collate_char_pri_table[i].sec); -} -#endif diff --git a/newlib/libc/posix/collate.h b/newlib/libc/posix/collate.h index 06a4b1ea07..7536463062 100644 --- a/newlib/libc/posix/collate.h +++ b/newlib/libc/posix/collate.h @@ -30,37 +30,8 @@ #ifndef _COLLATE_H_ #define _COLLATE_H_ -#include -#include - -#define STR_LEN 10 -#define TABLE_SIZE 100 -#define COLLATE_VERSION "1.0\n" - -struct __collate_st_char_pri { - int prim, sec; -}; -struct __collate_st_chain_pri { - u_char str[STR_LEN]; - int prim, sec; -}; - -extern int __collate_load_error; -extern int __collate_substitute_nontrivial; -extern char __collate_version[STR_LEN]; -extern u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN]; -extern struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1]; -extern struct __collate_st_chain_pri __collate_chain_pri_table[TABLE_SIZE]; - -__BEGIN_DECLS -u_char *__collate_strdup(u_char *); -u_char *__collate_substitute(const u_char *); -int __collate_load_tables(char *); -void __collate_lookup(const u_char *, int *, int *, int *); +_BEGIN_STD_C int __collate_range_cmp(int, int); -#ifdef COLLATE_DEBUG -void __collate_print_tables(void); -#endif __END_DECLS #endif /* !_COLLATE_H_ */ diff --git a/newlib/libc/posix/collcmp.c b/newlib/libc/posix/collcmp.c index 67cacb7cf0..e80715f224 100644 --- a/newlib/libc/posix/collcmp.c +++ b/newlib/libc/posix/collcmp.c @@ -24,15 +24,9 @@ * SUCH DAMAGE. */ -#define _GNU_SOURCE - -#define ASCII_COMPATIBLE_COLLATE /* see share/colldef */ - #include +#include #include "collate.h" -#ifndef ASCII_COMPATIBLE_COLLATE -#include -#endif /* * Compare two characters converting collate information @@ -42,41 +36,17 @@ int __collate_range_cmp (int c1, int c2) { - static char s1[2], s2[2]; + char s1[2], s2[2]; int ret; -#ifndef ASCII_COMPATIBLE_COLLATE - int as1, as2, al1, al2; -#endif c1 &= UCHAR_MAX; c2 &= UCHAR_MAX; if (c1 == c2) return (0); - -#ifndef ASCII_COMPATIBLE_COLLATE - as1 = isascii(c1); - as2 = isascii(c2); - al1 = isalpha(c1); - al2 = isalpha(c2); - - if (as1 || as2 || al1 || al2) { - if ((as1 && as2) || (!al1 && !al2)) - return (c1 - c2); - if (al1 && !al2) { - if (isupper(c1)) - return ('A' - c2); - else - return ('a' - c2); - } else if (al2 && !al1) { - if (isupper(c2)) - return (c1 - 'A'); - else - return (c1 - 'a'); - } - } -#endif s1[0] = c1; + s1[1] = 0; s2[0] = c2; + s2[1] = 0; if ((ret = strcoll(s1, s2)) != 0) return (ret); return (c1 - c2); diff --git a/newlib/libc/posix/fnmatch.c b/newlib/libc/posix/fnmatch.c index 6164c80488..3eca9158c1 100644 --- a/newlib/libc/posix/fnmatch.c +++ b/newlib/libc/posix/fnmatch.c @@ -207,9 +207,7 @@ rangematch(const char *pattern, char test, int flags, char **newp) if ( #ifdef __HAVE_LOCALE_INFO__ - __collate_load_error ? - c <= test && test <= c2 : - __collate_range_cmp(c, test) <= 0 + __collate_range_cmp(c, test) <= 0 && __collate_range_cmp(test, c2) <= 0 #else c <= test && test <= c2 diff --git a/newlib/libc/posix/meson.build b/newlib/libc/posix/meson.build index f775008ac1..3fa4ed0cd6 100644 --- a/newlib/libc/posix/meson.build +++ b/newlib/libc/posix/meson.build @@ -44,7 +44,6 @@ srcs_posix = [ if newlib_locale_info srcs_posix += [ - 'collate.c', 'collcmp.c', ] endif diff --git a/newlib/libc/posix/namespace.h b/newlib/libc/posix/namespace.h deleted file mode 100644 index 807349b2dd..0000000000 --- a/newlib/libc/posix/namespace.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (c) 2001 Daniel Eischen . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/lib/libc/include/namespace.h,v 1.9 2002/03/29 22:43:42 markm Exp $ - */ - -#ifndef _NAMESPACE_H_ -#define _NAMESPACE_H_ - -/* - * Adjust names so that headers declare "hidden" names. - */ - -/* - * ISO C (C90) section. Most names in libc aren't in ISO C, so they - * should be here. Most aren't here... - */ -#define err _err -#define warn _warn - -/* - * Prototypes for syscalls/functions that need to be overridden - * in libc_r/libpthread. - */ -#define accept _accept -#define __acl_aclcheck_fd ___acl_aclcheck_fd -#define __acl_delete_fd ___acl_delete_fd -#define __acl_get_fd ___acl_get_fd -#define __acl_set_fd ___acl_set_fd -#define bind _bind -#define __cap_get_fd ___cap_get_fd -#define __cap_set_fd ___cap_set_fd -#define close _close -#define connect _connect -#define dup _dup -#define dup2 _dup2 -#define execve _execve -#define fcntl _fcntl -/*#define flock _flock */ -#define fstat _fstat -#define fstatfs _fstatfs -#define fsync _fsync -#define getdirentries _getdirentries -#define getlogin _getlogin -#define getpeername _getpeername -#define getprogname _getprogname -#define getsockname _getsockname -#define getsockopt _getsockopt -#define ioctl _ioctl -/* #define kevent _kevent */ -#define listen _listen -#define nanosleep _nanosleep -#define open _open -#define poll _poll -#define pthread_cond_signal _pthread_cond_signal -#define pthread_cond_wait _pthread_cond_wait -#define pthread_cond_init _pthread_cond_init -#define pthread_exit _pthread_exit -#define pthread_getspecific _pthread_getspecific -#define pthread_key_create _pthread_key_create -#define pthread_key_delete _pthread_key_delete -#define pthread_main_np _pthread_main_np -#define pthread_mutex_destroy _pthread_mutex_destroy -#define pthread_mutex_init _pthread_mutex_init -#define pthread_mutex_lock _pthread_mutex_lock -#define pthread_mutex_trylock _pthread_mutex_trylock -#define pthread_mutex_unlock _pthread_mutex_unlock -#define pthread_mutexattr_init _pthread_mutexattr_init -#define pthread_mutexattr_destroy _pthread_mutexattr_destroy -#define pthread_mutexattr_settype _pthread_mutexattr_settype -#define pthread_once _pthread_once -#define pthread_rwlock_init _pthread_rwlock_init -#define pthread_rwlock_rdlock _pthread_rwlock_rdlock -#define pthread_rwlock_wrlock _pthread_rwlock_wrlock -#define pthread_rwlock_unlock _pthread_rwlock_unlock -#define pthread_self _pthread_self -#define pthread_setspecific _pthread_setspecific -#define pthread_sigmask _pthread_sigmask -#define read _read -#define readv _readv -#define recvfrom _recvfrom -#define recvmsg _recvmsg -#define select _select -#define sendmsg _sendmsg -#define sendto _sendto -#define setsockopt _setsockopt -/*#define sigaction _sigaction*/ -#define sigprocmask _sigprocmask -#define sigsuspend _sigsuspend -#define socket _socket -#define socketpair _socketpair -#define wait4 _wait4 -/*#define write _write*/ -#define writev _writev - - -/* - * Other hidden syscalls/functions that libc_r needs to override - * but are not used internally by libc. - * - * XXX - When modifying libc to use one of the following, remove - * the prototype from below and place it in the list above. - */ -#if 0 -#define creat _creat -#define fchflags _fchflags -#define fchmod _fchmod -#define fpathconf _fpathconf -#define msync _msync -#define nfssvc _nfssvc -#define pause _pause -#define pthread_rwlock_destroy _pthread_rwlock_destroy -#define pthread_rwlock_tryrdlock _pthread_rwlock_tryrdlock -#define pthread_rwlock_trywrlock _pthread_rwlock_trywrlock -#define pthread_rwlockattr_init _pthread_rwlockattr_init -#define pthread_rwlockattr_destroy _pthread_rwlockattr_destroy -#define sched_yield _sched_yield -#define sendfile _sendfile -#define shutdown _shutdown -#define sigaltstack _sigaltstack -#define sigpending _sigpending -#define sigreturn _sigreturn -#define sigsetmask _sigsetmask -#define sleep _sleep -#define system _system -#define tcdrain _tcdrain -#define wait _wait -#define waitpid _waitpid -#endif - -#endif /* _NAMESPACE_H_ */ diff --git a/newlib/libc/posix/regcomp.c b/newlib/libc/posix/regcomp.c index 45f9b05d3a..8225fef337 100644 --- a/newlib/libc/posix/regcomp.c +++ b/newlib/libc/posix/regcomp.c @@ -806,21 +806,17 @@ p_b_term(struct parse *p, cset *cs) CHadd(cs, start); else { #ifdef __HAVE_LOCALE_INFO__ - if (__collate_load_error) { -#endif - (void)REQUIRE((uch)start <= (uch)finish, REG_ERANGE); - for (i = (uch)start; i <= (uch)finish; i++) - CHadd(cs, i); -#ifdef __HAVE_LOCALE_INFO__ - } else { - (void)REQUIRE(__collate_range_cmp(start, finish) <= 0, REG_ERANGE); - for (i = CHAR_MIN; i <= CHAR_MAX; i++) { - if ( __collate_range_cmp(start, i) <= 0 - && __collate_range_cmp(i, finish) <= 0 - ) - CHadd(cs, i); - } - } + (void)REQUIRE(__collate_range_cmp(start, finish) <= 0, REG_ERANGE); + for (i = CHAR_MIN; i <= CHAR_MAX; i++) { + if ( __collate_range_cmp(start, i) <= 0 + && __collate_range_cmp(i, finish) <= 0 + ) + CHadd(cs, i); + } +#else + (void)REQUIRE((uch)start <= (uch)finish, REG_ERANGE); + for (i = (uch)start; i <= (uch)finish; i++) + CHadd(cs, i); #endif } break; diff --git a/newlib/libc/posix/un-namespace.h b/newlib/libc/posix/un-namespace.h deleted file mode 100644 index 01d9b8fa0a..0000000000 --- a/newlib/libc/posix/un-namespace.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2001 Daniel Eischen . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/lib/libc/include/un-namespace.h,v 1.7 2002/03/29 22:43:42 markm Exp $ - */ - -#ifndef _UN_NAMESPACE_H_ -#define _UN_NAMESPACE_H_ - -#undef accept -#undef __acl_aclcheck_fd -#undef __acl_delete_fd -#undef __acl_get_fd -#undef __acl_set_fd -#undef bind -#undef __cap_get_fd -#undef __cap_set_fd -#undef close -#undef connect -#undef dup -#undef dup2 -#undef execve -#undef fcntl -#undef flock -#undef fstat -#undef fstatfs -#undef fsync -#undef getdirentries -#undef getlogin -#undef getpeername -#undef getprogname -#undef getsockname -#undef getsockopt -#undef ioctl -#undef kevent -#undef listen -#undef nanosleep -#undef open -#undef pthread_getspecific -#undef pthread_key_create -#undef pthread_key_delete -#undef pthread_mutex_destroy -#undef pthread_mutex_init -#undef pthread_mutex_lock -#undef pthread_mutex_trylock -#undef pthread_mutex_unlock -#undef pthread_mutexattr_init -#undef pthread_mutexattr_destroy -#undef pthread_mutexattr_settype -#undef pthread_once -#undef pthread_self -#undef pthread_setspecific -#undef read -#undef readv -#undef recvfrom -#undef recvmsg -#undef select -#undef sendmsg -#undef sendto -#undef setsockopt -#undef sigaction -#undef sigprocmask -#undef sigsuspend -#undef socket -#undef socketpair -#undef wait4 -#undef write -#undef writev - -#if 0 -#undef creat -#undef fchflags -#undef fchmod -#undef fpathconf -#undef msync -#undef nfssvc -#undef pause -#undef poll -#undef pthread_rwlock_destroy -#undef pthread_rwlock_init -#undef pthread_rwlock_rdlock -#undef pthread_rwlock_tryrdlock -#undef pthread_rwlock_trywrlock -#undef pthread_rwlock_unlock -#undef pthread_rwlock_wrlock -#undef pthread_rwlockattr_init -#undef pthread_rwlockattr_destroy -#undef sched_yield -#undef sendfile -#undef shutdown -#undef sigaltstack -#undef sigpending -#undef sigreturn -#undef sigsetmask -#undef sleep -#undef system -#undef tcdrain -#undef wait -#undef waitpid -#endif /* 0 */ - -#ifdef _SIGNAL_H_ -int _sigaction(int, const struct sigaction *, struct sigaction *); -#endif - -#ifdef _SYS_EVENT_H_ -int _kevent(int, const struct kevent *, int, struct kevent *, - int, const struct timespec *); -#endif - -#ifdef _SYS_FCNTL_H_ -int _flock(int, int); -#endif - -#undef err -#undef warn - -#endif /* _UN_NAMESPACE_H_ */ From 025c2cffd4433348411a4d78790624831ca40c78 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 8 Aug 2024 11:23:12 -0700 Subject: [PATCH 36/42] test: semihost test needs POSIX limits for PATH_MAX PATH_MAX is a posix value, not a C value. Signed-off-by: Keith Packard --- test/semihost/semihost-get-cmdline.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/semihost/semihost-get-cmdline.c b/test/semihost/semihost-get-cmdline.c index bec97ec698..4a2dc090b8 100644 --- a/test/semihost/semihost-get-cmdline.c +++ b/test/semihost/semihost-get-cmdline.c @@ -33,6 +33,7 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define _DEFAULT_SOURCE #include #include #include From 2f5f8439bd61e93e0f42d8009324d8c5227153c1 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 7 Aug 2024 12:56:23 -0700 Subject: [PATCH 37/42] include: _POSIX_2_RE_DUP_MAX -> unistd.h. Mask POSIX limits. Make sure limits.h doesn't expose any non-C limits unless the application requests them. Signed-off-by: Keith Packard --- newlib/libc/include/limits.h | 28 +++++++--------------------- newlib/libc/include/sys/syslimits.h | 25 +++++++++++++------------ newlib/libc/include/sys/unistd.h | 6 ++++++ newlib/libc/posix/utils.h | 2 ++ newlib/libc/time/tzset.c | 2 +- 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/newlib/libc/include/limits.h b/newlib/libc/include/limits.h index f663eeb9a1..d05a759be6 100644 --- a/newlib/libc/include/limits.h +++ b/newlib/libc/include/limits.h @@ -128,30 +128,16 @@ #endif /* !_LIBC_LIMITS_H_ */ -#if defined __GNUC__ && !defined _GCC_LIMITS_H_ -/* `_GCC_LIMITS_H_' is what GCC's file defines. */ +/* + * Placing this outside of the above condition means that this will + * get run even from another picolibc provided limits.h file down the + * include chain. + */ +#ifdef __GNUC__ #ifdef __clang__ #ifndef __GLIBC_USE #define __GLIBC_USE(x) 1 #endif #endif # include_next -#endif /* __GNUC__ && !_GCC_LIMITS_H_ */ - -#ifndef _POSIX2_RE_DUP_MAX -/* The maximum number of repeated occurrences of a regular expression - * permitted when using the interval notation `\{M,N\}'. */ -#define _POSIX2_RE_DUP_MAX 255 -#endif /* _POSIX2_RE_DUP_MAX */ - -#ifndef ARG_MAX -#define ARG_MAX 4096 -#endif - -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif - -#ifndef ATEXIT_MAX -#define ATEXIT_MAX 32 -#endif +#endif /* __GNUC__ */ diff --git a/newlib/libc/include/sys/syslimits.h b/newlib/libc/include/sys/syslimits.h index db575cdec2..98fccf9961 100644 --- a/newlib/libc/include/sys/syslimits.h +++ b/newlib/libc/include/sys/syslimits.h @@ -35,32 +35,33 @@ #include +#if __POSIX_VISIBLE + +/* Runtime invariant values */ #define ARG_MAX 65536 /* max bytes for an exec function */ -#ifndef CHILD_MAX +#define ATEXIT_MAX 32 /* max atexit functions */ #define CHILD_MAX 40 /* max simultaneous processes */ -#endif +#define IOV_MAX 1024 /* max elements in i/o vector */ +#define OPEN_MAX 64 /* max open files per process */ +#define TZNAME_MAX 10 /* max time zone name length */ + +/* Pathname values */ #define LINK_MAX 32767 /* max file link count */ #define MAX_CANON 255 /* max bytes in term canon input line */ #define MAX_INPUT 255 /* max bytes in terminal input */ #define NAME_MAX 255 /* max bytes in a file name */ -#define NGROUPS_MAX 16 /* max supplemental group id's */ -#ifndef OPEN_MAX -#define OPEN_MAX 64 /* max open files per process */ -#endif #define PATH_MAX 1024 /* max bytes in pathname */ #define PIPE_BUF 512 /* max bytes for atomic pipe writes */ -#define IOV_MAX 1024 /* max elements in i/o vector */ -#define BC_BASE_MAX 99 /* max ibase/obase values in bc(1) */ -#define BC_DIM_MAX 2048 /* max array elements in bc(1) */ -#define BC_SCALE_MAX 99 /* max scale value in bc(1) */ -#define BC_STRING_MAX 1000 /* max const string length in bc(1) */ +/* Runtime increasable values */ #define COLL_WEIGHTS_MAX 0 /* max weights for order keyword */ #define EXPR_NEST_MAX 32 /* max expressions nested in expr(1) */ #define LINE_MAX 2048 /* max bytes in an input line */ #define RE_DUP_MAX 255 /* max RE's in interval notation */ -#if __POSIX_VISIBLE +#endif /* __POSIX_VISIBLE */ + +#if __MISC_VISIBLE #define NSIG_MAX __LONG_WIDTH__ /* max signal number */ #endif diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h index dabd1f8558..cfb43460be 100644 --- a/newlib/libc/include/sys/unistd.h +++ b/newlib/libc/include/sys/unistd.h @@ -375,6 +375,12 @@ int unlinkat (int, const char *, int); #define STDOUT_FILENO 1 /* standard output file descriptor */ #define STDERR_FILENO 2 /* standard error file descriptor */ +#ifndef _POSIX2_RE_DUP_MAX +/* The maximum number of repeated occurrences of a regular expression + * permitted when using the interval notation `\{M,N\}'. */ +#define _POSIX2_RE_DUP_MAX 255 +#endif /* _POSIX2_RE_DUP_MAX */ + /* * sysconf values per IEEE Std 1003.1, 2008 Edition */ diff --git a/newlib/libc/posix/utils.h b/newlib/libc/posix/utils.h index 96ad0e1e98..e534246cd1 100644 --- a/newlib/libc/posix/utils.h +++ b/newlib/libc/posix/utils.h @@ -34,6 +34,8 @@ * $FreeBSD: src/lib/libc/regex/utils.h,v 1.2 2002/03/22 23:41:56 obrien Exp $ */ +#include /* for _POSIX2_RE_DUP_MAX */ + /* utility definitions */ #define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */ #define REGEX_INFINITY (DUPMAX + 1) diff --git a/newlib/libc/time/tzset.c b/newlib/libc/time/tzset.c index 3be6f889ba..d2c003cb4b 100644 --- a/newlib/libc/time/tzset.c +++ b/newlib/libc/time/tzset.c @@ -104,10 +104,10 @@ Supporting OS subroutine required: None #include #include #include +#include #include "local.h" #define TZNAME_MIN 3 /* POSIX min TZ abbr size local def */ -#define TZNAME_MAX 10 /* POSIX max TZ abbr size local def */ static char __tzname_std[TZNAME_MAX + 2]; static char __tzname_dst[TZNAME_MAX + 2]; From 38b527a96adcc1d1a48d67478d8656ffb8151baf Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 7 Aug 2024 13:30:35 -0700 Subject: [PATCH 38/42] Move sys/fenv.h to machine/fenv.h This is a machine-specific file, not an OS specific file. Signed-off-by: Keith Packard --- newlib/libc/include/fenv.h | 2 +- newlib/libc/include/machine/CMakeLists.txt | 1 + newlib/libc/include/{sys => machine}/fenv.h | 9 ++-- newlib/libc/include/machine/meson.build | 1 + newlib/libc/include/sys/CMakeLists.txt | 1 - newlib/libc/include/sys/meson.build | 1 - .../machine/aarch64/machine/CMakeLists.txt | 1 + .../machine/aarch64/{sys => machine}/fenv.h | 0 .../libc/machine/aarch64/machine/meson.build | 1 + newlib/libc/machine/aarch64/meson.build | 1 - .../libc/machine/aarch64/sys/CMakeLists.txt | 37 ------------- newlib/libc/machine/aarch64/sys/meson.build | 53 ------------------- newlib/libc/machine/arm/CMakeLists.txt | 6 +-- .../libc/machine/arm/machine/CMakeLists.txt | 1 + .../libc/machine/arm/{sys => machine}/fenv.h | 6 +-- newlib/libc/machine/arm/machine/meson.build | 1 + newlib/libc/machine/arm/meson.build | 1 - newlib/libc/machine/arm/sys/CMakeLists.txt | 37 ------------- newlib/libc/machine/arm/sys/meson.build | 53 ------------------- newlib/libc/machine/m68k/CMakeLists.txt | 5 +- .../libc/machine/m68k/machine/CMakeLists.txt | 1 + .../libc/machine/m68k/{sys => machine}/fenv.h | 6 +-- newlib/libc/machine/m68k/machine/meson.build | 1 + newlib/libc/machine/m68k/meson.build | 1 - newlib/libc/machine/m68k/sys/CMakeLists.txt | 37 ------------- newlib/libc/machine/m68k/sys/meson.build | 53 ------------------- newlib/libc/machine/microblaze/CMakeLists.txt | 3 -- newlib/libc/machine/mips/CMakeLists.txt | 1 - .../libc/machine/mips/machine/CMakeLists.txt | 1 + .../libc/machine/mips/{sys => machine}/fenv.h | 4 +- newlib/libc/machine/mips/machine/meson.build | 1 + newlib/libc/machine/mips/meson.build | 1 - newlib/libc/machine/mips/sys/CMakeLists.txt | 37 ------------- newlib/libc/machine/mips/sys/meson.build | 53 ------------------- newlib/libc/machine/powerpc/CMakeLists.txt | 1 - .../machine/powerpc/machine/CMakeLists.txt | 1 + .../machine/powerpc/{sys => machine}/fenv.h | 6 +-- .../libc/machine/powerpc/machine/meson.build | 1 + newlib/libc/machine/powerpc/meson.build | 1 - .../libc/machine/powerpc/sys/CMakeLists.txt | 37 ------------- newlib/libc/machine/powerpc/sys/meson.build | 53 ------------------- newlib/libc/machine/riscv/CMakeLists.txt | 6 +-- newlib/libc/machine/riscv/{sys => }/asm.h | 0 .../machine/riscv/{sys/string.h => local.h} | 5 -- .../libc/machine/riscv/machine/CMakeLists.txt | 1 + .../machine/riscv/{sys => machine}/fenv.h | 6 +-- newlib/libc/machine/riscv/machine/meson.build | 1 + newlib/libc/machine/riscv/meson.build | 1 - newlib/libc/machine/riscv/setjmp.S | 2 +- newlib/libc/machine/riscv/strcmp.S | 2 +- newlib/libc/machine/riscv/strcpy.c | 1 + newlib/libc/machine/riscv/strlen.c | 1 + newlib/libc/machine/riscv/sys/CMakeLists.txt | 39 -------------- newlib/libc/machine/riscv/sys/meson.build | 53 ------------------- newlib/libc/machine/sh/CMakeLists.txt | 5 +- newlib/libc/machine/sh/machine/CMakeLists.txt | 1 + .../libc/machine/sh/{sys => machine}/fenv.h | 6 +-- newlib/libc/machine/sh/machine/meson.build | 1 + newlib/libc/machine/sh/meson.build | 1 - newlib/libc/machine/sh/sys/CMakeLists.txt | 37 ------------- newlib/libc/machine/sh/sys/meson.build | 53 ------------------- newlib/libc/machine/sparc/CMakeLists.txt | 4 +- .../libc/machine/sparc/machine/CMakeLists.txt | 1 + .../machine/sparc/{sys => machine}/fenv.h | 6 +-- newlib/libc/machine/sparc/machine/meson.build | 1 + newlib/libc/machine/sparc/meson.build | 1 - newlib/libc/machine/sparc/sys/CMakeLists.txt | 37 ------------- newlib/libc/machine/sparc/sys/meson.build | 53 ------------------- .../libc/machine/spu/{sys => machine}/fenv.h | 4 +- newlib/libc/machine/x86/CMakeLists.txt | 1 - .../libc/machine/x86/machine/CMakeLists.txt | 1 + .../libc/machine/x86/{sys => machine}/fenv.h | 4 +- newlib/libc/machine/x86/machine/meson.build | 1 + newlib/libc/machine/x86/meson.build | 1 - newlib/libc/machine/x86/sys/CMakeLists.txt | 37 ------------- newlib/libc/machine/x86/sys/meson.build | 53 ------------------- newlib/libc/machine/xtensa/CMakeLists.txt | 4 +- .../machine/xtensa/machine/CMakeLists.txt | 1 + .../machine/xtensa/{sys => machine}/fenv.h | 4 +- .../libc/machine/xtensa/machine/meson.build | 1 + newlib/libc/machine/xtensa/meson.build | 1 - newlib/libc/machine/xtensa/sys/CMakeLists.txt | 37 ------------- newlib/libc/machine/xtensa/sys/meson.build | 53 ------------------- 83 files changed, 70 insertions(+), 976 deletions(-) rename newlib/libc/include/{sys => machine}/fenv.h (97%) rename newlib/libc/machine/aarch64/{sys => machine}/fenv.h (100%) delete mode 100644 newlib/libc/machine/aarch64/sys/CMakeLists.txt delete mode 100644 newlib/libc/machine/aarch64/sys/meson.build rename newlib/libc/machine/arm/{sys => machine}/fenv.h (96%) delete mode 100644 newlib/libc/machine/arm/sys/CMakeLists.txt delete mode 100644 newlib/libc/machine/arm/sys/meson.build rename newlib/libc/machine/m68k/{sys => machine}/fenv.h (96%) delete mode 100644 newlib/libc/machine/m68k/sys/CMakeLists.txt delete mode 100644 newlib/libc/machine/m68k/sys/meson.build rename newlib/libc/machine/mips/{sys => machine}/fenv.h (98%) delete mode 100644 newlib/libc/machine/mips/sys/CMakeLists.txt delete mode 100644 newlib/libc/machine/mips/sys/meson.build rename newlib/libc/machine/powerpc/{sys => machine}/fenv.h (98%) delete mode 100644 newlib/libc/machine/powerpc/sys/CMakeLists.txt delete mode 100644 newlib/libc/machine/powerpc/sys/meson.build rename newlib/libc/machine/riscv/{sys => }/asm.h (100%) rename newlib/libc/machine/riscv/{sys/string.h => local.h} (93%) rename newlib/libc/machine/riscv/{sys => machine}/fenv.h (97%) delete mode 100644 newlib/libc/machine/riscv/sys/CMakeLists.txt delete mode 100644 newlib/libc/machine/riscv/sys/meson.build rename newlib/libc/machine/sh/{sys => machine}/fenv.h (96%) delete mode 100644 newlib/libc/machine/sh/sys/CMakeLists.txt delete mode 100644 newlib/libc/machine/sh/sys/meson.build rename newlib/libc/machine/sparc/{sys => machine}/fenv.h (97%) delete mode 100644 newlib/libc/machine/sparc/sys/CMakeLists.txt delete mode 100644 newlib/libc/machine/sparc/sys/meson.build rename newlib/libc/machine/spu/{sys => machine}/fenv.h (99%) rename newlib/libc/machine/x86/{sys => machine}/fenv.h (99%) delete mode 100644 newlib/libc/machine/x86/sys/CMakeLists.txt delete mode 100644 newlib/libc/machine/x86/sys/meson.build rename newlib/libc/machine/xtensa/{sys => machine}/fenv.h (98%) delete mode 100644 newlib/libc/machine/xtensa/sys/CMakeLists.txt delete mode 100644 newlib/libc/machine/xtensa/sys/meson.build diff --git a/newlib/libc/include/fenv.h b/newlib/libc/include/fenv.h index 45b4d031c0..134fde4873 100644 --- a/newlib/libc/include/fenv.h +++ b/newlib/libc/include/fenv.h @@ -16,7 +16,7 @@ _BEGIN_STD_C -#include +#include #ifndef FE_ALL_EXCEPT #define FE_ALL_EXCEPT 0 diff --git a/newlib/libc/include/machine/CMakeLists.txt b/newlib/libc/include/machine/CMakeLists.txt index cc7b4e5ed6..2653699036 100644 --- a/newlib/libc/include/machine/CMakeLists.txt +++ b/newlib/libc/include/machine/CMakeLists.txt @@ -39,6 +39,7 @@ picolibc_headers(machine _endian.h endian.h fastmath.h + fenv.h fenv-softfloat.h ieeefp.h malloc.h diff --git a/newlib/libc/include/sys/fenv.h b/newlib/libc/include/machine/fenv.h similarity index 97% rename from newlib/libc/include/sys/fenv.h rename to newlib/libc/include/machine/fenv.h index 659b437a68..0967797296 100644 --- a/newlib/libc/include/sys/fenv.h +++ b/newlib/libc/include/machine/fenv.h @@ -27,10 +27,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _SYS_FENV_H_ -#define _SYS_FENV_H_ - -#include +#ifndef _MACHINE_FENV_H_ +#define _MACHINE_FENV_H_ _BEGIN_STD_C @@ -115,5 +113,4 @@ _END_STD_C #include #endif - -#endif /* _SYS_FENV_H_ */ +#endif /* _MACHINE_FENV_H_ */ diff --git a/newlib/libc/include/machine/meson.build b/newlib/libc/include/machine/meson.build index 4eed38b2e0..fe4ad4ab58 100644 --- a/newlib/libc/include/machine/meson.build +++ b/newlib/libc/include/machine/meson.build @@ -39,6 +39,7 @@ inc_machine_headers_all = [ '_endian.h', 'endian.h', 'fastmath.h', + 'fenv.h', 'fenv-softfloat.h', 'ieeefp.h', 'malloc.h', diff --git a/newlib/libc/include/sys/CMakeLists.txt b/newlib/libc/include/sys/CMakeLists.txt index e45aaca9e0..0b796c7754 100644 --- a/newlib/libc/include/sys/CMakeLists.txt +++ b/newlib/libc/include/sys/CMakeLists.txt @@ -43,7 +43,6 @@ picolibc_headers(sys errno.h fcntl.h features.h - fenv.h file.h iconvnls.h _initfini.h diff --git a/newlib/libc/include/sys/meson.build b/newlib/libc/include/sys/meson.build index 1cfc7482a9..1b48e35b0a 100644 --- a/newlib/libc/include/sys/meson.build +++ b/newlib/libc/include/sys/meson.build @@ -43,7 +43,6 @@ inc_sys_headers_all = [ 'errno.h', 'fcntl.h', 'features.h', - 'fenv.h', 'file.h', 'iconvnls.h', '_initfini.h', diff --git a/newlib/libc/machine/aarch64/machine/CMakeLists.txt b/newlib/libc/machine/aarch64/machine/CMakeLists.txt index 1ff49b76ef..3bb3b256b3 100644 --- a/newlib/libc/machine/aarch64/machine/CMakeLists.txt +++ b/newlib/libc/machine/aarch64/machine/CMakeLists.txt @@ -34,6 +34,7 @@ # picolibc_headers(machine _types.h + fenv.h fenv-fp.h math.h ) diff --git a/newlib/libc/machine/aarch64/sys/fenv.h b/newlib/libc/machine/aarch64/machine/fenv.h similarity index 100% rename from newlib/libc/machine/aarch64/sys/fenv.h rename to newlib/libc/machine/aarch64/machine/fenv.h diff --git a/newlib/libc/machine/aarch64/machine/meson.build b/newlib/libc/machine/aarch64/machine/meson.build index 94504afa5f..1bd0c182ca 100644 --- a/newlib/libc/machine/aarch64/machine/meson.build +++ b/newlib/libc/machine/aarch64/machine/meson.build @@ -34,6 +34,7 @@ # inc_machine_headers_machine = [ '_types.h', + 'fenv.h', 'fenv-fp.h', 'math.h', ] diff --git a/newlib/libc/machine/aarch64/meson.build b/newlib/libc/machine/aarch64/meson.build index 5a8cd9565d..176b818f05 100644 --- a/newlib/libc/machine/aarch64/meson.build +++ b/newlib/libc/machine/aarch64/meson.build @@ -70,7 +70,6 @@ srcs_machine = [ 'strrchr.S', ] -subdir('sys') subdir('machine') foreach target : targets diff --git a/newlib/libc/machine/aarch64/sys/CMakeLists.txt b/newlib/libc/machine/aarch64/sys/CMakeLists.txt deleted file mode 100644 index babcc95ec6..0000000000 --- a/newlib/libc/machine/aarch64/sys/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -picolibc_headers(sys - fenv.h - ) diff --git a/newlib/libc/machine/aarch64/sys/meson.build b/newlib/libc/machine/aarch64/sys/meson.build deleted file mode 100644 index f6b87566bb..0000000000 --- a/newlib/libc/machine/aarch64/sys/meson.build +++ /dev/null @@ -1,53 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2020 Keith Packard, -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -inc_sys_headers_machine = [ - 'fenv.h' -] - -install_headers(inc_sys_headers_machine, - install_dir: include_dir / 'sys') - -if enable_cdefs_tests - ignore_headers = [] - foreach header : inc_sys_headers_machine - if not (header in ignore_headers) and not (header.startswith('_')) - test_name = 'check-cdef-sys-' + header - test(test_name, - validate_cdefs, - args: [meson.current_source_dir() / header] + cc.cmd_array() + c_args + inc_args, - suite: 'headers') - endif - endforeach -endif diff --git a/newlib/libc/machine/arm/CMakeLists.txt b/newlib/libc/machine/arm/CMakeLists.txt index 5e502dc1c5..d8f48bdec1 100644 --- a/newlib/libc/machine/arm/CMakeLists.txt +++ b/newlib/libc/machine/arm/CMakeLists.txt @@ -32,6 +32,9 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. # + +add_subdirectory(machine) + picolibc_sources_flags("-fno-builtin" setjmp.S strcmp.S @@ -48,6 +51,3 @@ picolibc_sources_flags("-fno-builtin" strlen.c strlen.S ) - -add_subdirectory(sys) -add_subdirectory(machine) diff --git a/newlib/libc/machine/arm/machine/CMakeLists.txt b/newlib/libc/machine/arm/machine/CMakeLists.txt index a841c0d5ca..1a8322920a 100644 --- a/newlib/libc/machine/arm/machine/CMakeLists.txt +++ b/newlib/libc/machine/arm/machine/CMakeLists.txt @@ -35,6 +35,7 @@ picolibc_headers(machine acle-compat.h _endian.h + fenv.h fenv-fp.h math.h param.h diff --git a/newlib/libc/machine/arm/sys/fenv.h b/newlib/libc/machine/arm/machine/fenv.h similarity index 96% rename from newlib/libc/machine/arm/sys/fenv.h rename to newlib/libc/machine/arm/machine/fenv.h index 5179d64441..caa7e35e45 100644 --- a/newlib/libc/machine/arm/sys/fenv.h +++ b/newlib/libc/machine/arm/machine/fenv.h @@ -28,8 +28,8 @@ * $FreeBSD$ */ -#ifndef _SYS_FENV_H_ -#define _SYS_FENV_H_ 1 +#ifndef _MACHINE_FENV_H_ +#define _MACHINE_FENV_H_ 1 _BEGIN_STD_C @@ -84,4 +84,4 @@ _END_STD_C #endif #endif -#endif /* _SYS_FENV_H_ */ +#endif /* _MACHINE_FENV_H_ */ diff --git a/newlib/libc/machine/arm/machine/meson.build b/newlib/libc/machine/arm/machine/meson.build index 7328103b75..a3b2015c4d 100644 --- a/newlib/libc/machine/arm/machine/meson.build +++ b/newlib/libc/machine/arm/machine/meson.build @@ -35,6 +35,7 @@ inc_machine_headers_machine = [ 'acle-compat.h', '_endian.h', + 'fenv.h', 'fenv-fp.h', 'math.h', 'param.h', diff --git a/newlib/libc/machine/arm/meson.build b/newlib/libc/machine/arm/meson.build index 058aa715f6..59f430b3bf 100644 --- a/newlib/libc/machine/arm/meson.build +++ b/newlib/libc/machine/arm/meson.build @@ -49,7 +49,6 @@ srcs_machine = [ 'strlen.S', ] -subdir('sys') subdir('machine') foreach target : targets diff --git a/newlib/libc/machine/arm/sys/CMakeLists.txt b/newlib/libc/machine/arm/sys/CMakeLists.txt deleted file mode 100644 index babcc95ec6..0000000000 --- a/newlib/libc/machine/arm/sys/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -picolibc_headers(sys - fenv.h - ) diff --git a/newlib/libc/machine/arm/sys/meson.build b/newlib/libc/machine/arm/sys/meson.build deleted file mode 100644 index f6b87566bb..0000000000 --- a/newlib/libc/machine/arm/sys/meson.build +++ /dev/null @@ -1,53 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2020 Keith Packard, -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -inc_sys_headers_machine = [ - 'fenv.h' -] - -install_headers(inc_sys_headers_machine, - install_dir: include_dir / 'sys') - -if enable_cdefs_tests - ignore_headers = [] - foreach header : inc_sys_headers_machine - if not (header in ignore_headers) and not (header.startswith('_')) - test_name = 'check-cdef-sys-' + header - test(test_name, - validate_cdefs, - args: [meson.current_source_dir() / header] + cc.cmd_array() + c_args + inc_args, - suite: 'headers') - endif - endforeach -endif diff --git a/newlib/libc/machine/m68k/CMakeLists.txt b/newlib/libc/machine/m68k/CMakeLists.txt index 5abb7eb123..bab99e5d08 100644 --- a/newlib/libc/machine/m68k/CMakeLists.txt +++ b/newlib/libc/machine/m68k/CMakeLists.txt @@ -32,6 +32,8 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. +add_subdirectory(machine) + picolibc_sources_flags("-fno-builtin" memcpy.S memset.S @@ -39,6 +41,3 @@ picolibc_sources_flags("-fno-builtin" strcpy.c strlen.c ) - -add_subdirectory(sys) -add_subdirectory(machine) diff --git a/newlib/libc/machine/m68k/machine/CMakeLists.txt b/newlib/libc/machine/m68k/machine/CMakeLists.txt index 53f73951d5..0545f7f899 100644 --- a/newlib/libc/machine/m68k/machine/CMakeLists.txt +++ b/newlib/libc/machine/m68k/machine/CMakeLists.txt @@ -33,5 +33,6 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # picolibc_headers(machine + fenv.h fenv-fp.h ) diff --git a/newlib/libc/machine/m68k/sys/fenv.h b/newlib/libc/machine/m68k/machine/fenv.h similarity index 96% rename from newlib/libc/machine/m68k/sys/fenv.h rename to newlib/libc/machine/m68k/machine/fenv.h index aeb917e923..da22bfa90e 100644 --- a/newlib/libc/machine/m68k/sys/fenv.h +++ b/newlib/libc/machine/m68k/machine/fenv.h @@ -33,8 +33,8 @@ * OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _SYS_FENV_H_ -#define _SYS_FENV_H_ +#ifndef _MACHINE_FENV_H_ +#define _MACHINE_FENV_H_ #ifdef __cplusplus @@ -80,4 +80,4 @@ typedef int fexcept_t; } #endif -#endif /* _SYS_FENV_H_ */ +#endif /* _MACHINE_FENV_H_ */ diff --git a/newlib/libc/machine/m68k/machine/meson.build b/newlib/libc/machine/m68k/machine/meson.build index 57586087cb..40c2f257e7 100644 --- a/newlib/libc/machine/m68k/machine/meson.build +++ b/newlib/libc/machine/m68k/machine/meson.build @@ -33,6 +33,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # inc_sys_headers_machine = [ + 'fenv.h', 'fenv-fp.h' ] diff --git a/newlib/libc/machine/m68k/meson.build b/newlib/libc/machine/m68k/meson.build index 690d69793c..de05911ae4 100644 --- a/newlib/libc/machine/m68k/meson.build +++ b/newlib/libc/machine/m68k/meson.build @@ -40,7 +40,6 @@ srcs_machine = [ 'strlen.c', ] -subdir('sys') subdir('machine') foreach target : targets diff --git a/newlib/libc/machine/m68k/sys/CMakeLists.txt b/newlib/libc/machine/m68k/sys/CMakeLists.txt deleted file mode 100644 index babcc95ec6..0000000000 --- a/newlib/libc/machine/m68k/sys/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -picolibc_headers(sys - fenv.h - ) diff --git a/newlib/libc/machine/m68k/sys/meson.build b/newlib/libc/machine/m68k/sys/meson.build deleted file mode 100644 index f6b87566bb..0000000000 --- a/newlib/libc/machine/m68k/sys/meson.build +++ /dev/null @@ -1,53 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2020 Keith Packard, -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -inc_sys_headers_machine = [ - 'fenv.h' -] - -install_headers(inc_sys_headers_machine, - install_dir: include_dir / 'sys') - -if enable_cdefs_tests - ignore_headers = [] - foreach header : inc_sys_headers_machine - if not (header in ignore_headers) and not (header.startswith('_')) - test_name = 'check-cdef-sys-' + header - test(test_name, - validate_cdefs, - args: [meson.current_source_dir() / header] + cc.cmd_array() + c_args + inc_args, - suite: 'headers') - endif - endforeach -endif diff --git a/newlib/libc/machine/microblaze/CMakeLists.txt b/newlib/libc/machine/microblaze/CMakeLists.txt index c08d4d71aa..dba3e09787 100644 --- a/newlib/libc/machine/microblaze/CMakeLists.txt +++ b/newlib/libc/machine/microblaze/CMakeLists.txt @@ -34,9 +34,6 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # -add_subdirectory(sys) -add_subdirectory(machine) - picolibc_sources_flags("-fno-builtin" abort.c longjmp.S diff --git a/newlib/libc/machine/mips/CMakeLists.txt b/newlib/libc/machine/mips/CMakeLists.txt index 0a2cf60f14..eb7a784ad5 100644 --- a/newlib/libc/machine/mips/CMakeLists.txt +++ b/newlib/libc/machine/mips/CMakeLists.txt @@ -33,7 +33,6 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # -add_subdirectory(sys) add_subdirectory(machine) picolibc_sources_flags("-fno-builtin" diff --git a/newlib/libc/machine/mips/machine/CMakeLists.txt b/newlib/libc/machine/mips/machine/CMakeLists.txt index 08d9b4fe08..e019f1e9bd 100644 --- a/newlib/libc/machine/mips/machine/CMakeLists.txt +++ b/newlib/libc/machine/mips/machine/CMakeLists.txt @@ -34,6 +34,7 @@ # picolibc_headers(machine asm.h + fenv.h fenv-fp.h regdef.h ) diff --git a/newlib/libc/machine/mips/sys/fenv.h b/newlib/libc/machine/mips/machine/fenv.h similarity index 98% rename from newlib/libc/machine/mips/sys/fenv.h rename to newlib/libc/machine/mips/machine/fenv.h index f1017a726a..6b78a3b6f8 100644 --- a/newlib/libc/machine/mips/sys/fenv.h +++ b/newlib/libc/machine/mips/machine/fenv.h @@ -28,8 +28,8 @@ * $FreeBSD$ */ -#ifndef _SYS_FENV_H_ -#define _SYS_FENV_H_ +#ifndef _MACHINE_FENV_H_ +#define _MACHINE_FENV_H_ #if !defined(__mips_soft_float) && !defined(__mips_hard_float) diff --git a/newlib/libc/machine/mips/machine/meson.build b/newlib/libc/machine/mips/machine/meson.build index ffc66d63d8..0ac93640dd 100644 --- a/newlib/libc/machine/mips/machine/meson.build +++ b/newlib/libc/machine/mips/machine/meson.build @@ -34,6 +34,7 @@ # inc_machine_headers_machine = [ 'asm.h', + 'fenv.h', 'fenv-fp.h', 'regdef.h', ] diff --git a/newlib/libc/machine/mips/meson.build b/newlib/libc/machine/mips/meson.build index 966f05757a..e59b13d756 100644 --- a/newlib/libc/machine/mips/meson.build +++ b/newlib/libc/machine/mips/meson.build @@ -42,7 +42,6 @@ srcs_machine = [ 'strncpy.c', ] -subdir('sys') subdir('machine') src_machine = files(srcs_machine) diff --git a/newlib/libc/machine/mips/sys/CMakeLists.txt b/newlib/libc/machine/mips/sys/CMakeLists.txt deleted file mode 100644 index babcc95ec6..0000000000 --- a/newlib/libc/machine/mips/sys/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -picolibc_headers(sys - fenv.h - ) diff --git a/newlib/libc/machine/mips/sys/meson.build b/newlib/libc/machine/mips/sys/meson.build deleted file mode 100644 index 4e431da6c0..0000000000 --- a/newlib/libc/machine/mips/sys/meson.build +++ /dev/null @@ -1,53 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard, -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -inc_sys_headers_machine = [ - 'fenv.h' -] - -install_headers(inc_sys_headers_machine, - install_dir: include_dir / 'sys') - -if enable_cdefs_tests - ignore_headers = [] - foreach header : inc_sys_headers_machine - if not (header in ignore_headers) and not (header.startswith('_')) - test_name = 'check-cdef-sys-' + header - test(test_name, - validate_cdefs, - args: [meson.current_source_dir() / header] + cc.cmd_array() + c_args + inc_args, - suite: 'headers') - endif - endforeach -endif diff --git a/newlib/libc/machine/powerpc/CMakeLists.txt b/newlib/libc/machine/powerpc/CMakeLists.txt index 59442e2c6c..1309606ea9 100644 --- a/newlib/libc/machine/powerpc/CMakeLists.txt +++ b/newlib/libc/machine/powerpc/CMakeLists.txt @@ -33,7 +33,6 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # -add_subdirectory(sys) add_subdirectory(machine) picolibc_sources_flags("-fno-builtin" diff --git a/newlib/libc/machine/powerpc/machine/CMakeLists.txt b/newlib/libc/machine/powerpc/machine/CMakeLists.txt index 53f73951d5..0545f7f899 100644 --- a/newlib/libc/machine/powerpc/machine/CMakeLists.txt +++ b/newlib/libc/machine/powerpc/machine/CMakeLists.txt @@ -33,5 +33,6 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # picolibc_headers(machine + fenv.h fenv-fp.h ) diff --git a/newlib/libc/machine/powerpc/sys/fenv.h b/newlib/libc/machine/powerpc/machine/fenv.h similarity index 98% rename from newlib/libc/machine/powerpc/sys/fenv.h rename to newlib/libc/machine/powerpc/machine/fenv.h index 8523b89f7f..ad4db9a1c3 100644 --- a/newlib/libc/machine/powerpc/sys/fenv.h +++ b/newlib/libc/machine/powerpc/machine/fenv.h @@ -28,8 +28,8 @@ * $FreeBSD$ */ -#ifndef _SYS_FENV_H_ -#define _SYS_FENV_H_ +#ifndef _MACHINE_FENV_H_ +#define _MACHINE_FENV_H_ #ifdef __cplusplus @@ -129,4 +129,4 @@ union __fpscr { } #endif -#endif /* !_SYS_FENV_H_ */ +#endif /* !_MACHINE_FENV_H_ */ diff --git a/newlib/libc/machine/powerpc/machine/meson.build b/newlib/libc/machine/powerpc/machine/meson.build index d92e0b6892..1decdb8d04 100644 --- a/newlib/libc/machine/powerpc/machine/meson.build +++ b/newlib/libc/machine/powerpc/machine/meson.build @@ -33,6 +33,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # inc_machine_headers_machine = [ + 'fenv.h', 'fenv-fp.h', ] diff --git a/newlib/libc/machine/powerpc/meson.build b/newlib/libc/machine/powerpc/meson.build index ef68f6db4b..67d1e54571 100644 --- a/newlib/libc/machine/powerpc/meson.build +++ b/newlib/libc/machine/powerpc/meson.build @@ -57,7 +57,6 @@ srcs_machine = [ # 'vfscanf.c', ] -subdir('sys') subdir('machine') src_machine = files(srcs_machine) diff --git a/newlib/libc/machine/powerpc/sys/CMakeLists.txt b/newlib/libc/machine/powerpc/sys/CMakeLists.txt deleted file mode 100644 index babcc95ec6..0000000000 --- a/newlib/libc/machine/powerpc/sys/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -picolibc_headers(sys - fenv.h - ) diff --git a/newlib/libc/machine/powerpc/sys/meson.build b/newlib/libc/machine/powerpc/sys/meson.build deleted file mode 100644 index 4e431da6c0..0000000000 --- a/newlib/libc/machine/powerpc/sys/meson.build +++ /dev/null @@ -1,53 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard, -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -inc_sys_headers_machine = [ - 'fenv.h' -] - -install_headers(inc_sys_headers_machine, - install_dir: include_dir / 'sys') - -if enable_cdefs_tests - ignore_headers = [] - foreach header : inc_sys_headers_machine - if not (header in ignore_headers) and not (header.startswith('_')) - test_name = 'check-cdef-sys-' + header - test(test_name, - validate_cdefs, - args: [meson.current_source_dir() / header] + cc.cmd_array() + c_args + inc_args, - suite: 'headers') - endif - endforeach -endif diff --git a/newlib/libc/machine/riscv/CMakeLists.txt b/newlib/libc/machine/riscv/CMakeLists.txt index 6bc378b2b3..9e49753247 100644 --- a/newlib/libc/machine/riscv/CMakeLists.txt +++ b/newlib/libc/machine/riscv/CMakeLists.txt @@ -32,6 +32,9 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. # + +add_subdirectory(machine) + picolibc_sources_flags("-fno-builtin" ieeefp.c memcpy-asm.S @@ -44,6 +47,3 @@ picolibc_sources_flags("-fno-builtin" strcpy.c strlen.c ) - -add_subdirectory(sys) -add_subdirectory(machine) diff --git a/newlib/libc/machine/riscv/sys/asm.h b/newlib/libc/machine/riscv/asm.h similarity index 100% rename from newlib/libc/machine/riscv/sys/asm.h rename to newlib/libc/machine/riscv/asm.h diff --git a/newlib/libc/machine/riscv/sys/string.h b/newlib/libc/machine/riscv/local.h similarity index 93% rename from newlib/libc/machine/riscv/sys/string.h rename to newlib/libc/machine/riscv/local.h index beebe31f72..26ec6fe8ff 100644 --- a/newlib/libc/machine/riscv/sys/string.h +++ b/newlib/libc/machine/riscv/local.h @@ -9,9 +9,6 @@ http://www.opensource.org/licenses. */ -#ifndef _SYS_STRING_H -#define _SYS_STRING_H - static __inline unsigned long __libc_detect_null(unsigned long w) { unsigned long mask = 0x7f7f7f7f; @@ -19,5 +16,3 @@ static __inline unsigned long __libc_detect_null(unsigned long w) mask = ((mask << 16) << 16) | mask; return ~(((w & mask) + mask) | w | mask); } - -#endif diff --git a/newlib/libc/machine/riscv/machine/CMakeLists.txt b/newlib/libc/machine/riscv/machine/CMakeLists.txt index e5b30ac489..ee63d5d32e 100644 --- a/newlib/libc/machine/riscv/machine/CMakeLists.txt +++ b/newlib/libc/machine/riscv/machine/CMakeLists.txt @@ -33,6 +33,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # picolibc_headers(machine + fenv.h fenv-fp.h math.h ) diff --git a/newlib/libc/machine/riscv/sys/fenv.h b/newlib/libc/machine/riscv/machine/fenv.h similarity index 97% rename from newlib/libc/machine/riscv/sys/fenv.h rename to newlib/libc/machine/riscv/machine/fenv.h index 48bd0420a3..5429064efa 100644 --- a/newlib/libc/machine/riscv/sys/fenv.h +++ b/newlib/libc/machine/riscv/machine/fenv.h @@ -9,8 +9,8 @@ http://www.opensource.org/licenses. */ -#ifndef _SYS_FENV_H -#define _SYS_FENV_H +#ifndef _MACHINE_FENV_H +#define _MACHINE_FENV_H #include @@ -89,4 +89,4 @@ typedef size_t fexcept_t; #endif #endif -#endif /* _SYS_FENV_H */ +#endif /* _MACHINE_FENV_H */ diff --git a/newlib/libc/machine/riscv/machine/meson.build b/newlib/libc/machine/riscv/machine/meson.build index a4c00e4663..d6648419fb 100644 --- a/newlib/libc/machine/riscv/machine/meson.build +++ b/newlib/libc/machine/riscv/machine/meson.build @@ -33,6 +33,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # inc_machine_headers_machine = [ + 'fenv.h', 'fenv-fp.h', 'math.h' ] diff --git a/newlib/libc/machine/riscv/meson.build b/newlib/libc/machine/riscv/meson.build index ffe2023775..f7edf8ef54 100644 --- a/newlib/libc/machine/riscv/meson.build +++ b/newlib/libc/machine/riscv/meson.build @@ -47,7 +47,6 @@ srcs_machine = [ has_ieeefp_funcs = true -subdir('sys') subdir('machine') foreach target : targets diff --git a/newlib/libc/machine/riscv/setjmp.S b/newlib/libc/machine/riscv/setjmp.S index 4bc5b970da..2185038fbc 100644 --- a/newlib/libc/machine/riscv/setjmp.S +++ b/newlib/libc/machine/riscv/setjmp.S @@ -11,7 +11,7 @@ #include -#include +#include "asm.h" /* int setjmp (jmp_buf); */ .section .text.setjmp diff --git a/newlib/libc/machine/riscv/strcmp.S b/newlib/libc/machine/riscv/strcmp.S index 1a62951bd0..e75dfbe3a2 100644 --- a/newlib/libc/machine/riscv/strcmp.S +++ b/newlib/libc/machine/riscv/strcmp.S @@ -11,7 +11,7 @@ #include -#include +#include "asm.h" .section .text.strcmp .globl strcmp diff --git a/newlib/libc/machine/riscv/strcpy.c b/newlib/libc/machine/riscv/strcpy.c index 1af1a1c89c..a8cce1858a 100644 --- a/newlib/libc/machine/riscv/strcpy.c +++ b/newlib/libc/machine/riscv/strcpy.c @@ -13,6 +13,7 @@ #include #include +#include "local.h" #undef strcpy diff --git a/newlib/libc/machine/riscv/strlen.c b/newlib/libc/machine/riscv/strlen.c index dac91db92f..29bbc26c0e 100644 --- a/newlib/libc/machine/riscv/strlen.c +++ b/newlib/libc/machine/riscv/strlen.c @@ -13,6 +13,7 @@ #include #include +#include "local.h" size_t strlen(const char *str) { diff --git a/newlib/libc/machine/riscv/sys/CMakeLists.txt b/newlib/libc/machine/riscv/sys/CMakeLists.txt deleted file mode 100644 index a958921d97..0000000000 --- a/newlib/libc/machine/riscv/sys/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -picolibc_headers(sys - fenv.h - asm.h - string.h - ) diff --git a/newlib/libc/machine/riscv/sys/meson.build b/newlib/libc/machine/riscv/sys/meson.build deleted file mode 100644 index 2ffc055639..0000000000 --- a/newlib/libc/machine/riscv/sys/meson.build +++ /dev/null @@ -1,53 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2019 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -inc_sys_headers_machine = [ - 'fenv.h' -] - -install_headers(inc_sys_headers_machine, - install_dir: include_dir / 'sys') - -if enable_cdefs_tests - ignore_headers = [] - foreach header : inc_sys_headers_machine - if not (header in ignore_headers) and not (header.startswith('_')) - test_name = 'check-cdef-sys-' + header - test(test_name, - validate_cdefs, - args: [meson.current_source_dir() / header] + cc.cmd_array() + c_args + inc_args, - suite: 'headers') - endif - endforeach -endif diff --git a/newlib/libc/machine/sh/CMakeLists.txt b/newlib/libc/machine/sh/CMakeLists.txt index 8e3a9ba8cc..71a4268332 100644 --- a/newlib/libc/machine/sh/CMakeLists.txt +++ b/newlib/libc/machine/sh/CMakeLists.txt @@ -33,6 +33,8 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # +add_subdirectory(machine) + picolibc_sources_flags("-fno-builtin" memcpy.S memset.S @@ -43,6 +45,3 @@ picolibc_sources_flags("-fno-builtin" strncpy.S strncpy.c ) - -add_subdirectory(sys) -add_subdirectory(machine) diff --git a/newlib/libc/machine/sh/machine/CMakeLists.txt b/newlib/libc/machine/sh/machine/CMakeLists.txt index f82ff5e94e..f1529b1f46 100644 --- a/newlib/libc/machine/sh/machine/CMakeLists.txt +++ b/newlib/libc/machine/sh/machine/CMakeLists.txt @@ -33,5 +33,6 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # picolibc_headers(machine + fenv.h fenv-fp.h ) diff --git a/newlib/libc/machine/sh/sys/fenv.h b/newlib/libc/machine/sh/machine/fenv.h similarity index 96% rename from newlib/libc/machine/sh/sys/fenv.h rename to newlib/libc/machine/sh/machine/fenv.h index ae95eda7e9..fd75796791 100644 --- a/newlib/libc/machine/sh/sys/fenv.h +++ b/newlib/libc/machine/sh/machine/fenv.h @@ -28,8 +28,8 @@ * $FreeBSD$ */ -#ifndef _SYS_FENV_H_ -#define _SYS_FENV_H_ 1 +#ifndef _MACHINE_FENV_H_ +#define _MACHINE_FENV_H_ 1 #include @@ -89,4 +89,4 @@ typedef int fexcept_t; _END_STD_C -#endif /* _SYS_FENV_H_ */ +#endif /* _MACHINE_FENV_H_ */ diff --git a/newlib/libc/machine/sh/machine/meson.build b/newlib/libc/machine/sh/machine/meson.build index 9fe3ff6c4c..e97e5ba218 100644 --- a/newlib/libc/machine/sh/machine/meson.build +++ b/newlib/libc/machine/sh/machine/meson.build @@ -33,6 +33,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # inc_machine_headers_machine = [ + 'fenv.h', 'fenv-fp.h', ] diff --git a/newlib/libc/machine/sh/meson.build b/newlib/libc/machine/sh/meson.build index 7b88109c13..b210df2b95 100644 --- a/newlib/libc/machine/sh/meson.build +++ b/newlib/libc/machine/sh/meson.build @@ -44,7 +44,6 @@ srcs_machine = [ 'strncpy.c', ] -subdir('sys') subdir('machine') src_machine = files(srcs_machine) diff --git a/newlib/libc/machine/sh/sys/CMakeLists.txt b/newlib/libc/machine/sh/sys/CMakeLists.txt deleted file mode 100644 index 34cff44429..0000000000 --- a/newlib/libc/machine/sh/sys/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2024 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -picolibc_headers(sys - fenv.h - ) diff --git a/newlib/libc/machine/sh/sys/meson.build b/newlib/libc/machine/sh/sys/meson.build deleted file mode 100644 index f6b87566bb..0000000000 --- a/newlib/libc/machine/sh/sys/meson.build +++ /dev/null @@ -1,53 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2020 Keith Packard, -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -inc_sys_headers_machine = [ - 'fenv.h' -] - -install_headers(inc_sys_headers_machine, - install_dir: include_dir / 'sys') - -if enable_cdefs_tests - ignore_headers = [] - foreach header : inc_sys_headers_machine - if not (header in ignore_headers) and not (header.startswith('_')) - test_name = 'check-cdef-sys-' + header - test(test_name, - validate_cdefs, - args: [meson.current_source_dir() / header] + cc.cmd_array() + c_args + inc_args, - suite: 'headers') - endif - endforeach -endif diff --git a/newlib/libc/machine/sparc/CMakeLists.txt b/newlib/libc/machine/sparc/CMakeLists.txt index 827ae075ac..7cf2b4cbb4 100644 --- a/newlib/libc/machine/sparc/CMakeLists.txt +++ b/newlib/libc/machine/sparc/CMakeLists.txt @@ -33,11 +33,11 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # +add_subdirectory(machine) + picolibc_sources_flags("-fno-builtin" setjmp.S scan.c shuffle.c ) -add_subdirectory(sys) -add_subdirectory(machine) diff --git a/newlib/libc/machine/sparc/machine/CMakeLists.txt b/newlib/libc/machine/sparc/machine/CMakeLists.txt index 15307d882d..c4e919c444 100644 --- a/newlib/libc/machine/sparc/machine/CMakeLists.txt +++ b/newlib/libc/machine/sparc/machine/CMakeLists.txt @@ -33,6 +33,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # picolibc_headers(machine + fenv.h fenv-fp.h sparclet.h ) diff --git a/newlib/libc/machine/sparc/sys/fenv.h b/newlib/libc/machine/sparc/machine/fenv.h similarity index 97% rename from newlib/libc/machine/sparc/sys/fenv.h rename to newlib/libc/machine/sparc/machine/fenv.h index 7d17b7205a..bf728a8f59 100644 --- a/newlib/libc/machine/sparc/sys/fenv.h +++ b/newlib/libc/machine/sparc/machine/fenv.h @@ -28,8 +28,8 @@ * $FreeBSD$ */ -#ifndef _SYS_FENV_H_ -#define _SYS_FENV_H_ +#ifndef _MACHINE_FENV_H_ +#define _MACHINE_FENV_H_ _BEGIN_STD_C @@ -97,4 +97,4 @@ typedef __UINT32_TYPE__ fexcept_t; _END_STD_C -#endif /* !_SYS_FENV_H_ */ +#endif /* !_MACHINE_FENV_H_ */ diff --git a/newlib/libc/machine/sparc/machine/meson.build b/newlib/libc/machine/sparc/machine/meson.build index 4cb3078663..acfc8203ec 100644 --- a/newlib/libc/machine/sparc/machine/meson.build +++ b/newlib/libc/machine/sparc/machine/meson.build @@ -33,6 +33,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # inc_machine_headers_machine = [ + 'fenv.h', 'fenv-fp.h', 'sparclet.h', ] diff --git a/newlib/libc/machine/sparc/meson.build b/newlib/libc/machine/sparc/meson.build index 1693bfbbce..b98d2de91e 100644 --- a/newlib/libc/machine/sparc/meson.build +++ b/newlib/libc/machine/sparc/meson.build @@ -41,5 +41,4 @@ srcs_machine = [ src_machine = files(srcs_machine) -subdir('sys') subdir('machine') diff --git a/newlib/libc/machine/sparc/sys/CMakeLists.txt b/newlib/libc/machine/sparc/sys/CMakeLists.txt deleted file mode 100644 index babcc95ec6..0000000000 --- a/newlib/libc/machine/sparc/sys/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -picolibc_headers(sys - fenv.h - ) diff --git a/newlib/libc/machine/sparc/sys/meson.build b/newlib/libc/machine/sparc/sys/meson.build deleted file mode 100644 index 4e431da6c0..0000000000 --- a/newlib/libc/machine/sparc/sys/meson.build +++ /dev/null @@ -1,53 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard, -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -inc_sys_headers_machine = [ - 'fenv.h' -] - -install_headers(inc_sys_headers_machine, - install_dir: include_dir / 'sys') - -if enable_cdefs_tests - ignore_headers = [] - foreach header : inc_sys_headers_machine - if not (header in ignore_headers) and not (header.startswith('_')) - test_name = 'check-cdef-sys-' + header - test(test_name, - validate_cdefs, - args: [meson.current_source_dir() / header] + cc.cmd_array() + c_args + inc_args, - suite: 'headers') - endif - endforeach -endif diff --git a/newlib/libc/machine/spu/sys/fenv.h b/newlib/libc/machine/spu/machine/fenv.h similarity index 99% rename from newlib/libc/machine/spu/sys/fenv.h rename to newlib/libc/machine/spu/machine/fenv.h index 974222850f..170af3d333 100644 --- a/newlib/libc/machine/spu/sys/fenv.h +++ b/newlib/libc/machine/spu/machine/fenv.h @@ -30,8 +30,8 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _SYS_FENV_H -#define _SYS_FENV_H +#ifndef _MACHINE_FENV_H +#define _MACHINE_FENV_H /* * The exception macros are such that the functions to pack/unpack them diff --git a/newlib/libc/machine/x86/CMakeLists.txt b/newlib/libc/machine/x86/CMakeLists.txt index 5998bc06dd..915c90ba0f 100644 --- a/newlib/libc/machine/x86/CMakeLists.txt +++ b/newlib/libc/machine/x86/CMakeLists.txt @@ -48,5 +48,4 @@ if(${CMAKE_SYSTEM_SUB_PROCESSOR} STREQUAL "i686") ) endif() -add_subdirectory(sys) add_subdirectory(machine) diff --git a/newlib/libc/machine/x86/machine/CMakeLists.txt b/newlib/libc/machine/x86/machine/CMakeLists.txt index c882a1024c..261c301642 100644 --- a/newlib/libc/machine/x86/machine/CMakeLists.txt +++ b/newlib/libc/machine/x86/machine/CMakeLists.txt @@ -33,5 +33,6 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # picolibc_headers(machine + fenv.h fastmath.h ) diff --git a/newlib/libc/machine/x86/sys/fenv.h b/newlib/libc/machine/x86/machine/fenv.h similarity index 99% rename from newlib/libc/machine/x86/sys/fenv.h rename to newlib/libc/machine/x86/machine/fenv.h index 3df0e302c1..caa54e18e3 100644 --- a/newlib/libc/machine/x86/sys/fenv.h +++ b/newlib/libc/machine/x86/machine/fenv.h @@ -26,8 +26,8 @@ * SUCH DAMAGE. */ -#ifndef _SYS_FENV_H -#define _SYS_FENV_H 1 +#ifndef _MACHINE_FENV_H +#define _MACHINE_FENV_H 1 #ifdef __cplusplus diff --git a/newlib/libc/machine/x86/machine/meson.build b/newlib/libc/machine/x86/machine/meson.build index 395bf604a2..bbb32566aa 100644 --- a/newlib/libc/machine/x86/machine/meson.build +++ b/newlib/libc/machine/x86/machine/meson.build @@ -33,6 +33,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # inc_machine_headers_machine = [ + 'fenv.h', 'fastmath.h' ] diff --git a/newlib/libc/machine/x86/meson.build b/newlib/libc/machine/x86/meson.build index 167516efe9..bd1bfa4fca 100644 --- a/newlib/libc/machine/x86/meson.build +++ b/newlib/libc/machine/x86/meson.build @@ -57,7 +57,6 @@ srcs_machine_32 = [ srcs_machine = srcs_machine_common + srcs_machine_64 -subdir('sys') subdir('machine') x86_64_code = '''#ifndef __x86_64 diff --git a/newlib/libc/machine/x86/sys/CMakeLists.txt b/newlib/libc/machine/x86/sys/CMakeLists.txt deleted file mode 100644 index babcc95ec6..0000000000 --- a/newlib/libc/machine/x86/sys/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -picolibc_headers(sys - fenv.h - ) diff --git a/newlib/libc/machine/x86/sys/meson.build b/newlib/libc/machine/x86/sys/meson.build deleted file mode 100644 index a77c0ddb42..0000000000 --- a/newlib/libc/machine/x86/sys/meson.build +++ /dev/null @@ -1,53 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2021 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -inc_sys_headers_machine = [ - 'fenv.h' -] - -install_headers(inc_sys_headers_machine, - install_dir: include_dir / 'sys') - -if enable_cdefs_tests - ignore_headers = [] - foreach header : inc_sys_headers_machine - if not (header in ignore_headers) and not (header.startswith('_')) - test_name = 'check-cdef-sys-' + header - test(test_name, - validate_cdefs, - args: [meson.current_source_dir() / header] + cc.cmd_array() + c_args + inc_args, - suite: 'headers') - endif - endforeach -endif diff --git a/newlib/libc/machine/xtensa/CMakeLists.txt b/newlib/libc/machine/xtensa/CMakeLists.txt index 3ae102686b..1de0724907 100644 --- a/newlib/libc/machine/xtensa/CMakeLists.txt +++ b/newlib/libc/machine/xtensa/CMakeLists.txt @@ -33,6 +33,8 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # +add_subdirectory(machine) + picolibc_sources_flags("-fno-builtin" memcpy.S memset.S @@ -43,5 +45,3 @@ picolibc_sources_flags("-fno-builtin" strncpy.S ) -add_subdirectory(sys) -add_subdirectory(machine) diff --git a/newlib/libc/machine/xtensa/machine/CMakeLists.txt b/newlib/libc/machine/xtensa/machine/CMakeLists.txt index 484df28156..e6587016a6 100644 --- a/newlib/libc/machine/xtensa/machine/CMakeLists.txt +++ b/newlib/libc/machine/xtensa/machine/CMakeLists.txt @@ -34,5 +34,6 @@ # picolibc_headers(machine core-isa.h + fenv.h fenv-fp.h ) diff --git a/newlib/libc/machine/xtensa/sys/fenv.h b/newlib/libc/machine/xtensa/machine/fenv.h similarity index 98% rename from newlib/libc/machine/xtensa/sys/fenv.h rename to newlib/libc/machine/xtensa/machine/fenv.h index f634543016..7ba60a078a 100644 --- a/newlib/libc/machine/xtensa/sys/fenv.h +++ b/newlib/libc/machine/xtensa/machine/fenv.h @@ -26,8 +26,8 @@ OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _SYS_FENV_H -#define _SYS_FENV_H +#ifndef _MACHINE_FENV_H +#define _MACHINE_FENV_H #ifdef __cplusplus diff --git a/newlib/libc/machine/xtensa/machine/meson.build b/newlib/libc/machine/xtensa/machine/meson.build index 7988d30404..c17c78bf4c 100644 --- a/newlib/libc/machine/xtensa/machine/meson.build +++ b/newlib/libc/machine/xtensa/machine/meson.build @@ -34,6 +34,7 @@ # inc_machine_headers_machine = [ 'core-isa.h', + 'fenv.h', 'fenv-fp.h' ] diff --git a/newlib/libc/machine/xtensa/meson.build b/newlib/libc/machine/xtensa/meson.build index b92ccce470..bacd75aae3 100644 --- a/newlib/libc/machine/xtensa/meson.build +++ b/newlib/libc/machine/xtensa/meson.build @@ -47,7 +47,6 @@ conf_data.set('_XTENSA_HAVE_CONFIG_CORE_ISA_H', cc.check_header('xtensa/config/core-isa.h'), description: 'Xtensa toolchain includes core-isa.h') -subdir('sys') subdir('machine') src_machine = files(srcs_machine) diff --git a/newlib/libc/machine/xtensa/sys/CMakeLists.txt b/newlib/libc/machine/xtensa/sys/CMakeLists.txt deleted file mode 100644 index babcc95ec6..0000000000 --- a/newlib/libc/machine/xtensa/sys/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2022 Keith Packard -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -picolibc_headers(sys - fenv.h - ) diff --git a/newlib/libc/machine/xtensa/sys/meson.build b/newlib/libc/machine/xtensa/sys/meson.build deleted file mode 100644 index f6b87566bb..0000000000 --- a/newlib/libc/machine/xtensa/sys/meson.build +++ /dev/null @@ -1,53 +0,0 @@ -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright © 2020 Keith Packard, -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following -# disclaimer in the documentation and/or other materials provided -# with the distribution. -# -# 3. Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -# OF THE POSSIBILITY OF SUCH DAMAGE. -# -inc_sys_headers_machine = [ - 'fenv.h' -] - -install_headers(inc_sys_headers_machine, - install_dir: include_dir / 'sys') - -if enable_cdefs_tests - ignore_headers = [] - foreach header : inc_sys_headers_machine - if not (header in ignore_headers) and not (header.startswith('_')) - test_name = 'check-cdef-sys-' + header - test(test_name, - validate_cdefs, - args: [meson.current_source_dir() / header] + cc.cmd_array() + c_args + inc_args, - suite: 'headers') - endif - endforeach -endif From e2d144aae19f814e8580410bea7e6bc334a7c4aa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 7 Aug 2024 16:01:27 -0700 Subject: [PATCH 39/42] sys/time.h: remove time_t declaration This is declared in sys/_timespec.h already, no need to duplicate it here. Signed-off-by: Keith Packard --- newlib/libc/include/sys/time.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/newlib/libc/include/sys/time.h b/newlib/libc/include/sys/time.h index 1dfbb0bffa..75f21dc860 100644 --- a/newlib/libc/include/sys/time.h +++ b/newlib/libc/include/sys/time.h @@ -47,11 +47,6 @@ _BEGIN_STD_C -#ifndef _TIME_T_DECLARED -typedef __time_t time_t; -#define _TIME_T_DECLARED -#endif - #ifndef _SUSECONDS_T_DECLARED typedef __suseconds_t suseconds_t; #define _SUSECONDS_T_DECLARED From 5a04e1cc3378edf5db1410c31dd98534a1382754 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 7 Aug 2024 16:01:57 -0700 Subject: [PATCH 40/42] include/math.h: Define FP_FMA* These are required by C. Signed-off-by: Keith Packard --- newlib/libc/include/math.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h index 33a6a38444..c04dad6ede 100644 --- a/newlib/libc/include/math.h +++ b/newlib/libc/include/math.h @@ -221,6 +221,18 @@ extern int isnan (double); # define FP_ILOGBNAN __INT_MAX__ #endif +#if !defined(FP_FAST_FMA) && (_HAVE_FAST_FMA || defined(__FP_FAST_FMA)) +#define FP_FAST_FMA +#endif + +#if !defined(FP_FAST_FMAF) && (_HAVE_FAST_FMAF || defined(__FP_FAST_FMAF)) +#define FP_FAST_FMAF +#endif + +#if !defined(FP_FAST_FMAL) && (_HAVE_FAST_FMAL || defined(__FP_FAST_FMAL)) +#define FP_FAST_FMAL +#endif + #ifndef MATH_ERRNO # define MATH_ERRNO 1 #endif From 29f1da4633c0d8d54be8408f81cba8c8ba92c0f7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 8 Aug 2024 11:21:53 -0700 Subject: [PATCH 41/42] regex: Use RE_DUP_MAX instead of _POSIX2_RE_DUP_MAX _POSIX2_RE_DUP_MAX is the minimum acceptable value for any POSIX system while RE_DUP_MAX is the value supported by the library. Signed-off-by: Keith Packard --- newlib/libc/posix/utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/newlib/libc/posix/utils.h b/newlib/libc/posix/utils.h index e534246cd1..3be2491f0f 100644 --- a/newlib/libc/posix/utils.h +++ b/newlib/libc/posix/utils.h @@ -34,10 +34,10 @@ * $FreeBSD: src/lib/libc/regex/utils.h,v 1.2 2002/03/22 23:41:56 obrien Exp $ */ -#include /* for _POSIX2_RE_DUP_MAX */ +#include /* for RE_DUP_MAX */ /* utility definitions */ -#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */ +#define DUPMAX RE_DUP_MAX /* xxx is this right? */ #define REGEX_INFINITY (DUPMAX + 1) #define NC (CHAR_MAX - CHAR_MIN + 1) typedef unsigned char uch; From 1e23bb13059049bd0ef0970cb4f16dc7ec70b76d Mon Sep 17 00:00:00 2001 From: Mostafa Salman Date: Sun, 4 Aug 2024 11:07:38 +0300 Subject: [PATCH 42/42] Add Support for Annex K functions according to C11 Adding an implementation of the bounds-checking C functions (as specified in Annex K of the C11 standard) to the PicoLibc. These functions lower the risk of introducing security vulnerabilities such as buffer overflows and format string vulnerabilities into your code by providing clear and easy-to-use interfaces. For each C function a secure alternate function ending in a "_s" postfix is provided (e.g., strcpy_s). Use of these functions is recommended by security experts and secure coding standards. also, Implemented unit tests for the Annex-K functions to ensure their corrctness. Covered various scenarios including normal operation, boundary conditions, and error handling. Signed-off-by: Mostafa Salman --- newlib/libc/include/errno.h | 9 + newlib/libc/include/stdint.h | 10 +- newlib/libc/include/stdlib.h | 21 +++ newlib/libc/include/string.h | 25 +++ newlib/libc/include/sys/_types.h | 11 ++ newlib/libc/include/time.h | 14 ++ newlib/libc/include/wchar.h | 14 ++ newlib/libc/stdio/stdio.h | 14 ++ newlib/libc/stdlib/CMakeLists.txt | 1 + newlib/libc/stdlib/local_s.h | 52 ++++++ newlib/libc/stdlib/meson.build | 1 + newlib/libc/stdlib/set_constraint_handler_s.c | 61 ++++++ newlib/libc/string/CMakeLists.txt | 10 + newlib/libc/string/memcpy_s.c | 94 ++++++++++ newlib/libc/string/memmove_s.c | 86 +++++++++ newlib/libc/string/memset_s.c | 79 ++++++++ newlib/libc/string/meson.build | 11 ++ newlib/libc/string/strcat_s.c | 142 ++++++++++++++ newlib/libc/string/strcpy_s.c | 125 +++++++++++++ newlib/libc/string/strerror.c | 1 + newlib/libc/string/strerror_s.c | 85 +++++++++ newlib/libc/string/strerrorlen_s.c | 43 +++++ newlib/libc/string/string_private.h | 44 +++++ newlib/libc/string/strncat_s.c | 169 +++++++++++++++++ newlib/libc/string/strncpy_s.c | 147 +++++++++++++++ newlib/libc/string/strnlen_s.c | 60 ++++++ newlib/libc/tinystdio/CMakeLists.txt | 1 + newlib/libc/tinystdio/meson.build | 1 + newlib/libc/tinystdio/sprintf_s.c | 147 +++++++++++++++ newlib/libc/tinystdio/stdio.h | 17 ++ test/CMakeLists.txt | 11 ++ test/meson.build | 65 +++++++ test/test-memcpy_s.c | 151 +++++++++++++++ test/test-memmove_s.c | 150 +++++++++++++++ test/test-memset_s.c | 142 ++++++++++++++ test/test-sprintf_s.c | 152 +++++++++++++++ test/test-strcat_s.c | 161 ++++++++++++++++ test/test-strcpy_s.c | 155 ++++++++++++++++ test/test-strerror_s.c | 146 +++++++++++++++ test/test-strerrorlen_s.c | 125 +++++++++++++ test/test-strncat_s.c | 174 ++++++++++++++++++ test/test-strncpy_s.c | 154 ++++++++++++++++ test/test-strnlen_s.c | 150 +++++++++++++++ 43 files changed, 3230 insertions(+), 1 deletion(-) create mode 100644 newlib/libc/stdlib/local_s.h create mode 100644 newlib/libc/stdlib/set_constraint_handler_s.c create mode 100644 newlib/libc/string/memcpy_s.c create mode 100644 newlib/libc/string/memmove_s.c create mode 100644 newlib/libc/string/memset_s.c create mode 100644 newlib/libc/string/strcat_s.c create mode 100644 newlib/libc/string/strcpy_s.c create mode 100644 newlib/libc/string/strerror_s.c create mode 100644 newlib/libc/string/strerrorlen_s.c create mode 100644 newlib/libc/string/string_private.h create mode 100644 newlib/libc/string/strncat_s.c create mode 100644 newlib/libc/string/strncpy_s.c create mode 100644 newlib/libc/string/strnlen_s.c create mode 100644 newlib/libc/tinystdio/sprintf_s.c create mode 100644 test/test-memcpy_s.c create mode 100644 test/test-memmove_s.c create mode 100644 test/test-memset_s.c create mode 100644 test/test-sprintf_s.c create mode 100644 test/test-strcat_s.c create mode 100644 test/test-strcpy_s.c create mode 100644 test/test-strerror_s.c create mode 100644 test/test-strerrorlen_s.c create mode 100644 test/test-strncat_s.c create mode 100644 test/test-strncpy_s.c create mode 100644 test/test-strnlen_s.c diff --git a/newlib/libc/include/errno.h b/newlib/libc/include/errno.h index cf73f0460c..41ba3a1449 100644 --- a/newlib/libc/include/errno.h +++ b/newlib/libc/include/errno.h @@ -36,6 +36,15 @@ SUCH DAMAGE. #include +#if __STDC_WANT_LIB_EXT1__ == 1 +#include + +#ifndef _ERRNO_T_DEFINED +typedef __errno_t errno_t; +#define _ERRNO_T_DEFINED +#endif +#endif + #include #endif /* !__ERRNO_H__ */ diff --git a/newlib/libc/include/stdint.h b/newlib/libc/include/stdint.h index d7e9bf3666..efb57a9ced 100644 --- a/newlib/libc/include/stdint.h +++ b/newlib/libc/include/stdint.h @@ -457,6 +457,14 @@ typedef __uint_least64_t uint_least64_t; #endif #endif -_END_STD_C +#if __STDC_WANT_LIB_EXT1__ == 1 + // could be defined by the user +#ifndef RSIZE_MAX +#define RSIZE_MAX SIZE_MAX +#endif +#endif + + _END_STD_C #endif /* _STDINT_H */ + diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h index 7468be3a93..1cc9d728cc 100644 --- a/newlib/libc/include/stdlib.h +++ b/newlib/libc/include/stdlib.h @@ -408,6 +408,27 @@ char *__ldtoa (long double, int, int, int *, int *, char **); void __eprintf (const char *, const char *, unsigned int, const char *); #endif +#if __STDC_WANT_LIB_EXT1__ == 1 +#include + +#ifndef _ERRNO_T_DEFINED +typedef __errno_t errno_t; +#define _ERRNO_T_DEFINED +#endif + +#ifndef _RSIZE_T_DEFINED +typedef __rsize_t rsize_t; +#define _RSIZE_T_DEFINED +#endif + +typedef void (*constraint_handler_t)(const char *restrict msg, + void *restrict ptr, __errno_t error); + +constraint_handler_t set_constraint_handler_s(constraint_handler_t handler); +void abort_handler_s(const char *restrict msg, void *restrict ptr, + __errno_t error); +#endif + _END_STD_C #if __SSP_FORTIFY_LEVEL > 0 diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h index 77b61ccd2c..c76609dc79 100644 --- a/newlib/libc/include/string.h +++ b/newlib/libc/include/string.h @@ -200,6 +200,31 @@ int timingsafe_bcmp (const void *, const void *, size_t); int timingsafe_memcmp (const void *, const void *, size_t); #endif +#if __STDC_WANT_LIB_EXT1__ == 1 +#include + +#ifndef _ERRNO_T_DEFINED +typedef __errno_t errno_t; +#define _ERRNO_T_DEFINED +#endif + +#ifndef _RSIZE_T_DEFINED +typedef __rsize_t rsize_t; +#define _RSIZE_T_DEFINED +#endif + +errno_t memcpy_s(void *__restrict, rsize_t, const void *__restrict, rsize_t); +errno_t memset_s(void *, rsize_t, int, rsize_t); +errno_t memmove_s(void *, rsize_t, const void *, rsize_t); +errno_t strcpy_s(char *__restrict, rsize_t, const char *__restrict); +errno_t strcat_s(char *__restrict, rsize_t, const char *__restrict); +errno_t strncpy_s(char *__restrict, rsize_t, const char *__restrict, rsize_t); +errno_t strncat_s(char *__restrict, rsize_t, const char *__restrict, rsize_t); +size_t strnlen_s(const char *, size_t); +errno_t strerror_s(char *, rsize_t, errno_t); +size_t strerrorlen_s(errno_t); +#endif + #include _END_STD_C diff --git a/newlib/libc/include/sys/_types.h b/newlib/libc/include/sys/_types.h index 9dce1e7b39..149756dc9b 100644 --- a/newlib/libc/include/sys/_types.h +++ b/newlib/libc/include/sys/_types.h @@ -257,4 +257,15 @@ typedef unsigned short __nlink_t; typedef long __suseconds_t; /* microseconds (signed) */ typedef unsigned long __useconds_t; /* microseconds (unsigned) */ +#ifdef __STDC_WANT_LIB_EXT1__ +#if (__STDC_WANT_LIB_EXT1__ != 0) && (__STDC_WANT_LIB_EXT1__ != 1) +#error Please define __STDC_WANT_LIB_EXT__ as 0 or 1 +#endif + +#if __STDC_WANT_LIB_EXT1__ == 1 +typedef size_t __rsize_t; +typedef int __errno_t; +#endif +#endif + #endif /* _SYS__TYPES_H */ diff --git a/newlib/libc/include/time.h b/newlib/libc/include/time.h index fb4f6c543b..b7acf25e3a 100644 --- a/newlib/libc/include/time.h +++ b/newlib/libc/include/time.h @@ -291,6 +291,20 @@ int timer_settime (timer_t timerid, int flags, void tzset (void); +#if __STDC_WANT_LIB_EXT1__ == 1 +#include + +#ifndef _ERRNO_T_DEFINED +typedef __errno_t errno_t; +#define _ERRNO_T_DEFINED +#endif + +#ifndef _RSIZE_T_DEFINED +typedef __rsize_t rsize_t; +#define _RSIZE_T_DEFINED +#endif +#endif + _END_STD_C #endif /* _TIME_H_ */ diff --git a/newlib/libc/include/wchar.h b/newlib/libc/include/wchar.h index fa411cd0aa..6e948439b5 100644 --- a/newlib/libc/include/wchar.h +++ b/newlib/libc/include/wchar.h @@ -301,6 +301,20 @@ int wprintf (const wchar_t *__restrict, ...); int wscanf (const wchar_t *__restrict, ...); #endif +#if __STDC_WANT_LIB_EXT1__ == 1 +#include + +#ifndef _ERRNO_T_DEFINED +typedef __errno_t errno_t; +#define _ERRNO_T_DEFINED +#endif + +#ifndef _RSIZE_T_DEFINED +typedef __rsize_t rsize_t; +#define _RSIZE_T_DEFINED +#endif +#endif + _END_STD_C #if __SSP_FORTIFY_LEVEL > 0 diff --git a/newlib/libc/stdio/stdio.h b/newlib/libc/stdio/stdio.h index a8c60920a5..aeca73b9f8 100644 --- a/newlib/libc/stdio/stdio.h +++ b/newlib/libc/stdio/stdio.h @@ -794,6 +794,20 @@ _putchar_unlocked(int _c) #endif /* !__CUSTOM_FILE_IO__ */ +#if __STDC_WANT_LIB_EXT1__ == 1 +#include + +#ifndef _ERRNO_T_DEFINED +typedef __errno_t errno_t; +#define _ERRNO_T_DEFINED +#endif + +#ifndef _RSIZE_T_DEFINED +typedef __rsize_t rsize_t; +#define _RSIZE_T_DEFINED +#endif +#endif + _END_STD_C #if __SSP_FORTIFY_LEVEL > 0 diff --git a/newlib/libc/stdlib/CMakeLists.txt b/newlib/libc/stdlib/CMakeLists.txt index 523243ba5f..8df4955c05 100644 --- a/newlib/libc/stdlib/CMakeLists.txt +++ b/newlib/libc/stdlib/CMakeLists.txt @@ -115,6 +115,7 @@ picolibc_sources( pico-exit.c pico-onexit.c pico-cxa-atexit.c + set_constraint_handler_s.c ) picolibc_sources_flags("-fno-builtin-malloc;-fno-builtin-free" diff --git a/newlib/libc/stdlib/local_s.h b/newlib/libc/stdlib/local_s.h new file mode 100644 index 0000000000..7d628c9105 --- /dev/null +++ b/newlib/libc/stdlib/local_s.h @@ -0,0 +1,52 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LOCAL_S_H_ +#define _LOCAL_S_H_ + +#if __STDC_WANT_LIB_EXT1__ == 1 +#include +#include + +#if RSIZE_MAX == SIZE_MAX +#define CHECK_RSIZE(s) 0 +#else +#define CHECK_RSIZE(s) (RSIZE_MAX == SIZE_MAX ? 0 : (s) > RSIZE_MAX) +#endif + +extern constraint_handler_t __cur_handler; + +#endif +#endif diff --git a/newlib/libc/stdlib/meson.build b/newlib/libc/stdlib/meson.build index 2c31fd2c9b..fffe4c8398 100644 --- a/newlib/libc/stdlib/meson.build +++ b/newlib/libc/stdlib/meson.build @@ -161,6 +161,7 @@ srcs_stdlib = [ 'wctob.c', 'wctomb.c', 'wctomb_r.c', + 'set_constraint_handler_s.c', ] srcs_stdlib_stdio = [ diff --git a/newlib/libc/stdlib/set_constraint_handler_s.c b/newlib/libc/stdlib/set_constraint_handler_s.c new file mode 100644 index 0000000000..dd4c996389 --- /dev/null +++ b/newlib/libc/stdlib/set_constraint_handler_s.c @@ -0,0 +1,61 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include "local_s.h" + +constraint_handler_t __cur_handler = abort_handler_s; + +void +abort_handler_s(const char *restrict msg, void *restrict ptr, __errno_t error) +{ + (void)msg; + (void)ptr; + (void)error; + abort(); +} + +constraint_handler_t +set_constraint_handler_s(constraint_handler_t handler) +{ + constraint_handler_t h = __cur_handler; + + if (handler == (constraint_handler_t)NULL) { + __cur_handler = abort_handler_s; // null restores to default handler + } else { + __cur_handler = handler; + } + + return h; +} diff --git a/newlib/libc/string/CMakeLists.txt b/newlib/libc/string/CMakeLists.txt index d31976e928..48ce38aa5c 100644 --- a/newlib/libc/string/CMakeLists.txt +++ b/newlib/libc/string/CMakeLists.txt @@ -135,4 +135,14 @@ picolibc_sources( wmempcpy.c wmemset.c xpg_strerror_r.c + memcpy_s.c + memmove_s.c + memset_s.c + strcat_s.c + strcpy_s.c + strerror_s.c + strerrorlen_s.c + strncat_s.c + strncpy_s.c + strnlen_s.c ) diff --git a/newlib/libc/string/memcpy_s.c b/newlib/libc/string/memcpy_s.c new file mode 100644 index 0000000000..84c5e91499 --- /dev/null +++ b/newlib/libc/string/memcpy_s.c @@ -0,0 +1,94 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include "string_private.h" + +__errno_t +memcpy_s(void *restrict s1, rsize_t s1max, const void *restrict s2, rsize_t n) +{ + const char *msg = ""; + + if (s1 == NULL) { + msg = "memcpy_s: dest is NULL"; + goto handle_error; + } + + if (CHECK_RSIZE(s1max)) { + msg = "memcpy_s: buffer size exceeds RSIZE_MAX"; + goto handle_error; + } + + if (s2 == NULL) { + msg = "memcpy_s: source is NULL"; + goto handle_error; + } + + if (CHECK_RSIZE(n)) { + msg = "memcpy_s: copy count exceeds RSIZE_MAX"; + goto handle_error; + } + + if (n > s1max) { + msg = "memcpy_s: copy count exceeds buffer size"; + goto handle_error; + } + + const char *s1cp = (const char *)s1; + const char *s2cp = (const char *)s2; + const char *s1cp_limit = &s1cp[n]; + const char *s2cp_limit = &s2cp[n]; + + if (((s1cp_limit <= s2cp) || (s2cp_limit <= s1cp)) == false) { + msg = "memcpy_s: overlapping copy"; + goto handle_error; + } + + // Normal return path + (void)memcpy(s1, s2, n); + return 0; + +handle_error: + if (s1 != NULL) { + (void)memset(s1, (int32_t)'\0', s1max); + } + + if (__cur_handler != NULL) { + __cur_handler(msg, NULL, -1); + } + + return -1; +} diff --git a/newlib/libc/string/memmove_s.c b/newlib/libc/string/memmove_s.c new file mode 100644 index 0000000000..1b6b217f5d --- /dev/null +++ b/newlib/libc/string/memmove_s.c @@ -0,0 +1,86 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include "string_private.h" + +__errno_t +memmove_s(void *s1, rsize_t s1max, const void *s2, rsize_t n) +{ + const char *msg = ""; + + if (s1 == NULL) { + msg = "memmove_s: dest is NULL"; + goto handle_error; + } + + if (CHECK_RSIZE(s1max)) { + msg = "memmove_s: buffer size exceeds RSIZE_MAX"; + goto handle_error; + } + + if (s2 == NULL) { + msg = "memmove_s: source is NULL"; + goto handle_error; + } + + if (CHECK_RSIZE(n)) { + msg = "memmove_s: copy count exceeds RSIZE_MAX"; + goto handle_error; + } + + if (n > s1max) { + msg = "memmove_s: copy count exceeds buffer size"; + goto handle_error; + } + + /* overlapping memory is allowed for memmove_s so no checks for that */ + + // Normal return path + (void)memmove(s1, s2, n); + return 0; + +handle_error: + if (s1 != NULL) { + (void)memset(s1, (int32_t)'\0', s1max); + } + + if (__cur_handler != NULL) { + __cur_handler(msg, NULL, -1); + } + + return -1; +} diff --git a/newlib/libc/string/memset_s.c b/newlib/libc/string/memset_s.c new file mode 100644 index 0000000000..ca8b1e117b --- /dev/null +++ b/newlib/libc/string/memset_s.c @@ -0,0 +1,79 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include "string_private.h" + +__errno_t +memset_s(void *s, rsize_t smax, int c, rsize_t n) +{ + const char *msg = ""; + + if (s == NULL) { + msg = "memset_s: dest is NULL"; + goto handle_error; + } + + if (CHECK_RSIZE(smax)) { + msg = "memset_s: buffer size exceeds RSIZE_MAX"; + goto handle_error; + } + + if (CHECK_RSIZE(n)) { + msg = "memset_s: count exceeds RSIZE_MAX"; + goto handle_error; + } + + if (n > smax) { + msg = "memset_s: count exceeds buffer size"; + goto handle_error; + } + + // Normal return path + (void)memset(s, c, n); + return 0; + +handle_error: + if (s != NULL) { + (void)memset(s, c, smax); + } + + if (__cur_handler != NULL) { + __cur_handler(msg, NULL, -1); + } + + return -1; +} diff --git a/newlib/libc/string/meson.build b/newlib/libc/string/meson.build index 9aac49ea23..e7e9f264ce 100644 --- a/newlib/libc/string/meson.build +++ b/newlib/libc/string/meson.build @@ -134,11 +134,22 @@ srcs_string = [ 'wmempcpy.c', 'wmemset.c', 'xpg_strerror_r.c', + 'memcpy_s.c', + 'memmove_s.c', + 'memset_s.c', + 'strcat_s.c', + 'strcpy_s.c', + 'strerror_s.c', + 'strerrorlen_s.c', + 'strncat_s.c', + 'strncpy_s.c', + 'strnlen_s.c', ] hdrs_string = [ 'local.h', 'str-two-way.h', + 'string_private.h', ] srcs_strcmp = [ diff --git a/newlib/libc/string/strcat_s.c b/newlib/libc/string/strcat_s.c new file mode 100644 index 0000000000..64fabbe0d5 --- /dev/null +++ b/newlib/libc/string/strcat_s.c @@ -0,0 +1,142 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include "string_private.h" + +__errno_t +strcat_s(char *restrict s1, rsize_t s1max, const char *restrict s2) +{ + const char *msg = ""; + size_t s1_len = 0; + bool write_null = true; + + if (s1 == NULL) { + msg = "strcat_s: dest is NULL"; + write_null = false; + goto handle_error; + } + + if ((s1max == 0) || (CHECK_RSIZE(s1max))) { + msg = "strcat_s: dest buffer size is 0 or exceeds RSIZE_MAX"; + write_null = false; + goto handle_error; + } + + if (s2 == NULL) { + msg = "strcat_s: source is NULL"; + goto handle_error; + } + + /* It is a constraint violation if s1max is not large enough to contain + * the concatenation s2: no truncation permitted. + * It is also a constraint violation if the string pointed to by s2 + * overlaps s1 in any way. + * The C11 Rationale says we are permitted to proceed with the copy and + * detect dest buffer overrun and overlapping memory blocks as a byproduct + * of performing the copy operation. This is to avoid calling strlen on + * s2 to detect these violations prior to attempting the copy. + */ + // compute chars available in s1 + s1_len = strnlen_s(s1, s1max); + if (s1_len == s1max) { + msg = "strcat_s: string 1 length exceeds buffer size"; + goto handle_error; + } + + const char *overlap_point; + bool check_s1_for_overlap; + unsigned m = s1max - s1_len; + char *s1cp = s1 + s1_len; + const char *s2cp = s2; + + if (s1 <= s2) { + // if we ever reach s2 when storing to s1 we have overlap + overlap_point = s2; + check_s1_for_overlap = true; + // make sure source does not lie within initial dest string. + if (s2 <= s1cp) { + msg = "strcat_s: overlapping copy"; + goto handle_error; + } + } else { + // if we ever reach s1 when reading from s2 we have overlap + overlap_point = s1; + check_s1_for_overlap = false; + // issue with checking initial dest string does not apply in this + // case, overlap will be detected only by hitting overlap_point. + } + + unsigned written = 0; + char c = '.'; + while (written < m) { + if (check_s1_for_overlap) { + if (s1cp == overlap_point) { + msg = "strcat_s: overlapping copy"; + goto handle_error; + } + } else if (s2cp == overlap_point) { + msg = "strcat_s: overlapping copy"; + goto handle_error; + } + + c = *s2cp++; + *s1cp++ = c; + written++; + if (c == '\0') { + break; + } + } + + if (c != '\0') { + msg = "strcat_s: dest buffer size insufficent to append string"; + goto handle_error; + } + + // Normal return path + return 0; + +handle_error: + if (write_null && s1 != NULL) { + *s1 = '\0'; + } + + if (__cur_handler != NULL) { + __cur_handler(msg, NULL, -1); + } + + return -1; +} diff --git a/newlib/libc/string/strcpy_s.c b/newlib/libc/string/strcpy_s.c new file mode 100644 index 0000000000..30e9438ae5 --- /dev/null +++ b/newlib/libc/string/strcpy_s.c @@ -0,0 +1,125 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include "string_private.h" + +__errno_t +strcpy_s(char *restrict s1, rsize_t s1max, const char *restrict s2) +{ + const char *msg = ""; + bool write_null = true; + + if (s1 == NULL) { + msg = "strcpy_s: dest is NULL"; + write_null = false; + goto handle_error; + } + + if ((s1max == 0) || (CHECK_RSIZE(s1max))) { + msg = "strcpy_s: dest buffer size is 0 or exceeds RSIZE_MAX"; + write_null = false; + goto handle_error; + } + + if (s2 == NULL) { + msg = "strcpy_s: source is NULL"; + goto handle_error; + } + + /* It is a constraint violation if s1max is not large enough to contain + * s2: no truncation permitted. + * It is also a constraint violation if the string pointed to by s2 + * overlaps s1 in any way. + * The C11 Rationale says we are permitted to proceed with the copy and + * detect dest buffer overrun and overlapping memory blocks as a byproduct + * of performing the copy operation. This is to avoid calling strlen on + * s2 to detect these violations prior to attempting the copy. + */ + const char *overlap_point; + bool check_s1_for_overlap; + char *s1cp = s1; + const char *s2cp = s2; + if (s1 < s2) { + // if we ever reach s2 when storing to s1 we have overlap + overlap_point = s2; + check_s1_for_overlap = true; + } else { + // if we ever reach s1 when reading from s2 we have overlap + overlap_point = s1; + check_s1_for_overlap = false; + } + + unsigned written = 0; + char c = '.'; + while (written < s1max) { + if (check_s1_for_overlap) { + if (s1cp == overlap_point) { + msg = "strcpy_s: overlapping copy"; + goto handle_error; + } + } else if (s2cp == overlap_point) { + msg = "strcpy_s: overlapping copy"; + goto handle_error; + } + + c = *s2cp++; + *s1cp++ = c; + written++; + if (c == '\0') { + break; + } + } + + if (c != '\0') { + msg = "strcpy_s: dest buffer size insufficent to copy string"; + goto handle_error; + } + + // Normal return path + return 0; + +handle_error: + if (write_null && s1 != NULL) { + *s1 = '\0'; + } + + if (__cur_handler != NULL) { + __cur_handler(msg, NULL, -1); + } + + return -1; +} diff --git a/newlib/libc/string/strerror.c b/newlib/libc/string/strerror.c index 5788505b1b..9c3e38191d 100644 --- a/newlib/libc/string/strerror.c +++ b/newlib/libc/string/strerror.c @@ -400,6 +400,7 @@ QUICKREF #define _DEFAULT_SOURCE #include #include +#include "string_private.h" #include "local.h" extern char *_user_strerror (int, int, int *) _ATTRIBUTE((__weak__)); diff --git a/newlib/libc/string/strerror_s.c b/newlib/libc/string/strerror_s.c new file mode 100644 index 0000000000..8822168c10 --- /dev/null +++ b/newlib/libc/string/strerror_s.c @@ -0,0 +1,85 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include "string_private.h" + +/* C11 version; required by LLVM's C++11 library */ +__errno_t +strerror_s(char *buf, rsize_t buflen, __errno_t errnum) +{ + int32_t result = 0; + const char *msg = ""; + + if (buf == NULL) { + msg = "strerror_s: dest is NULL"; + goto handle_error; + } + + if ((buflen == 0u) || (CHECK_RSIZE(buflen))) { + msg = "strerror_s: dest buffer size is 0 or exceeds RSIZE_MAX"; + goto handle_error; + } + + const char *cp = _strerror_r(errnum, 0, NULL); + uint32_t len = strnlen_s(cp, MAX_ERROR_MSG); + + if (len < buflen) { + (void)strncpy(buf, cp, MAX_ERROR_MSG); + } else { + /* Standard allows truncation of error message with '...' to + indicate truncation. */ + (void)memcpy(buf, cp, (buflen - 1u)); + buf[(buflen - 1u)] = '\0'; + + if (buflen > 3u) { + (void)strncpy(&buf[(buflen - 4u)], "...", 4u); + } + + result = ERANGE; + } + + // Normal return path + return result; + +handle_error: + if (__cur_handler != NULL) { + __cur_handler(msg, NULL, -1); + } + + return -1; +} diff --git a/newlib/libc/string/strerrorlen_s.c b/newlib/libc/string/strerrorlen_s.c new file mode 100644 index 0000000000..b22215ccaf --- /dev/null +++ b/newlib/libc/string/strerrorlen_s.c @@ -0,0 +1,43 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include "string_private.h" + +size_t +strerrorlen_s(__errno_t errnum) +{ + return strnlen_s(_strerror_r(errnum, 0, NULL), MAX_ERROR_MSG); +} diff --git a/newlib/libc/string/string_private.h b/newlib/libc/string/string_private.h new file mode 100644 index 0000000000..8c5cd3a0b5 --- /dev/null +++ b/newlib/libc/string/string_private.h @@ -0,0 +1,44 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef STRING_PRIVATE_H_ +#define STRING_PRIVATE_H_ + +#include "../stdlib/local_s.h" + +#define MAX_ERROR_MSG 100 + +char *_strerror_r(int errnum, int internal, int *errptr); + +#endif //STRING_PRIVATE_H_ diff --git a/newlib/libc/string/strncat_s.c b/newlib/libc/string/strncat_s.c new file mode 100644 index 0000000000..7290bdab64 --- /dev/null +++ b/newlib/libc/string/strncat_s.c @@ -0,0 +1,169 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include "string_private.h" + +__errno_t +strncat_s(char *restrict s1, rsize_t s1max, const char *restrict s2, rsize_t n) +{ + const char *msg = ""; + size_t s1_len = 0; + bool write_null = true; + + s1_len = strnlen_s(s1, s1max); + + if (s1 == NULL) { + msg = "strncat_s: dest is NULL"; + write_null = false; + goto handle_error; + } else if ((s1max == 0u) || (CHECK_RSIZE(s1max))) { + msg = "strncat_s: dest buffer size is 0 or exceeds RSIZE_MAX"; + write_null = false; + goto handle_error; + } else if (s2 == NULL) { + msg = "strncat_s: source is NULL"; + goto handle_error; + } else if (CHECK_RSIZE(n)) { + msg = "strncat_s: copy count exceeds RSIZE_MAX"; + goto handle_error; + } + + /* It is a constraint violation if s1max is not large enough to contain + * the concatenation of s2. + * It is also a constraint violation if the string pointed to by s2 + * overlaps s1 in any way. + * The C11 Rationale says we are permitted to proceed with the copy and + * detect dest buffer overrun and overlapping memory blocks as a byproduct + * of performing the copy operation. This is to avoid calling strlen on + * s2 to detect these violations prior to attempting the copy. + */ + // compute chars available in s1 + + else if (s1_len == s1max) { + msg = "strncat_s: string 1 length exceeds buffer size"; + goto handle_error; + } else { + // compute chars available in s1 + uint32_t m = (s1max - s1_len); + uint32_t i = 0; + char *s1cp = s1; + + for (i = 0u; i < s1_len; i++) { + s1cp++; + } + + // Question; at this point should we just return + // strncpy_s(s1cp, m, s2, n) ? + // perhaps not since overlap check needs to be over entire s1 vs. s2? + + const char *overlap_point; + bool check_s1_for_overlap; + const char *s2cp = s2; + + if (s1 <= s2) { + // if we ever reach s2 when storing to s1 we have overlap + overlap_point = s2; + check_s1_for_overlap = true; + // make sure source does not lie within initial dest string. + if (s2 <= s1cp) { + msg = "strncat_s: overlapping copy"; + goto handle_error; + } + } else { + // if we ever reach s1 when reading from s2 we have overlap + overlap_point = s1; + check_s1_for_overlap = false; + } + + uint32_t written = 0; + char c = '.'; + + while ((written < m) && (written < n)) { + if (check_s1_for_overlap == true) { + if (s1cp == overlap_point) { + msg = "strncat_s: overlapping copy"; + goto handle_error; + } + } else if (s2cp == overlap_point) { + msg = "strncat_s: overlapping copy"; + goto handle_error; + } else { + /* Normal case*/ + } + + c = *s2cp; + s2cp++; + *s1cp = c; + s1cp++; + written++; + + if (c == '\0') { + break; + } + } + + if ((c != '\0') && (written == n) && (written < m)) { + // we copied n chars from s2 and there is room for null char in s1 + if ((check_s1_for_overlap == true) && (s1cp == overlap_point)) { + msg = "strncat_s: overlapping copy"; + goto handle_error; + } else { + c = '\0'; + *s1cp = '\0'; + } + } + + if (c != '\0') { + msg = "strncat_s: dest buffer size insufficent to copy string"; + goto handle_error; + } + } + + // Normal return path + return 0; + +handle_error: + if (write_null && s1 != NULL) { + *s1 = '\0'; + } + + if (__cur_handler != NULL) { + __cur_handler(msg, NULL, -1); + } + + return -1; +} diff --git a/newlib/libc/string/strncpy_s.c b/newlib/libc/string/strncpy_s.c new file mode 100644 index 0000000000..b35946404e --- /dev/null +++ b/newlib/libc/string/strncpy_s.c @@ -0,0 +1,147 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include "string_private.h" + +__errno_t +strncpy_s(char *restrict s1, rsize_t s1max, const char *restrict s2, rsize_t n) +{ + const char *msg = ""; + bool write_null = true; + + if (s1 == NULL) { + msg = "strncpy_s: dest is NULL"; + write_null = false; + goto handle_error; + } else if ((s1max == 0u) || (CHECK_RSIZE(s1max))) { + msg = "strncpy_s: dest buffer size is 0 or exceeds RSIZE_MAX"; + write_null = false; + goto handle_error; + } + + else if (s2 == NULL) { + msg = "strncpy_s: source is NULL"; + goto handle_error; + } else if (CHECK_RSIZE(n)) { + msg = "strncpy_s: copy count exceeds RSIZE_MAX"; + goto handle_error; + } + + /* It is a constraint violation if s1max is not large enough to contain + * a copy of s2 (with n as upper bound on chars copied). + * It is also a constraint violation if the string pointed to by s2 + * overlaps s1 in any way. + * The C11 Rationale says we are permitted to proceed with the copy and + * detect dest buffer overrun and overlapping memory blocks as a byproduct + * of performing the copy operation. This is to avoid calling strlen on + * s2 to detect these violations prior to attempting the copy. + */ + + else { + const char *overlap_point; + bool check_s1_for_overlap; + char *s1cp = s1; + const char *s2cp = s2; + + if (s1 < s2) { + // if we ever reach s2 when storing to s1 we have overlap + overlap_point = s2; + check_s1_for_overlap = true; + } else { + // if we ever reach s1 when reading from s2 we have overlap + overlap_point = s1; + check_s1_for_overlap = false; + } + + uint32_t written = 0; + char c = '.'; + + while ((written < s1max) && (written < n)) { + if (check_s1_for_overlap == true) { + if (s1cp == overlap_point) { + msg = "strncpy_s: overlapping copy"; + goto handle_error; + } + } else if (s2cp == overlap_point) { + msg = "strncpy_s: overlapping copy"; + goto handle_error; + } else { + /* Normal case*/ + } + + c = *s2cp; + s2cp++; + *s1cp = c; + s1cp++; + written++; + + if (c == '\0') { + break; + } + } + + if ((c != '\0') && (written == n) && (written < s1max)) { + // we copied n chars from s2 and there is room for null char in s1 + if ((check_s1_for_overlap == true) && (s1cp == overlap_point)) { + msg = "strncpy_s: overlapping copy"; + goto handle_error; + } else { + c = '\0'; + *s1cp = '\0'; + } + } + + if (c != '\0') { + msg = "strncpy_s: dest buffer size insufficent to copy string"; + goto handle_error; + } + } + + // Normal return path + return 0; + +handle_error: + if (write_null && s1 != NULL) { + *s1 = '\0'; + } + + if (__cur_handler != NULL) { + __cur_handler(msg, NULL, -1); + } + + return -1; +} diff --git a/newlib/libc/string/strnlen_s.c b/newlib/libc/string/strnlen_s.c new file mode 100644 index 0000000000..bfbfb98618 --- /dev/null +++ b/newlib/libc/string/strnlen_s.c @@ -0,0 +1,60 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include "string_private.h" + +size_t +strnlen_s(const char *s, size_t maxsize) +{ + const void *s_end; + size_t rtn = 0; + + if (s == NULL) { + rtn = 0; + } else { + s_end = memchr((const void *)s, (int)'\0', maxsize); + + if (s_end == NULL) { + rtn = maxsize; + } else { + int s_size; + s_size = s_end - (const void *)s; + rtn = (size_t)s_size; + } + } + + return rtn; +} diff --git a/newlib/libc/tinystdio/CMakeLists.txt b/newlib/libc/tinystdio/CMakeLists.txt index 71f6318d16..97077ac6c5 100644 --- a/newlib/libc/tinystdio/CMakeLists.txt +++ b/newlib/libc/tinystdio/CMakeLists.txt @@ -166,6 +166,7 @@ picolibc_sources( vwscanf.c wprintf.c wscanf.c + sprintf_s.c ) picolibc_sources( diff --git a/newlib/libc/tinystdio/meson.build b/newlib/libc/tinystdio/meson.build index 8c5c8b40de..0f45fe0ec2 100644 --- a/newlib/libc/tinystdio/meson.build +++ b/newlib/libc/tinystdio/meson.build @@ -169,6 +169,7 @@ srcs_tinystdio = [ 'vwscanf.c', 'wprintf.c', 'wscanf.c', + 'sprintf_s.c', ] # exact float/string conversion code diff --git a/newlib/libc/tinystdio/sprintf_s.c b/newlib/libc/tinystdio/sprintf_s.c new file mode 100644 index 0000000000..18936037c3 --- /dev/null +++ b/newlib/libc/tinystdio/sprintf_s.c @@ -0,0 +1,147 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#define __STDC_WANT_LIB_EXT1__ 1 +#include "stdio_private.h" +#include +#include +#include +#include "../stdlib/local_s.h" + +int +sprintf_s(char *restrict s, rsize_t bufsize, const char *restrict fmt, ...) +{ + bool write_null = true; + const char *msg = ""; + va_list args; + int rc; + + if (s == NULL) { + write_null = false; + msg = "sprintf_s: dest buffer is null"; + goto handle_error; + } else if ((bufsize == 0) || (CHECK_RSIZE(bufsize))) { + write_null = false; + msg = "sprintf_s: invalid buffer size"; + goto handle_error; + } else if (fmt == NULL) { + msg = "sprintf_s: null format string"; + goto handle_error; + } else if (strstr(fmt, " %n") != NULL) { + msg = "sprintf_s: format string contains percent-n"; + goto handle_error; + } else { + va_start(args, fmt); + + va_list args_copy; + va_copy(args_copy, args); + + const char *check_ptr = fmt; + uint8_t null_str = 0; + while (*check_ptr && null_str == 0) { + if (check_ptr[0] == '%') { + switch (check_ptr[1]) { + case 's': { + char *str_arg = va_arg(args_copy, char *); + if (str_arg == NULL) { + msg = "sprintf_s: null string argument"; + va_end(args_copy); + va_end(args); + null_str = 1; + goto handle_error; + } + break; + } + case 'd': + case 'i': + case 'u': + case 'o': + case 'x': + case 'X': + case 'c': + case 'h': + case 'l': + case 'L': + case 'z': + case 't': + va_arg(args_copy, int); + break; + case 'f': + case 'F': + case 'e': + case 'E': + case 'g': + case 'G': + case 'a': + case 'A': + va_arg(args_copy, double); + break; + case 'p': + va_arg(args_copy, void *); + break; + default: + break; + } + } + check_ptr++; + } + + rc = vsnprintf(s, bufsize, fmt, args); + va_end(args_copy); + va_end(args); + } + + if (rc < 0 || rc >= (int)bufsize) { + msg = "sprintf_s: dest buffer overflow"; + goto handle_error; + } else { + s[rc] = 0; + } + + // Normal return path + return rc; + +handle_error: + if (__cur_handler != NULL) { + __cur_handler(msg, NULL, -1); + } + + rc = 0; /* standard stipulates this */ + + if (write_null && s != NULL) { + s[0] = '\0'; /* again, standard requires this */ + } + + return rc; +} diff --git a/newlib/libc/tinystdio/stdio.h b/newlib/libc/tinystdio/stdio.h index 994567da2f..211473de06 100644 --- a/newlib/libc/tinystdio/stdio.h +++ b/newlib/libc/tinystdio/stdio.h @@ -381,6 +381,23 @@ int putchar_unlocked (int); #define putchar_unlocked(c, f) fgetc(c, stdin) #endif +#if __STDC_WANT_LIB_EXT1__ == 1 +#include + +#ifndef _ERRNO_T_DEFINED +typedef __errno_t errno_t; +#define _ERRNO_T_DEFINED +#endif + +#ifndef _RSIZE_T_DEFINED +typedef __rsize_t rsize_t; +#define _RSIZE_T_DEFINED +#endif + +int sprintf_s(char *__restrict __s, rsize_t __bufsize, + const char *__restrict __format, ...); +#endif + /* * The format of tmpnam names is TXXXXXX, which works with mktemp */ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index da55c79760..3fc61f4594 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -61,6 +61,17 @@ set(tests test-sprintf-percent-n malloc_stress posix-io + test-memcpy_s + test-memset_s + test-memmove_s + test-strcat_s + test-strcpy_s + test-strerror_s + test-strerrorlen_s + test-strncat_s + test-strncpy_s + test-strnlen_s + test-sprintf_s ) set(tests_fail diff --git a/test/meson.build b/test/meson.build index e37faabf54..790b0bd8b4 100644 --- a/test/meson.build +++ b/test/meson.build @@ -572,6 +572,71 @@ foreach target : targets timeout: 60, env: test_env) + plain_tests = ['rand', 'regex', 'ungetc', 'fenv', + 'malloc', 'tls', + 'ffs', 'setjmp', 'atexit', 'on_exit', + 'math-funcs', 'timegm', 'time-tests', + 'test-strtod', 'test-strchr', + 'test-memset', 'test-put', + 'test-efcvt', 'test-atomic', + 'test-raise', + 'test-fma', + 'test-funopen', + ] + + if have_attr_ctor_dtor + plain_tests += 'constructor' + endif + + if have_complex + plain_tests += 'complex-funcs' + endif + + if newlib_nano_malloc or tests_enable_full_malloc_stress + plain_tests += 'malloc_stress' + endif + + if tinystdio + plain_tests += 't_fmemopen' + endif + + if (posix_io or not tinystdio) and tests_enable_posix_io + plain_tests += ['posix-io'] + + # legacy stdio doesn't work on semihosting, so just skip it + if tinystdio + plain_tests += ['test-fopen', + 'test-mktemp', + 'test-tmpnam', + 'test-fread-fwrite', + 'test-ungetc-ftell', + 'test-fgetc', + 'test-fgets-eof', + ] + endif + endif + + if tests_enable_stack_protector + plain_tests += 'stack-smash' + endif + + plain_tests += ['test-memcpy_s', + 'test-memset_s', + 'test-memmove_s', + 'test-strcat_s', + 'test-strcpy_s', + 'test-strerror_s', + 'test-strerrorlen_s', + 'test-strncat_s', + 'test-strncpy_s', + 'test-strnlen_s', + ] + + if tinystdio + plain_tests += 'test-sprintf_s' + endif + + foreach t1 : plain_tests t1_src = t1 + '.c' if target == '' diff --git a/test/test-memcpy_s.c b/test/test-memcpy_s.c new file mode 100644 index 0000000000..734e64bf90 --- /dev/null +++ b/test/test-memcpy_s.c @@ -0,0 +1,151 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include + +#define MAX_ERROR_MSG 100 + +char handler_msg[MAX_ERROR_MSG] = ""; + +static void +custom_constraint_handler(const char *restrict msg, void *restrict ptr, + errno_t error) +{ + (void)ptr; + (void)error; + strcpy(handler_msg, msg); +} + +#define TEST_RES(cond, msg, handler_res, test_id) \ + if ((!(cond)) || (handler_res == 1)) { \ + printf("Test %d Failed: %s\n", test_id, msg); \ + return 1; \ + } else { \ + printf("Test %d Passed: %s\n", test_id, msg); \ + } + +static int +test_handler_called(int handler_called, char *expected_msg, int test_id) +{ + int ret = 0; + if (handler_called == 0) { + (void)expected_msg; + if (handler_msg[0] != '\0') { + printf( + "ERROR: Custom constraint handler called without error detiction!\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } + } else { + if (handler_msg[0] == '\0') { + (void)expected_msg; + printf("ERROR: Custom constraint handler not called\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + if (strcmp(expected_msg, handler_msg) != 0) { + printf( + "ERROR: Custom constraint handler called with incorrect msg: %s\n", + handler_msg); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + (void)expected_msg; + printf( + "Custom constraint handler called with correct msg: %s\n", + handler_msg); + handler_msg[0] = '\0'; + ret = 0; + } + } + } + return ret; +} + +int +main(void) +{ + char src[] = "Hello, world!"; + char dest[50]; + int test_id = 0; + int handler_res = 0; + errno_t res; + + set_constraint_handler_s(custom_constraint_handler); + + // Test case 1: Normal copy + test_id++; + res = memcpy_s(dest, sizeof(dest), src, strlen(src) + 1); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Normal Copy", handler_res, test_id); + TEST_RES(strcmp(dest, "Hello, world!") == 0, "Normal Copy Contents", + handler_res, test_id); + + // Test case 2: Copy with insufficient destination size + test_id++; + res = memcpy_s(dest, 5, src, strlen(src) + 1); + handler_res = test_handler_called( + 1, "memcpy_s: copy count exceeds buffer size", test_id); + TEST_RES(res != 0, "Copy with insufficient destination size", handler_res, + test_id); + + // Test case 3: Copy with Null destination + test_id++; + res = memcpy_s(NULL, sizeof(dest), src, strlen(src) + 1); + handler_res = test_handler_called(1, "memcpy_s: dest is NULL", test_id); + TEST_RES(res != 0, "Copy with Null destination", handler_res, test_id); + + // Test case 4: Copy with Null source + test_id++; + res = memcpy_s(dest, sizeof(dest), NULL, strlen(src) + 1); + handler_res = test_handler_called(1, "memcpy_s: source is NULL", test_id); + TEST_RES(res != 0, "Copy with Null source", handler_res, test_id); + + // Test case 5: Copy with zero length + test_id++; + strcpy(dest, ""); + res = memcpy_s(dest, sizeof(dest), src, 0); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Copy with zero length", handler_res, test_id); + TEST_RES(dest[0] == '\0', "Copy with zero length Contents", handler_res, + test_id); + + printf("All memcpy_s tests passed!\n"); + return 0; +} diff --git a/test/test-memmove_s.c b/test/test-memmove_s.c new file mode 100644 index 0000000000..98e188e616 --- /dev/null +++ b/test/test-memmove_s.c @@ -0,0 +1,150 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include + +#define MAX_ERROR_MSG 100 + +char handler_msg[MAX_ERROR_MSG] = ""; + +static void +custom_constraint_handler(const char *restrict msg, void *restrict ptr, + errno_t error) +{ + (void)ptr; + (void)error; + strcpy(handler_msg, msg); +} + +#define TEST_RES(cond, msg, handler_res, test_id) \ + if ((!(cond)) || (handler_res == 1)) { \ + printf("Test %d Failed: %s\n", test_id, msg); \ + return 1; \ + } else { \ + printf("Test %d Passed: %s\n", test_id, msg); \ + } + +static int +test_handler_called(int handler_called, char *expected_msg, int test_id) +{ + int ret = 0; + if (handler_called == 0) { + (void)expected_msg; + if (handler_msg[0] != '\0') { + printf( + "ERROR: Custom constraint handler called without error detiction!\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } + } else { + if (handler_msg[0] == '\0') { + (void)expected_msg; + printf("ERROR: Custom constraint handler not called\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + if (strcmp(expected_msg, handler_msg) != 0) { + printf( + "ERROR: Custom constraint handler called with incorrect msg: %s\n", + handler_msg); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + (void)expected_msg; + printf( + "Custom constraint handler called with correct msg: %s\n", + handler_msg); + handler_msg[0] = '\0'; + ret = 0; + } + } + } + return ret; +} + +int +main(void) +{ + char buf[50] = "Hello, world!"; + int test_id = 0; + int handler_res = 0; + errno_t res; + + set_constraint_handler_s(custom_constraint_handler); + + // Test case 1: Normal move + test_id++; + res = memmove_s(buf + 7, sizeof(buf) - 7, buf, strlen(buf) + 1); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Normal move", handler_res, test_id); + TEST_RES(strcmp(buf, "Hello, Hello, world!") == 0, "Normal move Contents", + handler_res, test_id); + + // Test case 2: Move with insufficient destination size + test_id++; + res = memmove_s(buf + 7, 5, buf, strlen(buf) + 1); + handler_res = test_handler_called( + 1, "memmove_s: copy count exceeds buffer size", test_id); + TEST_RES(res != 0, "Move with insufficient destination size", handler_res, + test_id); + + // Test case 3: Move with Null destination + test_id++; + res = memmove_s(NULL, sizeof(buf), buf, strlen(buf) + 1); + handler_res = test_handler_called(1, "memmove_s: dest is NULL", test_id); + TEST_RES(res != 0, "Move with Null destination", handler_res, test_id); + + // Test case 4: Move with Null source + test_id++; + res = memmove_s(buf, sizeof(buf), NULL, strlen(buf) + 1); + handler_res = test_handler_called(1, "memmove_s: source is NULL", test_id); + TEST_RES(res != 0, "Move with Null source", handler_res, test_id); + + // Test case 5: Move with zero length + test_id++; + strcpy(buf, ""); + res = memmove_s(buf, sizeof(buf), buf, 0); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Move with zero length", handler_res, test_id); + TEST_RES(buf[0] == '\0', "Move with zero length Contents", handler_res, + test_id); + + printf("All memmove_s tests passed!\n"); + return 0; +} diff --git a/test/test-memset_s.c b/test/test-memset_s.c new file mode 100644 index 0000000000..c1b1aa5fc7 --- /dev/null +++ b/test/test-memset_s.c @@ -0,0 +1,142 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include + +#define MAX_ERROR_MSG 100 + +char handler_msg[MAX_ERROR_MSG] = ""; + +static void +custom_constraint_handler(const char *restrict msg, void *restrict ptr, + errno_t error) +{ + (void)ptr; + (void)error; + strcpy(handler_msg, msg); +} + +#define TEST_RES(cond, msg, handler_res, test_id) \ + if ((!(cond)) || (handler_res == 1)) { \ + printf("Test %d Failed: %s\n", test_id, msg); \ + return 1; \ + } else { \ + printf("Test %d Passed: %s\n", test_id, msg); \ + } + +static int +test_handler_called(int handler_called, char *expected_msg, int test_id) +{ + int ret = 0; + if (handler_called == 0) { + (void)expected_msg; + if (handler_msg[0] != '\0') { + printf( + "ERROR: Custom constraint handler called without error detiction!\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } + } else { + if (handler_msg[0] == '\0') { + (void)expected_msg; + printf("ERROR: Custom constraint handler not called\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + if (strcmp(expected_msg, handler_msg) != 0) { + printf( + "ERROR: Custom constraint handler called with incorrect msg: %s\n", + handler_msg); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + (void)expected_msg; + printf( + "Custom constraint handler called with correct msg: %s\n", + handler_msg); + handler_msg[0] = '\0'; + ret = 0; + } + } + } + return ret; +} + +int +main(void) +{ + char buf[50] = "Hello, world!"; + int test_id = 0; + int handler_res = 0; + errno_t res; + + set_constraint_handler_s(custom_constraint_handler); + + // Test case 1: Normal Set + test_id++; + res = memset_s(buf, sizeof(buf), 'A', strlen("Hello, world!")); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Normal Set", handler_res, test_id); + TEST_RES(strcmp(buf, "AAAAAAAAAAAAA") == 0, "Normal Set Contents", + handler_res, test_id); + + // Test case 2: Zero-length Set + test_id++; + res = memset_s(buf, sizeof(buf), 'B', 0); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Zero-length Set", handler_res, test_id); + TEST_RES(strcmp(buf, "AAAAAAAAAAAAA") == 0, "Zero-length Set Contents", + handler_res, test_id); + + // Test case 3: Null pointers + test_id++; + res = memset_s(NULL, sizeof(buf), 'C', strlen("Hello, world!")); + handler_res = test_handler_called(1, "memset_s: dest is NULL", test_id); + TEST_RES(res != 0, "NULL Destination Pointer", handler_res, test_id); + + // Test case 4: Set with zero buffer size + test_id++; + res = memset_s(buf, 0, 'D', strlen("Hello, world!")); + handler_res = + test_handler_called(1, "memset_s: count exceeds buffer size", test_id); + TEST_RES(res != 0, "Set with zero buffer size", handler_res, test_id); + + printf("All memset_s tests passed!\n"); + return 0; +} diff --git a/test/test-sprintf_s.c b/test/test-sprintf_s.c new file mode 100644 index 0000000000..8e9d1acc5d --- /dev/null +++ b/test/test-sprintf_s.c @@ -0,0 +1,152 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include + +#define MAX_ERROR_MSG 100 + +char handler_msg[MAX_ERROR_MSG] = ""; + +static void +custom_constraint_handler(const char *restrict msg, void *restrict ptr, + errno_t error) +{ + (void)ptr; + (void)error; + strcpy(handler_msg, msg); +} + +#define TEST_RES(cond, msg, handler_res, test_id) \ + if ((!(cond)) || (handler_res == 1)) { \ + printf("Test %d Failed: %s\n", test_id, msg); \ + return 1; \ + } else { \ + printf("Test %d Passed: %s\n", test_id, msg); \ + } + +static int +test_handler_called(int handler_called, char *expected_msg, int test_id) +{ + int ret = 0; + if (handler_called == 0) { + (void)expected_msg; + if (handler_msg[0] != '\0') { + printf( + "ERROR: Custom constraint handler called without error detiction!\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } + } else { + if (handler_msg[0] == '\0') { + (void)expected_msg; + printf("ERROR: Custom constraint handler not called\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + if (strcmp(expected_msg, handler_msg) != 0) { + printf( + "ERROR: Custom constraint handler called with incorrect msg: %s\n", + handler_msg); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + (void)expected_msg; + printf( + "Custom constraint handler called with correct msg: %s\n", + handler_msg); + handler_msg[0] = '\0'; + ret = 0; + } + } + } + return ret; +} + +int +main(void) +{ + char buf[50]; + int test_id = 0; + int handler_res = 0; + errno_t res; + + set_constraint_handler_s(custom_constraint_handler); + + // Test case 1: Normal formatting + test_id++; + res = sprintf_s(buf, sizeof(buf), "Hello, %s!", "world"); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == (int)strlen("Hello, world!"), "Normal formatting", + handler_res, test_id); + TEST_RES(strcmp(buf, "Hello, world!") == 0, "Normal formatting Contents", + handler_res, test_id); + + // Test case 2: Formatting with buffer overflow + test_id++; + res = sprintf_s(buf, 10, "Hello, %s!", "world"); + handler_res = + test_handler_called(1, "sprintf_s: dest buffer overflow", test_id); + TEST_RES(res == 0, "Formatting with buffer overflow", handler_res, test_id); + + // Test case 3: Formatting with Null buffer + test_id++; + res = sprintf_s(NULL, sizeof(buf), "Hello, %s!", "world"); + handler_res = + test_handler_called(1, "sprintf_s: dest buffer is null", test_id); + TEST_RES(res == 0, "Formatting with Null buffer", handler_res, test_id); + + // Test case 4: Formatting with Null format string + test_id++; + res = sprintf_s(buf, sizeof(buf), NULL, "world"); + handler_res = + test_handler_called(1, "sprintf_s: null format string", test_id); + TEST_RES(res == 0, "Formatting with Null format string", handler_res, + test_id); + + // Test case 5: Empty format string + test_id++; + res = sprintf_s(buf, sizeof(buf), "", "world"); + TEST_RES(res == 0, "Empty format string", handler_res, test_id); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(strcmp(buf, "") == 0, "Empty format string Contents", handler_res, + test_id); + + printf("All sprintf_s tests passed!\n"); + return 0; +} diff --git a/test/test-strcat_s.c b/test/test-strcat_s.c new file mode 100644 index 0000000000..17eee11b4c --- /dev/null +++ b/test/test-strcat_s.c @@ -0,0 +1,161 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include + +#define MAX_ERROR_MSG 100 + +char handler_msg[MAX_ERROR_MSG] = ""; + +static void +custom_constraint_handler(const char *restrict msg, void *restrict ptr, + errno_t error) +{ + (void)ptr; + (void)error; + strcpy(handler_msg, msg); +} + +#define TEST_RES(cond, msg, handler_res, test_id) \ + if ((!(cond)) || (handler_res == 1)) { \ + printf("Test %d Failed: %s\n", test_id, msg); \ + return 1; \ + } else { \ + printf("Test %d Passed: %s\n", test_id, msg); \ + } + +static int +test_handler_called(int handler_called, char *expected_msg, int test_id) +{ + int ret = 0; + if (handler_called == 0) { + (void)expected_msg; + if (handler_msg[0] != '\0') { + printf( + "ERROR: Custom constraint handler called without error detiction!\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } + } else { + if (handler_msg[0] == '\0') { + (void)expected_msg; + printf("ERROR: Custom constraint handler not called\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + if (strcmp(expected_msg, handler_msg) != 0) { + printf( + "ERROR: Custom constraint handler called with incorrect msg: %s\n", + handler_msg); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + (void)expected_msg; + printf( + "Custom constraint handler called with correct msg: %s\n", + handler_msg); + handler_msg[0] = '\0'; + ret = 0; + } + } + } + return ret; +} + +int +main(void) +{ + char dest[50] = "Hello"; + char src[] = ", world!"; + int test_id = 0; + int handler_res = 0; + errno_t res; + + set_constraint_handler_s(custom_constraint_handler); + + // Test case 1: Normal Concatenation + test_id++; + res = strcat_s(dest, sizeof(dest), src); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Normal Concatenation", handler_res, test_id); + TEST_RES(strcmp(dest, "Hello, world!") == 0, + "Normal Concatenation Contents", handler_res, test_id); + + // Test case 2: Concatenation with insufficient buffer + test_id++; + res = strcat_s(dest, 10, src); + handler_res = test_handler_called( + 1, "strcat_s: string 1 length exceeds buffer size", test_id); + TEST_RES(res != 0, "Concatenation with insufficient buffer", handler_res, + test_id); + + // Test case 3: Null pointers + test_id++; + res = strcat_s(NULL, sizeof(dest), src); + handler_res = test_handler_called(1, "strcat_s: dest is NULL", test_id); + TEST_RES(res != 0, "NULL Destination Pointer", handler_res, test_id); + res = strcat_s(dest, sizeof(dest), NULL); + handler_res = test_handler_called(1, "strcat_s: source is NULL", test_id); + TEST_RES(res != 0, "NULL Source Pointer", handler_res, test_id); + + // Test case 4: Concatenation of empty source string + test_id++; + strcpy(dest, "Hello"); + res = strcat_s(dest, sizeof(dest), ""); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Concatenation of empty source string", handler_res, + test_id); + TEST_RES(strcmp(dest, "Hello") == 0, + "Concatenation of empty source string Contents", handler_res, + test_id); + + // Test case 5: Concatenation with empty destination string + test_id++; + char dest2[50] = ""; + res = strcat_s(dest2, sizeof(dest2), ", World!"); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Concatenation of non-empty source to empty destination", + handler_res, test_id); + TEST_RES(strcmp(dest2, ", World!") == 0, + "Concatenation of non-empty source to empty destination Contents", + handler_res, test_id); + + printf("All strcat_s tests passed!\n"); + return 0; +} diff --git a/test/test-strcpy_s.c b/test/test-strcpy_s.c new file mode 100644 index 0000000000..a47416c265 --- /dev/null +++ b/test/test-strcpy_s.c @@ -0,0 +1,155 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include + +#define MAX_ERROR_MSG 100 + +char handler_msg[MAX_ERROR_MSG] = ""; + +static void +custom_constraint_handler(const char *restrict msg, void *restrict ptr, + errno_t error) +{ + (void)ptr; + (void)error; + strcpy(handler_msg, msg); +} + +#define TEST_RES(cond, msg, handler_res, test_id) \ + if ((!(cond)) || (handler_res == 1)) { \ + printf("Test %d Failed: %s\n", test_id, msg); \ + return 1; \ + } else { \ + printf("Test %d Passed: %s\n", test_id, msg); \ + } + +static int +test_handler_called(int handler_called, char *expected_msg, int test_id) +{ + int ret = 0; + if (handler_called == 0) { + (void)expected_msg; + if (handler_msg[0] != '\0') { + printf( + "ERROR: Custom constraint handler called without error detiction!\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } + } else { + if (handler_msg[0] == '\0') { + (void)expected_msg; + printf("ERROR: Custom constraint handler not called\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + if (strcmp(expected_msg, handler_msg) != 0) { + printf( + "ERROR: Custom constraint handler called with incorrect msg: %s\n", + handler_msg); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + (void)expected_msg; + printf( + "Custom constraint handler called with correct msg: %s\n", + handler_msg); + handler_msg[0] = '\0'; + ret = 0; + } + } + } + return ret; +} + +int +main(void) +{ + char dest[50]; + const char *src = "Hello, world!"; + int test_id = 0; + int handler_res = 0; + errno_t res; + + set_constraint_handler_s(custom_constraint_handler); + + // Test case 1: Normal copy + test_id++; + res = strcpy_s(dest, sizeof(dest), src); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Normal Copy", handler_res, test_id); + TEST_RES(strcmp(dest, "Hello, world!") == 0, "Normal Copy Contents", + handler_res, test_id); + + // Test case 2: Copy with insufficient buffer + test_id++; + res = strcpy_s(dest, 5, src); + handler_res = test_handler_called( + 1, "strcpy_s: dest buffer size insufficent to copy string", test_id); + TEST_RES(res != 0, "Copy with insufficient buffer", handler_res, test_id); + + // Test case 3: Null pointers + test_id++; + res = strcpy_s(NULL, sizeof(dest), src); + handler_res = test_handler_called(1, "strcpy_s: dest is NULL", test_id); + TEST_RES(res != 0, "NULL Destination Pointer", handler_res, test_id); + res = strcpy_s(dest, sizeof(dest), NULL); + handler_res = test_handler_called(1, "strcpy_s: source is NULL", test_id); + TEST_RES(res != 0, "NULL Source Pointer", handler_res, test_id); + + // Test case 4: Copy of empty string + test_id++; + res = strcpy_s(dest, sizeof(dest), ""); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Copy of empty string", handler_res, test_id); + TEST_RES(strcmp(dest, "") == 0, "Copy of empty string Contents", + handler_res, test_id); + + // Test case 5: Copy to empty buffer + test_id++; + char buf2[50] = ""; + res = strcpy_s(buf2, sizeof(buf2), "world"); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Copy to empty buffer", handler_res, test_id); + TEST_RES(strcmp(buf2, "world") == 0, "Copy to empty buffer Contents", + handler_res, test_id); + + printf("All strcpy_s tests passed!\n"); + return 0; +} diff --git a/test/test-strerror_s.c b/test/test-strerror_s.c new file mode 100644 index 0000000000..561b7c8e8d --- /dev/null +++ b/test/test-strerror_s.c @@ -0,0 +1,146 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include + +#define MAX_ERROR_MSG 100 + +char handler_msg[MAX_ERROR_MSG] = ""; + +static void +custom_constraint_handler(const char *restrict msg, void *restrict ptr, + errno_t error) +{ + (void)ptr; + (void)error; + strcpy(handler_msg, msg); +} + +#define TEST_RES(cond, msg, handler_res, test_id) \ + if ((!(cond)) || (handler_res == 1)) { \ + printf("Test %d Failed: %s\n", test_id, msg); \ + return 1; \ + } else { \ + printf("Test %d Passed: %s\n", test_id, msg); \ + } + +static int +test_handler_called(int handler_called, char *expected_msg, int test_id) +{ + int ret = 0; + if (handler_called == 0) { + (void)expected_msg; + if (handler_msg[0] != '\0') { + printf( + "ERROR: Custom constraint handler called without error detiction!\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } + } else { + if (handler_msg[0] == '\0') { + (void)expected_msg; + printf("ERROR: Custom constraint handler not called\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + if (strcmp(expected_msg, handler_msg) != 0) { + printf( + "ERROR: Custom constraint handler called with incorrect msg: %s\n", + handler_msg); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + (void)expected_msg; + printf( + "Custom constraint handler called with correct msg: %s\n", + handler_msg); + handler_msg[0] = '\0'; + ret = 0; + } + } + } + return ret; +} + +int +main(void) +{ + char buf[100]; + int test_id = 0; + int handler_res = 0; + errno_t res; + + set_constraint_handler_s(custom_constraint_handler); + + // Test case 1: Normal error message + test_id++; + res = strerror_s(buf, sizeof(buf), EINVAL); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Normal error message", handler_res, test_id); + TEST_RES(strcmp(buf, "Invalid argument") == 0, + "Normal error message Contents", handler_res, test_id); + + // Test case 2: Buffer too small + test_id++; + res = strerror_s(buf, 10, EINVAL); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == ERANGE, "Buffer too small", handler_res, test_id); + + // Test case 3: Null Destination Pointer + test_id++; + res = strerror_s(NULL, sizeof(buf), EINVAL); + handler_res = test_handler_called(1, "strerror_s: dest is NULL", test_id); + TEST_RES(res != 0, "Null Destination Pointer", handler_res, test_id); + + // Test case 4: Zero-length Buffer + test_id++; + res = strerror_s(buf, 0, EINVAL); + handler_res = test_handler_called( + 1, "strerror_s: dest buffer size is 0 or exceeds RSIZE_MAX", test_id); + TEST_RES(res != 0, "Zero-length Buffer", handler_res, test_id); + + // Test case 5: Unknown error code + test_id++; + res = strerror_s(buf, sizeof(buf), 12345); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Unknown error code", handler_res, test_id); + + printf("All strerror_s tests passed!\n"); + return 0; +} diff --git a/test/test-strerrorlen_s.c b/test/test-strerrorlen_s.c new file mode 100644 index 0000000000..32892e3df1 --- /dev/null +++ b/test/test-strerrorlen_s.c @@ -0,0 +1,125 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include + +#define MAX_ERROR_MSG 100 + +char handler_msg[MAX_ERROR_MSG] = ""; + +static void +custom_constraint_handler(const char *restrict msg, void *restrict ptr, + errno_t error) +{ + (void)ptr; + (void)error; + strcpy(handler_msg, msg); +} + +#define TEST_RES(cond, msg, handler_res, test_id) \ + if ((!(cond)) || (handler_res == 1)) { \ + printf("Test %d Failed: %s\n", test_id, msg); \ + return 1; \ + } else { \ + printf("Test %d Passed: %s\n", test_id, msg); \ + } + +static int +test_handler_called(int handler_called, char *expected_msg, int test_id) +{ + int ret = 0; + if (handler_called == 0) { + (void)expected_msg; + if (handler_msg[0] != '\0') { + printf( + "ERROR: Custom constraint handler called without error detiction!\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } + } else { + if (handler_msg[0] == '\0') { + (void)expected_msg; + printf("ERROR: Custom constraint handler not called\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + if (strcmp(expected_msg, handler_msg) != 0) { + printf( + "ERROR: Custom constraint handler called with incorrect msg: %s\n", + handler_msg); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + (void)expected_msg; + printf( + "Custom constraint handler called with correct msg: %s\n", + handler_msg); + handler_msg[0] = '\0'; + ret = 0; + } + } + } + return ret; +} + +int +main(void) +{ + size_t length; + int test_id = 0; + int handler_res = 0; + + set_constraint_handler_s(custom_constraint_handler); + + // Test case 1: Normal error code + test_id++; + length = strerrorlen_s(EINVAL); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(length == strlen("Invalid argument"), "Normal error code length", + handler_res, test_id); + + // Test case 2: Unknown error code + test_id++; + length = strerrorlen_s(12345); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(length == 0, "Unknown error code length", handler_res, test_id); + + printf("All strerrorlen_s tests passed!\n"); + return 0; +} diff --git a/test/test-strncat_s.c b/test/test-strncat_s.c new file mode 100644 index 0000000000..a03b7cfe8d --- /dev/null +++ b/test/test-strncat_s.c @@ -0,0 +1,174 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include + +#define MAX_ERROR_MSG 100 + +char handler_msg[MAX_ERROR_MSG] = ""; + +static void +custom_constraint_handler(const char *restrict msg, void *restrict ptr, + errno_t error) +{ + (void)ptr; + (void)error; + strcpy(handler_msg, msg); +} + +#define TEST_RES(cond, msg, handler_res, test_id) \ + if ((!(cond)) || (handler_res == 1)) { \ + printf("Test %d Failed: %s\n", test_id, msg); \ + return 1; \ + } else { \ + printf("Test %d Passed: %s\n", test_id, msg); \ + } + +static int +test_handler_called(int handler_called, char *expected_msg, int test_id) +{ + int ret = 0; + if (handler_called == 0) { + (void)expected_msg; + if (handler_msg[0] != '\0') { + printf( + "ERROR: Custom constraint handler called without error detiction!\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } + } else { + if (handler_msg[0] == '\0') { + (void)expected_msg; + printf("ERROR: Custom constraint handler not called\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + if (strcmp(expected_msg, handler_msg) != 0) { + printf( + "ERROR: Custom constraint handler called with incorrect msg: %s\n", + handler_msg); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + (void)expected_msg; + printf( + "Custom constraint handler called with correct msg: %s\n", + handler_msg); + handler_msg[0] = '\0'; + ret = 0; + } + } + } + return ret; +} + +int +main(void) +{ + char dest[50] = "Hello"; + const char *src = ", world!"; + int test_id = 0; + int handler_res = 0; + errno_t res; + + set_constraint_handler_s(custom_constraint_handler); + + // Test case 1: Normal Concatenation + test_id++; + strcpy(dest, "Hello"); + res = strncat_s(dest, sizeof(dest), src, 8); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Normal Concatenation", handler_res, test_id); + TEST_RES(strcmp(dest, "Hello, world!") == 0, + "Normal Concatenation Contents", handler_res, test_id); + + // Test case 2: Concatenation with insufficient buffer + test_id++; + strcpy(dest, "Hello"); + res = strncat_s(dest, 10, src, 8); + handler_res = test_handler_called( + 1, "strncat_s: dest buffer size insufficent to copy string", test_id); + TEST_RES(res != 0, "Concatenation with insufficient buffer", handler_res, + test_id); + + // Test case 3: Null pointers + test_id++; + res = strncat_s(NULL, sizeof(dest), src, 8); + handler_res = test_handler_called(1, "strncat_s: dest is NULL", test_id); + TEST_RES(res != 0, "NULL Destination Pointer", handler_res, test_id); + res = strncat_s(dest, sizeof(dest), NULL, 8); + handler_res = test_handler_called(1, "strncat_s: source is NULL", test_id); + TEST_RES(res != 0, "NULL Source Pointer", handler_res, test_id); + + // Test case 4: Concatenation of empty source string + test_id++; + strcpy(dest, "Hello"); + res = strncat_s(dest, sizeof(dest), "", 0); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Concatenation of empty source string", handler_res, + test_id); + TEST_RES(strcmp(dest, "Hello") == 0, + "Concatenation of empty source string Contents", handler_res, + test_id); + + // Test case 5: Concatenation with empty destination string + test_id++; + char buf2[50] = ""; + res = strncat_s(buf2, sizeof(buf2), src, 8); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Concatenation of non-empty source to empty destination", + handler_res, test_id); + TEST_RES(strcmp(buf2, ", world!") == 0, + "Concatenation of non-empty source to empty destination Contents", + handler_res, test_id); + + // Test case 6: Concatenation with Zero Characters + test_id++; + strcpy(dest, "Hello"); + res = strncat_s(dest, sizeof(dest), src, 0); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Concatenation with Zero Characters", handler_res, + test_id); + TEST_RES(strcmp(dest, "Hello") == 0, + "Concatenation with Zero Characters Contents", handler_res, + test_id); + + printf("All strncat_s tests passed!\n"); + return 0; +} diff --git a/test/test-strncpy_s.c b/test/test-strncpy_s.c new file mode 100644 index 0000000000..36f8f517c1 --- /dev/null +++ b/test/test-strncpy_s.c @@ -0,0 +1,154 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include + +#define MAX_ERROR_MSG 100 + +char handler_msg[MAX_ERROR_MSG] = ""; + +static void +custom_constraint_handler(const char *restrict msg, void *restrict ptr, + errno_t error) +{ + (void)ptr; + (void)error; + strcpy(handler_msg, msg); +} + +#define TEST_RES(cond, msg, handler_res, test_id) \ + if ((!(cond)) || (handler_res == 1)) { \ + printf("Test %d Failed: %s\n", test_id, msg); \ + return 1; \ + } else { \ + printf("Test %d Passed: %s\n", test_id, msg); \ + } + +static int +test_handler_called(int handler_called, char *expected_msg, int test_id) +{ + int ret = 0; + if (handler_called == 0) { + (void)expected_msg; + if (handler_msg[0] != '\0') { + printf( + "ERROR: Custom constraint handler called without error detiction!\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } + } else { + if (handler_msg[0] == '\0') { + (void)expected_msg; + printf("ERROR: Custom constraint handler not called\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + if (strcmp(expected_msg, handler_msg) != 0) { + printf( + "ERROR: Custom constraint handler called with incorrect msg: %s\n", + handler_msg); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + (void)expected_msg; + printf( + "Custom constraint handler called with correct msg: %s\n", + handler_msg); + handler_msg[0] = '\0'; + ret = 0; + } + } + } + return ret; +} + +int +main(void) +{ + char dest[50]; + const char *src = "Hello, world!"; + int test_id = 0; + int handler_res = 0; + errno_t res; + + set_constraint_handler_s(custom_constraint_handler); + + // Test case 1: Normal copy + test_id++; + res = strncpy_s(dest, sizeof(dest), src, 13); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Normal Copy", handler_res, test_id); + TEST_RES(strcmp(dest, "Hello, world!") == 0, "Normal Copy Contents", + handler_res, test_id); + + // Test case 2: Copy with insufficient buffer + test_id++; + res = strncpy_s(dest, 5, src, 13); + handler_res = test_handler_called( + 1, "strncpy_s: dest buffer size insufficent to copy string", test_id); + TEST_RES(res != 0, "Copy with insufficient buffer", handler_res, test_id); + + // Test case 3: Null pointers + test_id++; + res = strncpy_s(NULL, sizeof(dest), src, 13); + handler_res = test_handler_called(1, "strncpy_s: dest is NULL", test_id); + TEST_RES(res != 0, "NULL Destination Pointer", handler_res, test_id); + res = strncpy_s(dest, sizeof(dest), NULL, 13); + handler_res = test_handler_called(1, "strncpy_s: source is NULL", test_id); + TEST_RES(res != 0, "NULL Source Pointer", handler_res, test_id); + + // Test case 4: Copy of empty string + test_id++; + res = strncpy_s(dest, sizeof(dest), "", 0); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Copy of empty string", handler_res, test_id); + TEST_RES(strcmp(dest, "") == 0, "Copy of empty string Contents", + handler_res, test_id); + + // Test case 5: Copy with zero Characters + test_id++; + res = strncpy_s(dest, sizeof(dest), "Hello, world!", 0); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(res == 0, "Copy with zero Characters", handler_res, test_id); + TEST_RES(strcmp(dest, "") == 0, "Copy with zero Characters Contents", + handler_res, test_id); + + printf("All strncpy_s tests passed!\n"); + return 0; +} diff --git a/test/test-strnlen_s.c b/test/test-strnlen_s.c new file mode 100644 index 0000000000..a08f866284 --- /dev/null +++ b/test/test-strnlen_s.c @@ -0,0 +1,150 @@ +/* + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright © 2024, Synopsys Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#define __STDC_WANT_LIB_EXT1__ 1 +#include +#include +#include +#include + +#define MAX_ERROR_MSG 100 + +char handler_msg[MAX_ERROR_MSG] = ""; + +static void +custom_constraint_handler(const char *restrict msg, void *restrict ptr, + errno_t error) +{ + (void)ptr; + (void)error; + strcpy(handler_msg, msg); +} + +#define TEST_RES(cond, msg, handler_res, test_id) \ + if ((!(cond)) || (handler_res == 1)) { \ + printf("Test %d Failed: %s\n", test_id, msg); \ + return 1; \ + } else { \ + printf("Test %d Passed: %s\n", test_id, msg); \ + } + +static int +test_handler_called(int handler_called, char *expected_msg, int test_id) +{ + int ret = 0; + if (handler_called == 0) { + (void)expected_msg; + if (handler_msg[0] != '\0') { + printf( + "ERROR: Custom constraint handler called without error detiction!\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } + } else { + if (handler_msg[0] == '\0') { + (void)expected_msg; + printf("ERROR: Custom constraint handler not called\n"); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + if (strcmp(expected_msg, handler_msg) != 0) { + printf( + "ERROR: Custom constraint handler called with incorrect msg: %s\n", + handler_msg); + printf("Test %d Failed: Error msg is incorrect\n", test_id); + ret = 1; + } else { + (void)expected_msg; + printf( + "Custom constraint handler called with correct msg: %s\n", + handler_msg); + handler_msg[0] = '\0'; + ret = 0; + } + } + } + return ret; +} + +int +main(void) +{ + size_t length; + int test_id = 0; + int handler_res = 0; + + set_constraint_handler_s(custom_constraint_handler); + + // Test case 1: Normal length + test_id++; + length = strnlen_s("Hello, world!", 50); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(length == 13, "Normal length", handler_res, test_id); + + // Test case 2: Length with exact buffer size + test_id++; + length = strnlen_s("Hello, world!", 13); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(length == 13, "Length with exact buffer size", handler_res, + test_id); + + // Test case 3: Length with insufficient buffer + test_id++; + length = strnlen_s("Hello, world!", 5); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(length == 5, "Length with insufficient buffer", handler_res, + test_id); + + // Test case 4: Length of empty string + test_id++; + length = strnlen_s("", 50); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(length == 0, "Length of empty string", handler_res, test_id); + + // Test case 5: Length with Null string + test_id++; + length = strnlen_s(NULL, 50); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(length == 0, "Length with Null string", handler_res, test_id); + + // Test case 6: Length with zero buffer size + test_id++; + length = strnlen_s("Hello, world!", 0); + handler_res = test_handler_called(0, "", test_id); + TEST_RES(length == 0, "Length with zero buffer size", handler_res, test_id); + + printf("All strnlen_s tests passed!\n"); + return 0; +}