aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdlib
AgeCommit message (Collapse)AuthorFilesLines
2018-12-31Bump release to 3.1.0 for yearly snapshotnewlib-snapshot-20181231newlib-3.1.0Jeff Johnston1-23/+26
2018-10-10newlib: Build internal strtold code only if HAVE_LONG_DOUBLE definedCorinna Vinschen2-8/+9
Commit fbace81684f8cbb80a2048c01dc545af247f5cb7 ("Import correctly working strtold from David M. Gay.") introduced two new files, strtorx.c and strtodg.c. The functions are only called from strtold.c. However, while strtold.c is only built if HAVE_LONG_DOUBLE is defined, the patch erroneously added the two new files to GENERAL_SOURCES unconditionally. Fix this by building both files only if HAVE_LONG_DOUBLE has been defined. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-10-10newlib: strtold: use __builtin_nanl to avoid libm dependencyCorinna Vinschen1-1/+1
Commit 6c212a8b7873703c4f98c6b68579b234918be83a ("Fix strtod ("nan") and strtold ("nan") returns wrong negative NaN") introduced an unconditional dependency to nanl and, in turn, to libm. Rather than including nanl in libc as well, just call __builtin_nanl from here. Requires GCC 3.3 or later. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-09-06stdlib: Use __get_numeric_locale instead of __localeconv_l for decimal_pointKeith Packard5-13/+14
The string/float conversion functions need to get the locale decimal point. Instead of calling __localeconv_l (which copies locale data into lconv form from __get_numeric_locale), use __get_numeric_locale directly. Signed-off-by: Keith Packard <keithp@keithp.com>
2018-09-06stdlib/arc4random.c: Fix reseed count for 16-bit targets.Jon Beniston1-1/+1
2018-08-29Use nanf("") instead of nanf(NULL)Keith Packard2-5/+5
Newer GCC versions require a non-NULL argument to this function for some reason. Signed-off-by: Keith Packard <keithp@keithp.com>
2018-08-16Fix strtof ("-nan") returns positive NaNMasamichi Hosoda1-2/+2
strtof ("-nan") returned positive NaN instead of negative NaN. strtod ("-nan") and strtold ("-nan") return negative NaN. Linux glibc has been fixed that strto{f|d|ld} ("-nan") returns negative NaN. https://sourceware.org/bugzilla/show_bug.cgi?id=23007 This commit makes strtof preserves the negative sign bit when parsing "-nan" like glibc.
2018-08-16Remove unused NaN's integer representation definitionsMasamichi Hosoda6-93/+8
By previous commit, strto{d|ld} ("nan") does not use the definition of NaN. There is no other function that uses the definitions. This commit remove the definitions.
2018-08-16Fix strtod ("nan") and strtold ("nan") returns wrong negative NaNMasamichi Hosoda2-9/+2
The definition of qNaN for x86_64 and i386 was wrong. strto{d|ld} ("nan") returned wrong negative NaN instead of correct positive NaN since it used the wrong definition. On the other hand, strtof ("nan") returns correct positive NaN since it uses nanf ("") instead of the wrong definition. This commit makes strto{d|ld} ("nan") uses {nan|nanl} ("") like strtof ("nan") using. So strto{d|ld} ("nan") returns positive NaN.
2018-08-13Added Restriction on base valueAditya Upadhyay1-0/+4
2018-08-08newlib: don't check malloc/free pointerCorinna Vinschen2-17/+2
use preprocessor check for MALLOC_PROVIDED instead Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-08-08newlib: fix various gcc warningsCorinna Vinschen4-10/+16
* unused variables * potentially used uninitialized * suggested bracketing * misleading indentation Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-06-18newlib: getopt now permutes multi-flag options correctlyThomas Kindler1-12/+21
Previously, "test 1 2 3 -a -b -c" was permuted to "test -a -b -c 1 2 3", but "test 1 2 3 -abc" was left as "test 1 2 3 -abc". Signed-off-by: Thomas Kindler <mail+newlib@t-kindler.de>
2018-05-29Fix issue with malloc_extend_topJeff Johnston1-1/+6
- when calculating a correction to align next brk to page boundary, ensure that the correction is less than a page size - if allocating the correction fails, ensure that the top size is set to brk + sbrk_size (minus any front alignment made) Signed-off-by: Jeff Johnston <jjohnstn@redhat.com>
2018-04-13Add nvptx port.Jeff Johnston3-32/+22
- From: Cesar Philippidis <cesar@codesourcery.com> Date: Tue, 10 Apr 2018 14:43:42 -0700 Subject: [PATCH] nvptx port This port adds support for Nvidia GPU's, which are primarily used as offload accelerators in OpenACC and OpenMP.
2018-04-09strtod: Convert 64 bit double to 64 bit int during computationCorinna Vinschen1-0/+9
The gdtoa implementation uses the type long, defined as Long, in lots of code. For historical reason newlib defines Long as int32_t instead. This works fine, as long as floating point exceptions are not enabled. The conversion to 32 bit int can lead to a FE_INVALID situation. Example: const char *str = "121645100408832000.0"; char *ptr; feenableexcept (FE_INVALID); strtod (str, &ptr); This leads to the following situation in strtod double aadj; Long L; [...] L = (Long)aadj; For instance, on x86_64 the code here is cvttsd2si %xmm0,%eax At this point, aadj is 2529648000.0 in our example. The conversion to 32 bit %eax results in a negative int value, thus the conversion is invalid. With feenableexcept (FE_INVALID), a SIGFPE is raised. Fix this by always using 64 bit ints here if double is not a 32 bit type to avoid this type of FP exceptions. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16Add prototype to _malloc_lock() and *unlock() to malloc.h, and inlude this ↵Jaap de Wolff1-15/+1
from nano-mallocr.c
2018-01-19Fix syntax error in exit.cOrlando Arias1-1/+1
This patch fixes a syntax error in exit.c that was introduced during the ANSI-fication of newlib. The patch fixes a compile-time issue that arises when newlib is configured with the --enable-lite-exit feature.
2018-01-17ansification: remove _HAVE_STDCYaakov Selkowitz1-6/+0
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _EXFUN, _EXFUN_NOTHROWYaakov Selkowitz5-30/+30
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _EXFNPTR, _EXPARMYaakov Selkowitz2-2/+2
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _DEFUNYaakov Selkowitz90-350/+179
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _VOIDYaakov Selkowitz5-7/+7
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _DEFUN_VOIDYaakov Selkowitz7-8/+8
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _PTRYaakov Selkowitz12-22/+22
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _PARAMSYaakov Selkowitz5-6/+6
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _CONSTYaakov Selkowitz26-129/+129
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17ansification: remove _ANDYaakov Selkowitz67-309/+309
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-12-07makedoc: make errors visibleJon Turney1-3/+3
Discard QUICKREF sections, rather than writing them to stderr Discard MATHREF sections, rather than discarding as an error Pass NOTES sections through to texinfo, rather than discarding as an error Don't redirect makedoc stderr to .ref file Remove makedoc output on error Remove .ref files from CLEANFILES Regenerate Makefile.ins Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-12-01stdlib: remove TRAD_SYNOPSISYaakov Selkowitz50-607/+51
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-14newlib/libc/stdlib/realloc.c: fix variable nameFlorian Schmidt1-1/+1
The variable doesn't follow the convention of having the same name as the function it's bundled with. Furthermore, it clashes with the variable of the same name in newlib/libc/stdlib/calloc.c. Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
2017-08-11newlib: regenerate libc/stdlib/Makefile.amCorinna Vinschen1-9/+36
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-08-02Importing wcstoumax inttypes method from FreeBSD.Aditya Upadhyay2-0/+158
2017-08-02Importing wcstoimax inttypes method from FreeBSD.Aditya Upadhyay2-0/+159
2017-08-02Importing strtoumax inttypes method from FreeBSD.Aditya Upadhyay2-0/+152
2017-08-02Importing strtoimax inttypes method from FreeBSD.Aditya Upadhyay2-0/+170
2017-07-28newlib: regenerate stdlib/Makefile.inCorinna Vinschen1-33/+62
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-07-28Importing imaxdiv inttypes method from FreeBSD.Aditya Upadhyay2-0/+49
2017-07-28Importing imaxabs inttypes method from FreeBSD.Aditya Upadhyay2-0/+37
2017-04-04Add BSD-specific reallocarray()Sebastian Huber3-17/+66
It is available in FreeBSD, NetBSD and OpenBSD, but not in glibc. It is used for example by OpenSSH.
2017-04-03Use enum __packed in favour of -fshort-enumsSebastian Huber3-7/+3
Some architectures like ARM encode the short enum option state in the object file and the linker checks that this option is consistent for all objects of an executable. In case applications use -fno-short-enums, then this leads to linker warnings. Use the enum __packed attribute for the relevent enums to avoid the -fshort-enums compiler option. This attribute is at least available on GCC, LLVM/clang and the Intel compiler. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-02-13Only define static locks in multithreaded modeThomas Preud'homme4-0/+18
Newlib build system defines __SINGLE_THREAD__ to allow concurrency code to be only compiled when newlib is configured for multithread. One such example are locks which become useless in single thread mode. Although most static locks are indeed guarded by !defined(__SINGLE_THREAD__), some are not. This commit adds these missing guards to __dd_hash_mutex, __atexit_recursive_mutex, __at_quick_exit_mutex and __arc4random_mutex. It also makes sure locking macros in lock.h are noop in single thread mode.
2017-02-06Unify names of all lock objectsFreddie Chopin6-23/+23
In preparation for the patch that would allow retargeting of locking routines, rename all lock objects to follow this pattern: "__<name>_[recursive_]mutex". Following locks were renamed: __dd_hash_lock -> __dd_hash_mutex __sfp_lock -> __sfp_recursive_mutex __sinit_lock -> __sinit_recursive_mutex __atexit_lock -> __atexit_recursive_mutex _arc4random_mutex -> __arc4random_mutex __env_lock_object -> __env_recursive_mutex __malloc_lock_object -> __malloc_recursive_mutex __atexit_mutex -> __at_quick_exit_mutex __tz_lock_object -> __tz_mutex
2017-01-25Prefix consistenly target-independent locks with __Thomas Preudhomme1-3/+3
Hi, With the patch to allow newlib's locking routine to be retargeted currently under discussion, we need to start thinking of locks as part of newlib's ABI since newlib depends on specific names being provided by the OS. This patch renames 2 locks so that they follow the same naming convention as other locks. It needs to be applied before the retargeting patch, while locks are still an internal consideration. Newlib builds successfully with this change. Ok for master branch? Best regards, Thomas
2017-01-13Expand comments on padding used by nano_mallocJoe Seymour1-14/+37
This patch adds further comments to nano-mallocr.c, to more comprehensively explain how padding works in the malloc_chunk structure. It was originally discussed in the following thread: https://sourceware.org/ml/newlib/2017/msg00031.html 2017-01-13 Joe Seymour <joe.s@somniumtech.com> newlib/ * libc/stdlib/nano-mallocr.c (malloc_chunk, get_chunk_from_ptr) (nano_malloc): Add comments.
2017-01-09Fix incorrect cast in nano mallocJoe Seymour1-2/+2
As described in nano-mallocr.c, chunks of heap are represented in memory as a size (of type long), followed by some optional padding containing a negative offset to size, followed by the data area. get_chunk_from_ptr is responsible for taking a pointer to the data area (as returned by malloc) and finding the start of the chunk. It does this by assuming there is no padding and trying to read the size, if the size is negative then it uses that as an offset to find the true size. Crucially, it reads the padding area as a long. nano_malloc is responsible for populating the optional padding area. It does so by casting a pointer to an (int *) and writing the negative offset into it. This means that padding is being written as an int but read as a long. On msp430 an int is 2 bytes, while a long is 4 bytes. This means that 2 bytes are written to the padding, but 4 bytes are read from it: it has only been partially initialised. nano_malloc is the default malloc implementation for msp430. This patch changes the cast from (int *) to (long *). The change to nano_malloc has has been observed to fix a TI Energia project that had been malfunctioning because malloc was returning invalid addresses. The change to nano_memalign is based entirely on code inspection. I've built and tested as follows: Configured (gcc+newlib) with: --target=msp430-elf --enable-languages=c gcc testsuite variations: msp430-sim/-mcpu=msp430 msp430-sim/-mcpu=msp430x msp430-sim/-mcpu=msp430x/-mlarge/-mdata-region=either/-mcode-region=either msp430-sim/-mhwmult=none msp430-sim/-mhwmult=f5series My testing has shown no regressions, however I don't know if the gcc testsuite provides sufficient coverage for this patch? I don't have write access, so if this patch is acceptable after review, I would appreciate it if someone would commit it for me. Thanks, 2017-01-XX Joe Seymour <joe.s@somniumtech.com> newlib/ * libc/stdlib/nano-mallocr.c (nano_malloc): Fix incorrect cast. (nano_memalign): Likewise.
2016-12-16Remove extraneous float casts in wcstod.c.Corinna Vinschen1-2/+2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-16Remove extraneous float casts in strtod.c.Jeff Johnston1-2/+2
2016-12-152016-12-15 Kyrylo Tkachov <kyrylo.tkachov@arm.com>cygwin-2_6_1-releaseJeff Johnston2-8/+29
* libc/stdlib/strtod.c (strtof_l): Set errno to ERANGE when double to float conversion results in infinity. (strtof): Likewise. * libc/stdlib/wcstod.c (wcstof_l): Likewise. (wcstof): Likewise.
2016-10-22Actually return value from __cp_indexCorinna Vinschen1-1/+1
Fixes Coverty CID 153470 Also drop redundant declaration of __cp_index. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>