aboutsummaryrefslogtreecommitdiff
path: root/newlib
AgeCommit message (Collapse)AuthorFilesLines
2023-10-05aarch64: Import memrchr.SSebastian Huber4-0/+168
Import memrchr.S for AArch64 from: https://github.com/ARM-software/optimized-routines commit 0cf84f26b6b8dcad8287fe30a4dcc1fdabd06560 Author: Sebastian Huber <sebastian.huber@embedded-brains.de> Date: Thu Jul 27 17:14:57 2023 +0200 string: Fix corrupt GNU_PROPERTY_TYPE (5) size For ELF32 the notes alignment is 4 and not 8.
2023-10-05aarch64: Sync with ARM-software/optimized-routinesSebastian Huber14-1666/+1226
Update AArch64 assembly string routines from: https://github.com/ARM-software/optimized-routines commit 0cf84f26b6b8dcad8287fe30a4dcc1fdabd06560 Author: Sebastian Huber <sebastian.huber@embedded-brains.de> Date: Thu Jul 27 17:14:57 2023 +0200 string: Fix corrupt GNU_PROPERTY_TYPE (5) size For ELF32 the notes alignment is 4 and not 8. Add license and copyright information to COPYING.NEWLIB as entry (56).
2023-09-25newlib: Add missing prototype for _getentropyTorbjörn SVENSSON1-0/+1
2023-09-18newlib: Fix header installAlexey Lapshin2-2/+2
2023-09-11Reentrancy, attempt to always provide _Thread_local in <sys/reent.h>Pekka Seppänen1-0/+1
Attempt to always provide _Thread_local in <sys/reent.h> by including <sys/cdefs.h>. The C specific keyword _Thread_local is not available unless targetting a suitable C version.
2023-09-11Reentrancy, conditionally provide default __getreent() implementationPekka Seppänen1-0/+4
Conditionally provide default __getreent() implementation only if _REENT_THREAD_LOCAL is not defined. If struct _reent is replaced by dedicated thread-local objects neither the structure nor _impure_ptr is available.
2023-09-11Reentrancy, use _REENT_ERRNO()Pekka Seppänen4-14/+14
Use _REENT_ERRNO() macro to access errno. This encapsulation is required, as errno might be either _errno member of struct _reent, _tls_errno or any such implementation detail.
2023-08-29libc/stdlib/nano-mallocr.c, typo in variable namePekka Seppänen1-1/+1
Nano malloc uses `size' in assertation whereas the correct variable would be `s'. Given this has existed ever since nano malloc support was added, based on the context ("returned payload area of desired size does not exceed the actual allocated chunk") I presume that indeed `s' (user input) and not `r->size' (computed) shall be used.
2023-08-29newlib: fix 'sed' for sys headers path prefixAlexey Lapshin2-4/+4
Precisely remove the prefix from the filepath.
2023-08-17newlib: add Xtensa portAlexey Lapshin42-255/+3646
2023-08-15struct _reent: add state for unicode functionsCorinna Vinschen1-0/+16
C23 requires that the unicode functions c16rtomb, c8rtomb, mbrtoc16, mbrtoc32 and mbrtoc8 use their own internal state object. c32rtomb only needs an internal state if the lib supports encoding with shift states, but that's the case for newlib and Cygwin. Only Cygwin implements these functions so add the states objects only for Cygwin for now. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-10Add wildcard support to recurse into sys include directoriesAlexey Lapshin2-46/+32
2023-08-09sys/unistd.h: define GNU extensions SEEK_DATA and SEEK_HOLECorinna Vinschen1-0/+4
SEEK_DATA and SEEK_HOLE are GNU nonstandard extensions also present in Solaris, FreeBSD, and DragonFly BSD; they are proposed for inclusion in the next POSIX revision (Issue 8). Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-09Add stub for getentropyTorbjörn SVENSSON7-54/+164
Example test case that fails with undefined reference to getentropy: Testing g++.robertl/eb77.C, -std=c++20 doing compile Executing on host: /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++ /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -fmessage-length=0 -std=c++20 -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe (timeout = 800) spawn -ignore SIGHUP /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++ /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -fmessage-length=0 -std=c++20 -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe pid is 28414 -28414 /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)': (.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy' /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': (.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy' /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): in function `_rs_stir': (.text._rs_stir+0x8): undefined reference to `getentropy' collect2: error: ld returned 1 exit status pid is -1 close result is 28414 exp6 0 1 output is /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)': (.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy' /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': (.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy' /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): in function `_rs_stir': (.text._rs_stir+0x8): undefined reference to `getentropy' collect2: error: ld returned 1 exit status status 1 compiler exited with status 1 FAIL: g++.old-deja/g++.robertl/eb77.C -std=c++20 (test for excess errors) Excess errors: (.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy' (.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy' (.text._rs_stir+0x8): undefined reference to `getentropy' UNRESOLVED: g++.old-deja/g++.robertl/eb77.C -std=c++20 compilation failed to produce executable Contributed by STMicroelectronics Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2023-08-07sys/cdefs.h: introduce __restrict_arr, as in glibcCorinna Vinschen1-0/+13
C99 allows to define arrays as non-overlappiung using the restrict keyword. This is supported by GCC 3.1 and later, but it's not allowed in C++. This is in preparation of fixing a Cygwin build problem introduce by commit 3c75fac130b5. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-07sys/cdefs.h: fix for use __restrict in C++Sebastian Huber1-9/+7
Newlib shares large parts of <sys/cdefs.h> with FreeBSD and received this bug report: https://sourceware.org/pipermail/newlib/2023/020400.html As an extension, GCC and clang offer C99-style restricted pointers in C++ mode: https://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html We notice that this extension is broken when including newlib headers: restricted pointers are treated as ordinary pointers. We traced this to the following section of newlib/libc/include/sys/cdefs.h: /* * GCC 2.95 provides `__restrict' as an extension to C90 to support the * C99-specific `restrict' type qualifier. We happen to use `__restrict' as * a way to define the `restrict' type qualifier without disturbing older * software that is unaware of C99 keywords. */ #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 #define __restrict #else #define __restrict restrict #endif #endif While the GCC __restrict extension was indeed introduced in GCC 2.95, it is not limited to this version; the extension is also not limited to C90: https://gcc.gnu.org/gcc-2.95/c++features.html Rewrite the logic in the header so that __restrict is kept alone when available. PR: 272723 MFC after: 1 week
2023-08-07<sys/cdefs.h>: Decay expression passed to fallbackJohn Baldwin1-1/+4
version of __generic() This ensures that __generic() more closely matches _Generic() when using the fallback version when _Generic() is not available (such as GCC). Co-authored by: jrtc27 Reviewed by: jrtc27 Differential Revision: https://reviews.freebsd.org/D38215
2023-08-04newlib: gdtoa: Suppress compiler warning.Takashi Yano1-1/+1
Fixes: 5ac83ea47a7a ("newlib: Fix memory leak regarding gdtoa-based _ldtoa_r().") Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-08-02sys/features.h: Define _ISOC2X_SOURCE and __ISO_C_VISIBLECorinna Vinschen1-1/+14
Add feature test for C2X code. Add matching definitions _ISOC2X_SOURCE for requesting sources and __ISO_C_VISIBLE to be used in headers. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-02newlib: Fix memory leak regarding gdtoa-based _ldtoa_r().Takashi Yano2-13/+14
After the commit a4705d387f78, printf() for floating-point values causes a memory leak. The legacy _ldtoa_r() assumed the char pointer returned will be free'ed by Bfree(). However, gdtoa-based _ldtoa_r() returns the pointer returned by gdtoa() which should be free'ed by freedtoa(). Due to this issue, the caller of _ldtoa_r() fails to free the allocated char buffer. This is the cause of the said memory leak. https://cygwin.com/pipermail/cygwin/2023-July/254054.html This patch makes rv_alloc()/freedtoa() allocate/free the buffer in a compatible way with legacy _ldtoa_r(). Fixes: a4705d387f78 ("ldtoa: Import gdtoa from OpenBSD.") Reported-by: natan_b <natan_b@libero.it> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-07-31Revert "* libc/stdlib/mbtowc_r.c (__ascii_mbtowc): Disallow conversion of"Corinna Vinschen2-12/+0
This reverts commit 2b77087a48ea56e77fca5aeab478c922f6473d7c. For some reason lost in time, commit 2b77087a48ea5 introduced Cygwin-specific code treating single byte characters outside the portable character set as illegal chars. However, Cygwin was always alone with this over-correct behaviour and it leads to stuff like gnulib replacing functions defined in Cygwin with their own implementation just due to that. Revert this change, sans the changes to ChangeLog. Fixes: 2b77087a48ea ("* libc/stdlib/mbtowc_r.c (__ascii_mbtowc): Disallow conversion of") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-27Fix rounding results in lrint() & llrint() when close to 0Jesse Huang via Newlib4-48/+26
soft-fp should round floating pointer numbers according to the current rounding mode. However, in the current code of lrint() and llrint(), there are if statements before the actual rounding computation if(j0 < -1) return 0; Where j0 is the exponent of the floating point number. It means any number having a exponent less than -1 (i.e. interval (-0.5, 0.5)) will be rounded to 0 regardeless of the rounding mode. The bug already fixed in glibc in 2006 by moving the check afterwards the rounding computation, but still persists in newlib. This patch fixed it in a similar way to glibc Ref Commit in glibc: 6624dbc07b5a9fb316ed188ef01f65b8eea8b47c
2023-07-26Rename _NL_CTYPE_OUTDIGITSx_MB/WC to _NL_CTYPE_OUTDIGITx_MB/WCCorinna Vinschen1-20/+20
The extended _NL_foo names were originally designed after their GLibc counterparts. However, the OUTDIGIT macros were accidentally defined as OUTDIGITS, plural. Fix them. Fixes: d47d5b850bed ("Extend locale support to maintain wide char values of native strings") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-26RISC-V: Support Zfinx/Zdinx extension.Kito Cheng via Newlib42-56/+93
Zfinx/Zdinx are new extensions ratified in 2022, it similar to F/D extensions, support hard float operation for single/double precision, but the difference between Zfinx/Zdinx and F/D is Zfinx/Zdinx is operating under general purpose registers rather than dedicated floating-point registers. This patch improve the hard float support detection for RISC-V port, so that Zfinx/Zdinx can have better/right performance. Co-authored-by: Jesse Huang <jesse.huang@sifive.com>
2023-07-26Define _AT_NULL_PATHNAME_ALLOWEDCorinna Vinschen1-5/+6
Cygwin needs an internal flag to allow specifying an empty pathname in utimesat (GLIBC extension). We define it in _default_fcntl.h to make sure we never introduce a value collision accidentally. While at it, define the values as 16 bit hex values. Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-18Fix typo.Jeff Johnston1-1/+1
2023-07-17Change getlogin() to only check stdin being nullJordi Sanfeliu1-2/+0
2023-07-13newlib: posix: add HAVE_OPENDIR build condition for [n]ftw.cAlexey Lapshin2-0/+6
2023-06-22For GCC, newlib combined tree, newlib build-tree testing, use standard ↵Thomas Schwinge1-0/+7
search paths For example, for GCC/GCN target (AMD GPUs), target libraries are built individually per supported hardware ISA ('-march=[...]'). Testing such a toolchain via, for example: $ make RUNTESTFLAGS='--target_board=[...]/-march=gfx90a' check[...] ... does work fine for all 'check-gcc-[...]' as well as GCC-provided target libraries, 'check-target-[...]'. Just for 'check-target-newlib', for the example above, not the '-march=gfx90a' newlib libraries are linked in, but instead always the default ones, which results in link FAILure. This is cured simply by skipping use of 'newlib/testsuite/lib/flags.exp', so that the standard search paths as determined by GCC, DejaGnu are used for newlib, too.
2023-06-21Make SIG2STR_MAX usable in #ifMingye Wang1-2/+2
The text accepted for POSIX issue 8 requires that SIG2STR_MAX be usable in #if, which we currently break with sizeof. Use static values instead.
2023-05-30m68k: disallow unaligned access for m68010 and m68020Remy Bohmer1-1/+1
Disable at least m68010 and m68020. These processors certainly do not like unaligned accesses. Signed-off-by: Remy Bohmer <linux@bohmer.net> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr> Signed-off-by: Austin Morton <austinpmorton@gmail.com> Signed-off-by: Chris Packham <judge.packham@gmail.com>
2023-05-17fix __time_load_locale return codeAlexey Lapshin1-1/+3
- add explicit __HAVE_LOCALE_INFO__ check
2023-05-16Regenerated source for adding non LDBL_EQ_DBLJennifer Averett2-65/+1414
2023-05-16newlib: Add non LDBL_EQ_DBL math support for aarch64, i386, and x86_64Jennifer Averett43-60/+275
Rename s_nearbyint.c, s_fdim.c and s_scalbln.c to remove conflicts Remove functions that are not needed from above files Modify include paths Add includes missing in cygwin build Add missing types Create Makefiles Create header files to resolve dependencies between directories Modify some instances of unsigned long to uint64_t for 32 bit platforms Add HAVE_FPMATH_H
2023-05-16newlib: Add FreeBSD files for non LDBL_EQ_DBL supportJennifer Averett83-0/+13182
FreeBSD files to add long double support for i386, aarch64 and x86_64.
2023-05-05Regenerated source for moving signgam.cJennifer Averett1-58/+59
2023-05-05Move signgm.c from libc/reent to libm/mathJennifer Averett3-1/+1
2023-04-26Fix _REENT_EMERGENCY() if TLS is enabledSebastian Huber2-2/+2
If the thread-local storage (TLS) support was enabled, the _REENT_EMERGENCY() object had the wrong size. It must be a buffer of length _REENT_EMERGENCY_SIZE and not just a single character.
2023-04-24RTEMS: Add __m68k_read_tp() to crt0.cSebastian Huber1-0/+4
This is required to build libgomp.
2023-04-19posix_spawn_file_actions_addfchdir_np: return EBADF on negative fdCorinna Vinschen1-1/+6
FreeBSD and Musl implement posix_spawn_file_actions_addfchdir_np so that it checks the incoming descriptor for being negative, and, if so, return with EBADF. The POSIX proposal defining posix_spawn_file_actions_addfchdir follows this behaviour, see https://www.austingroupbugs.net/view.php?id=1208 Fixes: 7e03fc35f528 ("Add posix_spawn_file_actions_add{f}chdir_np") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18Add posix_spawn_file_actions_add{f}chdir_npCorinna Vinschen3-3/+95
These are defined as _np functions and available in glibc, musl, macOS, FreeBSD, Solaris ≥ 11.3 They are likely to be standardized without the _np suffix as a result of Austin Group issue 1208. if so, both names will be kept as aliases. Introduce HAVE_CHDIR and HAVE_FCHDIR to allow building on systems not providing these calls. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-13Replace always true if with elseAndoni Arregi1-2/+5
2023-04-13Compare j as unsignedAndoni Arregi1-1/+1
j is int32_t and thus j<<31 is undefined if j==1. Taken from FreeBSD commit bdd8abc6d6a93ce3ab8ad5db716222ee3110c4a3
2023-04-13Fix x close to 1, y between 2^31 and 2^64Andoni Arregi1-2/+2
E.g. known errors: x = 0x1.000002c5e2e99p+0, y = 0x1.c9eee35374af6p+31 had an error of 639 ULP and is now correctly rounded. x = 0x1.fffffd2e3e669p-1, y = 0x1.344c9823eb66cp+32 had an error of 428 ULP and is now correctly rounded.
2023-04-13Fix missing sign for overflow/underflow where x is negative and y is large ↵Andoni Arregi1-19/+18
odd integer
2023-03-30Bump newlib version in the manual to 4.3.0Tobias Burnus2-4/+4
While commit 9e09d6ed8 (tag: newlib-4.3.0) bumped the newlib version to 4.3.0, this commit updates the version/date in the libc/libm manuals to match.
2023-03-24newlocale: set errno to ENOENT if __loadlocale failsCorinna Vinschen1-1/+4
__loadlocale never sets errno, but newlocale is supposed to return ENOENT if the locale isn't valid. Fixes: aefd8b5b518b ("Implement newlocale, freelocale, duplocale, uselocale") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16Cygwin: add support for GB18030 codesetCorinna Vinschen2-4/+13
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-03arm: Restrict processor mode change when in hypervisor modeSrinath Parvathaneni1-7/+7
If a CPU implements EL2 as its highest exception level then programs using newlib may start in hypervisor mode. In that state it is not trivial to switch into the various EL1 modes to configure the individual exception stacks, so do not try.
2023-03-03arm: Fix the SP used in setting stack limit for standalone application.Srinath Parvathaneni1-2/+1
Move the instruction that saves SP before the mode check so that applications that start in USER mode correctly set the stack limit.