Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
AgeCommit message (Collapse)Author
2018-12-20RTEMS: Use __uint64_t for __ino_tSebastian Huber
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>
2018-12-20Plug routing sysctl leaks.markj
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
2018-12-13nano-vfprintf_float.c: Fix check if negative for nans.Jon Beniston
2018-12-10Fix powf overflow handling in non-nearest rounding modeSzabolcs Nagy
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.
2018-12-04sys/time.h: Remove KASSERTSebastian Huber
The KASSERT is only used by the FreeBSD kernel. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-12-04Ensure that all values of ns, us and ms workimp
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
2018-12-04When converting ns,us,ms to sbt, return the ceil()imp
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
2018-12-04Correct a misplaced closing paren.ian
Does not affect the result, but does clarify (at least for me) that the multiplication happens before the shift.
2018-12-04sys: further adoption of SPDX licensing ID tags.pfg
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.
2018-12-04Add inline functions to convert between sbintime_tian
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.)
2018-12-04Renumber copyright clause 4imp
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
2018-11-29stdio.h: Expose cuserid with __GNU_VISIBLECorinna Vinschen
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-11-29time.h: Introduce Linux-specific CLOCK id valuesCorinna Vinschen
- 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>
2018-11-26Builtin enable return code with SYS_EXIT_EXTENDEDMatthew Malcomson
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.
2018-11-08Fix issue with dst bias in memsetWilco Dijkstra
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. --
2018-11-08Fix v850 target for RTEMScygwin-2_11_2-releaseSebastian Huber
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>
2018-11-08RTEMS: Avoid <machine/param.h> in <sys/_cpuset.h>Sebastian Huber
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>
2018-11-06Adjust writeback in non-zero memsetWilco Dijkstra
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.
2018-11-05newlib/configure.host: Set have_init_fini to no for OpenRISCStafford Horne
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>
2018-10-22Fix posix_memalign() attributesSebastian Huber
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>
2018-10-22RTEMS: Use function and data sectionsSebastian Huber
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-19newlib/libc/sys/rtems/include/machine/param.h: Add _KERNEL to stop method ↵Joel Sherrill
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()
2018-10-18Improve performance of strstrWilco Dijkstra
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). --
2018-10-11newlib/libc/ctype/jp2uc.c: Declare "cs" variable as "const char *"Christophe Lyon
Instead of "char *" to avoid compiler warnings. This is OK because "cs" is only used as input of strcmp.
2018-10-11Add generic implementation of fdopendir()Sebastian Huber
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11Add generic implementation of dirfd()Sebastian Huber
Use existing HAVE_OPENDIR define to determine if a generic implementation should be provided. Cygwin for example has its own implementation of opendir() and dirfd(). Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11RTEMS: Add struct dirent::d_type memberSebastian Huber
This is used by the file system support of libstdc++ for example. Use content from latest FreeBSD <sys/dirent.h> Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11Move common <sys/dirent.h> content to <dirent.h>Sebastian Huber
Move common content of the various <sys/dirent.h> and the latest FreeBSD <dirent.h> to <dirent.h>. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11Open a directory with the usual flagsSebastian Huber
Use O_RDONLY since you are not supposed to write to a directory. Use O_DIRECTORY as mandated by POSIX (The Open Group Base Specifications Issue 7, 2018 edition IEEE Std 1003.1-2017): "If the type DIR is implemented using a file descriptor, the descriptor shall be obtained as if the O_DIRECTORY flag was passed to open()." Use O_CLOEXEC as mandated by POSIX: "When a file descriptor is used to implement the directory stream, it behaves as if the FD_CLOEXEC had been set for the file descriptor." Drop the fcntl() call in favour of O_CLOEXEC. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11Make some standard open() flags visibleSebastian Huber
Make the POSIX O_CLOEXEC, O_NOFOLLOW, O_DIRECTORY, O_EXEC, and O_SEARCH open() flags available also to non-Cygwin systems. Make the BSD/glibc O_DIRECT open() flag available also to non-Cygwin systems. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-10newlib: Build internal strtold code only if HAVE_LONG_DOUBLE definedCorinna Vinschen
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 Vinschen
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-10-10Implement nanl in newlib onlyCorinna Vinschen
Drop Cygwin-specific nanl in favor of a generic implementation in newlib. Requires GCC 3.3 or later. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-10-10newlib: Drop incorrect const qualifier from __loadlocale parameterCorinna Vinschen
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-10-10Add attributes to malloc-like functionsSebastian Huber
These attributes help static analysis tools to produce less false positives, e.g. double free warnings. Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-08[ARM] Make _kill() a noreturn function.Christophe Lyon
AngelSWI_Reason_ReportException does not return accoring to the ARM documentation, so it is valid to mark _kill() as noreturn. This way, the compiler does not warn about _exit() returning a value despite being noreturn. 2018-10-01 Christophe Lyon <christophe.lyon@linaro.org> * libgloss/arm/_exit.c (_exit): Declare _kill() as noreturn. * libgloss/arm/_exit.c (_kill): Likewise. Remove the return statements. * newlib/libc/sys/arm/syscalls.c (_kill): Likewise..
2018-10-05Define _COMPILING_NEWLIB on aarch64 to define function prototypes from unistd.h.Christophe Lyon
2018-10-01 Christophe Lyon <christophe.lyon@linaro.org> * newlib/configure.host: Define _COMPILING_NEWLIB for aarch64.
2018-10-05 [ARM] Cast string pointers to int to avoid compiler warnings.Christophe Lyon
2018-10-01 Christophe Lyon <christophe.lyon@linaro.org> * newlib/libc/sys/arm/syscalls.c (_unlink): Cast 'path' to int. (_system): Cast 's' to int. (_rename): Cast 'newpath' and 'oldpath' to int.
2018-09-28Update Arm copyright notices in new math filesWilco Dijkstra
While working on the strstr patch I noticed several copyright headers of the new math functions are missing closing quotes after ``AS IS. I've added these. Also update spellings of Arm Ltd in a few places (but still use ARM LTD in upper case portion). Finally add SPDX identifiers to make everything consistent.
2018-09-18Fix the documentation comment of checkintSzabolcs Nagy
checkint in pow is not supposed to be used with 0, inf or nan inputs.
2018-09-13Committed, CRIS port: fix fallout from time_t defaulting to 64 bits, part 2Hans-Peter Nilsson
It's been a while... I see the CRIS port broke with the time_t-default-to-64-bit change, observable by a few test-cases in the gcc fortran(!) tests failing, regressing when trying a recent newlib. This is a two-part belt-and-suspenders change: adjust the CRIS port gettimeofday syscall (the only one in newlib/CRIS passing a time_t or struct timeval) to handle a userspace 64-bit time_t and secondly default time_t to 32-bit long anyway. I considered making the local "kernel_timeval" copy in _gettimeofday conditional on (userspace) time_t being 64 bits, but thought it not worth bothering with the few move insns. The effect of a 64-bit time_t is however observable as longer simulation time when running the gcc testsuite and as bigger binaries without any actual upside from the larger time_t size, so I thought better make the default for this port go back to being a "long" again. Tested by running the gcc testsuite over the three combinations of two parts of the patch and observing the expected changes. Committed. newlib: * configure.host (cris, crisv32): Default to "long" time_t. Signed-off-by: Hans-Peter Nilsson <hp@axis.com>
2018-09-06search: Fix Berkeley DB hash code for 16-bit targets.Jon Beniston
hash.h: Use 32-bit type for data stored on disk, so code works for 16 and 64-bit targets. Reduce maximum bucket size on 16-bit targets, so it fits in available memory. hash.c: Check bucket size isn't too big for target. hash_buf.c: Fix overflow warning on 16-bit targets.
2018-09-06Use !__HAVE_LOCALE_INFO__ define to use _ctype_ directly [v2]Keith Packard
When __HAVE_LOCALE_INFO__ is not selected, directly access the existing _ctype_ variable from __locale_ctype_ptr() and __locale_ctype_ptr_l(), eliminating the need for any locale or reent structure Signed-off-by: Keith Packard <keithp@keithp.com> v2: locale: fix conflict with __locale_ctype_ptr macro If we are building without __HAVE_LOCALE_INFO__, there is a macro providing __locale_ctype_ptr which in turn fouls up this declaration. Signed-off-by: Michael Lyle <mlyle@lyle.org>
2018-09-06stdlib: Use __get_numeric_locale instead of __localeconv_l for decimal_pointKeith Packard
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-06Include sys/syslimits.h in limits.hKeith Packard
This makes sure any system-defined limits are specified before the defaults are checked. Without this, ARG_MAX and PATH_MAX end up getting the default definitions from limits.h rather than the defines from syslimits.h. This could potentially cause problems when different files used different values for the same name. Signed-off-by: Keith Packard <keithp@keithp.com>
2018-09-06xdr_private.h needs sys/types.h for u_charKeith Packard
u_char is defined in sys/types.h, which doesn't appear to get included, at least in my environments. Signed-off-by: Keith Packard <keithp@keithp.com>
2018-09-06Document the log table generation methodSzabolcs Nagy
Add comments with enough detail so the log lookup tables can be recreated.
2018-09-06stdlib/arc4random.c: Fix reseed count for 16-bit targets.Jon Beniston
2018-09-05Improve strstr performance of short needlesWilco Dijkstra
Improve strstr performance for the common case of short needles. For a single character strchr is best, for 2-4 characters a small loop is fastest. For these the speedup over the Two-Way algorithm is ~10 times on large strings. Newlib builds, the new code passes GLIBC testsuite. OK for commit?
2018-09-03math_config.h: Fix signed overflow warning for 16-bit targetscygwin-2_11_1-releaseJon Beniston