Age | Commit message (Collapse) | Author | Files | Lines |
|
Replace add instructions with addi where applicable in
the size optimized versions of memmove(), memset(), memcpy(),
and strcmp(). This change does not affect the functions themselves
and is only done to improve syntactic accuracy.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: m fally <marlene.fally@gmail.com>
|
|
Rename local labels to improve readability.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: m fally <marlene.fally@gmail.com>
|
|
Swap register t1 with a3, so that the affected instructions can be compressed.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Reviewed-by: m fally <marlene.fally@gmail.com>
Signed-off-by: Eric Salem <ericsalem@gmail.com>
|
|
Replace registers t1 and t2 with registers a3 and a4 respectively,
so that the affected instructions can be compressed.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: Mahmoud Abumandour <ma.mandourr@gmail.com>
|
|
Replace lb with lbu to avoid unnecessary sign extension.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: Mahmoud Abumandour <ma.mandourr@gmail.com>
|
|
Move the instruction that increments the remaining number of
bytes to be copied inbetween the load and store instructions.
This is done in order to relax the RAW dependency between the
load and store instructions.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: m fally <marlene.fally@gmail.com>
|
|
Replace lb with lbu to avoid unnecessary sign extension.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: m fally <marlene.fally@gmail.com>
|
|
Since the algorithm in this version of memmove() is different
from the original version, add comments to give a description.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Reviewed-by: Eric Salem <ericsalem@gmail.com>
Signed-off-by: m fally <marlene.fally@gmail.com>
|
|
Rename local lables so that the structure of the function is clearer.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: m fally <marlene.fally@gmail.com>
|
|
Change register t1 to register a4, so that the affected instructions
can be compressed. Since now we have less registers available, the
following changes need to be made:
In the previous version of this function, a4 was used to hold the offset
that needs to be added to source and destination addresses before copying
any data in the case of source address > destination address.
Since a4 now holds the destination address, this offset is not calculated
anymore. Instead, the value in a2 (the number of bytes to be copied) is added
to the source and destination addresses. Therefore, in the case of
source address > destination adress, a value of 1 needs to be subtracted
from both addresses before starting the copying process.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: m fally <marlene.fally@gmail.com>
|
|
Replace register t2 with register a5, so that lb/sb instructions can be compressed.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: m fally <marlene.fally@gmail.com>
|
|
Addresses: https://sourceware.org/pipermail/cygwin-patches/2025q2/013644.html
Fixes: 3e8a7eb1a868 ("sys/unistd.h: fix definition of setproctitle_init")
Reported-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
Co-authored-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
The sys/asm.h header file is included for certain assembly files, so
move the typedef to a separate header file due to the build breaking on
some systems. Also include the port's string header file (and move and
rename) instead of the system's version.
Addresses: https://sourceware.org/pipermail/newlib/2025/021591.html
Fixes: c3b9bb173c8c ("newlib: riscv: Add XLEN typedef and clean up types")
Reported-by: Jeff Law <jlaw@ventanamicro.com>
Suggested-by: Kito Cheng <kito.cheng@gmail.com>
Signed-off-by: Eric Salem <ericsalem@gmail.com>
|
|
The large code model assume the data may far away from the code, so we
must put the address of the target data wihin the `.text` section,
normally we will just put within the function or nearby the function to
prevent it out-of-range.
Report from riscv-gnu-toolchain:
https://github.com/riscv-collab/riscv-gnu-toolchain/issues/1699
Verified with riscv-gnu-toolchain with rv64gc.
|
|
Since January, GCC has been miscompiling Newlib libm on AMD GCN due to
undefined behaviour in the RESIZE_VECTOR macro. It was "working" but expanding
the size of a vector would no longer zero the additional lanes, as it expected.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119325
|
|
Following the changes from Austin Group bug
https://www.austingroupbugs.net/view.php?id=1741, getlocalename_l()
now allows to specify LC_ALL and returns a setlocale-conmpatible
LC_ALL locale string.
Consequentially we have to raise the size of _reent::_getlocalename_l_buf
so there's enough space for the LC_ALL locale string.
Guard all different definitions and usages of _getlocalename_l_buf
in reent.h with _MB_CAPABLE.
Link: https://www.austingroupbugs.net/view.php?id=1741
Fixes: 71511d4ac868 ("getlocalename_l: implement per SUS Base Specifications Issue 8 draft")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
After 71511d4ac868 ("getlocalename_l: implement per SUS Base
Specifications Issue 8 draft") the Austin Group changed the definition
of getlocalename_l() to return setlocale-compatible strings if LC_ALL
has been specified. In contrast to the former definition which
disallowed LC_ALL as category.
In preparation, add a locale_string to every locale_t, and drop
the static global_locale_string.
This in turn requires to change currentlocale() to work locale-agnostic.
Rename to __currentlocale and take two parameters, the locale object
and a target string to store the locale string. The latter is required
to allow specifiying a target string not in the current locale.
Link: https://www.austingroupbugs.net/view.php?id=1741
Fixes: 71511d4ac868 ("getlocalename_l: implement per SUS Base Specifications Issue 8 draft")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Fix name of the defining POSIX standard.
Fixes: 71511d4ac868 ("getlocalename_l: implement per SUS Base Specifications Issue 8 draft")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
The data was written to the per-reent getlocalename buffer,
but the value wasn't returned.
Fixes: 71511d4ac868 ("getlocalename_l: implement per SUS Base Specifications Issue 8 draft")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
A new C file was added to the RISC-V build
|
|
Add implementation of stpcpy() to the RISC-V port. Also refactor shared
code between strcpy() and stpcpy() to a common function.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: Eric Salem <ericsalem@gmail.com>
|
|
The RISC-V Zbb extension provides instructions optimized for bit
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>
|
|
The size of the long data type isn't precisely defined in the C
standard, so create a new typedef that uses either uint32_t or uint64_t
based on XLEN. The fixed width types are more robust against any ABI
changes and fit the data types of the intrinsic functions. Use the new
uintxlen_t type instead of long and uintptr_t.
Reviewed-by: Christian Herber <christian.herber@oss.nxp.com>
Signed-off-by: Eric Salem <ericsalem@gmail.com>
|
|
without "_printf_float" being linked
Patch fixes wrong number of written characters being returend from 'printf'
family of functionsx when '_printf_float' is not linked (nano.specs). If user
tries to print a floating point number anyway, returned number of written
characters is not correct. For example in
printf("%d%f", 1, 1.0);
should return 1, but actaully returns 2.
|
|
sigaction() returns EINVAL on SIGKILL & SIGSTOP. We need to skip them.
Fixes: c7c1a1ca1b33 ("* libc/posix/posix_spawn.c: New file.")
|
|
setproctitle_init is defined in c2x manner, omitting names for
the unused parameters. This can result in warnings or errors
on certain compiler versions:
clang 8:
error: parameter name omitted
clang 15:
warning: omitting the parameter name in a function definition is a C2x
extension [-Wc2x-extensions]
gcc -Wsystem-headers -pedantic -std=c17:
warning: ISO C does not support omitting parameter names in function
definitions before C2X [-Wpedantic]
Add parameters to avoid above warning and errors.
Fixes: 2e7f7b96e5f1 ("Cygwin: implement setproctitle")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
This patch fixes "integer overflow" warning in arc4random.c. It explicitly
casts REKEY_BASE macro to size_t. The existing code relies on an implicit
conversion to int and assumes that sizeof(int)=sizeof(size_t), which is
not always true.
2025-03-02 Jan Dubiec <jdx@o2.pl>
newlib/ChangeLog:
* libc/stdlib/arc4random.c (REKEY_BASE): Explicitly cast the macro
to size_t.
newlib/libc/stdlib/arc4random.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
This patch fixes a few "left shift count >= width of type
[-Wshift-count-overflow]" warnings. Before shifting a char 16 (or more)
bits left first it explicitly casts the char to uint32_t. The existing
code relies on implicit casts to int and assumes that ints are 32-bit.
This is not always true because the C standard does not require int to
be 32-bit and there are targets (e.g. H8/300) where by default int is
indeed 16-bit.
2025-03-02 Jan Dubiec <jdx@o2.pl>
newlib/ChangeLog:
* libc/stdlib/gdtoa-gdtoa.c (gdtoa): Cast to __ULong before left shift.
* libc/string/memmem.c (memmem): Cast to uint32_t before left shift.
* libc/string/strstr.c (strstr2): Ditto.
(strstr3): Ditto.
(strstr4): Ditto.
newlib/libc/stdlib/gdtoa-gdtoa.c | 2 +-
newlib/libc/string/memmem.c | 3 ++-
newlib/libc/string/strstr.c | 6 +++---
3 files changed, 6 insertions(+), 5 deletions(-)
|
|
2025-03-02 Jan Dubiec <jdx@o2.pl>
newlib/ChangeLog:
* libc/sys/h8300hms/sbrk.c: Replace the K&R definition with the
standard one.
* libc/sys/h8300hms/syscalls.c (_isatty): Ditto.
(_unlink): Ditto.
newlib/libc/sys/h8300hms/sbrk.c | 3 +--
newlib/libc/sys/h8300hms/syscalls.c | 6 ++----
2 files changed, 3 insertions(+), 6 deletions(-)
|
|
This improves compatibility with clang that does not support vfpxd and does not need these extra directives.
Change-Id: Id2027e622aef8457ac9c7e1d6715a9240ce8e3f0
|
|
This is to improve compatibility with LLVM clang: .align 0 is a special case for GCC that is not handled by clang.
Change-Id: I855939a32294c74813ecce7275a362265dbc3b1a
|
|
The strcasecmp family of functions (strcasecmp, strncasecmp,
strcasecmp_l, strncasecmp_l) call tolower on the incoming
character before comparison. tolower takes an int as parameter.
All four strcasecmp functions neglect to cast the character to
unsigned before using it as parameter to tolower. This tolower
is called with negative values if the incoming character is not
in the ASCII range. This breaks case-insensitive comparison in
other singlebyte codesets like ISO-8859-1 with native characters.
Adding casts to unsigned char when calling tolower fixes it.
Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
https://pubs.opengroup.org/onlinepubs/9799919799/functions/lseek.html
Signed-off-by: Christian Franke <christian.franke@t-online.de>
|
|
- related to Bug libc/32679
|
|
- fixes Bug libc/32679
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Some hardware may perform better when copying unaligned
word-sized memory compared to byte-by-byte copying.
In case not defined explicitly by --enable-newlib-hw-misaligned-access
config option or variable $default_newlib_hw_misaligned_access in
configure.host file the compiler check will be performed to detect if
__riscv_misaligned_fast or __riscv_misaligned_slow is defined.
This commit introduces autodetection for RISC-V. Additionally, checking
for __ARM_FEATURE_UNALIGNED could be checked for ARM architecture.
However, this was not implemented in the commit, as changes in
newlib/libc/machine/[arm|aarch64] need to be performed.
|
|
Prepare pointer to be aligned and than use word-size iterator on aligned
memory.
|
|
This change provides word-sized copy for overlapping buffers, that could
increase performance significantly. Performance measurement for RISCV:
uint8_t buf[1024];
memmove (buf + 4, buf, sizeof(buf) - 4);
CPU cycles: 12255 -> 2076
|
|
This change improves performance on memory blocks with sizes in range
[4..15]. Performance measurements made for RISCV machine (memset):
size 4, CPU cycles change: 50 -> 37
size 5, CPU cycles change: 57 -> 40
size 6, CPU cycles change: 64 -> 47
size 7, CPU cycles change: 71 -> 54
size 8, CPU cycles change: 78 -> 44
size 9, CPU cycles change: 85 -> 47
size 10, CPU cycles change: 92 -> 54
size 11, CPU cycles change: 99 -> 61
size 12, CPU cycles change: 106 -> 51
size 13, CPU cycles change: 113 -> 54
size 14, CPU cycles change: 120 -> 61
size 15, CPU cycles change: 127 -> 68
|
|
This change made just to have memccpy like others mem-functions
|
|
Move common macros to local.h header
|
|
add --enable-newlib-use-malloc-in-execl option
The previous version of these functions allocated a 256 entry array and
copied arguments in that array with no bound checking. That
implementation always occupied 1024 bytes of stack for the array even in
the common case in which the number of passed arguments is far less than
256, risking stack overflows in environments with small stacks, and
caused a stack buffer overflow if called with more than 256 arguments.
The improved implementation counts the actual number of passed arguments
and allocates a suitable buffer. The default implementation uses alloca
to allocate the buffer to satisfy the POSIX.1-2008 requirement that
execl and execle should be callable from signal handlers, but it is
possible to override this behavior and use malloc for targets where the
risk of stack overflow due to unbounded stack allocations is a more
pressing requirement than the corner case of allowing execl calls from
signal handlers.
|
|
The libc/sys/xtensa directory was removed in commit 48f1655c955c154b3165692e02aa66699212453c, but the change to Makefile.in wasn't committed.
|
|
Declare posix_close, a new function defined by POSIX-1.2024, per
https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_close.html
Define POSIX_CLOSE_RESTART.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
posix_devctl is now part of POSIX-1.2024, thus the requirement to
define _POSIX_26_C_SOURCE has been dropped.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
MISSING_SYSCALL_NAMES defined
If the macros REENTRANT_SYSCALLS_PROVIDED and MISSING_SYSCALL_NAMES are defined some
_reent_*-functions are replaced by the system-call and this leads to compile-warning
or a runtime-failure.
* newlib/libc/stdio/fopen.c _open_r is replaces by open(), declared in <fcntl.h>
* newlib/libc/stdio64/fopen64.c ditto
* newlib/libc/stdio/rename.c _rename_r is rename() itself; i.e, fix recursion
|
|
POSIX®.1-2024 now defines posix_spawn_file_actions_addchdir and
posix_spawn_file_actions_addfchdir. Add these interfaces to spawn.h,
guarded as POSIX 202405 symbols.
Cygwin-only: Export them as aliases of the *_np counterparts. Bump
API minor.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Regenerate Makefile.in.
Fixes: 71511d4ac8686 ("getlocalename_l: implement per SUS Base Specifications Issue 8 draft")
Reported-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
- bump up release to 4.5.0
|