Commit Graph

19342 Commits

Author SHA1 Message Date
Ken Brown 01d1aab0fd Cygwin: FIFO: remove the arm method
There's no reason to check for errors when we set read_ready or
write_ready.  We don't do that for other events.
2020-10-14 10:54:18 -04:00
Ken Brown cb3c6d0eb7 Cygwin: FIFO: simplify the listen_client_thread code
Always return 0; no one is doing anything with the return value
anyway.

Remove the return value from stop_listen_client.

Make the connection event auto-reset, so that we don't have to reset
it later.

Simplify the process of connecting a bogus client when thread
termination is signaled.

Make some failures fatal.

Remove the unnecessary extra check for thread termination near the end
of listen_client_thread.
2020-10-14 10:54:18 -04:00
Ken Brown 7e2a64d06b Cygwin: FIFO: change the fifo_client_connect_state enum
Make the values correspond to the possible return values of
fifo_client_handler::pipe_state().

When cleaning up the fc_handler list in listen_client_thread(), don't
delete handlers in the fc_closing state.  I think the pipe might still
have input to be read in that case.

Set the state to fc_closing later in the same function if a connection
is made and the status returned by NtFsControlFile is
STATUS_PIPE_CLOSING.

In raw_read, don't error out if NtReadFile returns an unexpected
status; just set the state of that handler to fc_error.  One writer in
a bad state doesn't justify giving up on reading.
2020-10-14 10:54:18 -04:00
Ken Brown 09ee986289 Cygwin: FIFO: simplify the fifo_client_handler structure
Replace the 'fhandler_base *' member by a HANDLE to the server side of
the Windows named pipe instance.  Make the corresponding
simplifications throughout.
2020-10-14 10:54:18 -04:00
Ken Brown 17c11db7d0 Cygwin: FIFO: minor change - use NtClose
Replace CloseHandle by NtClose since all handles are created by NT
functions.
2020-10-14 10:54:18 -04:00
Corinna Vinschen 8b69cce86f Revert "localtime define _DIAGASSERT" and followups affecting localtime.cc
This reverts commits 453b6d17bf,
                     489a47d603,
                     3003c3dacd,
                     9e29639ca0,
                     a40701c7dc,
                     0a41de2725,
                     b8aa5f7a0f,
                     0f4bda8792,
                     65bf580752,
                     3f0c2ac96e,
                     76d4d40b8b,
                     f2e06d8af5.
2020-10-14 10:54:18 -04:00
Johannes Schindelin 92b5518358 setup_pseudoconsole(): handle missing/incorrect helper gracefully
When `cygwin-console-helper.exe` is either missing, or corresponds to a
different Cygwin runtime, we currently wait forever while setting up
access to the pseudo console, even long after the process is gone that
was supposed to signal that it set up access to the pseudo console.

Let's handle that more gracefully: if the process exited without
signaling, we cannot use the pseudo console. In that case, let's just
fall back to not using it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2020-10-14 10:54:18 -04:00
Corinna Vinschen 4a0254c935 localtime define _DIAGASSERT 2020-10-14 10:54:18 -04:00
Corinna Vinschen f16b43e61a localtime 1.82 2020-10-14 10:54:18 -04:00
Corinna Vinschen df83c16c8f localtime 1.81 2020-10-14 10:54:18 -04:00
Corinna Vinschen 18f42547e7 localtime 1.80 2020-10-14 10:54:17 -04:00
Corinna Vinschen 0914ea9e18 localtime 1.79 2020-10-14 10:54:17 -04:00
Corinna Vinschen 23e0558ba0 localtime 1.78 2020-10-14 10:54:17 -04:00
Corinna Vinschen 2a84917364 localtime 1.77 2020-10-14 10:54:17 -04:00
Corinna Vinschen 51874852ff localtime 1.76 2020-10-14 10:54:17 -04:00
Corinna Vinschen a49e8c34e0 localtime 1.75 2020-10-14 10:54:17 -04:00
Corinna Vinschen 47ae9efd50 localtime 1.74 2020-10-14 10:54:17 -04:00
Corinna Vinschen 7373c12ce8 localtime 1.73 2020-10-14 10:54:17 -04:00
Corinna Vinschen 5d35ad8996 Cygwin: localtime.cc: reformat for easier patching
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:17 -04:00
Corinna Vinschen 9a8768233e Cygwin: add release message for fixed floppy bugs
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:17 -04:00
Corinna Vinschen 5b3594d4f9 Cygwin: raw disk I/O: lock floppys as well
The workaround to access the full disk required since Vista
and described in http://support.microsoft.com/kb/942448
(NOT ACCESSIBLE at the time of writing this commit message)
is required on floppy drives as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:17 -04:00
Corinna Vinschen e7bcd47bd5 Cygwin: raw disk I/O: Fix return value in error case
The cast to generate the return value uses a DWORD variable
as test and set value.  The error case is the constant -1.
Given the type of the other half of the conditioal expression,
-1 is cast to DWORD as well.

On 64 bit, this results in the error case returning a 32 bit
-1 value which is equivalent to (ssize_t) 4294967295 rather
than (ssize_t) -1.

Add a fixing cast.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:17 -04:00
Corinna Vinschen 726ad38d42 Cygwin: file I/O: make sure to treat write return value as ssize_t
The return type of fhandler write methods is ssize_t.  Don't
use an int to store the return value, use ssize_t.  Use ptrdiff_t
for the buffer size.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:17 -04:00
David Macek via Cygwin-patches 2d04009839 Cygwin: accounts: Report unrecognized db_* nsswitch.conf keywords
Signed-off-by: David Macek <david.macek.0@gmail.com>
2020-10-14 10:54:17 -04:00
David Macek via Cygwin-patches e8a9e5f7d8 Cygwin: accounts: Don't keep old schemes when parsing nsswitch.conf
The implicit assumption seemed to be that any subsequent occurence of
the same setting in nsswitch.conf is supposed to rewrite the previous
ones completely.  This was not the case if the third or any further
schema was previously defined and the last line defined less than that
(but at least 2), for example:

```
db_home: windows cygwin /myhome/%U
db_home: cygwin desc
```

Let's document this behavior as well.

Signed-off-by: David Macek <david.macek.0@gmail.com>
2020-10-14 10:54:17 -04:00
David Macek via Cygwin-patches 0531a163d3 Cygwin: accounts: Unify nsswitch.conf db_* defaults
Signed-off-by: David Macek <david.macek.0@gmail.com>
2020-10-14 10:54:17 -04:00
Corinna Vinschen 82ad860b2b Cygwin: Add David Macek to CONTRIBUTORS
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:17 -04:00
Corinna Vinschen 3435658492 Cygwin: symlinks: fix WSL symlink creation if cygdrive prefix is /
If the cygdrive prefix is /, then the following happens right now:

  $ ln -s /tmp/foo .
  $ ls -l foo
  lrwxrwxrwx 1 user group 12 Apr 15 23:44 foo -> /mnt/tmp/foo

Fix this by skipping cygdrive prefix conversion to WSL drive
prefix "/mnt", if the cygdrive prefix is just "/".  There's no
satisfying way to do the right thing all the time in this case
anyway.  For a description and the alternatives, see
https://cygwin.com/pipermail/cygwin-developers/2020-April/011859.html

Also, fix a typo in a comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:17 -04:00
David Macek via Cygwin-patches a4ee2c5550 cygheap_pwdgrp: Handle invalid db_* entries correctly
If the first scheme in db_* was invalid, the code would think there
were no schemes specified and replace the second scheme with
NSS_SCHEME_DESC.

Signed-off-by: David Macek <david.macek.0@gmail.com>
2020-10-14 10:54:17 -04:00
Corinna Vinschen 32c529deeb Cygwin: faq: disable outdated "sshd in domain" faq
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:17 -04:00
Brian Inglis dc27f5a3ce proc_cpuinfo: Add PPIN support for AMD
Newer AMD CPUs support a feature called protected processor
identification number (PPIN). This feature can be detected via
CPUID_Fn80000008_EBX[23].
2020-10-14 10:54:17 -04:00
Corinna Vinschen 06ab3932ab Cygwin: utils: override definition of PMEM_EXTENDED_PARAMETER
PMEM_EXTENDED_PARAMETER is defined in the local winlean.h as long
as mingw-w64 doesn't define it (in winnt.h).  ntdll.h needs the
definition for declaring NtMapViewOfSectionEx.  cygpath.cc and ps.cc
both include ntdll.h but not winlean.h, so they complain about the
missing definition.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen b6df67537b Cygwin: mmap_alloc: fix comment to document using the extended memory API
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen 725b690bba Cygwin: threads: use extended memory API if available
So far Cygwin was jumping through hoops to restrict memory
allocation to specific regions.  With the advent of VirtualAlloc2
and MapViewOfFile3 (and it's NT counterpart NtMapViewOfSectionEx),
we can skip searching for free space in the specific regions
and just call these functions and let the OS do the job more
efficiently and less racy.

Use VirtualAlloc2 on W10 1803 and later in thread stack allocation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen 5942ea58df Cygwin: mmap: use extended memory API if available
So far Cygwin was jumping through hoops to restrict memory
allocation to specific regions.  With the advent of VirtualAlloc2
and MapViewOfFile3 (and it's NT counterpart NtMapViewOfSectionEx),
we can skip searching for free space in the specific regions
and just call these functions and let the OS do the job more
efficiently and less racy.

Use the new functions on W10 1803 and later in mmap.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen 686e9259a8 Cygwin: memory: declare extended memory API
Windows 10 1803 introduced an extended memory API allowing
to specify memory regions allocations are to be taken off.

In preparation of using this API, define the struct
MEM_EXTENDED_PARAMETER and friends.  Declare and allow to
autoload the functions VirtualAlloc2 and NtMapViewOfSectionEx.

Introduce a wincap flag has_extended_mem_api.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen a9cafb56c1 Cygwin: threads: add missing include of mmap_alloc.h
This is needed for using mmap_alloc.alloc()

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen d9574d7867 Cygwin: threads: lower thread size from pool to 256 Megs
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen 6a078e48c3 Cygwin: threads: use mmap area to fulfill requests for big stacks
Otherwise big stacks have a higher probability to collide with
randomized PEBs and TEBs after fork.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen 0ef2f480fc Cygwin: symlinks: Allow traversing WSL symlinks
Unfortunately Windows doesn't understand WSL symlinks,
despite being a really easy job.  NT functions trying
to access paths traversing WSL symlinks return the status
code STATUS_IO_REPARSE_TAG_NOT_HANDLED.  Handle this
status code same as STATUS_OBJECT_PATH_NOT_FOUND in
symlink_info::check to align behaviour to traversing
paths with other non-NTFS type symlinks.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen 6c3e17dd79 Cygwin: docs: revamp docs explaining symlinks
The descriptions of symlink handling are a bit dated, so
revamp them and add the new WSL symlink type.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen b949568678 Cygwin: symlinks: create WSL symlinks on supporting filesystems
WSL symlinks are reparse points containing a POSIX path in UTF-8.
On filesystems supporting reparse points, use this symlink type.
On other filesystems, or in case of error, fall back to the good
old plain SYSTEM file.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen 2aa47e7d12 Cygwin: symlinks: fix WSL symlinks pointing to /mnt
Commit 4a36897af3 allowed to convert /mnt/<drive> path
prefixes to Cygwin cygdrive prefixes on the fly.  However,
the patch neglected WSL symlinks pointing to the /mnt
directory.  Rearrange path conversion so /mnt is converted
to the cygdrive prefix path itself.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Biswapriyo Nath c2a4b866db winsup/cygwin: remove defines added in mingw-w64 v7.0.0
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
2020-10-14 10:54:16 -04:00
Corinna Vinschen 31c3c0e306 Cygwin: symlinks: support WSL symlinks
Treat WSL symlinks just like other symlinks.  Convert
absolute paths pointing to Windows drives via
/mnt/<driveletter> to Windows-style paths <driveletter>:

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Corinna Vinschen f2b68dd7de Cygwin: serial: fix GCC warning
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:54:16 -04:00
Keith Packard via Newlib 7c84adcc2e newlib/libm/math: Make pow/powf return qnan for snan arg
The IEEE spec for pow only has special case for x**0 and 1**y when x/y
are quiet NaN. For signaling NaN, the general case applies and these functions
should signal the invalid exception and return a quiet NaN.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-10-14 10:54:16 -04:00
Keith Packard via Newlib 87edc8c912 newlib/libm/common: Don't re-convert float to bits in modf/modff
These functions shared a pattern of re-converting the argument to bits
when returning +/-0. Skip that as the initial conversion still has the
sign bit.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-10-14 10:54:16 -04:00
Keith Packard via Newlib e7aa772fe7 newlib/libm/common: Fix modf/modff returning snan
Recent GCC appears to elide multiplication by 1, which causes snan
parameters to be returned unchanged through *iptr. Use the existing
conversion of snan to qnan to also set the correct result in *iptr
instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-10-14 10:54:16 -04:00
Joseph S. Myers 6ed0615e25 Fix spurious underflow exceptions for Bessel functions for double(from glibc bug 14155)
This fix comes from glibc, from files which originated from
	the same place as the newlib files. Those files in glibc carry
	the same license as the newlib files.

Bug 14155 is spurious underflow exceptions from Bessel functions for
large arguments.  (The correct results for large x are roughly
constant * sin or cos (x + constant) / sqrt (x), so no underflow
exceptions should occur based on the final result.)

There are various places underflows may occur in the intermediate
calculations that cause the failures listed in that bug.  This patch
fixes problems for the double version where underflows occur in
calculating the intermediate functions P and Q (in particular, x**-12
gets computed while calculating Q).  Appropriate approximations are
used for P and Q for arguments at least 0x1p28 and above to avoid the
underflows.

For sufficiently large x - 0x1p129 and above - the code already has a
cut-off to avoid calculating P and Q at all, which means the
approximations -0.125 / x and 0.375 / x can't themselves cause
underflows calculating Q.  This cut-off is heuristically reasonable
for the point beyond which Q can be neglected (based on expecting
around 0x1p-64 to be the least absolute value of sin or cos for large
arguments representable in double).

The float versions use a cut-off 0x1p17, which is less heuristically
justifiable but should still only affect values near zeroes of the
Bessel functions where these implementations are intrinsically
inaccurate anyway (bugs 14469-14472), and should serve to avoid
underflows (the float underflow for jn in bug 14155 probably comes
from the recurrence to compute jn).  ldbl-96 uses 0x1p129, which may
not really be enough heuristically (0x1p143 or so might be safer - 143
= 64 + 79, number of mantissa bits plus total number of significant
bits in representation) but again should avoid underflows and only
affect values where the code is substantially inaccurate anyway.
ldbl-128 and ldbl-128ibm share a completely different implementation
with no such cut-off, which I propose to fix separately.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-10-14 10:54:16 -04:00