summaryrefslogtreecommitdiffstats
path: root/newlib
Commit message (Collapse)AuthorAgeFilesLines
* RISC-V: Add machine-specific implementation for lrint[f], lround[f], ↵Kito Cheng2020-11-1810-3/+503
| | | | llrint[f] and llround[f].
* RISC-V: Add machine-specific implementation for isnan[f] and copysign[f]Kito Cheng2020-11-186-3/+237
|
* RISC-V: Add missing compile rule for s_finite.c, sf_finite.c, s_isinf.c and ↵Kito Cheng2020-11-182-3/+33
| | | | sf_isinf.c
* malloc/nano-malloc: correctly check for out-of-bounds allocation reqsCorinna Vinschen2020-11-172-2/+27
| | | | | | | | | | | | The overflow check in mEMALIGn erroneously checks for INT_MAX, albeit the input parameter is size_t. Fix this to check for __SIZE_MAX__ instead. Also, it misses to check the req against adding the alignment before calling mALLOc. While at it, add out-of-bounds checks to pvALLOc, nano_memalign, nano_valloc, and Cygwin's (unused) dlpvalloc. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix return type of __locale_ctype_ptr_l()Sebastian Huber2020-11-161-1/+1
| | | | | | | This prevents warnings like this: ctype.h:118:9: warning: return discards 'const' qualifier from pointer target type
* libc/include/newlib.h: Fix C++ compilation issueJoel Sherrill2020-11-161-2/+2
|
* Fix 32-bit integer overflow when calculating TZ rulesIvan Grokhotov2020-11-041-1/+1
|
* RISC-V: Fix wrong including file in s_isinf.cKito Cheng2020-10-291-1/+1
|
* RISC-V: NaN should return 0 for finite[f]Kito Cheng2020-10-292-2/+2
|
* libc/sys/rtems/include/machine/_types.h: Define daddr_t to be 64 bits for RTEMSJoel Sherrill2020-10-281-0/+3
| | | | | This type needs to be able to represent a position on a disk or file system.
* RISC-V: Implment finite and fpclassifyKito Cheng2020-10-279-3/+421
|
* RISC-V: Add fabs[f], fmax[f] and fmin[f].Kito Cheng2020-10-278-3/+345
|
* Define RB_SET_PARENT to do all assignmentsdougm2020-10-261-30/+28
| | | | | | | | | | | | | | | to rb parent pointers. Define RB_SWAP_CHILD to replace the child of a parent with its twin, and use it in 4 places. Use RB_SET in rb_link_node to remove the only linuxkpi reference to color, and then drop color- and parent-related definitions that are defined and used only in rbtree.h. This is intended to be entirely cosmetic, with no impact on program behavior, and leave RB_PARENT and RB_SET_PARENT as the only ways to read and write rb parent pointers. Reviewed by: markj, kib Tested by: pho Differential Revision: https://reviews.freebsd.org/D25264
* In concluding RB_REMOVE_COLOR, in the case whendougm2020-10-261-15/+11
| | | | | | | | | | | | the sibling of the root of the too-short tree is black and at least one of the children of that sibling is red, either one or two rotations finish the rebalancing. In the case when both of the children are red, the current implementation uses two rotations where only one is necessary. This change removes that extra rotation, and in that case also removes a needless black-to-red-to-black recoloring. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D25335
* Linuxkpi uses the rb-tree structuresdougm2020-10-261-148/+137
| | | | | | | | | without using their interfaces, making them break when the representation changes. Revert changes that eliminated the color field from rb-trees, leaving everything as it was before. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D25250
* Fixup r361997 by balancing parens. Duh.dougm2020-10-261-1/+1
|
* Restore an RB_COLOR macro, for the benefit ofdougm2020-10-261-0/+6
| | | | | | | | a bit of DIAGNOSTIC code that depends on it. Reported by: rpokala, mjguzik Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D25204
* To reduce the size of an rb_node, drop the colordougm2020-10-261-138/+143
| | | | | | | | | | | | | | field. Set the least significant bit in the pointer to the node from its parent to indicate that the node is red. Have the tree rotation macros leave the old-parent/new-child node red and the new-parent/old-child node black. This change makes RB_LEFT and RB_RIGHT no longer assignable, and RB_COLOR no longer defined. Any code that modifies the tree or examines a node color would have to be modified after this change. Reviewed by: markj Tested by: pho Differential Revision: https://reviews.freebsd.org/D25105
* Remove from RB_REMOVE_COLOR some null checksdougm2020-10-261-26/+20
| | | | | | | | | where the pointer checked is provably never null. Restructure the surrounding code just enough to make the non-nullness obvious. Reviewed by: markj Tested by: pho Differential Revision: https://reviews.freebsd.org/D25089
* RB_REMOVE invokes RB_REMOVE_COLOR either whendougm2020-10-261-72/+65
| | | | | | | | | | | | | | | | | child is red or child is null. In the first case, RB_REMOVE_COLOR just changes the child to black and returns. With this change, RB_REMOVE handles that case, and drops the child argument to RB_REMOVE_COLOR, since that value is always null. RB_REMOVE_COLOR is changed to remove a couple of unneeded tests, and to eliminate some deep indentation. RB_ISRED is defined to combine a null check with a test for redness, to replace that combination in several places. Reviewed by: markj Tested by: pho Differential Revision: https://reviews.freebsd.org/D25032
* For the case when RB_REMOVE requires a nontrivialdougm2020-10-261-28/+24
| | | | | | | | | | | | search to find the node to replace the one being removed, restructure to first remove the replacement node and correct the parent pointers around it, and then let the all-cases code at the end deal with the parent of the deleted node, making it point to the replacement node. This removes one or two conditional branches. Reviewed by: markj Tested by: pho Differential Revision: https://reviews.freebsd.org/D24845
* Correct the use of RB_AUGMENT in the RB_TREEdougm2020-10-261-50/+38
| | | | | | | | | | | | | macros so that is invoked at the root of every subtree that changes in an insert or delete, and only once, and ordered from the bottom of the tree to the top. For intel_gas.c, the only user of RB_AUGMENT I can find, change the augmenting routine so that it does not climb from entry to tree root on every call, and remove a 'tree correcting' function that can be supplanted by proper tree augmentation. Reviewed by: kib Tested by: pho Differential Revision: https://reviews.freebsd.org/D23189
* Add RB_REINSERT(3), a low overhead alternative totrasz2020-10-261-2/+24
| | | | | | | | | | | | removing a node and reinserting it back with an updated key. This is one of dependencies for the upcoming stats(3) code. Reviewed by: cem Obtained from: Netflix MFC after: 2 weeks Sponsored by: Klara Inc, Netflix Differential Revision: https://reviews.freebsd.org/D21786
* amd64: prevent KCSan false positives on LAPIC mappingjah2020-10-261-0/+2
| | | | | | | | | | | | | | | | | | | For configurations without x2APIC support (guests, older hardware), the global LAPIC MMIO mapping will trigger false-positive KCSan reports as it will appear that multiple CPUs are concurrently reading and writing the same address. This isn't actually true, as the underlying physical access will be performed on the local CPU's APIC. Additionally, because LAPIC access can happen during event timer configuration, the resulting KCSan printf can produce a panic due to attempted recursion on event timer resources. Add a __nosanitizethread preprocessor define to prevent the compiler from inserting TSan hooks, and apply it to the x86 LAPIC accessors. PR: 249149 Reported by: gbe Reviewed by: andrew, kib Tested by: gbe Differential Revision: https://reviews.freebsd.org/D26354
* sys: clean up empty lines in .c and .h filesmjg2020-10-261-1/+0
|
* gcc: quiet Wattribute for no_sanitize("address")rlibby2020-10-261-2/+6
| | | | | | | | | | | | This is an unfortunate instance where the __has_attribute check does not function usefully. Gcc does have the attribute, but for gcc it only applies to functions, not variables, and trying to apply it to a variable generates Wattribute. So far we only apply the attribute to variables. Only enable the attribute for clang, for now. Reviewed by: Anton Rang <rang at acm.org> Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22875
* Don't sanitize linker_setdab2020-10-261-0/+7
| | | | | | | | | | | | | The assumptions of linker_set don't play nicely with AddressSanitizer. AddressSanitizer adds a 'redzone' of zeros around globals (including those in named sections), whereas linker_set assumes they are all packed consecutively like a pointer array. So: let's annotate linker_set so that AddressSanitizer ignores it. Submitted by: Matthew Bryan <matthew.bryan@isilon.com> Reviewed by: kib, rang_acm.org Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22239
* Make the system C11 atomics headers fully compatible with external GCC.jhb2020-10-262-15/+12
| | | | | | | | | | | | | | | | | | | | The <sys/cdefs.h> and <stdatomic.h> headers already included support for C11 atomics via intrinsincs in modern versions of GCC, but these versions tried to "hide" atomic variables inside a wrapper structure. This wrapper is not compatible with GCC's internal <stdatomic.h> header, so that if GCC's <stdatomic.h> was used together with <sys/cdefs.h>, use of C11 atomics would fail to compile. Fix this by not hiding atomic variables in a structure for modern versions of GCC. The headers already avoid using a wrapper structure on clang. Note that this wrapper was only used if C11 was not enabled (e.g. via -std=c99), so this also fixes compile failures if a modern version of GCC was used with -std=c11 but with FreeBSD's <stdatomic.h> instead of GCC's <stdatomic.h> and this change fixes that case as well. Reported by: Mark Millard Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D16585
* libc/time: Move internal newlib tz-structs into own headerTorbjörn SVENSSON via Newlib2020-10-155-57/+25
| | | | | | | | | | | | | | As discussed in GCC bug 97088 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97088), parameters in prototypes of library functions should use reserved names, or no name at all. This patch moves the internal struct __tzrule_struct to its own internal header sys/_tz_structs.h. This is included from newlib's time code as well as from Cygwin's localtime wrapper. Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* drop ambiguous-wide behaviour from Unicode CJK localesThomas Wolff2020-10-131-13/+5
|
* libc/include/wchar.h: Remove parameter nameTorbjörn SVENSSON2020-10-021-2/+2
| | | | | | | | | | | | | | | | | As discussed in GCC bug 97088 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97088), parameters in prototypes of library functions should use reserved names, or no name at all. This patch removes the 'ptr' parameter name from wint_t _getwchar_r (struct _reent *); wint_t _getwchar_unlocked_r (struct _reent *); to avoid possible clashes with user code in case someone uses before including Newlib's wchar.h (or uses some other conflicting definition) Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
* libc/include/inttypes.h: Remove parameter nameTorbjörn SVENSSON2020-10-021-1/+1
| | | | | | | | | | | | | | | | As discussed in GCC bug 97088 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97088), parameters in prototypes of library functions should use reserved names, or no name at all. This patch removes the 'j' parameter name from extern intmax_t imaxabs(intmax_t); to avoid possible clashes with user code in case someone uses before including Newlib's inttypes.h (or uses some other conflicting definition) Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
* libc/include/math.h: Remove parameter nameChristophe Lyon2020-09-251-8/+8
| | | | | | | | | | | | | | | | | | | | | As discussed in GCC bug 97088 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97088), parameters in prototypes of library functions should use reserved names, or no name at all. This patch removes the 'x' parameter name from extern int __isinff (float); extern int __isinfd (double); extern int __isnanf (float); extern int __isnand (double); extern int __fpclassifyf (float); extern int __fpclassifyd (double); extern int __signbitf (float); extern int __signbitd (double); to avoid possible clashes with user code in case someone uses before including Newlib's math.h (or uses some other conflicting definition)
* Port of C-SKY for newlibJojo R2020-09-2311-2/+6360
| | | | | | | | | Contributor list:   - Lifang Xia <lifang_xia@c-sky.com>   - Jojo R <jiejie_rong@c-sky.com>   - Xianmiao Qu <xianmiao_qu@c-sky.com>   - Yunhai Shang <yunhai_shang@c-sky.com>
* libm: Make tgamma(-small) = -INFINITYKeith Packard2020-09-181-1/+1
| | | | | | | Need to copy the argument sign to the output for tgamma(finite) overflow case. Signed-off-by: Keith Packard <keithp@keithp.com>
* libm: Fix 'gamma' and 'gammaf' functions. Clean up other gamma code. [v2]Keith Packard via Newlib2020-09-0413-118/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current gamma, gamma_r, gammaf and gammaf_r functions return |gamma(x)| instead of ln(|gamma(x)|) due to a change made back in 2002 to the __ieee754_gamma_r implementation. This patch fixes that, making all of these functions map too their lgamma equivalents. To fix the underlying bug, the __ieee754_gamma functions have been changed to return gamma(x), removing the _r variants as those are no longer necessary. Their names have been changed to __ieee754_tgamma to avoid potential confusion from users. Now that the __ieee754_tgamma functions return the correctly signed value, the tgamma functions have been modified to use them. libm.a now exposes the following gamma functions: ln(|gamma(x)|): __ieee754_lgamma_r __ieee754_lgammaf_r lgamma lgamma_r gamma gamma_r lgammaf lgammaf_r gammaf gammaf_r lgammal (on machines where long double is double) gamma(x): __ieee754_tgamma __ieee754_tgammaf tgamma tgammaf tgammal (on machines where long double is double) Additional aliases for any of the above functions can be added if necessary; in particular, I'm not sure if we need to include __ieee754_gamma*_r functions (which would return ln(|(gamma(x)|). Signed-off-by: Keith Packard <keithp@keithp.com> ---- v2: Switch commit message to ASCII
* libm/riscv: Use common fma code when necessaryKeith Packard via Newlib2020-09-042-0/+4
| | | | | | | For RISC-V targets without hardware FMA support, include the common fma implementation to provide that API. Signed-off-by: Keith Packard <keithp@keithp.com>
* libm/riscv: Fix machine-specific sqrt build processKeith Packard via Newlib2020-09-044-20/+16
| | | | | | | | | | | | Like ARM, some RISC-V implementations have hardware sqrt. Support for that can be detected at compile time, which the code did. However, the filenames were incorrect so that both the risc-v specific and general code were getting included in the resulting library. Fix this by following the ARM model and #include'ing the general code when the architecture-specific support is not available. Signed-off-by: Keith Packard <keithp@keithp.com>
* loadlocale: don't casecmp digitsCorinna Vinschen2020-09-041-1/+1
| | | | | | strcmp is sufficient here Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Fix warnings when building for msp430-elfJozef Lawrynowicz2020-09-036-16/+24
| | | | | | | | The MSP430 target supports both 16-bit and 20-bit size_t and intptr_t. Some implicit casts in Newlib expect these types to be "long", (a 32-bit type on MSP430) which causes warnings during compilation such as: "cast from pointer to integer of different size"
* libm/machine/arm: Rename s*_fma.c -> s*_fma_arm.cKeith Packard via Newlib2020-09-024-14/+14
| | | | | | | | | | | This is required to avoid colliding with files built from libm/common that would end up with the same object name. When libm.a was constructed from the individual sub-libraries, the contents of the libm/common files would be replaced by that from libm/machine/arm with the same name. Signed-off-by: Keith Packard <keithp@keithp.com>
* doc: Also update shebang for chapter-texi2docbook.pyJon Turney2020-08-261-1/+1
|
* Enabled _CS* defines for RTEMSEshan dhawan via Newlib2020-08-251-1/+2
| | | | Signed-off-by: Eshan dhawan <eshandhawan51@gmail.com>
* doc: Various fixes to makedocbook for python3.8Jon Turney2020-08-241-4/+6
| | | | | Also update shebang to explicitly use python3, since python2 is EOL and (per PEP 0394) 'python' may not exist at all.
* libm/stdlib: Realloc when shrinking by 2* or moreKeith Packard via Newlib2020-08-171-3/+3
| | | | | | This reduces memory usage when reallocating objects much smaller. Signed-off-by: Keith Packard <keithp@keithp.com>
* libm/stdlib: don't read past source in nano_reallocKeith Packard via Newlib2020-08-171-2/+4
| | | | | | | Save the computed block size and use it to avoid reading past the end of the source block. Signed-off-by: Keith Packard <keithp@keithp.com>
* libc/stdlib: Fix build failure in nano_callocCraig Blackmore2020-08-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 588a5e1ddebdf6d74391c7409680ea20e050c0e1 added a non-reentrant call to nano_malloc which causes a build failure if INTERNAL_NEWLIB is defined. Here is a snippet of the error: In file included from .../newlib/newlib/libc/stdlib/nano-mallocr.c:38: .../newlib/newlib/libc/include/malloc.h:42:25: note: expected 'struct _reent *' but argument is of type 'ptrdiff_t' {aka 'int'} 42 | extern void *_malloc_r (struct _reent *, size_t); | ^~~~~~~~~~~~~~~ .../newlib/newlib/libc/stdlib/nano-mallocr.c:67:22: error: too few arguments to function '_malloc_r' 67 | #define nano_malloc _malloc_r | ^~~~~~~~~ .../newlib/newlib/libc/stdlib/nano-mallocr.c:456:11: note: in expansion of macro 'nano_malloc' 456 | mem = nano_malloc(bytes); | ^~~~~~~~~~~ In file included from .../newlib/newlib/libc/stdlib/nano-mallocr.c:38: .../newlib/newlib/libc/include/malloc.h:42:14: note: declared here 42 | extern void *_malloc_r (struct _reent *, size_t); | ^~~~~~~~~ .../newlib/newlib/libc/stdlib/nano-mallocr.c:43: warning: "assert" redefined 43 | #define assert(x) ((void)0) | This patch adds a missing RCALL to the args when calling nano_malloc from nano_calloc, so that if the call is reentrant, reent_ptr is passed as the first argument. The variable `bytes` (also added in 588a5e1d) has been changed from a `ptrdiff_t` to `malloc_size_t` as it does not need to be signed. It is used to store the product of two unsigned malloc_size_t variables and then iff there was no overflow is it passed to malloc and memset which both expect size_t which is unsigned. Signed-off-by: Craig Blackmore <craig.blackmore@embecosm.com>
* libc/stdlib: Use __builtin_mul_overflow for reallocarray and callocKeith Packard via Newlib2020-08-123-15/+22
| | | | | | | This built-in function (available in both gcc and clang) is more efficient and generates shorter code than open-coding the test. Signed-off-by: Keith Packard <keithp@keithp.com>
* libm/machine/riscv: Add custom fma/sqrt functions when supported [v2]Keith Packard via Newlib2020-08-127-5/+237
| | | | | | | Check for HW FMA and SQRT support and use those instructions in place of software implementations. Signed-off-by: Keith Packard <keithp@keithp.com>
* libm/machine/arm: Add optimized fmaf and fma when availableKeith Packard via Newlib2020-08-106-5/+125
| | | | | | | | | | | When HAVE_FAST_FMAF is set, use the vfma.f32 instruction, when HAVE_FAST_FMA is set, use the vfma.f64 instruction. Usually the compiler built-ins will already have inlined these instructions, but provide these symbols for cases where that doesn't work instead of falling back to the (inaccurate) common code versions. Signed-off-by: Keith Packard <keithp@keithp.com>