summaryrefslogtreecommitdiffstats
path: root/newlib
Commit message (Collapse)AuthorAgeFilesLines
* Cygwin: add secure_getenvYaakov Selkowitz2019-02-191-0/+3
| | | | Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
* Define u_register_t if __BSD_VISIBLESebastian Huber2019-02-191-0/+2
| | | | | | Add u_register_t definition for FreeBSD compatibility. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Change register_t definitionSebastian Huber2019-02-191-1/+1
| | | | | | On 64-bit targets, the register_t type must be a 64-bit integer. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Fix comment in <sys/types.h>Sebastian Huber2019-02-191-1/+1
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Move RTEMS and XMK specific type definitionsSebastian Huber2019-02-193-16/+12
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* scandir: Add support for struct dirent::d_typeSebastian Huber2019-02-011-1/+4
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* a) Use strcoll() in opendir() and alphasort()ache2019-02-011-3/+4
| | | | | | | | | | | | | | | | | as POSIX 2008 requires. It also matches now how our 'ls' works for years. b) Remove comment expressed 2 fears: 1) One just simple describe how strcoll() works in _any_ context, not for directories only. Are we plan to remove strcoll() from everything just because it is little more complex than strcmp()? I doubt, and directories give nothing different here. Moreover, strcoll() used in 'ls' for years and nobody complaints yet. 2) Plain wrong statement about undefined strcoll() behaviour. strcoll() always gives predictable results, falling back to strcmp() on any trouble, see strcoll(3). No objections from -current list discussion.
* scandir(3) previously used st_sizedas2019-02-011-53/+31
| | | | | | | | | | | | | | to obtain an initial estimate of the array length needed to store all the directory entries. Although BSD has historically guaranteed that st_size is the size of the directory file, POSIX does not, and more to the point, some recent filesystems such as ZFS use st_size to mean something else. The fix is to not stat the directory at all, set the initial array size to 32 entries, and realloc it in powers of 2 if that proves insufficient. PR: 113668
* Remove __P and convert to ANSI prototypes.obrien2019-02-011-7/+4
| | | | * Fix SCM ID's.
* Clean up the vcs ID stringsjhb2019-02-011-3/+2
| | | | | | | | | | | | | | | | | | | in libc's gen/ directory. - Move CSRG IDs into __SCCSID(). - When a file has been copied, consistently use 'From: <tag>' for strings referencing the version of the source file copied from in the license block comment. - Some of the 'From:' tags were using $FreeBSD$ that was being expanded on each checkout. Fix those to hardcode the FreeBSD tag from the file that was copied at the time of the copy. - When multiple strings are present list them in "chronological" order, so CSRG (__SCCSID) before FreeBSD (__FBSDID). If a file came from OtherBSD and contains a CSRG ID from the OtherBSD file, use the order CSRG -> OtherBSD -> FreeBSD. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D15831
* Renumber copyright clause 4imp2019-02-011-1/+1
| | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96
* scandir: Update copyright notice from FreeBSDSebastian Huber2019-02-011-3/+3
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* General further adoption of SPDX licensing ID tags.pfg2019-02-011-0/+2
| | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. 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. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point.
* Use nanf() instead of nan() in single-precision float libm math functionsJozef Lawrynowicz2019-01-234-4/+4
| | | | | This patch reduces code size for a few single-precision float math functions, by using nanf() instead of nan() where required.
* Use HUGE_VALF instead of HUGE_VAL in single-precision float libm math functionsJozef Lawrynowicz2019-01-2316-18/+18
| | | | | This patch replaces instances of "(float).*HUGE_VAL" with a direct usage of HUGE_VALF, which is also defined in math.h.
* Remove HUGE_VAL definition from libm math functionsJozef Lawrynowicz2019-01-2331-186/+0
| | | | | | This patch removes the definitions of HUGE_VAL from some of the float math functions. HUGE_VAL is defined in newlib/libc/include/math.h, so it is not necessary to have a further definition in the math functions.
* Remove matherr, and SVID and X/Open math library configurationsJozef Lawrynowicz2019-01-2375-2298/+405
| | | | Default math library configuration is now IEEE
* time.h: Add CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARMCorinna Vinschen2019-01-221-8/+12
| | | | | | Slightly reshuffle and add comment Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* AMD GCN Port contributed by Andrew Stubbs <ams@codesourcery.com>Jeff Johnston2019-01-1531-4/+13112
| | | | | | | | | | | | | | Add support for the AMD GCN GPU architecture. This is primarily intended for use with OpenMP and OpenACC offloading. It can also be used for stand-alone programs, but this is intended mostly for testing the compiler and is not expected to be useful in general. The GPU architecture is highly parallel, and therefore Newlib must be configured to use dynamic re-entrancy, and thread-safe malloc. The only I/O available is a via a shared-memory interface provided by libgomp and the gcn-run tool included with GCC. At this time this is limited to stdout, argc/argv, and the return code.
* update to Unicode 11.0Thomas Wolff2019-01-134-93/+159
|
* map WEOF to undefined rather than the control char categoryThomas Wolff2019-01-131-1/+1
| | | | Fixes https://cygwin.com/ml/cygwin/2018-12/msg00173.html
* fcntl.h: expose AT_EMPTY_PATH with _GNU_SOURCE onlyCorinna Vinschen2019-01-071-0/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: linkat: support Linux-specific AT_EMPTY_PATH flagCorinna Vinschen2019-01-071-0/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: open: support Linux-specific O_PATH flagCorinna Vinschen2019-01-071-0/+2
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Improve performance of memmemWilco Dijkstra2019-01-012-51/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch significantly improves performance of memmem using a novel modified Horspool algorithm.  Needles up to size 256 use a bad-character table indexed by hashed pairs of characters to quickly skip past mismatches. Long needles use a self-adapting filtering step to avoid comparing the whole needle repeatedly. By limiting the needle length to 256, the shift table only requires 8 bits per entry, lowering preprocessing overhead and minimizing cache effects. This limit also implies worst-case performance is linear. Small needles up to size 2 use a dedicated linear search.  Very long needles use the Two-Way algorithm (to avoid increasing stack size inlining is now disabled). The performance gain is 6.6 times on English text on AArch64 using random needles with average size 8 (this is even faster than the recently improved strstr algorithm, so I'll update that in the near future). The size-optimized memmem has also been rewritten from scratch to get a 2.7x performance gain. Tested against GLIBC testsuite and randomized tests. Message-Id: <DB5PR08MB1030649D051FA8532A4512C883B20@DB5PR08MB1030.eurprd08.prod.outlook.com>
* Bump release to 3.1.0 for yearly snapshotnewlib-snapshot-20181231newlib-3.1.0Jeff Johnston2018-12-31106-1068/+1135
|
* RTEMS: Use __uint64_t for __ino_tSebastian Huber2018-12-201-1/+1
| | | | | | | FreeBSD uses a 64-bit ino_t since 2017-05-23. We need this for the pipe() support in libbsd. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Plug routing sysctl leaks.markj2018-12-201-1/+5
| | | | | | | | | | | | Various structures exported by sysctl_rtsock() contain padding fields which were not being zeroed. Reported by: Thomas Barabosch, Fraunhofer FKIE Reviewed by: ae MFC after: 3 days Security: kernel memory disclosure Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D18333
* nano-vfprintf_float.c: Fix check if negative for nans.Jon Beniston2018-12-131-1/+2
|
* Fix powf overflow handling in non-nearest rounding modeSzabolcs Nagy2018-12-101-0/+10
| | | | | | | | | | | | | | | | | | | | | The threshold value at which powf overflows depends on the rounding mode and the current check did not take this into account. So when the result was rounded away from zero it could become infinity without setting errno to ERANGE. Example: pow(0x1.7ac7cp+5, 23) is 0x1.fffffep+127 + 0.1633ulp If the result goes above 0x1.fffffep+127 + 0.5ulp then errno is set, which is fine in nearest rounding mode, but powf(0x1.7ac7cp+5, 23) is inf in upward rounding mode powf(-0x1.7ac7cp+5, 23) is -inf in downward rounding mode and the previous implementation did not set errno in these cases. The fix tries to avoid affecting the common code path or calling a function that may introduce a stack frame, so float arithmetics is used to check the rounding mode and the threshold is selected accordingly.
* sys/time.h: Remove KASSERTSebastian Huber2018-12-041-12/+0
| | | | | | The KASSERT is only used by the FreeBSD kernel. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Ensure that all values of ns, us and ms workimp2018-12-041-7/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for {n,u,m}stosbt Integer overflows and wrong constants limited the accuracy of these functions and created situatiosn where sbttoXs(Xstosbt(Y)) != Y. This was especailly true in the ns case where we had millions of values that were wrong. Instead, used fixed constants because there's no way to say ceil(X) for integer math. Document what these crazy constants are. Also, use a shift one fewer left to avoid integer overflow causing incorrect results, and adjust the equasion accordingly. Document this. Allow times >= 1s to be well defined for these conversion functions (at least the Xstosbt). There's too many users in the tree that they work for >= 1s. This fixes a failure on boot to program firmware on the mlx4 NIC. There was a msleep(1000) in the code. Prior to my recent rounding changes, msleep(1000) worked, but msleep(1001) did not because the old code rounded to just below 2^64 and the new code rounds to just above it (overflowing, causing the msleep(1000) to really sleep 1ms). A test program to test all cases will be committed shortly. The test exaustively tries every value (thanks to bde for the test). Sponsored by: Netflix, Inc Differential Revision: https://reviews.freebsd.org/D18051
* When converting ns,us,ms to sbt, return the ceil()imp2018-12-041-3/+7
| | | | | | | | | | | of the result rather than the floor(). Returning the floor means that sbttoX(Xtosbt(y)) != y for almost all values of y. In practice, this results in a difference of at most 1 in the lsb of the sbintime_t. This difference is meaningless for all current users of these functions, but is important for the newly introduced sysctl conversion routines which implicitly rely on the transformation being idempotent. Sponsored by: Netflix, Inc
* Correct a misplaced closing paren.ian2018-12-041-3/+3
| | | | | Does not affect the result, but does clarify (at least for me) that the multiplication happens before the shift.
* sys: further adoption of SPDX licensing ID tags.pfg2018-12-041-0/+2
| | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. 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. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point.
* Add inline functions to convert between sbintime_tian2018-12-041-7/+52
| | | | | | | | | | | | and decimal time units. Use them in some existing code that is vulnerable to roundoff errors. The existing constant SBT_1NS is a honeypot, luring unsuspecting folks into writing code such as long_timeout_ns*SBT_1NS to generate the argument for a sleep call. The actual value of 1ns in sbt units is ~4.3, leading to a large roundoff error giving a shorter sleep than expected when multiplying by the trucated value of 4 in SBT_1NS. (The evil honeypot aspect becomes clear after you waste a whole day figuring out why your sleeps return early.)
* Renumber copyright clause 4imp2018-12-041-1/+1
| | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96
* stdio.h: Expose cuserid with __GNU_VISIBLECorinna Vinschen2018-11-291-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* time.h: Introduce Linux-specific CLOCK id valuesCorinna Vinschen2018-11-291-4/+18
| | | | | | | | | | | | | | | - Add CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_RAW, CLOCK_MONOTONIC_COARSE and CLOCK_BOOTTIME - Guard new values with __GNU_VISIBLE - Add CLOCK_REALTIME_COARSE as (clockid_t) 0 for simplicity (It allows to have all values < 8 and so be used as array index into an array of clocks) - Fix macro bracketing Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Builtin enable return code with SYS_EXIT_EXTENDEDMatthew Malcomson2018-11-261-19/+43
| | | | | | | A previous commit introduced the ability to use the semi-hosting SYS_EXIT_EXTENDED operation to libgloss, this commit adds the same ability to the sys/arm/ backend so that building newlib only will provide the same capabilities.
* Fix issue with dst bias in memsetWilco Dijkstra2018-11-081-0/+1
| | | | | | | | | | | | This patch fixes an issue in the previous memset loop change. If the zva size is >= 256 and there are more than 64 bytes left in the tail, we could enter the loop and thus need to rebias dst by 32 as well. Since no known CPUs use this size this can't be tested natively, so I've tested it on a simulator initialized with a large zva size. --
* Fix v850 target for RTEMScygwin-2_11_2-releaseSebastian Huber2018-11-081-1/+1
| | | | | | | | | | | | | | | Do not define __ATTRIBUTE_IMPURE_PTR__ for RTMES on the v850 target. The previous definition lead to the following linker error in combination with -fdata-sections: relocation truncated to fit: R_V810_GPWLO_1 against symbol `_global_impure_ptr' defined in .rodata._global_impure_ptr section in libc.a(lib_a-impure.o) relocation truncated to fit: R_V810_GPWLO_1 against symbol `_impure_ptr' defined in .data._impure_ptr section in libc.a(lib_a-impure.o) Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* RTEMS: Avoid <machine/param.h> in <sys/_cpuset.h>Sebastian Huber2018-11-081-2/+5
| | | | | | | | The <machine/param.h> header file exposes some unrelated stuff not covered by C or POSIX. Avoid its use in <sys/_cpuset.h> since it is included in <rtems.h>. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* Adjust writeback in non-zero memsetWilco Dijkstra2018-11-061-3/+3
| | | | | | | | This fixes an ineffiency in the non-zero memset. Delaying the writeback until the end of the loop is slightly faster on some cores - this shows ~5% performance gain on Cortex-A53 when doing large non-zero memsets. Tested against the GLIBC testsuite.
* newlib/configure.host: Set have_init_fini to no for OpenRISCStafford Horne2018-11-051-0/+1
| | | | | | | | The new GCC port for OpenRISC will use the init_fini_array only and not provide the init() and fini() functions. Disable the function usage by default as its no longer needed. Signed-off-by: Stafford Horne <shorne@gmail.com>
* Fix posix_memalign() attributesSebastian Huber2018-10-221-2/+2
| | | | | | | | | | | The malloc, alloc_size and alloc_aligned attributes must be only used in case the function returns the pointer to the allocated memory. See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87683 Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* RTEMS: Use function and data sectionsSebastian Huber2018-10-221-0/+1
| | | | Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* newlib/libc/sys/rtems/include/machine/param.h: Add _KERNEL to stop method ↵Joel Sherrill2018-10-181-0/+3
| | | | | | | | | | | | | leakage The following FreeBSD kernel methods are not in any standard and prototypes/definitions were leaking into application space: + round_page() + trunc_page() + atop() + ptoa() + pgtok()
* Improve performance of strstrWilco Dijkstra2018-10-181-96/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | v3: Add support for read ahead using strnlen, giving an additional 25% speedup on large inputs (both short and long needles). This patch significantly improves performance of strstr by using Sunday's Quick-Search algorithm. Due to its simplicity it has the best average performance of string matching algorithms on almost all inputs. It uses a bad-character shift table to skip past mismatches. The needle length is limited to 254 - this reduces the shift table memory 4 to 8 times, lowering preprocessing overhead and minimizing cache effects. The limit also implies its worst-case performance is linear. Larger needles are processed by the Two-Way algorithm. The macro AVAILABLE has been improved to use strnlen to read the input in chunks. This results in a 2.5 times speedup for large needles, reducing the performance drop when the Quick-Search algorithm can't be used. The code for 1-4 byte needles has been simplified and now uses unsigned char. Since the optimized code relies on 8-bit chars, we defer to the size-optimized implementation if CHAR_BIT > 8. The performance gain of finding a set of randomly chosen words of size 8 in 256 bytes of English text is 14 times on AArch64. For longer haystacks the gain is well over 20 times. The size-optimized strstr has also been rewritten from scratch to improve performance. On the same test the performance gain is 69%. Tested against GLIBC testsuite, randomized tests and the GNULIB strstr test (https://git.savannah.gnu.org/cgit/gnulib.git/tree/tests/test-strstr.c). --
* newlib/libc/ctype/jp2uc.c: Declare "cs" variable as "const char *"Christophe Lyon2018-10-111-2/+2
| | | | | Instead of "char *" to avoid compiler warnings. This is OK because "cs" is only used as input of strcmp.