summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Cygwin: add header defining GCC exception codesKen Brown2020-08-202-9/+20
| | | | | Include it in exceptions.cc instead of defining the exception codes there.
* Cygwin: main exception handler (64-bit): continue GCC exceptionsKen Brown2020-08-182-0/+23
| | | | | | | | | | | | | | | | | This is necessary in order to be consistent with the following comment in the definition of _Unwind_RaiseException() in the GCC source file libgcc/unwind-seh.c: The exception handler installed in crt0 will continue any GCC exception that reaches there (and isn't marked non-continuable). Previously we failed to do this and, as a consequence, the C++ runtime didn't call std::terminate after an unhandled exception. This fixes the problem reported here: https://cygwin.com/pipermail/cygwin/2019-October/242795.html https://sourceware.org/pipermail/cygwin/2020-August/245897.html
* 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>
* Cygwin: pty: Change the timing of set_locale() call again.Takashi Yano via Cygwin-patches2020-08-172-4/+18
| | | | | | | | - After commit 095972ce5b1d319915501a7e381802914bed790c, charset conversion in mintty is broken if charset is set to other than UTF-8. This seems to be caused because mintty does not set locale yet at fork() call. This patch changes the timing of set_locale() call again to avoid this issue.
* Cygwin: pty: Change the timing of setup_locale() call.Takashi Yano via Cygwin-patches2020-08-131-4/+4
| | | | | | - If native app is exec()'ed in a new pty, setup_locale() loses the chance to be called. For example, with "mintty -e cmd", charset conversion does not work as expected. This patch fixes the issue.
* 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>
* Cygwin: pty: Add a workaround for issue of starting a lot of mintty.Takashi Yano2020-08-111-4/+11
| | | | | | | | | - If a lot of mintty are started in a short time from a mintty, some of them hang with empty screen, crash immediately or hang on exiting mintty. The following report seems to be related to this issue. https://cygwin.com/pipermail/cygwin/2020-August/245751.html The cause is not clear at all, but this patch seems to solve the issue.
* 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>
* libm: Detect fast fmaf supportKeith Packard via Newlib2020-08-101-0/+8
| | | | | | | Anything with fast FMA is assumed to have fast FMAF, along with 32-bit arms that advertise 32-bit FP support and __ARM_FEATURE_FMA Signed-off-by: Keith Packard <keithp@keithp.com>
* libm: ARM without HW double does not have fast FMAKeith Packard via Newlib2020-08-101-1/+1
| | | | | | | | 32-bit ARM processors with HW float (but not HW double) may define __ARM_FEATURE_FMA, but that only means they have fast FMA for 32-bit floats. Signed-off-by: Keith Packard <keithp@keithp.com>
* libm/math: ensure that expf(-huge) sets FE_UNDERFLOW exceptionKeith Packard via Newlib2020-08-101-1/+1
| | | | | | | | It was calling __math_uflow(0) instead of __math_uflowf(0), which resulted in no exception being set on machines with exception support for float but not double. Signed-off-by: Keith Packard <keithp@keithp.com>
* Cygwin: cygserver: build with -Wimplicit-fallthrough=5Ken Brown2020-08-074-3/+5
| | | | Define the pseudo keyword 'fallthrough' in woutsup.h to support this.
* Cygwin: Use documented QueryWorkingSetEx() in dumperJon Turney2020-08-071-29/+7
| | | | | In dumper, use the documented QueryWorkingSetEx(), rather than the undocumented NtQueryVirtualMemory() with MemoryWorkingSetExInformation.
* MSP430: Increase the amount of main memory available in sim ld scriptsJozef Lawrynowicz2020-08-072-2/+2
| | | | | | | | | | | | | | | | The main memory region of the GDB simulator ends at address 0xFFBF, but the simulator linker scripts do not make full use of this available memory. >From 61f3d212741acee583e21ff2c2808775584ecad6 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz <jozef.l@mittosystems.com> Date: Mon, 3 Aug 2020 19:38:23 +0100 Subject: [PATCH 2/2] MSP430: Increase the amount of main memory available in sim ld scripts The main memory region of the GDB simulator ends at address 0xFFBF, but the simulator linker scripts do not make full use of this available memory.
* MSP430: Word align __*_array_start symbols in sim linker scriptsJozef Lawrynowicz2020-08-072-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | __{preinit,init,fini}_array_start symbols must be word aligned in linker scripts. If the section preceding the __*_array_start symbol has an odd size, then a NULL byte will be present between the start symbol and the .*_array section itself, when the section gets automatically word-aligned. This results in a branch to an invalid address when the CRT startup code tries to run through the functions listed in the array sections. >From de115144d05ecbaa82c9c737cc261715ca4b7d67 Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz <jozef.l@mittosystems.com> Date: Mon, 3 Aug 2020 19:09:46 +0100 Subject: [PATCH 1/2] MSP430: Word align __*_array_start symbols in sim linker scripts __{preinit,init,fini}_array_start symbols must be word aligned in linker scripts. If the section preceding the __*_array_start symbol has an odd size, then a NULL byte will be present between the start symbol and the .*_array section itself, when the section gets automatically word-aligned. This results in a branch to an invalid address when the CRT startup code tries to run through the functions listed in the array sections.
* Cygwin: cygserver: build with -Wimplicit-fallthrough=4 -WerrorCorinna Vinschen2020-08-071-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: utils: build with -Wimplicit-fallthrough=4 -WerrorCorinna Vinschen2020-08-072-2/+4
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: utils: convert usage() to proper noreturn function throughoutCorinna Vinschen2020-08-0723-111/+55
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: utils: cygcheck: avoid GCC warning concatenating stringsCorinna Vinschen2020-08-071-1/+5
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: utils: refresh tzmapCorinna Vinschen2020-08-072-58/+91
| | | | | | | | - update path to Unicode windowsZones.xml file - drop Windows XP considerations - regenerate tzmap.h Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* libm: Control errno support with _IEEE_LIBM configuration parameterKeith Packard via Newlib2020-08-056-73/+22
| | | | | | | | | | | | | | | | This removes the run-time configuration of errno support present in portions of the math library and unifies all of the compile-time errno configuration under a single parameter so that the whole library is consistent. The run-time support provided by _LIB_VERSION is no longer present in the public API, although it is still used internally to disable errno setting in some functions. Now that it is a constant, the compiler should remove that code when errno is not supported. This removes s_lib_ver.c as _LIB_VERSION is no longer variable. Signed-off-by: Keith Packard <keithp@keithp.com>
* libm/math: Don't modify __ieee754_pow return values in powKeith Packard via Newlib2020-08-052-26/+2
| | | | | | | | The __ieee754 functions already return the right value in exception cases, so don't modify those. Setting the library to _POSIX_/_IEEE_ mode now only affects whether errno is modified. Signed-off-by: Keith Packard <keithp@keithp.com>
* libm/math: Set errno to ERANGE for pow(0, -y)Keith Packard via Newlib2020-08-052-4/+2
| | | | | | | | | POSIX says that the errno for pow(0, -y) should be ERANGE instead of EDOM. https://pubs.opengroup.org/onlinepubs/9699919799/functions/pow.html Signed-off-by: Keith Packard <keithp@keithp.com>
* libm/math: Make yx functions set errno=ERANGE for x=0Keith Packard via Newlib2020-08-056-42/+52
| | | | | | | | | | The y0, y1 and yn functions need separate conditions when x is zero as that returns ERANGE instead of EDOM. Also stop adjusting the return value from the __ieee754_y* functions as that is already correct and we were just breaking it. Signed-off-by: Keith Packard <keithp@keithp.com>
* libm/math: set errno to ERANGE at gamma polesKeith Packard via Newlib2020-08-054-39/+16
| | | | | | | For POSIX, gamma(i) (i non-positive integer) should set errno to ERANGE instead of EDOM. Signed-off-by: Keith Packard <keithp@keithp.com>
* Cygwin: Add 'fallthrough' pseudo keyword for switch/case useCorinna Vinschen2020-08-0533-63/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch has been inspired by the Linux kernel patch 294f69e662d1 compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use written by Joe Perches <joe AT perches DOT com> based on an idea from Dan Carpenter <dan DOT carpenter AT oracle DOT com>. The following text is from the original log message: Reserve the pseudo keyword 'fallthrough' for the ability to convert the various case block /* fallthrough */ style comments to appear to be an actual reserved word with the same gcc case block missing fallthrough warning capability. All switch/case blocks now should end in one of: break; fallthrough; goto <label>; return [expression]; continue; In C mode, GCC supports the __fallthrough__ attribute since 7.1, the same time the warning and the comment parsing were introduced. Cygwin-only: add an explicit -Wimplicit-fallthrough=5 to the build flags.
* Cygwin: Fix missing breaks in switch statementCorinna Vinschen2020-08-052-0/+10
| | | | | | | Two switch statements in sysconf() and fhandler_fifo::take_ownership were missing breaks. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* libm: Set math_errhandling to match library and hardware [v2]Keith Packard via Newlib2020-08-042-1/+22
| | | | | | | | | | | | | | | | math_errhandling is specified to contain two bits of information: 1. MATH_ERRNO -- Set when the library sets errno 2. MATH_ERREXCEPT -- Set when math operations report exceptions MATH_ERRNO should match whether the original math code is compiled in _IEEE_LIBM mode and the new math code has WANT_ERRNO == 1. MATH_ERREXCEPT should match whether the underlying hardware has exception support. This patch adds configurations of this value for RISC-V, ARM, Aarch64, x86 and x86_64 when using HW float. Signed-off-by: Keith Packard <keithp@keithp.com>
* libm/common: Set WANT_ERRNO based on _IEEE_LIBM valueKeith Packard via Newlib2020-08-041-1/+3
| | | | | | | | _IEEE_LIBM is the configuration value which controls whether the original libm functions modify errno. Use that in the new math code as well so that the resulting library is internally consistent. Signed-off-by: Keith Packard <keithp@keithp.com>
* Cygwin: FIFO: add a third pass to raw_readKen Brown2020-08-041-6/+60
| | | | | | | | | | | | | | | | | Currently raw_read makes two passes through the list of clients. On the first pass it tries to read from the client from which it last read successfully. On the second pass it tries to read from all connected clients. Add a new pass in between these two, in which raw_read tries to read from all clients that are in the fc_input_avail case. This should be more efficient in case select was previously called and detected input available. Slightly tweak the first pass. If a client is marked as having the last successful read but reading from it now finds no input, don't unmark it unless we successfully read from a different client on one of the later passes.
* Cygwin: FIFO: fix indentationKen Brown2020-08-041-48/+48
|
* Cygwin: FIFO: synchronize the fifo_reader and fifosel threadsKen Brown2020-08-043-9/+60
| | | | | | | | | | | | | | | | | | | | | | The fifo_reader thread function and the function select.cc:peek_fifo() can both change the state of a fifo_client_handler. These changes are made under fifo_client_lock, so there is no race, but the changes can still be incompatible. Add code to make sure that only one of these functions can change the state from its initial fc_listening state. Whichever function does this calls the fhandler_fifo::record_connection method, which is now public so that peek_fifo can call it. Slightly modify that method to make it suitable for being called by peek_fifo. Make a few other small changes to the fifo_reader thread function to change how it deals with the STATUS_PIPE_CLOSING value that can (rarely) be returned by NtFsControlFile. Add commentary to fhandler_fifo.cc to explain fifo_client connect states and where they can be changed.
* Cygwin: FIFO: don't read from pipes that are closingKen Brown2020-08-043-12/+5
| | | | | | | | | Don't try to read from fifo_client_handlers that are in the fc_closing state. Experiments have shown that this always yields STATUS_PIPE_BROKEN, so it just wastes a Windows system call. Re-order the values in enum fifo_client_connect_state to reflect the new status of fc_closing.
* Cygwin: FIFO: reorganize some fifo_client_handler methodsKen Brown2020-08-043-37/+50
| | | | | | | Rename the existing set_state() to query_and_set_state() to reflect what it really does. (It queries the O/S for the pipe state.) Add a new set_state() method, which is a standard setter, and a corresponding getter get_state().
* Cygwin: FIFO: add a timeout to take_ownershipKen Brown2020-08-043-53/+30
| | | | | | | | | | | | | | fhandler_fifo::take_ownership() is called from select.cc::peek_fifo and fhandler_fifo::raw_read and could potentially block indefinitely if something goes wrong. This is always undesirable in peek_fifo, and it is undesirable in a nonblocking read. Fix this by adding a timeout parameter to take_ownership. Arbitrarily use a 1 ms timeout in peek_fifo and a 10 ms timeout in raw_read. These numbers may have to be tweaked based on experience. Replace the call to cygwait in take_ownership by a call to WFSO. There's no need to allow interruption now that we have a timeout.
* Cygwin: FIFO: fix timing issue with owner changeKen Brown2020-08-041-4/+21
| | | | | | | | | | | | | | | | fhandler_fifo::take_ownership() tacitly assumes that the current owner's fifo_reader_thread will be woken up from WFMO when update_needed_evt is signaled. But it's possible that the the current owner's fifo_reader_thread is at the beginning of its main loop rather than in its WFMO call when that event is signaled. In this case the owner will never see that the event has been signaled, and it will never update the shared fifo_client_handlers. The reader that wants to take ownership will then spin its wheels forever. Fix this by having the current owner call update_shared_handlers at the beginning of its loop, if necessary.
* Cygwin: FIFO: lock fixesKen Brown2020-08-041-6/+17
| | | | | | Add some missing locks and remove one extra unlock. Clarify for some functions whether caller or callee acquires lock, and add appropriate comments.
* fhandler_proc.cc(format_proc_cpuinfo): use _small_sprintf %X for microcodeBrian Inglis2020-08-041-1/+1
| | | | | | | microcode is unsigned long long, printed by _small_sprintf using %x; Cygwin32 used last 4 bytes of microcode for next field MHz, printing 0; use correct _small_sprintf format %X to print microcode, producing correct MHz value under Cygwin32
* fhandler_proc.cc(format_proc_cpuinfo): add SERIALIZE instruction flagBrian Inglis2020-08-041-0/+1
| | | | | | | | | | | | | | | | | | | | CPUID 7:0 EDX[14] serialize added in linux-next 5.8 by Ricardo Neri-Calderon: The Intel architecture defines a set of Serializing Instructions (a detailed definition can be found in Vol.3 Section 8.3 of the Intel "main" manual, SDM). However, these instructions do more than what is required, have side effects and/or may be rather invasive. Furthermore, some of these instructions are only available in kernel mode or may cause VMExits. Thus, software using these instructions only to serialize execution (as defined in the manual) must handle the undesired side effects. As indicated in the name, SERIALIZE is a new Intel architecture Serializing Instruction. Crucially, it does not have any of the mentioned side effects. Also, it does not cause VMExit and can be used in user mode. This new instruction is currently documented in the latest "extensions" manual (ISE). It will appear in the "main" manual in the future. https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/arch/x86/include/asm/cpufeatures.h?id=85b23fbc7d88f8c6e3951721802d7845bc39663d
* libm/math: Use __math_xflow in obsolete math code [v2]Keith Packard2020-08-039-32/+34
| | | | | | | | | | | | | | | | | | C compilers may fold const values at compile time, so expressions which try to elicit underflow/overflow by performing simple arithemetic on suitable values will not generate the required exceptions. Work around this by replacing code which does these arithmetic operations with calls to the existing __math_xflow functions that are designed to do this correctly. Signed-off-by: Keith Packard <keithp@keithp.com> ---- v2: libm/math: Pass sign to __math_xflow instead of muliplying result
* select.h: update FD macros to latest FreeBSD, fix type conversion warningCorinna Vinschen2020-08-031-27/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compiling #include <sys/select.h> void f(int X) {   fd_set set;   FD_ZERO(&set);   FD_SET(X,&set);   FD_CLR(X+1,&set);   (void)FD_ISSET(X+2,&set); } results in plenty of gcc warnings when compiled with -Wconversion -Wsign-conversion: fds.c:7:2: warning: conversion to ‘long unsigned int’ from ‘int’ may   FD_SET(X,&set);   ^~~~~~ [...] The unsigned NFDBITS macro combined with the signed 1L constant are causing lots of implicit signed/unsigned type conversions. Fix this by updating the FD_* macro code to the latest from FreeBSD and adding an (int) cast to _NFDBITS. As a side-effect, this fixes the visibility of NFDBITS and fds_bits (only if __BSD_VISIBLE). This also eliminates the old, outdated fd_set workaround. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: posix_spawn: add Cygwin-specific code fixing process synchronisationCorinna Vinschen2020-08-034-8/+206
| | | | | | | | | | | | | | | | | | | | | | Newlib's posix_spawn has been taken from FreeBSD. The code relies on BSD-specific behaviour of vfork, namely the fact that vfork blocks the parent until the child exits or calls execve as well as the fact that the child shares parent memory in non-COW mode. This behaviour can't be emulated by Cygwin. Cygwin's vfork is equivalent to fork. This is POSIX-compliant, but it's lacking BSD's vfork ingrained synchronization of the parent to wait for the child calling execve, or the chance to just write a variable and the parent will see the result. So this requires a Cygwin-specific solution. The core function of posix_spawn, called do_posix_spawn is now implemented twice, once using the BSD method, and once for Cygwin using Windows synchronization under the hood waiting for the child to call execve and signalling errors upstream. The Windows specifics are hidden inside Cygwin, so newlib only calls internal Cygwin functions. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: Speed up dumperJon Turney2020-07-311-9/+4
| | | | | | | | Stop after we've written the dump in response to the initial breakpoint EXCEPTION_DEBUG_EVENT we recieve for attaching to the process. (rather than bogusly sitting there for 20 seconds waiting for more debug events from a stopped process after we've already written the dump).
* Cygwin: Remove synchronization event from dumperJon Turney2020-07-311-12/+0
| | | | | The use of the 'cygwin_error_start_event' for synchronization with dumper was removed from the DLL in commit 8abeff1e (April 2001).
* Cygwin: Add --nokill dumper optionJon Turney2020-07-312-4/+26
| | | | | Add --nokill option to dumper, for compatibility with minidumper, and to assist with testing.
* arm: Fix include to avoid undefined referenceSebastian Huber2020-07-291-1/+1
| | | | | | | ld: libm.a(lib_a-fesetenv.o): in function `fesetenv': newlib/libm/machine/arm/fesetenv.c:38: undefined reference to `vmsr_fpscr' Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
* arm: Split fenv.c into multiple filesEshan dhawan2020-07-2919-282/+696
| | | | | | | | | Use the already existing stub files if possible. These files are necessary to override the stub implementation with the machine-specific implementation through the build system. Reviewed-by: Sebastian Huber <sebastian.huber@embedded-brains.de> Signed-off-by: Eshan dhawan <eshandhawan51@gmail.com>