summaryrefslogtreecommitdiffstats
path: root/newlib/libc
Commit message (Collapse)AuthorAgeFilesLines
* arm: Fix addressing in optpld macroKyrill Tkachov2017-01-262-4/+4
| | | | | | | | | | | | | | | In patch b219285f873cc79361355938bd2a994957b4a6ef you have a syntax error in the PLD instruction. The syntax for the pld argument should be in square brackets as it's a memory address like so: pld [r1]. With your patch the newlib build fails for armv7-a targets. This patch fixes the build failures. Tested by making sure the newlib build completes successfully. 2016-01-26 Kyrylo Tkachov <kyrylo.tkachov@arm.com> * libc/machine/arm/strcpy.c (strcpy): Fix PLD assembly syntax. * libc/machine/arm/strlen-stub.c (strlen): Likewise.
* arm: Remove RETURN macroPat Pannuto2017-01-256-33/+23
| | | | | | | | | | | | | | LTO can re-order top-level assembly blocks, which can cause this macro definition to appear after its use (or not at all), causing compilation failures. On modern toolchains (armv4t+), assembly should write `bx lr` in all cases, and linkers will transparently convert them to `mov pc, lr`, allowing us to simply remove the macro. (source: https://groups.google.com/forum/#!topic/comp.sys.arm/3l7fVGX-Wug and verified empirically) For the armv4.S file, preserve this macro to maximize backwards compatibility.
* arm: Remove optpld macroPat Pannuto2017-01-253-18/+11
| | | | | | | | | | | LTO can re-order top-level assembly blocks, which can cause this macro definition to appear after its use (or not at all), causing compilation failures. As the macro has very few uses, simply removing it by inlining is a simple fix. n.b. one of the macro invocations in strlen-stub.c was already guarded by the relevant #define, so it is simply converted directly to a pld
* Remove unneeded references to arm_asm.hPat Pannuto2017-01-258-10/+4
| | | | | This should result in no functional changes, it simply removes references to arm_asm.h that did not use anything from that file.
* devctl.h: Fix typo and include proper headerSebastian Huber2017-01-251-6/+6
| | | | | | | Remove stray commas. Include <sys/cdefs.h> for __restrict (includes <stddef.h> indirectly). Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* RTEMS: Harmonize MAXNAMLEN and NAME_MAXSebastian Huber2017-01-251-0/+4
| | | | | | | Override MAXNAMLEN definition in <dirent.h> and make sure it equals NAME_MAX. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Prefix consistenly target-independent locks with __Thomas Preudhomme2017-01-252-11/+11
| | | | | | | | | | | | | | | | | | | 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
* nl_langinfo: Add NL_LOCALE_NAME macroEric Blake2017-01-202-1/+18
| | | | | | | | | | | | | | | | | | | | | Provide an extension NL_LOCALE_NAME() macro, with semantics matching glibc, which can be used as: nl_langinfo_l(NL_LOCALE_NAME(LC_MESSAGES), locale); to get back the locale string that locale was originally created with during newlocale(). This in turn allows a library (such as gettext) to determine what thread-local locale settings it has inherited from the main program without having to be told what parameters were passed to newlocale(), for less overall coupling between parts of the program. gnulib is set up to use the extension: https://lists.gnu.org/archive/html/bug-gnulib/2017-01/msg00129.html * libc/include/langinfo.h (NL_LOCALE_NAME): New macro * libc/locale/nl_langinfo.c (nl_langinfo_l): Expose locale names of a locale_t's category components. Signed-off-by: Eric Blake <eblake@redhat.com>
* devctl.h: Use __restrict not restrictJoel Sherrill2017-01-171-5/+5
|
* Add missing headers to fix implicit function defnsPat Pannuto2017-01-164-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few files were missing headers for memset/malloc, likely missed because the files don't directly call the functions, rather they come in via macros in libc/include/sys/reent.h: #define _REENT_CHECK(var, what, type, size, init) do { \ struct _reent *_r = (var); \ if (_r->what == NULL) { \ _r->what = (type)malloc(size); \ #define _REENT_CHECK_ASCTIME_BUF(var) \ _REENT_CHECK(var, _asctime_buf, char *, _REENT_ASCTIME_SIZE, \ memset((var)->_asctime_buf, 0, _REENT_ASCTIME_SIZE)) Without these fixes, implicit function signatures are provided, which gcc warns could cause aliasing issues down the line: ../../../../../../../newlib-2.5.0/newlib/libc/time/asctime.c:62:3: warning: type of 'memset' does not match original declaration [-Wlto-type-mismatch] /Volumes/code/external/newlib-cygwin/newlib/libc/include/string.h:29:7: note: return value type mismatch _PTR _EXFUN(memset,(_PTR, int, size_t)); ^ /Volumes/code/external/newlib-cygwin/newlib/libc/include/string.h:29:7: note: 'memset' was previously declared here /Volumes/code/external/newlib-cygwin/newlib/libc/include/string.h:29:7: note: code may be misoptimized unless -fno-strict-aliasing is used ../../../../../../../newlib-2.5.0/newlib/libc/time/asctime.c:62:3: warning: type of 'malloc' does not match original declaration [-Wlto-type-mismatch] /Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: return value type mismatch extern _PTR malloc _PARAMS ((size_t)); ^ /Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: 'malloc' was previously declared here /Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: code may be misoptimized unless -fno-strict-aliasing is used ../../../../../../../newlib-2.5.0/newlib/libc/time/lcltime.c:58:3: warning: type of 'malloc' does not match original declaration [-Wlto-type-mismatch] /Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: return value type mismatch extern _PTR malloc _PARAMS ((size_t)); ^ /Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: 'malloc' was previously declared here /Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: code may be misoptimized unless -fno-strict-aliasing is used ../../../../../../../newlib-2.5.0/newlib/libc/string/strsignal.c:70:3: warning: type of 'malloc' does not match original declaration [-Wlto-type-mismatch] /Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: return value type mismatch extern _PTR malloc _PARAMS ((size_t)); ^ /Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: 'malloc' was previously declared here /Volumes/code/external/newlib-cygwin/newlib/libc/include/malloc.h:37:13: note: code may be misoptimized unless -fno-strict-aliasing is used Including the proper headers elminates the implicit function signatures and these warnings.
* Add _POSIX_SHARED_MEMORY_OBJECTSGedare Bloom2017-01-131-1/+1
|
* Expand comments on padding used by nano_mallocJoe Seymour2017-01-131-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.
* Fix sys/reent.h to remove use of DEBUG flag.Jeff Johnston2017-01-101-2/+2
| | | | | | | | - use of DEBUG flag is non-standard and interferes with other project's using same flag - change to be _REENT_CHECK_DEBUG which means the flag is allowing debugging of _REENT_CHECK macros - use #ifdef instead of #if
* Fix versions in documentation (manually for now)Corinna Vinschen2017-01-091-2/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Add pthread_setname_np() and pthread_getname_np()Sebastian Huber2017-01-091-0/+6
| | | | | | | The pthread_setname_np() and pthread_getname_np() are GNU extensions and provided by glibc. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Fix incorrect cast in nano mallocJoe Seymour2017-01-091-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.
* RTEMS: Add user-defined name to thread queuesSebastian Huber2017-01-091-1/+65
| | | | | | | | Add a user-defined name to the self-contained synchronization objects in order to make system diagnostics, tracing and debugging more user friendly. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Bump release to 2.5.0 for yearly snapshot.newlib-2_5_0Jeff Johnston2016-12-2297-1040/+999
|
* RTEMS: Increase SEM_VALUE_MAXSebastian Huber2016-12-201-1/+1
| | | | | | | RTEMS defined SEM_VALUE_MAX to 32767 unlike other systems like FreeBSD and glibc. A common value is INT_MAX. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Remove extraneous float casts in wcstod.c.Corinna Vinschen2016-12-161-2/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Remove extraneous float casts in strtod.c.Jeff Johnston2016-12-161-2/+2
|
* 2016-12-15 Kyrylo Tkachov <kyrylo.tkachov@arm.com>cygwin-2_6_1-releaseJeff Johnston2016-12-152-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-12-15 Giuseppe Musumeci <giuseppe.musumeci@broadcom.com>Jeff Johnston2016-12-151-2/+2
| | | | | | | | | | | | | | __sinit initialises some common file descriptors as line buffered and relies on the first users of such FDs to call __smakebuf_r. If __smakebuf_r realises there's no space for a buffer (malloc returns NULL), it makes them unbuffered. However, while setting the __SNBF bit, it doesn't clear the __SLBF bit in the flags. Depending on the order in which functions check buffering flags in the FD, sometime they assume it's line buffered (e.g. __sfvwrite_r), trashing application memory that's not really been allocated to them. This patch solves the problem by clearing the unbuffered/line buffered flag when setting the line buffered/unbuffered flag.
* Big-endian fix for memcpy-armv7m.SJulian Brown2016-12-121-0/+8
| | | | | | | | In the case of memcpy-armv7m.S being built for a big-endian multilib (including armv7 without a specific profile), realignment code made assumptions about the byte ordering being little-endian. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Add <devctl.h> per POSIX 1003.26-2003Joel Sherrill2016-12-053-0/+55
|
* Add missing crt0 symbols for RTEMSSebastian Huber2016-12-051-0/+5
| | | | | | | In order to enable proper detection of thread-local storage availability we have to provide some symbols on ARM. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Enforce no arguments for __get_current_locale/__get_C_localeCorinna Vinschen2016-11-281-2/+2
| | | | | | Remember: foo() != foo(void) Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Correct argument to __get_current_locale.Douglas2016-11-281-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Self-contained pthread_spinlock_t for RTEMSSebastian Huber2016-11-241-1/+5
| | | | | | | | | | | | | | | | | | | | Turn pthread_spinlock_t into a self-contained object. On uni-processor configurations, interrupts are disabled in the lock/trylock operations and the previous interrupt status is restored in the corresponding unlock operations. On SMP configurations, a ticket lock is a acquired and released in addition. See also: https://devel.rtems.org/ticket/2674 This implementation is simple and efficient. However, this test case of the Linux Test Project would fail due to call of printf() and sleep() during spin lock ownership: https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_lock/1-2.c Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Provide <memory.h>Sebastian Huber2016-11-221-0/+4
| | | | | | | | Provide <memory.h> for all standard Newlib targets and remove Cygwin-specific header. Most POSIX like systems provide this historic header. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Declare non-standard pthread_yield()Sebastian Huber2016-11-221-0/+4
| | | | | | | The non-standard pthread_yield() function is available at least on Cygwin, FreeBSD and glibc. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Move pthread types to <sys/_pthreadtypes.h>Sebastian Huber2016-11-174-230/+449
| | | | | | | | | | This makes it possible provide operating system specific types for <pthread.h>. It is in line with the FreeBSD header file structure and allows a future cleanup of <pthread.h> to not expose unrelated things via <sys/types.h> and <unistd.h>. Glibc uses the similar <bits/pthreadtypes.h> for this purpose. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Add _TICKET_LOCK_INITIALIZER to <sys/lock.h>Sebastian Huber2016-11-171-1/+3
| | | | | | | | Add _TICKET_LOCK_INITIALIZER to statically initialize a _Ticket_lock_Control structure. This makes it possible to embed a ticket lock in other structures outside of <sys/lock.h>. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Use __inline in <sys/lock.h> for RTEMSSebastian Huber2016-11-171-10/+10
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* sys/cdefs.h: Define __hidden as empty on CygwinCorinna Vinschen2016-11-081-0/+5
| | | | | | | Non-default visibility attributes are unsupported on PE/COFF, so don't use in __hidden definition for Cygwin. Add comment. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Use external header file for kernel space timeSebastian Huber2016-11-071-144/+4
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Add kernel space header for <sys/lock.h> for RTEMSSebastian Huber2016-11-071-1/+6
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Use external header file for kernel space typesSebastian Huber2016-11-072-7/+5
| | | | | | | The FreeBSD kernel types are not used in Newlib. Provide them via an external header file to decouple Newlib and FreeBSD updates for RTEMS. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Provide cap_ioctl_t for RTEMSSebastian Huber2016-11-071-0/+5
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Fix pdf build failure with texinfo 6.1.0Thomas Preudhomme2016-10-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi, make pdf on Ubuntu 16.04 fail with: newlib/libc/libc.texinfo:9: Missing @endcsname inserted. After a lot of fiddling the reason appears to be the combination of concept and function index despite a lack of concept index entries. Arguably texinfo should not error in that case but here we are, newlib will fail to build its documentation on some systems because of this. Since libc.texinfo only contains function index entries this patch simply removes the combination of indices. It does the same for libm.texinfo which has concept index entries but no function index entries. Tested by running make pdf, make dvi, make info and make html successfully. libc.pdf appears to have only one index as expected. == Proposed commit message == Fix pdf build failure with texinfo 6.1.0 as provided in Ubuntu 16.04. Index combination in libc.texinfo and libm.texinfo fails because both file have only one type of index entries. Removing index combination is thus harmless and solves the problem. Is this ok for master? Best regards, Thomas
* Provide vm_page_t for RTEMS via <machine/_types.h>Sebastian Huber2016-10-251-0/+1
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Provide rman_res_t for RTEMS via <machine/types.h>Sebastian Huber2016-10-251-0/+2
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Provide __intmax_t and __uintmax_tSebastian Huber2016-10-254-33/+40
| | | | | | | | Provide __intmax_t and __uintmax_t via <machine/_default_types.h> and define intmax_t and uintmax_t in <sys/_stdint.h> for FreeBSD compatibility. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Fix typo in <sys/_stdint.h>Sebastian Huber2016-10-251-1/+1
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* towupper: Eliminate dead codeCorinna Vinschen2016-10-221-3/+0
| | | | | | Fixes Coverity CID 59865 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix a potential buffer overflow in wscanf familyCorinna Vinschen2016-10-221-6/+8
| | | | | | Fixes Coverity CID 60046 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* get_alt_digits: Fix typo in allocationCorinna Vinschen2016-10-221-1/+1
| | | | | | | | adi->digit is an array of CHAR *, not of CHAR **. Fixes Coverity CID 60043 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Actually return value from __cp_indexCorinna Vinschen2016-10-222-4/+1
| | | | | | | | Fixes Coverty CID 153470 Also drop redundant declaration of __cp_index. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Drop redundant checks for NULL input string in wctomb helper funcsCorinna Vinschen2016-10-221-6/+0
| | | | | | Fixes Coverity CIDs 153465 and 153466 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix check for empty locale string in newlocaleCorinna Vinschen2016-10-221-2/+5
| | | | | | | | | | | | | | | The original test is broken. It tests for a NULL locale which isn't just wrong, it simply can't occur at this point due to an earlier check for a NULL locale string. Thus, the locale info for a category is never taken from the environment. Fixes Coverty CID 153467. Also, add comment. Also, add some parens for readability. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>