aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdlib
AgeCommit message (Collapse)AuthorFilesLines
2018-01-18ansification: unifdef -D__STDC__ mallocr codeYaakov Selkowitz1-192/+28
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
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>
2016-10-22Drop redundant checks for NULL input string in wctomb helper funcsCorinna Vinschen1-6/+0
Fixes Coverity CIDs 153465 and 153466 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-17Fix pdf build failure wrt documentation of is*_l functionsThomas Preudhomme1-2/+2
make pdf on arm-none-eabi targets fails to build after the reorganization in baf0c9fcb56e5cf8f54357bf8d8646b51b236886 to fold is*_l documentation in their is* counterpart. This is due two issues: 1) newlib/libc/ctype/ctype.tex still including the def file for the long versions 2) missing angle brackets in .c files for some of is*_l functions This patch fixes the issues and allows make pdf to succeeds.
2016-08-16Avoid "implicit declaration of function ‘strtold_l’" in wcstold.cCorinna Vinschen1-0/+1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-16Don't use locale_t in internal headerCorinna Vinschen1-1/+1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15Implement strto[dflu]_l/wcsto[dflu]_lCorinna Vinschen21-807/+964
Implement GNU extensions strtod_l, strtof_l, strtol_l, strtold_l, strtoll_l, strtoul_l, strtoull_l, wcstod_l, wcstof_l, wcstol_l, wcstold_l, wcstoll_l, wcstoul_l, wcstoull_l. Export from Cygwin, fix posix.xml. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-15Consolidate wctomb/mbtowc calls for POSIX-1.2008Corinna Vinschen15-145/+762
- Remove charset parameter from low level __foo_wctomb/__foo_mbtowc calls. - Instead, create array of function for ISO and Windows codepages to point to function which does not require to evaluate the charset string on each call. Create matching helper functions. I.e., __iso_wctomb, __iso_mbtowc, __cp_wctomb and __cp_mbtowc are functions returning the right function pointer now. - Create __WCTOMB/__MBTOWC macros utilizing per-reent locale and replace calls to __wctomb/__mbtowc with calls to __WCTOMB/__MBTOWC. - Drop global __wctomb/__mbtowc vars. - Utilize aforementioned changes in Cygwin to get rid of charset in other, calling functions and simplify the code. - In Cygwin restrict global cygheap locale info to the job performed by internal_setlocale. Use UTF-8 instead of ASCII on the fly in internal conversion functions. - In Cygwin dll_entry, make sure to initialize a TLS area with a NULL _REENT->_locale pointer. Add comment to explain why. Signed-off by: Corinna Vinschen <corinna@vinschen.de>
2016-07-04Regenerate newlib MakefilesJon Turney1-3/+16
2016-06-16Re-enable malloc_lock for newlib-nanoAndre Vieira (lists)1-3/+2
Re-enable the use of __malloc_lock and __malloc_unlock newlib-nano, tied the newlib-multithread.
2016-04-15Use __machine_*_t_defined for internal typesSebastian Huber1-1/+1
Newlib defines defaults for internal types via <sys/_types.h> and uses <machine/_types.h> to let targets define their own type if necessary. Previously for example #ifndef __dev_t_defined typedef short __dev_t; #endif However, the __*_t_defined pattern conflicts with the glibc type guard pattern for user types, e.g. dev_t in this example. Introduce a __machine_*_t_defined pattern for internal types (defined by <machine/_types.h>, used by <sys/_types.h>). For example #ifndef __machine_dev_t_defined typedef short __dev_t; #endif Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-04Add Intel MCU targetIgor Venevtsev1-1/+2
Intel MCU System V ABI are incompartible with i386 System V ABI: o Minimum instruction set is Intel Pentium ISA minus x87 instructions o No x87 or vector registers o First three args are passed in %eax, %edx and %ecx o Full specification available here: https://github.com/hjl-tools/x86-psABI/wiki/iamcu-psABI-0.7.pdf newlib/ * configure.host: Add new ix86-*-elfiamcu target newlib/libc/include/ * setjmp.h: Change _JBLEN for Intel MCU target newlib/libc/machine/i386/ * memchr.S: (memchr) Target-specific size-optimized version * memcmp.S: (memcmp) Likewise * memcpy.S: (memcpy) Likewise * memmove.S: (memmove) Likewise * memset.S: (memset) Likewise * setjmp.S: (setjmp) Likewise * strchr.S: (strchr) Likewise * strlen.S: (strlen) Likewise newlib/libc/stdlib/ * srtold.c: (__flt_rounds) Disable for Intel MCU
2016-03-28Add simple versions of random() and srandom()Joel Sherrill4-14/+110
Prototypes also added for initstate() and setstate() but they were not implemented in the shared newlib code. * newlib/libc/include/cygwin/stdlib.h: Prototypes added. * winsup/cygwin/include/cygwin/stdlib.h: Prototypes removed. * newlib/libc/stdlib/random.c: New file. * newlib/libc/machine/epiphany/machine/stdlib.h: Removed * newlib/libc/stdlib/Makefile.am: Added random.c. * newlib/libc/stdlib/stdlib.tex: Added random.def. * newlib/libc/stdlib/Makefile.in: Regenerated.
2016-03-26strtold: Fix Infinity value.Corinna Vinschen1-1/+2
Infinity returned from strtold is recognized as NaN by GCC builtin functions. The reason is that ULtox is missing to set a bit. * libc/stdlib/strtorx.c (ULtox): Set high bit in second word to create valid Infinity value. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-21Move arc4random Cygwin only code to CygwinSebastian Huber1-15/+0
Keep the Newlib arc4random.c identical to the OpenBSD upstream version. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>.
2016-03-20Allow machine-dependent arc4 lockingCorinna Vinschen1-18/+5
newlib: * libc/stdlib/arc4random.h: Remove Cygwin-specific locking code. Conditionalize arc4 locking. Check for _ARC4_LOCK_INIT being undefined to fall back to default implementation. cygwin: * include/machine/_arc4random.h: New file. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-18Cleanup macros in chacha_private.h to be target-type independentHowland, Craig D1-5/+2
* libc/stdlib/chacha_private.h (U8C, U32C): Remove un-necessary macros. (U8V, U32V): Drop masking.
2016-03-18Only export arc4random_stir and arc4random_addrandom on CygwinCorinna Vinschen1-8/+5
Export to maintain backward compatibility, but don't let them do anything useful. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-18Arc4random locking: Check for threaded application on CygwinCorinna Vinschen1-0/+19
libc/stdlib/arc4random.h (_ARC4_LOCK): Special case Cygwin. (_ARC4_UNLOCK): Ditto. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>