Commit Graph

19574 Commits

Author SHA1 Message Date
Giacomo Tesio ded03c70bf Merge branch 'upstream-master' into merge-upstream-20200829 2020-08-29 00:05:13 +02:00
Corinna Vinschen bf251d5a0b Cygwin: sigproc: Fix a thinko in array size
We need one more entry than max children in the arrays.
There's no reason to do this for the static array, though.
One more entry in the overflow array is sufficient.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-28 19:38:05 +02:00
Corinna Vinschen b05b0b78fa Cygwin: sigproc: Eliminate redundant copying of chld_procs
On PROC_EXEC_CLEANUP, the pinfo's in chld_procs are removed.
This is done in a loop always removing the child with index 0.
This, however, results in copying the last child's pinfo in
chld_procs to position 0.  Do this for 100 children and you
get 99 entirely useless copy operations.

Fix this by calling remove_proc in reverse order.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-28 19:37:42 +02:00
Corinna Vinschen c6b45af544 Cygwin: sigproc: fix minor formatting issue
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-28 15:40:16 +02:00
Takashi Yano via Cygwin-patches c8b076a233 Cygwin: select: Fix a bug on closing pi->bye event.
- Close event handle pi->bye only if it was created.
  Addresses:
  https://cygwin.com/pipermail/cygwin-developers/2020-August/011948.html
2020-08-28 15:24:22 +02:00
Corinna Vinschen 7c963c7ba0 Cygwin: sigproc: Allow more child processes per process
256 children per process is a bit tight in some scenarios.

Fix this by revamping the `procs' array.  Convert it to an
extensible class child_procs and rename procs to chld_procs.
Fix code throughout to use matching class methods rather than
direct access.

To allow a lot more child processes while trying to avoid
allocations at DLL startup, maintain two arrays within class
child_procs, one using a default size for 255 (i686) or 1023
(x86_64) children, the other, dynamically allocated on overflowing
the first array, giving room for another 1023 (i686) or 4095
(x86_64) processes.

On testing with a simple reproducer on a x86_64 machine with
4 Gigs RAM, a system memory overflow occured after forking
about 1450 child processes, so this simple dynamic should
suffice for a while.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-28 15:22:58 +02:00
Corinna Vinschen 163daed37c Cygwin: drop PROC_DETACHED_CHILD flag
pinfo::remember with the detach parameter set to true is
the only way to call proc_subproc with PROC_DETACHED_CHILD.
This call is exclusively used in spawn to set up a pinfo for
a detached child, and that pinfo goes out of scope right
afterwards without any further action.

Drop the flag and drop the detach parameter from pinfo::remember.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-28 11:10:48 +02:00
Corinna Vinschen 558fa888e5 Cygwin: sigproc: drop __stdcall
Nothing to gain here

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-28 09:44:18 +02:00
Corinna Vinschen eb3e3e4738 Cygwin: sigproc: return int from remove_proc
The return value is used in a numerical context and remove_proc
already returned inconsistently "true" vs. 0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-28 09:44:18 +02:00
Corinna Vinschen 0a31ad6f4c Cygwin: fix up proc_subproc flags and matching pinfo methods
After patch 23a779bf3d
"Cygwin: pinfo: stop remember doing reattach",
PROC_ADDCHILD actually just sets up a new child, mirroring
PROC_DETACHED_CHILD.  The actual attaching of the child is
performed by action PROC_REATTACH_CHILD or pinfo::reattach
respectively.

To better reflect what's going on, rename PROC_REATTACH_CHILD
to PROC_ATTACH_CHILD and rename pinfo::reattach to pinfo::attach.
For better readability change PROC_ADDCHILD to PROC_ADD_CHILD.
Fix comments accordingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-28 09:44:18 +02:00
Ken Brown 49a9ffdf4b Cygwin: fhandler_fifo::delete_client_handler: improve efficiency
Delete a client handler by swapping it with the last one in the list
instead of calling memmove.
2020-08-27 07:14:19 -04:00
Brian Inglis 573dda0cf2 winsup/doc/faq-api.xml(faq.api.timezone): explain time zone updates
based on material from tz@IANA.org mailing list sources
2020-08-27 10:53:58 +02:00
Takashi Yano via Cygwin-patches 69a2a8db58 Cygwin: console: Replace WriteConsoleA() with WriteConsoleW().
- To allow sending non-ASCII chars to console, all WriteConsoleA()
  are replaced by WriteConsoleW().
  Addresses:
  https://cygwin.com/pipermail/cygwin-patches/2020q3/010476.html
2020-08-27 10:51:31 +02:00
Jon Turney ed1573fc17
doc: Also update shebang for chapter-texi2docbook.py 2020-08-26 16:12:52 +01:00
Brian Inglis ed97836149 winsup/doc/faq-api.xml, -programming.xml: change Win32 to Windows/API 2020-08-26 10:08:13 +02:00
Brian Inglis 6329d546dd winsup/doc/faq-setup.xml, faq-using.xml: update setup FAQ
change all kinds of setup references to "the Cygwin Setup program";
emphasize 64 bit and deemphasize 32 bit;
update options list;
explain why installing everything is now extremely inadvisable, with stats
2020-08-26 10:08:13 +02:00
Eshan dhawan via Newlib 39f057e2aa Enabled _CS* defines for RTEMS
Signed-off-by: Eshan dhawan <eshandhawan51@gmail.com>
2020-08-25 20:54:33 +02:00
Jon Turney c2d6e6f7f6
doc: Various fixes to makedocbook for python3.8
Also update shebang to explicitly use python3, since python2 is EOL and
(per PEP 0394) 'python' may not exist at all.
2020-08-24 17:36:10 +01:00
Ken Brown c1f177d6a9 Cygwin: cwdstuff::get: clean up debug_printf output
Set errno = 0 at the beginning so that the debug_printf call at the
end doesn't report a nonzero errno left over from some other function
call.
2020-08-23 18:50:00 -04:00
Takashi Yano bb42852062 Cygwin: pty: Implement new pseudo console support.
- In this implementation, pseudo console is created for each native
  console app. Advantages and disadvantages of this implementation
  over the previous implementation are as follows.

  Advantages:
  1) No performance degradation in pty output for cygwin process.
      https://cygwin.com/pipermail/cygwin/2020-February/243858.html
  2) Free from the problem caused by difference of behaviour of control
     sequences between real terminal and pseudo console.
      https://cygwin.com/pipermail/cygwin/2019-December/243281.html
      https://cygwin.com/pipermail/cygwin/2020-February/243855.html
  3) Free from the problem in cgdb and emacs gud.
      https://cygwin.com/pipermail/cygwin/2020-January/243601.html
      https://cygwin.com/pipermail/cygwin/2020-March/244146.html
  4) Redrawing screen on executing native console apps is not necessary.
  5) cygwin-console-helper is not necessary for the pseudo console
     support.
  6) The codes for pseudo console support are much simpler than that
     of the previous one.

  Disadvantages:
  1) The cygwin program which calls console API directly does not work.
  2) The apps which use console API cannot be debugged with gdb. This
     is because pseudo console is not activated since gdb uses
     CreateProcess() rather than exec(). Even with this limitation,
     attaching gdb to native apps, in which pseudo console is already
     activated, works.
  3) Typeahead key inputs are discarded while native console app is
     executed. Simirally, typeahead key inputs while cygwin app is
     executed are not inherited to native console app.
  4) Code page cannot be changed by chcp.com. Acctually, chcp works
     itself and changes code page of its own pseudo console.  However,
     since pseudo console is recreated for another process, it cannot
     inherit the code page.
  5) system_printf() does not work after stderr is closed. (Same with
     cygwin 3.0.7)
  6) Startup time of native console apps is about 3 times slower than
     previous implemenation.
  7) Pseudo console cannot be activated if it is already activated for
     another process on same pty.
2020-08-22 13:43:49 +02:00
Corinna Vinschen b9261fa1d9 Cygwin: bump version to 3.2.0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-22 13:43:46 +02:00
Ken Brown a93a85a1ff Cygwin: strace: ignore GCC exceptions
Any C++ app that calls 'throw' on 64-bit Cygwin results in an
exception of type STATUS_GCC_THROW (0x20474343) generated by the C++
runtime.  Don't pollute the strace output by printing information
about this and other GCC exceptions.
2020-08-20 10:48:48 -04:00
Ken Brown 14c0a4c67d Cygwin: add header defining GCC exception codes
Include it in exceptions.cc instead of defining the exception codes
there.
2020-08-20 10:46:23 -04:00
Ken Brown 74cf7dabcb Cygwin: main exception handler (64-bit): continue GCC exceptions
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
2020-08-18 07:04:25 -04:00
Keith Packard via Newlib 8a7ec55c53 libm/stdlib: Realloc when shrinking by 2* or more
This reduces memory usage when reallocating objects much smaller.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-08-17 11:43:55 +02:00
Keith Packard via Newlib ce4044adee libm/stdlib: don't read past source in nano_realloc
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>
2020-08-17 11:43:55 +02:00
Takashi Yano via Cygwin-patches 70d02aaca6 Cygwin: pty: Change the timing of set_locale() call again.
- After commit 095972ce5b, 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.
2020-08-17 11:12:59 +02:00
Takashi Yano via Cygwin-patches 095972ce5b Cygwin: pty: Change the timing of setup_locale() call.
- 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.
2020-08-13 10:20:53 +02:00
Craig Blackmore ab215e3dd1 libc/stdlib: Fix build failure in nano_calloc
commit 588a5e1dde 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>
2020-08-13 09:59:45 +02:00
Keith Packard via Newlib 588a5e1dde libc/stdlib: Use __builtin_mul_overflow for reallocarray and calloc
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>
2020-08-12 10:09:56 +02:00
Keith Packard via Newlib bafd65f2fb libm/machine/riscv: Add custom fma/sqrt functions when supported [v2]
Check for HW FMA and SQRT support and use those instructions in place
of software implementations.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-08-12 09:52:19 +02:00
Takashi Yano f14d123ac6 Cygwin: pty: Add a workaround for issue of starting a lot of mintty.
- 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.
2020-08-11 12:19:33 +02:00
Keith Packard via Newlib a44bc679a4 libm/machine/arm: Add optimized fmaf and fma when available
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>
2020-08-10 21:04:12 +02:00
Keith Packard via Newlib 0c1989070e libm: Detect fast fmaf support
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>
2020-08-10 21:01:46 +02:00
Keith Packard via Newlib 432b331c79 libm: ARM without HW double does not have fast FMA
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>
2020-08-10 21:01:46 +02:00
Keith Packard via Newlib 73b02710ec libm/math: ensure that expf(-huge) sets FE_UNDERFLOW exception
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>
2020-08-10 10:31:36 +02:00
Ken Brown 225d376b70 Cygwin: cygserver: build with -Wimplicit-fallthrough=5
Define the pseudo keyword 'fallthrough' in woutsup.h to support this.
2020-08-07 13:40:13 -04:00
Jon Turney 1be41b802a
Cygwin: Use documented QueryWorkingSetEx() in dumper
In dumper, use the documented QueryWorkingSetEx(), rather than the
undocumented NtQueryVirtualMemory() with MemoryWorkingSetExInformation.
2020-08-07 15:08:30 +01:00
Jozef Lawrynowicz e3f29b2472 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.

>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.
2020-08-07 15:16:43 +02:00
Jozef Lawrynowicz 748970c833 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.

>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.
2020-08-07 15:16:43 +02:00
Corinna Vinschen c8dc3fa0ba Cygwin: cygserver: build with -Wimplicit-fallthrough=4 -Werror
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-07 15:09:56 +02:00
Corinna Vinschen acfed1364a Cygwin: utils: build with -Wimplicit-fallthrough=4 -Werror
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-07 15:09:56 +02:00
Corinna Vinschen e7fca6f867 Cygwin: utils: convert usage() to proper noreturn function throughout
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-07 15:09:56 +02:00
Corinna Vinschen 9beb7b9771 Cygwin: utils: cygcheck: avoid GCC warning concatenating strings
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-07 15:09:48 +02:00
Corinna Vinschen 238c2b14ca Cygwin: utils: refresh tzmap
- update path to Unicode windowsZones.xml file
- drop Windows XP considerations
- regenerate tzmap.h

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-08-07 15:09:39 +02:00
Keith Packard via Newlib c3ce8405c1 libm: Control errno support with _IEEE_LIBM configuration parameter
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>
2020-08-05 22:23:02 +02:00
Keith Packard via Newlib e108d04432 libm/math: Don't modify __ieee754_pow return values in pow
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>
2020-08-05 22:16:31 +02:00
Keith Packard via Newlib 98a4f8de47 libm/math: Set errno to ERANGE for pow(0, -y)
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>
2020-08-05 22:16:31 +02:00
Keith Packard via Newlib 2eafcc78df libm/math: Make yx functions set errno=ERANGE for x=0
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>
2020-08-05 22:16:31 +02:00
Keith Packard via Newlib 905aa4c013 libm/math: set errno to ERANGE at gamma poles
For POSIX, gamma(i) (i non-positive integer) should set errno to
ERANGE instead of EDOM.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-08-05 22:16:31 +02:00