aboutsummaryrefslogtreecommitdiff
path: root/newlib
AgeCommit message (Collapse)AuthorFilesLines
2024-09-19powf: Fixed another precision bug in powf() (FreeBSD)HEADgithub/mastergithub/mainmastermainFabian Schriever1-1/+1
Fixed another precision bug in powf(). This one is in the computation [t=p_l+p_h High]. We multiply t by lg2_h, and want the result to be exact. For the bogus float case of the high-low decomposition trick, we normally discard the lowest 12 bits of the fraction for the high part, keeping 12 bits of precision. That was used for t here, but it doesnt't work because for some reason we only discard the lowest 9 bits in the fraction for lg2_h. Discard another 3 bits of the fraction for t to compensate. This bug gave wrong results like: powf(0.9999999, -2.9999995) = 1.0000002 (should be 1.0000001) hex values: 3F7FFFFF C03FFFFE 3F800002 3F800001 As explained in the log for the previous commit, the bug is normally masked by doing float calculations in extra precision on i386's, but is easily detected by ucbtest on systems that don't have accidental extra precision. Reference: https://github.com/freebsd/freebsd-src/commit/5f20e5ce7f396ad064bfc1f45b8075ea1c0580f9 Original Author: Bruce Evans
2024-09-19powf: Fixed 2 bugs in the computation /* t_h=ax+bp[k] High */. (FreeBSD)Fabian Schriever1-1/+2
(1) The bit for the 1.0 part of bp[k] was right shifted by 4. This seems to have been caused by a typo in converting e_pow.c to e_powf.c. (2) The lower 12 bits of ax+bp[k] were not discarded, so t_h was actually plain ax+bp[k]. This seems to have been caused by a logic error in the conversion. These bugs gave wrong results like: powf(-1.1, 101.0) = -15158.703 (should be -15158.707) hex values: BF8CCCCD 42CA0000 C66CDAD0 C66CDAD4 Fixing (1) gives a result wrong in the opposite direction (hex C66CDAD8), and fixing (2) gives the correct result. ucbtest has been reporting this particular wrong result on i386 systems with unpatched libraries for 9 years. I finally figured out the extent of the bugs. On i386's they are normally hidden by extra precision. We use the trick of representing floats as a sum of 2 floats (one much smaller) to get extra precision in intermediate calculations without explicitly using more than float precision. This trick is just a pessimization when extra precision is available naturally (as it always is when dealing with IEEE single precision, so the float precision part of the library is mostly misimplemented). (1) and (2) break the trick in different ways, except on i386's it turns out that the intermediate calculations are done in enough precision to mask both the bugs and the limited precision of the float variables (as far as ucbtest can check). ucbtest detects the bugs because it forces float precision, but this is not a normal mode of operation so the bug normally has little effect on i386's. On systems that do float arithmetic in float precision, e.g., amd64's, there is no accidental extra precision and the bugs just give wrong results. Reference: https://github.com/freebsd/freebsd-src/commit/12be4e0d5a54a6750913aee2564d164baa71f0dc Original Author: Bruce Evans
2024-09-19powf: Fix the hi+lo decomposition for 2/(3ln2) (FreeBSD)Fabian Schriever1-2/+2
The decomposition needs to be into 12+24 bits of precision for extra- precision multiplication, but was into 13+24 bits. On i386 with -O1 the bug was hidden by accidental extra precision, but on amd64, in 2^32 trials the bug caused about 200000 errors of more than 1 ulp, with a maximum error of about 80 ulps. Now the maximum error in 2^32 trials on amd64 is 0.8573 ulps. It is still 0.8316 ulps on i386 with -O1. The nearby decomposition of 1/ln2 and the decomposition of 2/(3ln2) in the double precision version seem to be sub-optimal but not broken. Reference: https://github.com/freebsd/freebsd-src/commit/b4437c3d322a0f6d23d12b6f76d2fc72d2ff0ec2 Original Author: Bruce Evans
2024-09-16Make sure mallinfo structure matches newlib's malloc.hJeff Johnston1-10/+10
2024-09-02Replace __restrict with __restrict_arr in regex.hyang.zhang1-1/+1
when a C++ source file include this header file, it would build fail. Signed-off-by: yang.zhang <zhangyang01@kylinos.cn>
2024-09-02newlib: esp: add dirent.h header fileAlexey Lapshin4-8/+63
Support dirent in *-esp-* toolchains
2024-09-02newlib: xtensa: remove sys/xtensa. use machine/xtensaAlexey Lapshin14-154/+9
Remove sys/xtensa that is actually duplicate newlib's code. Move used code to machine/xtensa or to libgloss
2024-08-22locales: Fix definition of lc_messages_T::codesetCorinna Vinschen1-1/+3
nl_langinfo_l accesses lc_messages_T::codeset as soon as __HAVE_LOCALE_INFO__ is defined, but codeset only exists if __HAVE_LOCALE_INFO_EXTENDED__ is defined. Fix this by defining lc_messages_T::codeset depending on __HAVE_LOCALE_INFO__. Fixes: ac7f1d5e931c ("Get rid of LCID, reformat type definitions in setlocale.h") Reported-by: Inglis <Brian.Inglis@SystematicSW.ab.ca> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-22nl_langinfo_l: drop erroneus messages::codeset entryCorinna Vinschen1-1/+0
The nl_ext array contains offsets into the extended info of locale structures, the index being equivalent to the nl_item values in langinfo.h. For the lc_messages_T struct, nl_ext erroneusly contains an entry for the codeset member, which is in fact not part of the extended info in nl_item. However, due to that, the offsets for subsequent entries are off by one. Fix this by dropping the messages::codeset entry from nl_ext. Fixes: d47d5b850bed ("Extend locale support to maintain wide char values of native strings") Reported-by: Brian Inglis <Brian.Inglis@systematicsw.ab.ca> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-21arc64: Add port for Synopsys DesignWare ARCv3 ISAYuriy Kolerov21-259/+3444
Synopsys ARCv3 ISA includes 32-bit ARC HS5x targets and 64-bit ARC HS6x targets. Both CPU families are placed in "arc64" subdirectories as it done for GCC port. Target name arc64 is used for historical reasons and Synopsys ARCv3 baremetal toolchains contain multilib configurations both for 32-bit and 64-bit families. arc32 target name is reserved for 32-bit ARC HS5x targets in case of non-multilib 32-bit builds. Note that libgloss libraries for ARCv3 are compatible with libgloss for ARCv1/2. Thus, Makefile.inc for libgloss uses sources from libgloss/arc directory except crtX.S files. Co-authored-by: Shahab Vahedi <list@vahedi.org> Co-authored-by: Claudiu Zissulescu <claziss@gmail.com> Co-authored-by: Bruno Mauricio <brunoasmauricio@gmail.com> Co-authored-by: Luis Silva <luis.m.silva99@hotmail.com> Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
2024-08-21Use ldflags instead of LDFLAGS in newlib.expClaudiu Zissulescu1-2/+2
This variable was accidentally renamed earlier. It must be ldflags according to DejaGNU documentation. Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2024-08-20arc: Remove @ from symbol references in assemblyAlexey Brodkin2-18/+18
There's no semantic change, it's only to make the same code compilable with MetaWare toolchian, which actually assumes @x as a full name, not omitting @. Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2024-08-20arc: Use __ARC_UNALIGNED__ compiler macroClaudiu Zissulescu1-1/+17
Replace __ARC_ALIGNED_ACCESS__ macro with the compiler defined macro __ARC_UNALIGNED__ and improve file comments. Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2024-08-20Fix glob() functionJordi Sanfeliu2-5/+9
Fixed glob() function to return GLOB_NOMATCH if pattern does not match any existing pathname (and GLOB_NOCHECK was not set in flags).
2024-08-19newlib/libc/include/sys/tree.h: Add deprecation warningJoel Sherrill1-0/+4
2024-08-19libc/include/sys/tree.h: Re-add sys/tree.hJoel Sherrill1-0/+864
Reverts 1339af44679aee0895fe311cfad89d38cfc2b919
2024-08-15stdlib.h: define __itoa/__utoa while building newlibCorinna Vinschen1-1/+1
This avoids a `__utoa undefined' warning when building newlib for Cygwin. We still need to export the symbols for backward compatibility. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-15Fix POSIX guards for POSIX.1-2024 extensionsCorinna Vinschen2-3/+3
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-15features.h: support POSIX.1-2024Corinna Vinschen1-3/+15
TBD: Align _GNU_SOURCE, too? Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-15features.h: fix whitespaceCorinna Vinschen1-44/+44
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-07-30stdatomic: make atomics compatible with GCC-14Alexey Lapshin1-1/+2
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631525.html brings c_atomic and cxx_atomic definitions into GCC. This patch makes atomics type detection correct for GCC. https://github.com/freebsd/freebsd-src/commit/680f40f38343de118d5b973129683804e496faaf
2024-07-16newlib: Add more FreeBSD files for non LDBL_EQ_DBL supportKito Cheng10-12/+681
For RISC-V, AArch64, i386, and x86_64 - k_tanl.c is required for tanl; the linker will report `__kernel_tanl` not found when tanl is called. - s_cospil.c and s_sinpil.c are added for cospil and sinpil, which are already available for ld80 but not for ld128.
2024-07-09sys/tree.h: RemovedJoel Sherrill1-864/+0
This file was from a specific older FreeBSD version. There have been multiple changes to this file with FreeBSD 14 including breaking changes to the file. Including this file as part of newlib results in not always having the correct version of sys/tree.h for any specific software. RTEMS will manage its use of this file outside of newlib.
2024-07-09libc/arm: add missing .cfi_sectionsClément Chigot7-0/+7
The modifications added by the series "M-profile PACBTI-enablement" (see 9d6b00511e50a54d2472d11f75f7c0f2b4a98b24) have introduced a couple of .cfi_* instructions. Like for e6459123e497409a9e3d845c39829a9602ba55a4, these instructions create object files which contain .eh_frame sections. However, ARM uses its own unwind info format, not .eh_frame, which is generated by ARM-specific directives, not .cfi_*. The .eh_frame sections are useless, but also not removed by strip and may be harmful with some linker scripts. Adding ".cfi_sections .debug_frame" (as in glibc) moves the generated directives towards .debug_frame instead of .eh_frame. Making them easier to handle. * libc/machine/arm/aeabi_memmove-thumb2.S: Use .cfi_sections .debug_frame. * libc/machine/arm/aeabi_memset-thumb2.S: Likewise. * libc/machine/arm/memchr.S: Likewise. * libc/machine/arm/memcpy-armv7m.S: Likewise. * libc/machine/arm/setjmp.S: Likewise. * libc/machine/arm/strlen-armv7.S: Likewise. * libc/machine/arm/strlen-thumb2-Os.S: Likewise.
2024-07-09libc/include/sys/resource.h: Add RUSAGE_THREADJoel Sherrill1-0/+3
2024-07-09sys: Remove $FreeBSD$: two-line .h patternWarner Losh1-2/+0
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2024-07-09spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh1-1/+1
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
2024-07-09sys/stdatomic.h: be nicer to c++Konstantin Belousov1-0/+10
Use of stdatomic.h is undefined in C++, even the C++ 2020 standard does not list stdatomic.h as a C library header supported by the language. More, there are some subtle differences between the <atomic> C++ header, and C11+ stdatomic.h provided features. Nonetheless, it is a quality of the implementation aspect, so let mis-users mis-use stdatomic.h as they want, by making a compat shim for _Bool. PR: 262683 Reported by: yuri Reviewed by: dim, emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D34686
2024-07-09sys/sys: further adoption of SPDX licensing ID tags.Pedro F. Giffuni1-0/+2
Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts.
2024-07-03libc/include/complex.h: Add CMPLX, CMPLXF, and CMPLXLJoel Sherrill1-0/+13
2024-07-03libc/include/sys/_default_fcntl.h: O_RSYNC and O_DSYNC are POSIXJoel Sherrill1-2/+3
These should not be in a Cygewin conditional.
2024-07-01arm: Fix fma & fmaf implementationsMickaël Thomas2-2/+2
The vfma.f32|64 z, x, y instruction performs the operation z += x * y without intermediate rounding. The register used for z is both read and written by the instruction. The inline assembly must therefore use the "+" constraint modifier.
2024-06-28libc: sh: add missing prototypes and change functions from K&R to ANSIPietro Monteiro4-18/+33
The SuperH target doesn't build on GCC 14.1 because of missing function prototypes or because some function declarations use the deprecated K&R style. This patch adds missing prototypes on the files the functions are used and convert K&R declarations to ANSI-style. Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2024-06-26arm: emit .type %function directive in FUNC_START macroChristophe Lyon1-0/+2
The linker needs to know whether a symbol is STT_FUNCTION when deciding which farcall stub to emit (if needed), this patch adds this to the FUNC_START macro which is used in crt0.
2024-06-06newlib: libm: skip "long double" complex functions if long double != doublePietro Monteiro14-6/+47
The rest of "long double" functions aren't compiled with long double and double are not the same. Do the same for all complex functions. Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2024-05-22arc: libc: Record r58/r59 in long-jump's bufferShahab Vahedi2-7/+19
The "longjmp" expects the "setjmp" to save the r58/r59 registers, if there is any. With this change they are saved accordingly. Checked for regression with running GCC's DejaGnu tests: $ runtest execute.exp=pr56982.c dg-torture.exp=pr48542.c Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
2024-05-22arc: libc, libgloss: Remove .file directive from .S filesYuriy Kolerov1-3/+1
Assembler for ARCv2 always extends the name provided by .file directive to an absolute form. On ARCv3 targets .file directive forces assembler to put a provided string to DW_AT_name field as is without extending to an absolute path. Then GDB cannot find source files because of it. The best way to fix this issue is just delete lines with .file directive in .S files and let the compiler to decide what DW_AT_name must contain. Particularly, the compiler fills this filed by an absolute path to a .S file because only absolute paths are used in toolchain's build process. Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
2024-05-22arc: libc: Add support of 16-entry register fileClaudiu Zissulescu28-56/+84
ARC supports a restricted register file with 16 registers. However, optimized routines support only a full register file. Thus, fallback on default implementation in case of 16-entry register file. Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2024-04-04amdgcn: Implement proper locks: Fix ↵Thomas Schwinge1-0/+4
'newlib/libc/sys/amdgcn/include/sys/lock.h' for C++ As of commit 7dd4eb1db9e1b1b9f14ef5b743705156e5f370e1 "amdgcn: Implement proper locks", we get, by the thousands, for C++ code: In file included from [...]/newlib/libc/include/stdio.h:60, from [...]: [...]/newlib/libc/include/sys/reent.h:911:1: error: expected declaration before '}' token
2024-03-25amdgcn: Implement proper locksAndrew Stubbs4-3/+250
This should prevent printf output from multiple threads getting garbled. I don't know why IO ever worked properly -- probably it was always a bit broken -- but the GFX11 devices have a different cache architecture and trying to print from many threads at once corrupted the FILE buffers.
2024-03-13libc/include/sys/select.h: Use elif not elifdefJoel Sherrill1-1/+1
The cpp directive "elifdef" is only available in very recent GCC versions. This should be able to compile on older toolchains in C99 mode.`
2024-03-13RTEMS: Increase FS_SETSIZE to 256 bitsChris Johns1-0/+2
2024-03-11libc/stdio: Remove wchar_t functions from NEWLIB_NANO_FORMATTED_IOTorbjörn SVENSSON2-471/+471
Regression tested in basepoints/gcc-14-9032-g945cb8490cb with arm-none-eabi. Example failure without this change: $ arm-none-eabi-g++ .../pr100611.C -std=c++20 --specs=nosys.specs -o /dev/null --specs=nano.specs .../ld: .../libc_nano.a(libc_a-svfwprintf.o): in function `_svfwprintf_r': (.text._svfwprintf_r+0xd8): undefined reference to `__ssputws_r' .../ld: (.text._svfwprintf_r+0x834): undefined reference to `__ssputws_r' .../ld: (.text._svfwprintf_r+0x85c): undefined reference to `__ssputws_r' .../ld: (.text._svfwprintf_r+0x8a8): undefined reference to `__ssputws_r' .../ld: (.text._svfwprintf_r+0x8dc): undefined reference to `__ssputws_r' .../ld: .../libc_nano.a(libc_a-svfwprintf.o):(.text._svfwprintf_r+0x900): more undefined references to `__ssputws_r' follow collect2: error: ld returned 1 exit status Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> Co-authored-by: Yvan ROUX <yvan.roux@foss.st.com>
2024-02-28Cygwin: add compile warning if ENOSHARE or ECASECLASH is usedChristian Franke1-3/+3
These errno values are no longer used by Cygwin. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-24RTEMS: Define ssize_t for <dirent.h>Sebastian Huber1-0/+5
This fixes the following build issue: newlib/libc/include/dirent.h:84:1: error: unknown type name 'ssize_t'; did you mean '_ssize_t'? 84 | ssize_t posix_getdents(int, void *, size_t, int); | ^~~~~~~ | _ssize_t
2024-02-21strptime: fix am/pm converting to 24-hour systemAlexey Lapshin1-5/+6
Fix the issue of parsing 08:00AM, which currently gives a 20:00 representation.
2024-02-05getlocalename_l: fix _reent for _REENT_SMALL targetsCorinna Vinschen1-1/+6
The new _MB_CAPABALE-only _misc_reent member getlocalename_l_buf was incorrectly initialized in the _REENT_INIT_MISC macro, so the build failed for _REENT_SMALL targets, independet of the _MB_CAPABALE setting. Fixes: 71511d4ac868 ("getlocalename_l: implement per SUS Base Specifications Issue 8 draft") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31Cygwin: implement setproctitlegithub/topic/3.6topic/3.6Corinna Vinschen1-0/+8
Make sure to create commandline according to setting of setproctitle. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31sys/stat.h: drop __INSIDE_CYGWIN__ guardsCorinna Vinschen1-2/+2
These were only necessary until we dropped 32 bit Cygwin. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31Cygwin: posix_getdents: implement per SUS Base Specifications Issue 8 draftCorinna Vinschen1-0/+3
- Basically maintain a hidden DIR* inside fhandlers. - lseek has to be tweaked to allow basic seeking on the directory descriptor. - the current implementation does not keep the dir positions between duplicated descriptor in sync. In fact, every descriptor keeps its own copy of the DIR* and after dup/fork/exec, the directory position is reset to 0, i. e., to the start of the directory, as if rewinddir() has been called on the new descriptors. While this behaviour isn't yet covered by the Issue 8 draft, a bug report along these lines exists and will probably be picked up for TC1. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>