aboutsummaryrefslogtreecommitdiff
path: root/newlib
AgeCommit message (Collapse)AuthorFilesLines
2020-03-03Fix error in float trig. function range reductionFabian Schriever1-1/+1
The single-precision trigonometric functions show rather high errors in specific ranges starting at about 30000 radians. For example the sinf procedure produces an error of 7626.55 ULP with the input 5.195880078125e+04 (0x474AF6CD) (compared with MPFR in 128bit precision). For the test we used 100k values evenly spaced in the range of [30k, 70k]. The issues are periodic at higher ranges. This error was introduced when the double precision range reduction was first converted to float. The shift by 8 bits always returns 0 as iq is never higher than 255. The fix reduces the error of the example above to 0.45 ULP, highest error within the test set fell to 1.31 ULP, which is not perfect, but still a significant improvement. Testing other previously erroneous ranges no longer show particularly large accuracy errors.
2020-03-02Fix error in powf for (-1.0, NaN) inputFabian Schriever1-1/+1
Prevent confusion between -1.0 and 1.0 in powf. The corresponding similar error was previously fixed for pow (see commit bb25dd1b)
2020-03-02arm: Finish moving newlib to unified syntax for Thumb1Richard Earnshaw1-7/+8
Most code in newlib already uses unified syntax, but just a couple of laggards remain. This patch removes these and means the the entire code base has now been converted.
2020-02-25x86_64/i386 fenv: Replace symlink with include fenv_stub.cJoel Sherrill23-23/+161
Having symlinks for these files led to an issue reported to the RTEMS Project that showed up using some tar for native Windows to unpack the newlib sources. It creates symlinks in the tar file as copies of the files the symlinks point to. If the links appear in the tar file before the source exists, it cannot copy the file. The solution in this patch is to convert the files that are symbolic links into simple files which include the file they were linked to. This should be more portable and avoids the symbolinc link problem.
2020-02-20newlib/libc/include/devctl.h: Add extern "C" wrapperJoel Sherrill1-0/+8
Adding this was necessary to allow posix_devctl() from C++.
2020-02-18Locale modifier "@cjksingle" to enforce single-width CJK width.Thomas Wolff2-4/+17
This option follows a proposal in the Terminals Working Group Specifications (https://gitlab.freedesktop.org/terminal-wg/specifications/issues/9#note_406682). It makes locale width consistent with the corresponding mintty feature.
2020-02-14pow: fix pow(-1.0, NaN)Nicolas Brunie1-1/+1
I think I may have encountered a bug in the implementation of pow: pow(-1.0, NaN) returns 1.0 when it should return NaN. Because ix is used to check input vs 1.0 rather than hx, -1.0 is mistaken for 1.0
2020-02-06Typo in license for newlib/libc/stdio/flags.cKeith Packard1-1/+1
Fix spelling: MERCHANT I BILITY -> MERCHANT A BILITY Signed-off-by: Keith Packard <keithp@keithp.com>
2020-02-06Typo in license terms for newlib/libm/common/log2.cKeith Packard1-1/+1
The closing quotes were in the wrong place Signed-off-by: Keith Packard <keithp@keithp.com>
2020-01-29Use remove-advertising-clause script to edit BSD licensesKeith Packard274-924/+281
This edits licenses held by Berkeley and NetBSD, both of which have removed the advertising requirement from their licenses. Signed-off-by: Keith Packard <keithp@keithp.com>
2020-01-29Revert "newlib: fix fseek optimization with SEEK_CUR"Corinna Vinschen2-12/+50
This reverts commit 59362c80e3a02c011fd0ef3d7f07a20098d2a9d5. This breaks gnulib's autoconf test for POSIX compatibility of fflush/fseek. After fflush/fseek, ftello and lseek are out of sync, with lseek having the wrong offset. This breaks backward compatibility with Cygwin applications. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-01-21Bump up newlib release to 3.3.0Jeff Johnston109-1083/+1083
2020-01-21Change the reent verify check option to document disabling itJeff Johnston3-5/+5
- also change the handling of default_newlib_reent_check_verify to be the same as other default variables in configure.host - regenerate newlib/configure
2020-01-21Default newlib_reent_check_verify to yes in configure.hostJeff Johnston1-3/+3
2020-01-21riscv: Map between ieeefp.h exception bits and RISC-V FCSR bitsKeith Packard1-3/+37
If we had architecture-specific exception bits, we could just set them to match the processor, but instead ieeefp.h is shared by all targets so we need to map between the public values and the register contents. Signed-off-by: Keith Packard <keithp@keithp.com>
2020-01-21riscv: Add 'break' statements to fpsetround switchKeith Packard1-4/+4
This makes the fpsetround function actually do something rather than just return -1 due to the default 'fall-through' behavior of the switch statement. Signed-off-by: Keith Packard <keithp@keithp.com>
2020-01-21riscv: Use current pseudo-instructions to access the FCSR registerKeith Packard1-2/+2
Use fscsr and frcsr to store and read the FCSR register instead of fssr and frsr. Signed-off-by: Keith Packard <keithp@keithp.com>
2020-01-09Prevent more NULL ptr accesses due to Balloc out of memoryJeff Johnston3-9/+9
- fix gdtoa-gethex.c, ldtoa.c, and strtodg.c to use eBalloc
2020-01-02Bump up release to 3.2.0 for yearly snapshotnewlib-snapshot-20200102newlib-3.2.0Jeff Johnston111-1094/+1111
2019-12-29doc: add more details about adding documentation to HOWTOJon Turney1-2/+4
Add a little more detail to the checklist for adding documentation Also update the list of supported sections
2019-12-20Optimize setjmp/longjmp for moxie.Anthony Green2-87/+39
We don't need to save/restore every register -- just those we don't expect to be trashed by function calls.
2019-12-18Don't display trailing '.' in _dcvtKeith Packard1-3/+12
In the two helper functions that _dcvt calls for 'f' and 'e' mode, if there are no digits to display after the decimal point, don't add one. Signed-off-by: Keith Packard <keithp@keithp.com>
2019-12-18Fix gcvt to always show 'ndigits' of precisionKeith Packard1-11/+7
Leading zeros after the decimal point should not count towards the 'ndigits' limit. This makes gcvt match glibc and the posix gcvt man page. Signed-off-by: Keith Packard <keithp@keithp.com>
2019-12-18Fix fcvt to only show 'ndigit' past decimalKeith Packard1-8/+1
Even if the number is really small and this means showing *no* digits. This makes newlib match glibc, and the fcvt posix man page. Signed-off-by: Keith Packard <keithp@keithp.com>
2019-12-18doc: Untabify python scripts used for making man pagesJon Turney2-219/+219
These scripts fail with a TabError exception if 'python' is python3, as mixing tabs and spaces in indentation is forbidden in python3.
2019-12-17Set __IEEE_LITTLE_ENDIAN for _XTENSA_EL__ (ESP32)Keith Packard1-0/+4
Signed-off-by: Keith Packard <keithp@keithp.com>
2019-12-17Return EINVAL for illegal base in strtolKeith Packard1-2/+7
Signed-off-by: Keith Packard <keithp@keithp.com>
2019-12-16strtold: set errno to ERANGE on underflow per POSIXBruno Haible1-0/+21
https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtod.html
2019-12-13Fix setjmp/longjmp for the moxie port.Anthony Green2-25/+48
These functions needs to save and restore the stack frame, because that's where the return address is stored.
2019-12-02libm: switch sf_log1p from double error routines to floatKeith Packard2-4/+2
sf_log1p was using __math_divzero and __math_invalid, which drag in a pile of double-precision code. Switch to using the single-precision variants. This also required making those available in __OBSOLETE_MATH mode. Signed-off-by: Keith Packard <keithp@keithp.com>
2019-11-26newlib/libc/include/sys/features.h: update __STDC_ISO_10646__Brian Inglis1-3/+7
newlib wide char conversion functions were updated to Unicode 11 on 2019-01-12 update standard symbol __STDC_ISO_10646__ to Unicode 11 release date 2018-06-05 for Cygwin
2019-11-18newlib: fix fseek optimization with SEEK_CURBastien Bouclet2-50/+12
The call to fflush was invalidating the read buffer, preventing relative seeks to positions that would have been inside the read buffer from being optimized. The call to srefill would then re-read mostly the same data that was initially in the read buffer.
2019-11-08Stash reent marker in upper bits of s1 on AMD GCNKwok Cheung Yeung1-10/+10
s[0:3] contain a descriptor used to set up the initial value of the stack, but only the lower 48 bits of s[0:1] are currently used. The reent marker is currently set in s3, but by stashing it in the upper 16 bits of s[0:1] instead, s3 can be freed up for other purposes.
2019-11-04Move timeval macros to <sys/time.h>Sebastian Huber2-32/+31
In FreeBSD, NetBSD, and OpenBSD these macros are defined in <sys/time.h>.
2019-11-04Synchronize <sys/time.h> with FreeBSDSebastian Huber1-0/+27
This change is based on the FreeBSD commit: Author: asomers <asomers@FreeBSD.org> Date: Mon Jul 30 15:46:40 2018 +0000 Make timespecadd(3) and friends public The timespecadd(3) family of macros were imported from NetBSD back in r35029. However, they were initially guarded by #ifdef _KERNEL. In the meantime, we have grown at least 28 syscalls that use timespecs in some way, leading many programs both inside and outside of the base system to redefine those macros. It's better just to make the definitions public. Our kernel currently defines two-argument versions of timespecadd and timespecsub. NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define three-argument versions. Solaris also defines a three-argument version, but only in its kernel. This revision changes our definition to match the common three-argument version. Bump _FreeBSD_version due to the breaking KPI change. Discussed with: cem, jilles, ian, bde Differential Revision: https://reviews.freebsd.org/D14725
2019-11-04Synchronize <sys/_timespec.h> with FreeBSDSebastian Huber1-2/+4
2019-11-04Fix sbttons for values > 2simp1-2/+9
Add test against negative times. Add code to cope with larger values properly. Discussed with: bde@ (quite some time ago, for an earlier version)
2019-10-31PRU: Align libmath to PRU ABIDimitar Dimitrov18-2/+6719
The TI proprietary toolchain uses nonstandard names for some math library functions. In order to achieve ABI compatibility between GNU and TI toolchains, add support for the TI function names. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2019-10-31Fix some generated filesJeff Johnston4-16/+16
2019-10-31Initial PRU port for libgloss and newlibDimitar Dimitrov11-3/+6320
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2019-10-09riscv/sys/fenv.h: Add missing extern for fe_dfl_env_pJoel Sherrill1-0/+2
2019-10-08Add patch from Joel Sherrill for i386 and x86_64 fenv supportJeff Johnston37-9/+16544
2019-10-07Allow verifying _REENT_CHECK macros memory allocationJeff Johnston6-5/+54
- change sys/reent.h to replace _REENT_CHECK_DEBUG with _REENT_CHECK_VERIFY which when set asserts that any memory allocated is non-NULL and calls __assert_func directly - add new --enable-newlib-reent-check-verify configure option - add support for configure.host to specify default for newlib_reent_check_verify - add _REENT_CHECK_VERIFY macro support to acconfig.h and newlib.hin
2019-10-07Optimize epilogue sequence for architectures with POP interworking.Christos Gentsos2-0/+12
ARMv5 and above supports arm/thumb interworking using POP, so we can improve the exit sequence in this case.
2019-10-04Prevent NULL ptr accesses due to Balloc out of memoryJeff Johnston3-12/+20
- add new eBalloc macro to mprec.h which calls Balloc and aborts if Balloc fails due to out of memory - change mprec.c functions that use Balloc without checking to use eBalloc instead - fix dtoa.c to use eBalloc
2019-09-25Add SIOCGIFDOWNREASON.kib2-2/+14
The ioctl(2) is intended to provide more details about the cause of the down for the link. Eventually we might define a comprehensive list of codes for the situations. But interface also allows the driver to provide free-form null-terminated ASCII string to provide arbitrary non-formalized information. Sample implementation exists for mlx5(4), where the string is fetched from firmware controlling the port. Reviewed by: hselasky, rrs Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D21527
2019-09-25Add kernel-side support for in-kernel TLS.jhb2-1/+16
KTLS adds support for in-kernel framing and encryption of Transport Layer Security (1.0-1.2) data on TCP sockets. KTLS only supports offload of TLS for transmitted data. Key negotation must still be performed in userland. Once completed, transmit session keys for a connection are provided to the kernel via a new TCP_TXTLS_ENABLE socket option. All subsequent data transmitted on the socket is placed into TLS frames and encrypted using the supplied keys. Any data written to a KTLS-enabled socket via write(2), aio_write(2), or sendfile(2) is assumed to be application data and is encoded in TLS frames with an application data type. Individual records can be sent with a custom type (e.g. handshake messages) via sendmsg(2) with a new control message (TLS_SET_RECORD_TYPE) specifying the record type. At present, rekeying is not supported though the in-kernel framework should support rekeying. KTLS makes use of the recently added unmapped mbufs to store TLS frames in the socket buffer. Each TLS frame is described by a single ext_pgs mbuf. The ext_pgs structure contains the header of the TLS record (and trailer for encrypted records) as well as references to the associated TLS session. KTLS supports two primary methods of encrypting TLS frames: software TLS and ifnet TLS. Software TLS marks mbufs holding socket data as not ready via M_NOTREADY similar to sendfile(2) when TLS framing information is added to an unmapped mbuf in ktls_frame(). ktls_enqueue() is then called to schedule TLS frames for encryption. In the case of sendfile_iodone() calls ktls_enqueue() instead of pru_ready() leaving the mbufs marked M_NOTREADY until encryption is completed. For other writes (vn_sendfile when pages are available, write(2), etc.), the PRUS_NOTREADY is set when invoking pru_send() along with invoking ktls_enqueue(). A pool of worker threads (the "KTLS" kernel process) encrypts TLS frames queued via ktls_enqueue(). Each TLS frame is temporarily mapped using the direct map and passed to a software encryption backend to perform the actual encryption. (Note: The use of PHYS_TO_DMAP could be replaced with sf_bufs if someone wished to make this work on architectures without a direct map.) KTLS supports pluggable software encryption backends. Internally, Netflix uses proprietary pure-software backends. This commit includes a simple backend in a new ktls_ocf.ko module that uses the kernel's OpenCrypto framework to provide AES-GCM encryption of TLS frames. As a result, software TLS is now a bit of a misnomer as it can make use of hardware crypto accelerators. Once software encryption has finished, the TLS frame mbufs are marked ready via pru_ready(). At this point, the encrypted data appears as regular payload to the TCP stack stored in unmapped mbufs. ifnet TLS permits a NIC to offload the TLS encryption and TCP segmentation. In this mode, a new send tag type (IF_SND_TAG_TYPE_TLS) is allocated on the interface a socket is routed over and associated with a TLS session. TLS records for a TLS session using ifnet TLS are not marked M_NOTREADY but are passed down the stack unencrypted. The ip_output_send() and ip6_output_send() helper functions that apply send tags to outbound IP packets verify that the send tag of the TLS record matches the outbound interface. If so, the packet is tagged with the TLS send tag and sent to the interface. The NIC device driver must recognize packets with the TLS send tag and schedule them for TLS encryption and TCP segmentation. If the the outbound interface does not match the interface in the TLS send tag, the packet is dropped. In addition, a task is scheduled to refresh the TLS send tag for the TLS session. If a new TLS send tag cannot be allocated, the connection is dropped. If a new TLS send tag is allocated, however, subsequent packets will be tagged with the correct TLS send tag. (This latter case has been tested by configuring both ports of a Chelsio T6 in a lagg and failing over from one port to another. As the connections migrated to the new port, new TLS send tags were allocated for the new port and connections resumed without being dropped.) ifnet TLS can be enabled and disabled on supported network interfaces via new '[-]txtls[46]' options to ifconfig(8). ifnet TLS is supported across both vlan devices and lagg interfaces using failover, lacp with flowid enabled, or lacp with flowid enabled. Applications may request the current KTLS mode of a connection via a new TCP_TXTLS_MODE socket option. They can also use this socket option to toggle between software and ifnet TLS modes. In addition, a testing tool is available in tools/tools/switch_tls. This is modeled on tcpdrop and uses similar syntax. However, instead of dropping connections, -s is used to force KTLS connections to switch to software TLS and -i is used to switch to ifnet TLS. Various sysctls and counters are available under the kern.ipc.tls sysctl node. The kern.ipc.tls.enable node must be set to true to enable KTLS (it is off by default). The use of unmapped mbufs must also be enabled via kern.ipc.mb_use_ext_pgs to enable KTLS. KTLS is enabled via the KERN_TLS kernel option. This patch is the culmination of years of work by several folks including Scott Long and Randall Stewart for the original design and implementation; Drew Gallatin for several optimizations including the use of ext_pgs mbufs, the M_NOTREADY mechanism for TLS records awaiting software encryption, and pluggable software crypto backends; and John Baldwin for modifications to support hardware TLS offload. Reviewed by: gallatin, hselasky, rrs Obtained from: Netflix Sponsored by: Netflix, Chelsio Communications Differential Revision: https://reviews.freebsd.org/D21277
2019-09-25Rename IPPROTO 33 from SEP to DCCPthj1-2/+2
IPPROTO 33 is DCCP in the IANA Registry: https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml IPPROTO_SEP was added about 20 years ago in r33804. The entries were added straight from RFC1700, without regard to whether they were used. The reference in RFC1700 for SEP is '[JC120] <mystery contact>', this is an indication that the protocol number was probably in use in a private network. As RFC1700 is no longer the authoritative list of internet numbers and that IANA assinged 33 to DCCP in RFC4340, change the header to the actual authoritative source. Reviewed by: Richard Scheffenegger, bz Approved by: bz (mentor) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D21178
2019-09-25This commit updates rack to what is basicallyrrs1-7/+20
being used at NF as well as sets in some of the groundwork for committing BBR. The hpts system is updated as well as some other needed utilities for the entrance of BBR. This is actually part 1 of 3 more needed commits which will finally complete with BBRv1 being added as a new tcp stack. Sponsored by: Netflix Inc. Differential Revision: https://reviews.freebsd.org/D20834
2019-09-25Add an external mbuf buffer type that holdsjhb1-0/+1
multiple unmapped pages. Unmapped mbufs allow sendfile to carry multiple pages of data in a single mbuf, without mapping those pages. It is a requirement for Netflix's in-kernel TLS, and provides a 5-10% CPU savings on heavy web serving workloads when used by sendfile, due to effectively compressing socket buffers by an order of magnitude, and hence reducing cache misses. For this new external mbuf buffer type (EXT_PGS), the ext_buf pointer now points to a struct mbuf_ext_pgs structure instead of a data buffer. This structure contains an array of physical addresses (this reduces cache misses compared to an earlier version that stored an array of vm_page_t pointers). It also stores additional fields needed for in-kernel TLS such as the TLS header and trailer data that are currently unused. To more easily detect these mbufs, the M_NOMAP flag is set in m_flags in addition to M_EXT. Various functions like m_copydata() have been updated to safely access packet contents (using uiomove_fromphys()), to make things like BPF safe. NIC drivers advertise support for unmapped mbufs on transmit via a new IFCAP_NOMAP capability. This capability can be toggled via the new 'nomap' and '-nomap' ifconfig(8) commands. For NIC drivers that only transmit packet contents via DMA and use bus_dma, adding the capability to if_capabilities and if_capenable should be all that is required. If a NIC does not support unmapped mbufs, they are converted to a chain of mapped mbufs (using sf_bufs to provide the mapping) in ip_output or ip6_output. If an unmapped mbuf requires software checksums, it is also converted to a chain of mapped mbufs before computing the checksum. Submitted by: gallatin (earlier version) Reviewed by: gallatin, hselasky, rrs Discussed with: ae, kp (firewalls) Relnotes: yes Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D20616