aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc
AgeCommit message (Collapse)AuthorFilesLines
2024-01-19ORIENT: avoid "expression has no effect" warningCorinna Vinschen3-3/+3
The warning "right-hand operand of comma expression has no effect [-Wunused-value]" crops up with -Wall in cases where ORIENT is called without checking or assigning its value. Explicitely void the expression in these cases to avoid the warning. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-19_fputwc_r: actually return result of __fputwcCorinna Vinschen1-1/+1
Compiling with -Wall uncovered a bug in _fputwc_r introduced in commit 09119463a1445 ("stdio: split byte- and wide-char-oriented low-level output functions"). The underlying function __fputwc has been accidentally called without fetching its return value. So the return value of _fputwc_r (and thus fputwc) was undefined. Fixes: 09119463a1445 ("stdio: split byte- and wide-char-oriented low-level output functions" Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-15Cygwin: introduce close_range(2)Christian Franke1-0/+6
This function closes or sets the close-on-exec flag for a specified range of file descriptors. It is available on FreeBSD and Linux. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-01-08fix strverscmp comparison of digit sequence with non-digitsBrian Inglis1-3/+3
From: Rich Felker <dalias@aerifal.cx> Date: Mon, 7 Nov 2022 22:17:55 -0500 the rule that longest digit sequence not beginning with a zero is greater only applies when both sequences being compared are non-degenerate. this is spelled out explicitly in the man page, which may be deemed authoritative for this nonstandard function: "If one or both of these is empty, then return what strcmp(3) would have returned..." we were wrongly treating any sequence of digits not beginning with a zero as greater than a non-digit in the other string. Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
2024-01-02newlib: libc: Improved the readability of strspn with minor optimizationXiao Zeng1-1/+2
Signed-off-by: Xiao Zeng <zengxiao@eswincomputing.com>
2023-12-31Changes for newlib 4.4.0 snapshotnewlib-4.4.0Jeff Johnston1-2/+2
- bump up version to 4.4.0
2023-12-31Minor improvement to H8 startup codeJeff Law1-18/+12
Basically the startup code needs to clear memory from _edata to _end. In the past it's been done with a fairly naive copy loop. This changes the code to just call memset and let memset figure out a sensible way to handle the operation given the size and alignment requirements. I don't have performance data on this. I cobbled it together some time ago in response to seeing some of the GCC tests with larger .bss sections taking an insane amount of time to just get from _start to main. With the fixes to the H8 decoder in the simulator it may not matter nearly as much anymore. This has been in my tester for months. Naturally it does not cause any regressions in the H8 port.
2023-12-29newlib MMIX: Fix compilation warnings that recent gcc treats as errorsHans-Peter Nilsson10-21/+30
Without this, when building with recent gcc, we'll see errors when compiling for --target mmix the first being: CC libc/sys/mmixware/libc_a-chmod.o In file included from /x/newlib/libc/sys/mmixware/chmod.c:17: /x/newlib/libc/sys/mmixware/chmod.c: In function 'chmod': /x/newlib/libc/sys/mmixware/sys/syscall.h:139:6: error: implicit declaration \ of function 'sprintf' [-Wimplicit-function-declaration] 139 | sprintf (buf, "UNIMPLEMENTED %s in %s\n", __FUNCTION__, __FILE__); \ Other warnings also quelled. * libc/sys/mmixware/sys/syscall.h: Include stdio.h, string.h and unistd.h. * libc/sys/mmixware/_exit.c: Call __unreachable after simulator exit. * libc/sys/mmixware/chown.c (chown): Match declaration in unistd.h. * libc/sys/mmixware/getpid.c (_getpid): Ditto. * libc/sys/mmixware/kill.c (_kill): Ditto. * libc/sys/mmixware/link.c (_link): Ditto. * libc/sys/mmixware/read.c (_read): Ditto. * libc/sys/mmixware/sbrk.c (_sbrk): Ditto. * libc/sys/mmixware/unlink.c (_unlink): Ditto. * libc/sys/mmixware/write.c (_write): Ditto.
2023-12-23GCN: Implement '_exit' instead of 'exit'Thomas Schwinge3-5/+4
... so that all of 'exit', '_exit', '_Exit' work. 'exit' thus becomes the standard 'newlib/libc/stdlib/exit.c'. (Getting 'atexit' functional needs further work elsewhere.) See also commit 5841b2f6a4208682264d03e3edfa0a09881932a6 "nvptx: Implement '_exit' instead of 'exit'".
2023-12-22Fix newlib H8/300 bits for C99/gcc-14Jeff Law1-0/+2
Similar to other patches. This adds a missing prototype and #include to some H8/300 specific code in newlib. Pushed to the trunk given Jeff J's pre-approval for these kinds of changes.
2023-12-21Optimize strpbrk.cJeff Johnston1-9/+2
2023-12-19newlib: libc: Improved the readability of strcspn with minor optimizationXiao Zeng1-4/+2
Signed-off-by: Xiao Zeng <zengxiao@eswincomputing.com>
2023-12-19Fix various v850 problemsJeff Law6-7/+10
These fixes fall into a few different buckets. First c99 doesn't allow a parameter without a type. So in cases where the type had previously been an implicit int, make it an explicit int. Second, for return values, don't allow them to be implicit ints either, make them explicit. In a few cases change c89 function definitions to c99 function definitions. Lastly include <stdlib.h> in sbrk.c to get the prototype for abort () which we call when we detect a heap/stack collision.
2023-12-19Remove curly braces in `@author` tag in .texi filesFreddie Chopin1-4/+4
Curly braces cause documentation build failure with texinfo 7.1 (works fine up to 7.0.3):
2023-12-06newlib cris: Fix compilation warnings that recent gcc treats as errorsHans-Peter Nilsson1-6/+37
For the newlib part, warnings are all from lack of sync between libc/machine/cris/sys/signal.h and libc/include/sys/signal.h. This commit gets them sufficiently in sync again, functionality-wise and declaration-wise. Still, nothing is declared that isn't supported at the system level (i.e. in libgloss system calls and handled by the CRIS simulator in the gdb project).
2023-12-04RISC-V: Support long double mathKito Cheng2-1/+66
Long double for RISC-V is using 128 bit IEEE 754 format like Aarch64, so we reference AArch64 to support that.
2023-12-02newlib: libc: Fix indentationKuan-Wei Chiu1-12/+12
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
2023-12-01newlib: libc: Fix memory leak in computematchjumps()Kuan-Wei Chiu1-2/+4
In cases where malloc fails for the 'g->matchjump' allocation, the code path does not handle the failure gracefully, potentially leading to a memory leak. This fix ensures proper cleanup by freeing the allocated memory for 'pmatches' before returning. Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
2023-11-24newlib: nl_langinfo: Fix a bug of time stuff.Takashi Yano1-4/+4
Previously, e.g. nl_langinfo(_NL_TIME_WMONTH_1) returns "February" due to the bug. Similarly, nl_langinfo(_NL_TIME_WWDAY_1) returns "Mon". This occurs because wide char month and weekday arrays are pointed off-by-one (e.g. the array wmon[12] is reffered as wmon[1-12] rather than wmon[0-11]). This patch fixes that. Fixes: d47d5b850bed ("Extend locale support to maintain wide char values of native strings") Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-11-21aarch64: Remove duplicated optimized memmove()Sebastian Huber3-158/+2
The optimized aarch64/memcpy.S already provides a memmove() implementation.
2023-11-20stdio: drop unnecessary calls to ORIENTCorinna Vinschen7-20/+0
Now that the low-level functions set and test stream orientation, a few calls in API functions are redundant. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-20stdio: set and test stream orientation in low-level input function __srget_rCorinna Vinschen1-0/+5
This allows to set and test orientation correctly if input is only using macros from stdio.h. Wide-char-oriented functions must call __srefill_r directly. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-20stdio: split byte- and wide-char-oriented low-level output functionsCorinna Vinschen7-20/+140
Introduce function __swbufw_r and macros/inline-functions called __swputc_r. Call these functions/macros exclusively from wide-char functions. This allows to set and test the stream orientation correctly even if output is only performed using byte-oriented macros from stdio.h. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-20stdio: Fix bugs in commit 3d94e07c49b5Takashi Yano27-12/+43
The commit 3d94e07c49b5 has a few bugs which cause testsuite failure in libstdc++. This is due to excess orientation check in __srefill_r() and _ungetc_r(). Further, sscanf() family also calls ssvfscanf() family with fp->_file == -1. This causes undesired orientation set/check for sscanf() family. This patch fixes these problems. Also, as in GLibC, do not set orientation in ungetc, and only set, but do not check orientation in ungetwc. Fixes: 3d94e07c49b5 ("newlib: libc: Fix crash on fprintf to a wide-oriented stream.") Reported-by: Christophe Lyon <christophe.lyon@linaro.org> Reported-by: Joel Sherrill <joel@rtems.org> Co-developed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-20Reclaim _REENT_MP_P5S in _reclaim_reentChris Johns1-0/+11
The _REENT_MP_P5S blocks are allocated using Balloc via i2b and linked in the pow5mult call. As a result these blocks are not on the freelist managed by the Bfree call. This change fixes a memory leak in threads that clean up using _reclaim_reent. RTEMS: Closes #4967
2023-11-17__sfvwrite_r: call __sputc_r rather than putc in __SCLE caseCorinna Vinschen1-1/+4
__sfvwrite_r is called under lock. There's no reason to call putc, locking the file recursively. Add a comment that locking is required when calling __sfvwrite_r. Fixes: 49d64538cd20 ("* libc/include/stdio.h (FILE): define __SCLE for "convert line endings" for Cygwin.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-17v{fs}printf/v{fs}wprintf: create external output helpersCorinna Vinschen11-263/+312
So far, the printf family of functions has two output helper functions called __sprint_r and __sfputs_r. Both are called from all variants of vfprintf as well as vfwprintf. There are also analogue helper functions for the string-creating functions vsprintf/vswprintf called __ssprint_r and __ssputs_r. However, the helpers are built once when building vfprintf/vsprintf with the INTEGER_ONLY flag, and then they are part of the vfiprintf.c and vsiprintf.c files. The problem is this: Even if a process only calls vfwprintf or the non-INTEGER_ONLY vfprintf it will always have to include the INTEGER_ONLY vfiprintf. Otherwise the helper functions are undefined. Analogue for the string-creating functions. That's a useless waste of space by including one (or two) big, unused function, if newlib is linked in statically. Create new files to define the printf output helpers separately and split them into byte-oriented and wide-char-oriented functions. This allows to link only the required functions. Also, simplify the string output helpers and fix a potential (but unlikely) buffer overflow in __ssprint_r. Fixes: 8a0efa53e449 ("import newlib-2000-02-17 snapshot") Fixes: 6121968b198d ("* libc/include/stdio.h (__VALIST): Guard against multiple definition.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-10newlib: libc: Fix crash on fprintf to a wide-oriented stream.Takashi Yano19-40/+92
Previously, fprintf() on a wide-oriented stream crashes or outputs garbage. This is because a narrow char string which can be odd bytes in length is cast into a wide char string which should be even bytes in length in __sprint_r/__sfputs_r based on the __SWID flag. As a result, if the length is odd bytes, the reading buffer runs over the buffer length, which causes a crash. If the length is even bytes, garbage is printed. With this patch, any output to the stream which is set to different orientation fails with error just like glibc. Note that it behaves differently from other libc implementations such as BSD, musl and Solaris. Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-10-31amdgcn: remove unnecessary scalar cache flushAndrew Stubbs1-1/+0
The exit code isn't actually written via the scalar cache so the cache flush is not actually needed.
2023-10-12sparc: Improve setjmp()Sebastian Huber1-0/+2
Flush the windows in setjmp(). This helps if the stack is changed after the setjmp() and we want to jump back to the original stack using longjmp().
2023-10-12riscv: Fix fenv.h supportSebastian Huber1-1/+1
Use the same C preprocessor expressions to define FE_RMODE_MASK and __RISCV_HARD_FLOAT. The problem was noticed on GCC 10 which does not define __riscv_f.
2023-10-05aarch64: Import memrchr.SSebastian Huber3-0/+128
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-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-17newlib: add Xtensa portAlexey Lapshin25-1/+2334
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-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 SVENSSON6-0/+71
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-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>