4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-02 12:30:24 +08:00

12669 Commits

Author SHA1 Message Date
David McFarland via Cygwin-patches
55f922dfc7 Cygwin: create install dir for libs
This fixes a race in parallel installs.
2020-10-14 10:54:30 -04:00
Corinna Vinschen
a82e5b33f4 Cygwin: libpthread: Export C11 thread symbols from libpthread.a as well
...as on glibc right now.  This is supposed to support autoconf scripts
checking for existence of these symbols in libpthread.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:30 -04:00
Corinna Vinschen
c35c798429 Cygwin: mtx_init: drop glibc workaround
GLibc will change this code in the forseeable future to align more
with FreeBSD, so this hack is not actually desired.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:30 -04:00
Takashi Yano via Cygwin-patches
c319a3c9f1 Cygwin: pty: Fix a bug in the code removing set window title sequence.
- Commit 4e08fe42c9f3fdba63a57a8e3a6d705c4e10f50f has a bug which
  may cause infinite loop in pty_master_fwd_thread(). This patch
  fixes the issue.
2020-10-14 10:54:30 -04:00
Takashi Yano via Cygwin-patches
0e6aa5e415 Cygwin: pty: Disable pseudo console if TERM does not have CSI6n.
- Pseudo console internally sends escape sequence CSI6n (query cursor
  position) on startup of non-cygwin apps. If the terminal does not
  support CSI6n, CreateProcess() hangs waiting for response. To prevent
  hang, this patch disables pseudo console if the terminal does not
  have CSI6n. This is checked on the first execution of non-cygwin
  app using the following steps.
    1) Check if the terminal support ANSI escape sequences by looking
       into terminfo database. If terminfo has cursor_home (ESC [H),
       the terminal is supposed to support ANSI escape sequences.
    2) If the terminal supports ANSI escape sequneces, send CSI6n for
       a test and wait for a responce for 40ms.
    3) If there is a responce within 40ms, CSI6n is supposed to be
       supported.
  Also set-title capability is checked, and removes escape sequence
  for setting window title if the terminal does not have the set-
  title capability.
2020-10-14 10:54:30 -04:00
Jon Turney
13a6ebe752 Cygwin: Remove waitloop argument from try_to_debug()
Currently, when using CYGWIN's error_start facility, the faulting
process isn't stopped while the error_start process is started when the
fault is caused by an exception. (it even seems possible in theory that
the faulting process could have exited before the error_start process
attaches).

This leads to e.g. the core dump written by CYGWIN='error_start=dumper'
in response to an exception being non-deterministic.

Remove the waitloop argument from try_to_debug(), only used in the
exception case, so the faulting process busy-waits until the error_start
process attaches.

Code archaeology to determine why the code is this way didn't really
turn up any answers, but this seems a low-risk change, as this only
changes the behaviour when:

 - a debugger isn't already attached
 - an error_start is specified in CYGWIN env var
 - an exception has occurred which will be translated to a signal

If error_start invokes something which doesn't attach using
DebugActiveProcess(), we will spin indefinitely, but that will also
currently occur for any of the existing other uses of try_to_debug(),
which default to waitloop=TRUE.
2020-10-14 10:54:30 -04:00
Ken Brown
8e58acb944 Cygwin: sigproc.cc: add comment 2020-10-14 10:54:29 -04:00
Corinna Vinschen
52311e4488 Cygwin: Add modfl fix to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:29 -04:00
Martin Storsjö
deabe05b6b Cygwin: crt: Add "volatile" to all inline assembly snippets under math
On 32 bit x86, clang seems to miss loading input parameters based
on asm constraints for inline assembly that uses the x87 floating
registers, unless the snippet has got the volatile keyword.

Signed-off-by: Martin Storsjö <martin@martin.st>
2020-10-14 10:54:29 -04:00
Liu Hao
788d168a0e Cygwin: math/modfl.c: Fix segment faults in modfl().
Reference: https://sourceforge.net/p/mingw-w64/bugs/478/
Signed-off-by: Liu Hao <lh_mouse@126.com>
2020-10-14 10:54:29 -04:00
Corinna Vinschen
36f4c703d4 Cygwin: Add Cygwin 3.2 release info
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:29 -04:00
Corinna Vinschen
c4c095f2cf Cygwin: Add C11 threads API
Code taken from FreeBSD, which implements C11 threads as
wrapper around pthreads.  Fix up machine/_threads.h which
is called from newlib's machine-independent threads.h to
match Cygwin's pthreads types.

Add the FreeBSD source files to libc subdir and take
opportunity to define LIBC_OFILES var in Makefile.

Add new symbols to common.din and sort symbols.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:29 -04:00
Corinna Vinschen
2052848eef Cygwin: make pthread_yield available for internal usage
In preparation of importing FreeBSDs stdthreads functions,
change the way pthread_yield is exported, so that the symbol
can be used internally as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:29 -04:00
Corinna Vinschen
a13a7e64f6 Cygwin: pthread_yield: Add BSD visibility
pthread_yield was only declared under GNU visibility,
but the function should be available under BSD visibility
as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:29 -04:00
Corinna Vinschen
2a9f6de66e Cygwin: pthreads: iterate over key destructors per POSIX
POSIX requires that key destructors are called in a loop
for each key with a non-NULL value until all values are
NULL, or until all destructors for non-NULL values
have been called at least PTHREAD_DESTRUCTOR_ITERATIONS
(per POSIX: 4) times.

Cygwinonly called all destructors with non-NULL values
exactly once.  This patch fixes Cygwin to follow POSIX.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:29 -04:00
Corinna Vinschen
5223e2908a 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-10-14 10:54:29 -04:00
Corinna Vinschen
e1ca36ff14 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-10-14 10:54:29 -04:00
Corinna Vinschen
bc9149b347 Cygwin: sigproc: fix minor formatting issue
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:29 -04:00
Takashi Yano via Cygwin-patches
403b48fc6b 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-10-14 10:54:29 -04:00
Corinna Vinschen
04b3868170 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-10-14 10:54:29 -04:00
Corinna Vinschen
445ce89781 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-10-14 10:54:29 -04:00
Corinna Vinschen
2ba1be783b Cygwin: sigproc: drop __stdcall
Nothing to gain here

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:28 -04:00
Corinna Vinschen
754d518649 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-10-14 10:54:28 -04:00
Corinna Vinschen
4b2f06afef Cygwin: fix up proc_subproc flags and matching pinfo methods
After patch 23a779bf3d7c2afc9eab88f6b8727c1db5544547
"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-10-14 10:54:28 -04:00
Ken Brown
d74cb647da 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-10-14 10:54:28 -04:00
Brian Inglis
39938ad946 winsup/doc/faq-api.xml(faq.api.timezone): explain time zone updates
based on material from tz@IANA.org mailing list sources
2020-10-14 10:54:28 -04:00
Takashi Yano via Cygwin-patches
22b6314b68 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-10-14 10:54:28 -04:00
Brian Inglis
ea4bf1544c winsup/doc/faq-api.xml, -programming.xml: change Win32 to Windows/API 2020-10-14 10:54:28 -04:00
Brian Inglis
3388fe2590 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-10-14 10:54:28 -04:00
Ken Brown
08605d945c 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-10-14 10:54:28 -04:00
Takashi Yano
c4d0a3cff9 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-10-14 10:54:28 -04:00
Corinna Vinschen
3679980578 Cygwin: bump version to 3.2.0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:28 -04:00
Ken Brown
4db5921ac3 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-10-14 10:54:28 -04:00
Ken Brown
acbeafa2fa Cygwin: add header defining GCC exception codes
Include it in exceptions.cc instead of defining the exception codes
there.
2020-10-14 10:54:28 -04:00
Ken Brown
3cc9204119 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-10-14 10:54:28 -04:00
Takashi Yano via Cygwin-patches
bd2a59f659 Cygwin: pty: Change the timing of set_locale() call again.
- 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.
2020-10-14 10:54:27 -04:00
Takashi Yano via Cygwin-patches
35db52d184 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-10-14 10:54:27 -04:00
Takashi Yano
bcbaf9d261 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-10-14 10:54:27 -04:00
Ken Brown
291a4b22df Cygwin: cygserver: build with -Wimplicit-fallthrough=5
Define the pseudo keyword 'fallthrough' in woutsup.h to support this.
2020-10-14 10:54:27 -04:00
Jon Turney
e85f34f069 Cygwin: Use documented QueryWorkingSetEx() in dumper
In dumper, use the documented QueryWorkingSetEx(), rather than the
undocumented NtQueryVirtualMemory() with MemoryWorkingSetExInformation.
2020-10-14 10:54:27 -04:00
Corinna Vinschen
0f14113664 Cygwin: cygserver: build with -Wimplicit-fallthrough=4 -Werror
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:27 -04:00
Corinna Vinschen
c28acd565c Cygwin: utils: build with -Wimplicit-fallthrough=4 -Werror
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:27 -04:00
Corinna Vinschen
4257d39dce Cygwin: utils: convert usage() to proper noreturn function throughout
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:26 -04:00
Corinna Vinschen
03beadd4eb Cygwin: utils: cygcheck: avoid GCC warning concatenating strings
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:26 -04:00
Corinna Vinschen
835865603d 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-10-14 10:54:26 -04:00
Corinna Vinschen
b6cedcd9a4 Cygwin: Add 'fallthrough' pseudo keyword for switch/case use
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.
2020-10-14 10:54:26 -04:00
Corinna Vinschen
758e0d2f5f Cygwin: Fix missing breaks in switch statement
Two switch statements in sysconf() and
fhandler_fifo::take_ownership were missing breaks.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:26 -04:00
Ken Brown
10f6c392b0 Cygwin: FIFO: add a third pass to raw_read
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.
2020-10-14 10:54:26 -04:00
Ken Brown
e3ccd69c3c Cygwin: FIFO: fix indentation 2020-10-14 10:54:26 -04:00
Ken Brown
c9f123281d Cygwin: FIFO: synchronize the fifo_reader and fifosel threads
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.
2020-10-14 10:54:26 -04:00