aboutsummaryrefslogtreecommitdiff
path: root/newlib
AgeCommit message (Collapse)AuthorFilesLines
5 hoursnewlib: Regenerate configuration filesHEADmastermainm fally1-26/+26
Regenerate the configuration files since a file was replaced in the RISC-V port, and one other file was renamed. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: m fally <marlene.fally@gmail.com>
5 hoursRISC-V: memmove() speed optimized: Call memcpy()m fally1-67/+93
Redirect to memcpy() if the memory areas of source and destination do not overlap. Only redirect if length is > SZREG in order to reduce overhead on very short copies. Signed-off-by: m fally <marlene.fally@gmail.com>
5 hoursRISC-V: memmove() speed optimized: Align source addressm fally1-50/+135
If misaligned accesses are slow or prohibited, either source or destination address are unaligned and the number of bytes to be copied is > SZREG*2, align the source address to xlen. This speeds up the function in the case where at least one address is unaligned, since now one word (or doubleword for rv64) is loaded at a time, therefore reducing the amount of memory accesses necessary. We still need to store back individual bytes since the destination address might (still) be unaligned after aligning the source. The threshold of SZREG*2 was chosen to keep the negative effect on shorter copies caused by the additional overhead from aligning the source low. This change also affects the case where both adresses are xlen- aligned, the memory areas overlap destructively, and length is not a multiple of SZREG. In the destructive-overlap case, the copying needs to be done in reversed order. Therefore the length is added to the addresses first, which causes them to become unaligned. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: m fally <marlene.fally@gmail.com>
5 hoursRISC-V: memmove() speed optimized: Add loop-unrollingm fally1-9/+48
Add loop-unrolling for the case where both source and destination address are aligned in the case of a destructive overlap, and increase the unroll factor from 4 to 9 for the word-by-word copy loop in the non-destructive case. This matches the loop-unrolling done in memcpy() and increases performance for lenghts >= SZREG*9 while almost not at all degrading performance for shorter lengths. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: m fally <marlene.fally@gmail.com>
5 hoursRISC-V: memmove() speed optimized: Replace macros and use fixed-width typesm fally1-25/+35
Replace macros with static inline functions or RISC-V specifc macros in order to keep consistency between all functions in the port. Change data types to fixed-width and/or RISC-V specific types. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: m fally <marlene.fally@gmail.com>
5 hoursRISC-V: memmove() speed optimized: Add implementationm fally4-15/+100
Copy the common implementation of memmove() to the RISC-V port. Rename memmove.S to memmove-asm.S to keep naming of files consistent between functions. Update Makefile.inc with the changed filenames. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: m fally <marlene.fally@gmail.com>
13 hoursposix_spawn: preserve FD flags when processing FAE_OPENJeremy Drake1-3/+11
According to the POSIX documentation, "when the new process image is executed, any file descriptor (from this new set) which has its FD_CLOEXEC flag set shall be closed (see posix_spawn())." The "new set" is after processing the file actions, so if addopen had the O_CLOEXEC flag set the descriptor should be closed after the exec. The adddup2 docs, by contrast, specify that the flag should be cleared, even if dup2 wouldn't have done so due to the specified file descriptors being equal. Add a comment to that effect. Addresses: https://sourceware.org/pipermail/newlib/2025/021968.html Fixes: c7c1a1ca1b ("2013-10-01 Petr Hosek <phosek@chromium.org>") Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
5 dayslibc: mips: fix strcmp bug for little endian targetsFaraz Shahbazker1-2/+5
strcmp gives incorrect result for little endian targets under the following conditions: 1. Length of 1st string is 1 less than a multiple of 4 (i.e len%4=3) 2. First string is a prefix of the second string 3. The first differing character in the second string is extended ASCII (that is > 127) Signed-off-by: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>
5 dayslibc: mips: Improve performance of strcmp implementationFaraz Shahbazker1-79/+123
Improve `strcmp` by using `ext` instruction, if available. Signed-off-by: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>
5 dayslibc: mips: memcpy prefetches beyond copied memoryFaraz Shahbazker1-53/+97
Fix prefetching in core loop to avoid exceeding the operated upon memory region. Revert accidentally changed prefetch-hint back to streaming mode. Refactor various bits and provide pre-processor checks to allow parameters to be overridden from compiler command line. Signed-off-by: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>
5 dayslibc: mips: Add improved C implementation of memcpy/memsetFaraz Shahbazker4-5/+586
Signed-off-by: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>
5 daysmips: Implement MIPS HAL and UHIJovan Dmitrović8-121/+158
Implement abstract interface for MIPS, including unified hosting interface (UHI). Signed-off-by: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>
6 daysaarch64: Export fe{enable,disable,get}except on CygwinRadek Bartoň1-4/+12
For aarch64 on ELF targets, the library does not export fe{enable,disable,get}except as symbols from the library, relying on static inline functions to provide suitable definitions if required. But for Cygwin we need to create real definitions to satisfy the DLL export script. So arrange for real definitions of these functions when building on Cygwin. Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
8 dayswcstombs: also call __WCTOMB on terminating NUL if output buffer is NULLChristian Franke1-3/+4
A __WCTOMB call on the terminating NUL may emit more than a NUL byte. This is the case if the string ends with a lone UTF-16 high surrogate. Fixes: 2a3a02a68764 ("Add SUSV2 support for calculating size if output buffer is NULL") Signed-off-by: Christian Franke <christian.franke@t-online.de>
8 daysnewlib: increase jump buffer length to 25 to fit all non-volatile registers ↵Radek Bartoň1-1/+10
for aarch64-pc-cygwin Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
8 daysRISC-V: Fix memcpy() for GCC 13Sebastian Huber1-2/+2
GCC 13 does not define the __riscv_misaligned_* builtin defines. They are supported by GCC 14 or later. Test for __riscv_misaligned_fast to select an always correct memcpy() implementation for GCC 13. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
11 dayswcrtomb: fix CESU-8 value of leftover lone high surrogateChristian Franke1-2/+2
Addresses: https://cygwin.com/pipermail/cygwin/2025-June/258378.html Fixes: 6ff28fc3b121 ("Allow CESU-8 surrogate value encoding") Signed-off-by: Christian Franke <christian.franke@t-online.de>
13 daysmbrtowc: fix handling invalid UTF-8 4 byte sequences if wchar_t == UTF-16Corinna Vinschen1-9/+16
When commit 28186e81d947 split _mbtowc_r into per-codeset functions, the code generating wchar_t from UTF-8 input was slightly rearranged. Unfortunately the new code introduced a bug: On systems with wchar_t being UTF-16, 4 byte sequences have to be converted to surrogate pairs. The low surrogate pair can be fully created from the first 3 bytes of the sequence. However, the surrogates should only be created if it's clear that the 4th byte is valid, and the entire 4 byte string represents a valid UTF-8 sequence. The code change in 28186e81d947 neglected just that: In contrast to the original code, it now created the low surrogate after having read the first 3 bytes of the sequence, without checking validity of the 4th byte. This patch moves the test sequence to check the 4th byte in front of the code generating the low surrogate. Make sure to return the value 3 (3 bytes digested) rather than the content of the local variable i, which is already set to 4 at this point. Reported-by: Christian Franke <Christian.Franke@t-online.de> Addresses: https://cygwin.com/pipermail/cygwin/2025-June/258358.html Fixes: 28186e81d947 ("* libc/ctype/iswalpha.c: Handle all wchar_t as unicode on _MB_CAPABLE systems.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-06-24libc: Update the guard for quick_exit() and at_quick_exit() functionsMazen Adel Elmessady1-1/+4
Updated the guard for stdlib functions to use the POSIX Issue 8 guard added in 2024.
2025-06-24libc: Added the prototype for ppoll()Mazen Adel Elmessady1-0/+9
Added prototype of ppoll() to newlib/libc/sys/rtems/include/sys/poll.h
2025-06-24libc: Added the prototype for sem_clockwait()Mazen Adel Elmessady1-0/+6
Added the prototype for sem_clockwait() to newlib/libc/sys/rtems/include/semaphore.h
2025-06-24libc/../pthread.h: Updated the guard for Posix Issue 8 functionsMazen Adel Elmessady1-6/+6
Updated the guard for pthread functions added in POSIX Issue 8 to use the POSIX Issue 8 guard added in 2024. These functions are: pthread_mutex_clocklock() pthread_cond_clockwait() pthread_rwlock_clockrdlock() pthread_rwlock_clockwrlock()
2025-06-24libc: Added timespec_get() to time.hMazen Adel Elmessady1-0/+5
Added timespec_get() prototype to libc/include/time.h and removed the prototype from winsup/cygwin/include/cygwin/time.h
2025-06-18add value for _h_errno in _REENT_INIT(var) for struct, _reentJohannes Rosa1-1/+2
The define '_REENT_INIT' for the case '!_REENT_SMALL' was missing an initializing value for 'int _h_errno'. If code uses the _REENT_INIT() macro to preset a variable of type struct _reent, this led to an issue when compiling with -Wmissing-field-initializers.
2025-06-18posix_spawn: factor out structs to an internal headerJeremy Drake2-44/+55
This will allow Cygwin to examine and handle the posix_spawnattr_t and posix_spawn_file_actions_t arguments itself. Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2025-06-18newlib: libc: define _ctype for AArch64 CygwinRadek Bartoň1-9/+0
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
2025-06-14rtems/include/limits.h: Do not define AIO_LISTIO_MAX or AIO_MAXJoel Sherrill1-4/+6
Per https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/limits.h.html, these limits.h constants should not be defined if the implementation does not have an inherent limit. These are based on available memory for RTEMS.
2025-06-14rtems/../sys/dirent.h: Enable DT_ symbols for POSIX >= 202405LJoel Sherrill1-1/+1
Issue 8 added these symbols which which previously BSD extensions.
2025-06-02RISC-V: strcmp [speed optimized]: optimize mismatch logic for targets with ↵puranikvinit1-63/+94
Zb* extension support Reworks the mismatch handling to use Zbb's ctz/clz instructions for faster byte difference detection, significantly improving performance on Zbb-capable targets. Non-Zbb targets retain the original logic for compatibility. Signed-off-by: puranikvinit <kvp933.vinit@gmail.com> Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
2025-06-02RISC-V: strcmp [speed optimized]: optimize null detect logic for targets ↵puranikvinit1-4/+8
with Zb* extension support Introduces conditional use of the orc.b instruction from the Zbb extension for null byte detection, falling back to the original logic for non-Zbb targets. This reduces cycles in the hot path for supported architectures. Signed-off-by: puranikvinit <kvp933.vinit@gmail.com> Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
2025-06-02RISC-V: strcmp [speed optimized]: use compressed registers wherever possiblepuranikvinit1-4/+4
Replaces temporary registers (t0) with compressed registers (a4) in the null detection loop, reducing instruction count and code size in speed-optimized builds while maintaining identical logic. Signed-off-by: puranikvinit <kvp933.vinit@gmail.com> Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
2025-06-02RISC-V: strcmp: refactor labels for improved readabilitypuranikvinit1-13/+18
Renames labels in strcmp.S to use descriptive .L prefixes (e.g., .Lcompare, .Lreturn_diff) instead of numeric labels (e.g., 1f, 2f). This improves maintainability and aligns with modern assembly conventions without affecting functionality. Signed-off-by: puranikvinit <kvp933.vinit@gmail.com> Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
2025-06-02RISC-V: setjmp: reduce code size for register load/store with Zilsdpuranikvinit1-25/+49
This patch optimizes the RISC-V setjmp implementation in newlib/libc/machine/riscv/setjmp.S for 32-bit targets. It reduces code size by using doubleword store/load instructions (sd/ld) when the Zilsd or Zclsd extensions are available for saving and restoring s0-s11 registers, while preserving the original single-word instructions (REG_S/REG_L) for compatibility with other configurations. Signed-off-by: puranikvinit <kvp933.vinit@gmail.com> Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> RISC-V: setjmp: reduce code size for register load/store with Zilsd
2025-06-02newlib: riscv: Remove undefined behavior in strlen()Eric Salem1-1/+4
Pointer arithmetic overflow is undefined behavior, so use a signed type to avoid it. Signed-off-by: Eric Salem <ericsalem@gmail.com>
2025-05-28newlib: riscv: Align whitespace of size optimized memset()Eric Salem1-4/+4
Align the whitespace of the size optimized implementation of memset() to match the speed optimized version. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: Eric Salem <ericsalem@gmail.com>
2025-05-28newlib: riscv: Optimize memset() for speedEric Salem1-71/+262
The RISC-V Zba, Zbkb, and Zilsd/Zclsd extensions provide instructions optimized for bit and load/store operations. Use them when available for the RISC-V port. Also increase loop unrolling for faster performance. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: Eric Salem <ericsalem@gmail.com>
2025-05-27RISC-V: memcpy() align dest when misaligned access is prohibitedMahmoud Abumandour1-12/+60
Add a code path for when source and dest are differently aligned. If misaligned access is slow or prohibited, and the alignments of the source and destination are different, we align the destination to do XLEN stores. This uses only one aligned store for every four (or eight for XLEN == 64) bytes of data. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: Mahmoud Abumandour <ma.mandourr@gmail.com>
2025-05-27RISC-V: memcpy() Use inline functions instead of macros and gotosMahmoud Abumandour1-18/+24
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: Mahmoud Abumandour <ma.mandourr@gmail.com>
2025-05-27RISC-V: memcpy() Use uintxlen_t for xlen-sized copyMahmoud Abumandour1-35/+36
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: Mahmoud Abumandour <ma.mandourr@gmail.com>
2025-05-22glob: Fix old style function declarations warningsSebastian Huber1-64/+22
2025-05-22glob: Fix incompatible pointer types errorSebastian Huber1-2/+2
This fixes a compile error with GCC 15.
2025-05-22ftw: Fix incompatible pointer types errorSebastian Huber1-1/+3
This fixes a compile error with GCC 15.
2025-05-21libm: riscv: Reduce sqrt and sqrtf function for code sizezhusonghe2-0/+2
The merged below patch modifies the __ieee754_sqrtf and __ieee754_sqrt functions to use a shared implementation, replacing the original fsqrt.d[s] instruction usage. patch:https://sourceware.org/git/?p=newlib-cygwin.git;a=commit;h=d572c4482b473d7725be0f9380d4f5d8342e4390 Signed-off-by: Songhe Zhu <zhusonghe@eswincomputing.com>
2025-05-21newlib: Regenerate configuration fileEric Salem1-2/+39
Two new C files were added to the RISC-V build, so regenerate the relevant configuration file. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: Eric Salem <ericsalem@gmail.com>
2025-05-21newlib: riscv: Optimize memchr() and memrchr()Eric Salem4-83/+249
The RISC-V Zbb, Zbkb, and Zilsd extensions provide instructions optimized for bit and load/store operations. Use them when available for the RISC-V port. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: Eric Salem <ericsalem@gmail.com>
2025-05-21newlib: riscv: Add memchr() and memrchr() implementationsEric Salem3-1/+199
Copy stock implementations of memchr() and memrchr() to the RISC-V port. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: Eric Salem <ericsalem@gmail.com>
2025-05-14Remove Marcus Shawcroft from MAINTAINERSRichard Earnshaw1-1/+0
2025-05-02newlib: riscv: Remove unnecessary byte load for strlen()Eric Salem1-7/+7
For architectures where XLEN is 32 bits, when detecting a null byte, a word is read at a time. Once a null is found in the word, its precise location is then determined. Make clear to the compiler that if the first three bytes are not null, the last byte must be null, and does not need to be read from the string, since its value is always zero. Reviewed-by: Christian Herber <christian.herber@oss.nxp.com> Signed-off-by: Eric Salem <ericsalem@gmail.com>
2025-05-02Newlib: Update search.h functions for POSIX.1-2024Mark Geisert5-9/+11
Add type posix_tnode. Change certain uses of "void" to "posix_tnode" in both the prototypes and definitions of functions associated with <search.h>. (Necessary changes to Cygwin's /usr/include/search.h will follow in a separate patch to be sent to cygwin-patches.) Reported-by: Collin Funk <collin.funk1@gmail.com> Addresses: https://cygwin.com/pipermail/cygwin/2025-April/258032.html Signed-off-by: Mark Geisert <mark@maxrnd.com> Fixes: ec98d19a08c2 "* wininfo.h (wininfo::timer_active): Delete."
2025-04-28makedocbook: Avoid python deprecation warningsJon Turney1-2/+2
Avoid some deprecation warnings with recent python: > .../newlib/doc/makedocbook.py:201: DeprecationWarning: 'count' is passed as positional argument > .../newlib/doc/makedocbook.py:566: DeprecationWarning: 'count' is passed as positional argument