]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
11 months agoCygwin: Add '--names-only' flag to cygcheck cygwin-3_4-branch github/cygwin-3_4-branch
Jon Turney [Fri, 24 Nov 2023 16:17:05 +0000 (16:17 +0000)]
Cygwin: Add '--names-only' flag to cygcheck

Add '--names-only' flag to cygcheck, to output just the bare package
names.

(cherry picked from commit 127166f7070f67a3b322e72119df8a547fd1f85d)

11 months agoCygwin: bump DLL version to 3.4.11
Corinna Vinschen [Wed, 29 Nov 2023 11:44:46 +0000 (12:44 +0100)]
Cygwin: bump DLL version to 3.4.11

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
11 months agoCygwin: open(2): reset sparseness on O_TRUNCated files cygwin-3.4.10
Corinna Vinschen [Mon, 27 Nov 2023 20:14:49 +0000 (21:14 +0100)]
Cygwin: open(2): reset sparseness on O_TRUNCated files

open(2) implements O_TRUNC by just reducing the size of the file
to 0, to make sure EAs stay available.

Turns out, file sparseness is not removed this way either, so add
code to do just that.

Fixes: 603ef545bdbd ("* fhandler.cc (fhandler_base::open): Never open files with FILE_OVERWITE/FILE_OVERWRITE_IF.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
11 months agoCygwin: posix_fallocate: return ENODEV
Corinna Vinschen [Sat, 25 Nov 2023 19:56:52 +0000 (20:56 +0100)]
Cygwin: posix_fallocate: return ENODEV

The fhandler method ftruncate returns either EISDIR if it has been
called on directories, or EINVAL if called on files other than
regular files.  This matches what ftruncate(2) is supposed to return,
but it doesn't match posix_fallocate(3), which is supposed to return
ENODEV in both cases.

To accomplish that, return ENODEV from fhandler_base::ftruncate()
and convert it to EINVAL in ftruncate(2). In posix_fallocate(3),
convert EISDIR to ENODEV.

Fixes: 7636b58590621 ("* autoload.cc (NtSetInformationFile): Define.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
12 months agonewlib: nl_langinfo: Fix a bug of time stuff.
Takashi Yano [Thu, 23 Nov 2023 11:00:55 +0000 (20:00 +0900)]
newlib: nl_langinfo: Fix a bug of time stuff.

Previously, e.g. nl_langinfo(_NL_TIME_WMONTH_1) returns "February"
due to the bug. Similarly, nl_langinfo(_NL_TIME_WWDAY_1) returns
"Mon". This occurs because wide char month and weekday arrays are
pointed off-by-one (e.g. the array wmon[12] is reffered as wmon[1-12]
rather than wmon[0-11]). This patch fixes that.

Fixes: d47d5b850bed ("Extend locale support to maintain wide char values of native strings")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
12 months agoCygwin: rand(3): implement in terms of random(3)
Corinna Vinschen [Tue, 14 Nov 2023 16:52:48 +0000 (17:52 +0100)]
Cygwin: rand(3): implement in terms of random(3)

This makes rand(3) ISO C compliant and adds locking to avoid
race conditions.

Reported-by: Bruno Haible <bruno@clisp.org>
Fixes: 8a0efa53e4491 ("import newlib-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
12 months agoFix profiler error() definition and usage
Mark Geisert [Tue, 14 Nov 2023 08:58:33 +0000 (00:58 -0800)]
Fix profiler error() definition and usage

Minor updates to profiler and gmondump, which share some code:
- fix operation of error() so it actually works as intended
- resize 4K-size auto buffer reservations to BUFSIZ (==1K)
- remove trailing '\n' from 2nd arg on error() calls everywhere
- provide consistent annotation of Windows error number displays

Fixes: 9887fb27f6126 ("Cygwin: New tool: profiler")
Fixes: 087a3d76d7335 ("Cygwin: New tool: gmondump")
Signed-off-by: Mark Geisert <mark@maxrnd.com>
12 months agoAdd release text for random(3) fix
Corinna Vinschen [Mon, 13 Nov 2023 19:01:36 +0000 (20:01 +0100)]
Add release text for random(3) fix

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
12 months agoCygwin: random: drop unused function srandomdev()
Corinna Vinschen [Mon, 13 Nov 2023 18:37:56 +0000 (19:37 +0100)]
Cygwin: random: drop unused function srandomdev()

Also drop includes only required for srandomdev().

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
12 months agoCygwin: random: make random(3) functions thread-safe
Corinna Vinschen [Mon, 13 Nov 2023 18:41:08 +0000 (19:41 +0100)]
Cygwin: random: make random(3) functions thread-safe

Add locking to the random(3) family of functions to gain
thread-safety per POSIX. Use NetBSD version of the file as
role-model.

Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
12 months agoCygwin: let feraiseexcept actually raise an exception
Corinna Vinschen [Tue, 31 Oct 2023 12:07:36 +0000 (13:07 +0100)]
Cygwin: let feraiseexcept actually raise an exception

The exception handling inside of Cygwin functions marked as SIGFE
covers exceptions and lets the library code handle them gracefully.
If these functions want to raise an exception, they have to send a
signal explicitely via raise(3).

That's not what we want in feraiseexcept(). It triggers a floating
point exception explicitely by calling the i387 op "fwait".  Being
marked as SIGFE, this exception will be suppressed and the normal
exception handling won't kick in.

Fix this by moving feraiseexcept into the NOSIGFE realm.

Fixes: 0f81b5d4bcaa ("* Makefile.in (DLL_OFILES): Add new fenv.o module.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
12 months agoCygwin: cwd: avoid releasing the cwdstuff SRW Lock twice
Corinna Vinschen [Mon, 30 Oct 2023 18:40:31 +0000 (19:40 +0100)]
Cygwin: cwd: avoid releasing the cwdstuff SRW Lock twice

cwdstuff::set has a code snippet handling the case where a process
can't create a handle to a directory, e. g., due to permissions.

Commit 88443b0a22589 ("cwdstuff: Don't leave from setting the CWD
prematurely on init") introduced a special case to handle this
situation at process initialization. It also introduces an early
mutex release, which is not required, but ok, because we're in the
init phase. Releasing the mutex twice is no problem since the mutexes
are recursive.

Fast forward to commit 0819679a7a210 ("Cygwin: cwd: use SRWLOCK
instead of muto"). The mechanical change from a recursive mutex
to a non-recursive SRWLOCK failed to notice that this very specific
situation will release the SRWLOCK twice.

Remove the superfluous release action. While at it, don't set dir to
NULL, but h, since dir will get the value of h anyway later on.
Setting h to NULL may not be necessary, but better safe than sorry.

Reported-by: tryandbuy >tryandbuy@proton.me>
Fixes: 88443b0a22589 ("cwdstuff: Don't leave from setting the CWD prematurely on init")
Fixes: 0819679a7a210 ("Cygwin: cwd: use SRWLOCK instead of muto")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
14 months agoCygwin: dsp: Fix a bug that app hangs if it killed during write().
Takashi Yano [Sat, 16 Sep 2023 23:32:09 +0000 (08:32 +0900)]
Cygwin: dsp: Fix a bug that app hangs if it killed during write().

If app is killed during blocking write(), it sometimes hangs. This
patch fixes the issue.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
14 months agoCygwin: Add relnote to 3.4.10 release file
Mark Geisert [Sat, 9 Sep 2023 06:48:30 +0000 (23:48 -0700)]
Cygwin: Add relnote to 3.4.10 release file

Document the most recent update to include/sys/cpuset.h.

(cherry picked from commit 27e8815535fc7e6a9ed204323682f22be02946a5)

14 months agoCygwin: Fix __cpuset_zero_s prototype
Mark Geisert [Fri, 8 Sep 2023 05:36:39 +0000 (22:36 -0700)]
Cygwin: Fix __cpuset_zero_s prototype

Add a missing "void" to the prototype for __cpuset_zero_s().

Reported-by: Marco Mason <marco.mason@gmail.com>
Addresses: https://cygwin.com/pipermail/cygwin/2023-September/254423.html
Signed-off-by: Mark Geisert <mark@maxrnd.com>
Fixes: c6cfc99648d6 (Cygwin: sys/cpuset.h: add cpuset-specific external functions)
(cherry picked from commit 003fc339425b28283f86a05cdb9cbfb194167222)

14 months agoCygwin: bump DLL version to 3.4.10
Corinna Vinschen [Wed, 6 Sep 2023 10:40:24 +0000 (12:40 +0200)]
Cygwin: bump DLL version to 3.4.10

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
14 months agoCygwin: dps: Fix a bug that read() could not return -1 on error. cygwin-3.4.9
Takashi Yano [Tue, 5 Sep 2023 07:59:51 +0000 (16:59 +0900)]
Cygwin: dps: Fix a bug that read() could not return -1 on error.

14 months agoCygwin: CI: Stop running testsuite on 3.4 branch
Jon Turney [Sat, 2 Sep 2023 16:54:39 +0000 (17:54 +0100)]
Cygwin: CI: Stop running testsuite on 3.4 branch

It often (always?) gets stuck and takes a long time

14 months agoCygwin: document latest sys/cpuset.h fix
Corinna Vinschen [Fri, 1 Sep 2023 10:41:43 +0000 (12:41 +0200)]
Cygwin: document latest sys/cpuset.h fix

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
14 months agoCygwin: sys/cpuset.h: use internal base types
Corinna Vinschen [Wed, 30 Aug 2023 19:11:42 +0000 (21:11 +0200)]
Cygwin: sys/cpuset.h: use internal base types

Use __size_t and __pid_t instead of size_t and pid_t to avoid
further dependencies to external headers.

Reported-by: Brian Inglis <Brian.Inglis@Shaw.ca>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
14 months agoCygwin: sys/cpuset.h: add cpuset-specific external functions
Corinna Vinschen [Wed, 30 Aug 2023 09:32:02 +0000 (11:32 +0200)]
Cygwin: sys/cpuset.h: add cpuset-specific external functions

The latest incarnation of sys/cpuset.h broke building coreutils.
The reason is the inclusion of stdlib.h and string.h and hence
premature requests for datatypes not yet defined in the include
chain.

Avoid this by defining __cpuset_alloc and __cpuset_free as external
functions, now defined in sched.cc.  Linux is doing this too, just
using different names for the functions. Redefine  __cpuset_zero_s
to use __builtin_memset only on compilers supporting it, otherwise
using a simple loop. Drop the stdlib.h and string.h includes.

Fixes: 3f2790e04439 ("Cygwin: Make gcc-specific code in <sys/cpuset.h> compiler-agnostic")
Reported-by: Denis Excoffier <cygwin@Denis-Excoffier.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
14 months agoCygwin: dsp: Fix a few trivial bugs.
Takashi Yano [Fri, 1 Sep 2023 02:32:51 +0000 (11:32 +0900)]
Cygwin: dsp: Fix a few trivial bugs.

Signed-off-by: Takashi Yano <takashi.yanao@nifty.ne.jp>
14 months agoCygwin: execve: drop argument size limit
Corinna Vinschen [Tue, 29 Aug 2023 09:55:10 +0000 (11:55 +0200)]
Cygwin: execve: drop argument size limit

Before commit 44f73c5a6206 ("Cygwin: Fix segfalt when too many command
line args are specified.") we had no actual argument size limit, except
for the fact that the child process created another copy of the argv
array on the stack, which could result in a stack overflow and a
subsequent SEGV.  Commit 44f73c5a6206 changed that by allocating the
additional argv array via malloc, and it introduced a new SC_ARG_MAX
limit along the lines of the typical Linux limit.

However, this new limit is artificial. Cygwin allocates all argument
and environment data on the cygheap.  We only run out of ARG_MAX space
if we're out of memory resources.

Change argument size handling accordingly:
- Drop the args size check from  child_info_spawn::worker.
- Return -1 from sysconf (SC_ARG_MAX), i. e., the argument size limit
  is undefined.
- Change argv handling in class av, so that a failing cmalloc is not
  fatal.  This allows the parent process to return E2BIG if it's out
  of cygheap resources.
- In the child, add a check around the new malloc call, so that it
  doesn't result in a SEGV if the child process gets unexpectedly into
  an ENOMEM situation at this point. In this (unlikely) case, proceed
  with the original __argv array instead.  Add comment to explain why.

Fixes: 44f73c5a6206 ("Cygwin: Fix segfalt when too many command line args are specified.")
Tested-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
14 months agoCygwin: Fix segfalt when too many command line args are specified.
Takashi Yano [Mon, 28 Aug 2023 13:14:41 +0000 (22:14 +0900)]
Cygwin: Fix segfalt when too many command line args are specified.

Previously, the number of command line args was not checked for
cygwin process. Due to this, segmentation fault was caused if too
many command line args are specified.
https://cygwin.com/pipermail/cygwin/2023-August/254333.html

Since char *argv[argc + 1] is placed on the stack in dll_crt0_1(),
STATUS_STACK_OVERFLOW occurs if the stack does not have enough
space.

With this patch, char *argv[] is placed in heap instead of stack
and ARG_MAX is increased from 32000 to 2097152 which is default
value of Linux. The argument length is also compared with ARG_MAX
and spawnve() returns E2BIG if it is too long.

Reported-by: Ed Morton
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
15 months agoCygwin: document disabling mknod/mkfifo on NFS
Corinna Vinschen [Fri, 25 Aug 2023 12:50:48 +0000 (14:50 +0200)]
Cygwin: document disabling mknod/mkfifo on NFS

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
15 months agoCygwin: mknod: disable creating special files on NFS
Corinna Vinschen [Fri, 25 Aug 2023 12:39:04 +0000 (14:39 +0200)]
Cygwin: mknod: disable creating special files on NFS

This simply doesn't work (yet?) but leaves unusable files behind.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
15 months agoCygwin: configure: Add option to disable building 'dumper'
Jon Turney [Tue, 13 Dec 2022 23:17:48 +0000 (23:17 +0000)]
Cygwin: configure: Add option to disable building 'dumper'

Rather than guessing, based on just the presence of libbfd, add an
explicit configuration option, to build dumper or not, defaulting to
building it.

This might have some use when bootstrapping Cygwin for a new
architecture, or when building your own Cygwin-targetted cross-compiler,
rather than installing one from the copr, along with the dependencies of
libbfd.

(cherry picked from commit 1b5fc91a1daa90fb955f57937f4590c5079dd161)

15 months agoCygwin: pty: Fix failure to clear switch_to_nat_pipe flag.
Takashi Yano [Sat, 19 Aug 2023 05:10:16 +0000 (14:10 +0900)]
Cygwin: pty: Fix failure to clear switch_to_nat_pipe flag.

After the commit fbfea31dd9b9, switch_to_nat_pipe is not cleared
properly when non-cygwin app is terminated in the case where the
pseudo console is disabled. This is because get_winpid_to_hand_over()
sometimes returns PID of cygwin process even though it should return
only PID of non-cygwin process. This patch fixes the issue by adding
a new argument which requests only PID of non-cygwin process to
get_console_process_id().

Fixes: fbfea31dd9b9 ("Cygwin: pty: Avoid cutting the branch the pty master is sitting on.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
15 months agoCygwin: bump DLL version to 3.4.9
Corinna Vinschen [Thu, 17 Aug 2023 16:06:05 +0000 (18:06 +0200)]
Cygwin: bump DLL version to 3.4.9

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
15 months agoCygwin: shared: Fix access permissions setting in open_shared(). cygwin-3.4.8
Takashi Yano [Tue, 15 Aug 2023 23:00:27 +0000 (08:00 +0900)]
Cygwin: shared: Fix access permissions setting in open_shared().

After the commit 62f11a5a5704, the access permissions argument passed
to open_shared() is ignored and always replaced with (FILE_MAP_READ |
FILE_MAP_WRITE). This causes the weird behaviour that sshd service
process loses its cygwin PID. This triggers the failure in pty that
transfer_input() does not work properly.

This patch resumes the access permission settings to fix that.

Fixes: 62f11a5a5704 ("Cygwin: open_shared: don't reuse shared_locations parameter as output")
Fixes: fb16f490bf6e ("Cygwin: open_shared: try harder allocating a shared region")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signedd-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
15 months agoCygwin: pty: Add missing pinfo check in transfer_input().
Takashi Yano [Mon, 14 Aug 2023 10:48:12 +0000 (19:48 +0900)]
Cygwin: pty: Add missing pinfo check in transfer_input().

The commit 10d083c745dd has a bug that lacks a check for pinfo pointer
value for master_pid. This causes segmentation fault if the process
whose pid is master_pid no longer exists. This patch fixes the issue.

Fixes: 10d083c745dd ("Cygwin: pty: Inherit typeahead data between two input pipes.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
15 months agoCygwin: pty: Fix thread safety of readahead buffer handling in pty master.
Takashi Yano [Fri, 4 Aug 2023 08:45:34 +0000 (17:45 +0900)]
Cygwin: pty: Fix thread safety of readahead buffer handling in pty master.

Previously, though readahead buffer handling in pty master was not
fully thread-safe, accept_input() was called from peek_pipe() thread
in select.cc. This caused the problem reported in:
https://cygwin.com/pipermail/cygwin/2023-July/253984.html

The mechanism of the problem is:
1) accept_input() which is called from peek_pipe() thread calls
   eat_readahead(-1) before reading readahead buffer. This allows
   writing to the readahead buffer from another (main) thread.
2) The main thread calls fhandler_pty_master::write() just after
   eat_readahead(-1) was called and before reading the readahead
   buffer by accept_input() called from peek_pipe() thread. This
   overwrites the readahead buffer.
3) The read result from readahead buffer which was overwritten is
   sent to the slave.

This patch makes readahead buffer handling fully thread-safe using
input_mutex to resolve this issue.

Fixes: 7b03b0d8cee0 ("select.cc (peek_pipe): Call flush_to_slave whenever we're checking for a pty master.")
Reported-by: Thomas Wolff <towo@towo.net>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
15 months agonewlib: gdtoa: Suppress compiler warning.
Takashi Yano [Fri, 4 Aug 2023 08:42:18 +0000 (17:42 +0900)]
newlib: gdtoa: Suppress compiler warning.

Fixes: 5ac83ea47a7a ("newlib: Fix memory leak regarding gdtoa-based _ldtoa_r().")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
15 months agonewlib: Fix memory leak regarding gdtoa-based _ldtoa_r().
Takashi Yano [Wed, 2 Aug 2023 05:31:53 +0000 (14:31 +0900)]
newlib: Fix memory leak regarding gdtoa-based _ldtoa_r().

After the commit a4705d387f78, printf() for floating-point values
causes a memory leak. The legacy _ldtoa_r() assumed the char pointer
returned will be free'ed by Bfree(). However, gdtoa-based _ldtoa_r()
returns the pointer returned by gdtoa() which should be free'ed by
freedtoa(). Due to this issue, the caller of _ldtoa_r() fails to free
the allocated char buffer. This is the cause of the said memory leak.
https://cygwin.com/pipermail/cygwin/2023-July/254054.html

This patch makes rv_alloc()/freedtoa() allocate/free the buffer in
a compatible way with legacy _ldtoa_r().

Fixes: a4705d387f78 ("ldtoa: Import gdtoa from OpenBSD.")
Reported-by: natan_b <natan_b@libero.it>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
16 months agoRename _NL_CTYPE_OUTDIGITSx_MB/WC to _NL_CTYPE_OUTDIGITx_MB/WC
Corinna Vinschen [Wed, 26 Jul 2023 17:48:34 +0000 (19:48 +0200)]
Rename _NL_CTYPE_OUTDIGITSx_MB/WC to _NL_CTYPE_OUTDIGITx_MB/WC

The extended _NL_foo names were originally designed after their GLibc
counterparts.  However, the OUTDIGIT macros were accidentally defined as
OUTDIGITS, plural.  Fix them.

Fixes: d47d5b850bed ("Extend locale support to maintain wide char values of native strings")
Conflicts: Context formatting changes in winsup/utils/locale.cc not
           backported to 3.4 branch
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
16 months agoCygwin: add AT_EMPTY_PATH fix to release message
Corinna Vinschen [Wed, 12 Jul 2023 11:55:23 +0000 (13:55 +0200)]
Cygwin: add AT_EMPTY_PATH fix to release message

Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
16 months agoCygwin: Fix and streamline AT_EMPTY_PATH handling
Corinna Vinschen [Wed, 12 Jul 2023 11:47:49 +0000 (13:47 +0200)]
Cygwin: Fix and streamline AT_EMPTY_PATH handling

The GLIBC extension AT_EMPTY_PATH allows the functions fchownat
and fstatat to operate on dirfd alone, if the given pathname is an
empty string.  This also allows to operate on any file type, not
only directories.

Commit fa84aa4dd2fb4 broke this.  It only allows dirfd to be a
directory in calls to these two functions.

Fix that by handling AT_EMPTY_PATH right in gen_full_path_at.
A valid dirfd and an empty pathname is now a valid combination
and, noticably, this returns a valid path in path_ret.  That
in turn allows to remove the additional path generation code
from the callers.

Fixes: fa84aa4dd2fb ("Cygwin: fix errno values set by readlinkat")
Reported-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Tested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
16 months agoCygwin: use new _AT_NULL_PATHNAME_ALLOWED flag
Corinna Vinschen [Wed, 12 Jul 2023 11:45:24 +0000 (13:45 +0200)]
Cygwin: use new _AT_NULL_PATHNAME_ALLOWED flag

Convert gen_full_path_at to take flag values from the caller, rather
than just a bool indicating that empty paths are allowed.  This is in
preparation of a better AT_EMPTY_PATH handling in a followup patch.

Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
16 months agoDefine _AT_NULL_PATHNAME_ALLOWED
Corinna Vinschen [Wed, 12 Jul 2023 11:27:04 +0000 (13:27 +0200)]
Define _AT_NULL_PATHNAME_ALLOWED

Cygwin needs an internal flag to allow specifying an empty pathname
in utimesat (GLIBC extension). We define it in _default_fcntl.h to
make sure we never introduce a value collision accidentally.
While at it, define the values as 16 bit hex values.

Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
16 months agoCygwin: gen_full_path_at: drop never reached code
Corinna Vinschen [Wed, 12 Jul 2023 11:31:31 +0000 (13:31 +0200)]
Cygwin: gen_full_path_at: drop never reached code

The check if the local variable p is NULL is useless.  The preceeding
code always sets p to a valid pointer, or it crashes if path_ret is
invalid (which would be a bug in Cygwin).

Fixes: c57b57e5c43a ("* cygwin.din: Sort.")
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
16 months agoCygwin: Update release/3.4.8 for latest <sys/cpuset.h> commit
Mark Geisert [Thu, 13 Jul 2023 05:36:59 +0000 (22:36 -0700)]
Cygwin: Update release/3.4.8 for latest <sys/cpuset.h> commit

(cherry picked from commit c836d26d768b9db1b948ba5dcef571cd356cfb6c)

16 months agoCygwin: Make gcc-specific code in <sys/cpuset.h> compiler-agnostic
Mark Geisert [Sun, 9 Jul 2023 07:59:22 +0000 (00:59 -0700)]
Cygwin: Make gcc-specific code in <sys/cpuset.h> compiler-agnostic

The current version of <sys/cpuset.h> cannot be compiled by Clang due to
the use of builtin versions of malloc, free, and memset.  Their presence
here was a dubious optimization anyway, so their usage has been
converted to standard library functions.

The use of __builtin_popcountl remains because Clang implements it just
like gcc does.  If/when some other compiler (Rust? Go?) runs into this
issue we can deal with specialized handling then.

The "#include <sys/cdefs>" here to define __inline can be removed since
both of the new includes sub-include it.

Addresses: https://cygwin.com/pipermail/cygwin/2023-July/253927.html
Fixes: 9cc910dd33a5 (Cygwin: Make <sys/cpuset.h> safe for c89 compilations)
Signed-off-by: Mark Geisert <mark@maxrnd.com>
16 months agoCygwin: Fix latest release message being in the wrong release file.
Corinna Vinschen [Tue, 4 Jul 2023 14:50:00 +0000 (16:50 +0200)]
Cygwin: Fix latest release message being in the wrong release file.

Fixes: 6422e76637d3 ("Cygwin: Make <sys/cpuset.h> safe for c89 compilations")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
16 months agoCygwin: Make <sys/cpuset.h> safe for c89 compilations
Mark Geisert [Tue, 4 Jul 2023 00:51:41 +0000 (17:51 -0700)]
Cygwin: Make <sys/cpuset.h> safe for c89 compilations

Four modifications to include/sys/cpuset.h:
* Change C++-style comments to C-style also supported by C++
* Change "inline" to "__inline" on code lines
* Add "#include <sys/cdefs.h>" to make sure __inline is defined
* Don't declare loop variables on for-loop init clauses

Tested by first reproducing the reported issue with home-grown test
programs by compiling with gcc option "-std=c89", then compiling again
using the modified <sys/cpuset.h>. Other "-std=" options tested too.

Addresses: https://cygwin.com/pipermail/cygwin-patches/2023q3/012308.html
Fixes: 315e5fbd99ec ("Cygwin: Fix type mismatch on sys/cpuset.h")
Signed-off-by: Mark Geisert <mark@maxrnd.com>
17 months agoCygwin: thread: Reset _my_tls.tid if it's pthread_null in init_mainthread().
Takashi Yano [Thu, 22 Jun 2023 15:07:26 +0000 (00:07 +0900)]
Cygwin: thread: Reset _my_tls.tid if it's pthread_null in init_mainthread().

Currently, _my_tls.tid is set to pthread_null if pthread::self()
is called before pthread::init_mainthread(). As a result, pthread::
init_mainthread() does not set _my_tls.tid appropriately. Due to
this, pthread_join() fails in LDAP environment if the program is
the first program which loads cygwin1.dll.

https://cygwin.com/pipermail/cygwin/2023-June/253792.html

With this patch, _my_tls.tid is re-initialized in pthread::
init_mainthread() if it is pthread_null.

Reported-by: Mümin A. <muminaydin06@gmail.com>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
17 months agoCygwin: bump DLL version to 3.4.8
Corinna Vinschen [Fri, 16 Jun 2023 12:56:08 +0000 (14:56 +0200)]
Cygwin: bump DLL version to 3.4.8

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
17 months agoCygwin: pty: Additional fix for transferring input at exit. cygwin-3.4.7
Takashi Yano [Fri, 2 Jun 2023 01:19:18 +0000 (10:19 +0900)]
Cygwin: pty: Additional fix for transferring input at exit.

The commit 3456e8b7db5b does not fix transferring input at exit
appropriately. If the more than one non-cygwin apps are executed
simultaneously and one of them is terminated, the pty master failed
to send input to the other non-cygwin apps. This patch fixes that.

Fixes: 3456e8b7db5b ("Cygwin: pty: Fix transferring type-ahead input between input pipes.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
17 months agoCygwin: pty: Fix transferring type-ahead input between input pipes.
Takashi Yano [Thu, 1 Jun 2023 10:44:41 +0000 (19:44 +0900)]
Cygwin: pty: Fix transferring type-ahead input between input pipes.

After the commit 595fcb21ffc0, transferring type-ahead input between
the pipe for cygwin app and the pipe for non-cygwin app will not be
done appropriately when the stdin of the non-cygwin app is not pty.
Due to this issue, sometimes the keyboard input might be lost which
should be sent to cygwin app. This patch fixes the issue.

Fixes: 595fcb21ffc0 ("Cygwin: pty: Fix reading CONIN$ when stdin is not a pty.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
18 months agoCygwin: Adjust CWD magic to accommodate for the latest Windows previews
Johannes Schindelin [Mon, 22 May 2023 11:36:27 +0000 (13:36 +0200)]
Cygwin: Adjust CWD magic to accommodate for the latest Windows previews

Reportedly Windows 11 build 25*** from Insider changed the current
working directory logic a bit, and Cygwin's "magic" (or:
"technologically sufficiently advanced") code needs to be adjusted
accordingly.

This fixes https://github.com/git-for-windows/git/issues/4429

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
(cherry picked from commit 4840a5632520c1a3c1598f73f9d1cdd37df371ba)

18 months agoCygwin: Fix compiling with w32api-headers v11.0.0
Biswapriyo Nath [Sat, 29 Apr 2023 18:33:21 +0000 (00:03 +0530)]
Cygwin: Fix compiling with w32api-headers v11.0.0

This solves redefinition of FILE_CS_FLAG_CASE_SENSITIVE_DIR in winnt.h
and fixes the following compiler errors

ntdll.h:523:3: error: expected identifier before numeric constant
  523 |   FILE_CS_FLAG_CASE_SENSITIVE_DIR                       = 0x01
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ntdll.h:522:1: note: to match this â€˜{’
  522 | {
      | ^

(cherry picked from commit 3bee68248fc8e164a8bb6bba3f105b10fdec8a71)

19 months agoCygwin: align renameat2 to Linux behaviour
Corinna Vinschen [Tue, 18 Apr 2023 16:18:27 +0000 (18:18 +0200)]
Cygwin: align renameat2 to Linux behaviour

In contrast to rename default behaviour, Linux' renameat2 returns -1
with errno set to EEXIST, if oldfile and newfile refer to the same
file, and the RENAME_NOREPLACE flag is set.

Follow suit, given this is a Linux-only function anyway.

Fixes: f665b1cef30f ("cygwin: Implement renameat2")
Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: fix errno values set by readlinkat
Corinna Vinschen [Tue, 18 Apr 2023 11:52:50 +0000 (13:52 +0200)]
Cygwin: fix errno values set by readlinkat

readlinkat(fd, "", ...) is supposed to return ENOENT per POSIX,
but Cygwin returns EBADF.

At the same time, we have to maintain the special feature of
glibc that readlinkat(fd, "", ...) operates on fd, if fd is pointing
at a symlink opened with O_PATH|O_NOFOLLOW.

And, while fixing that, readlinkat(fd, path, ...) *still* has to set errno
to EBADF, if fd is an invalid descriptor *and* path is a relative path.

This required to change the evaluation order in the helper function
gen_full_path_at.

Last but not least, in case of the aforementioned glibc-like special
handling for symlink descriptors, we have to make sure that errors from
gen_full_path_at are not spilled into that special handling.

Fixes: 6cc05784e16a ("Cygwin: readlinkat: allow pathname to be empty")
Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: fix return value of ilogbl(NaN)
Corinna Vinschen [Tue, 18 Apr 2023 11:43:06 +0000 (13:43 +0200)]
Cygwin: fix return value of ilogbl(NaN)

Fixes: 792e51b72149 ("Add missing long double functions to Cygwin")
Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: add release text for previous commit
Corinna Vinschen [Tue, 18 Apr 2023 08:12:03 +0000 (10:12 +0200)]
Cygwin: add release text for previous commit

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: cygheap: fix fork error after heap has grown
David McFarland [Tue, 18 Apr 2023 00:41:55 +0000 (21:41 -0300)]
Cygwin: cygheap: fix fork error after heap has grown

2f9b8ff0 introduced a problem where forks would sometimes fail with:

child_copy: cygheap read copy failed, 0x0..0x80044C750, done 0, windows pid 14032, Win32 error 299

When cygheap_max was > CYGHEAP_STORAGE_INITIAL, commit_size would be set to
allocsize(cygheap_max), which is an address, not a size.  VirtualAlloc would be
called to commit commit_size bytes, which would fail, and then child_copy would
be called with zero as the base address.

Fixes: 2f9b8ff00cce ("Cygwin: decouple cygheap from Cygwin DLL")
Signed-off-by: David McFarland <corngood@gmail.com>
19 months agoCygwin: pty: Fix reading CONIN$ when stdin is not a pty.
Takashi Yano [Fri, 14 Apr 2023 01:52:08 +0000 (10:52 +0900)]
Cygwin: pty: Fix reading CONIN$ when stdin is not a pty.

Previously, the pty master sends inputs to the pipe for cygwin app
even when pseudo console is activated if stdin is not the pty.
This causes the problem that key input is not sent to non cygwin
app even if the app opens CONIN$. This patch sets switch_to_nat_pipe
to true regardless whether stdin is the pty or not to allow that case.

https://cygwin.com/pipermail/cygwin/2023-April/253424.html

Reported-by: Wladislav Artsimovich <cygwin@frost.kiwi>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
19 months agoCygwin: dirname: fix handling of leading slashes
Corinna Vinschen [Wed, 29 Mar 2023 08:18:23 +0000 (10:18 +0200)]
Cygwin: dirname: fix handling of leading slashes

Per https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/xbd_chap04.html:

  "A pathname that begins with two successive slashes may be interpreted
   in an implementation-defined manner, although more than two leading
   slashes shall be treated as a single slash."

So more than 2 leading slashes are supposed to be folded into one,
which our dirname neglected.  Fix that.

Fixes: 24e8fc6872a3b ("* cygwin.din (basename): Export.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
20 months agoCygwin: kill(1): don't print spurious error message
Corinna Vinschen [Wed, 15 Mar 2023 20:50:32 +0000 (21:50 +0100)]
Cygwin: kill(1): don't print spurious error message

Make kill -V and kill -l exit immediately, thus stopping to
print "not enough arguments" accidentally.

Fixes: ef48a2cad3704 ("* kill.cc (prog_name) New global variable.")
Fixes: c49fa762631f9 ("* Makefile.in (kill.exe): Add as a specific target.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
20 months agoCygwin: signals: drop accidental spaces from real-time signal names
Corinna Vinschen [Wed, 15 Mar 2023 20:44:52 +0000 (21:44 +0100)]
Cygwin: signals: drop accidental spaces from real-time signal names

The signal names for the real-time signals contain spaces from
the beginning of their availability.  Fix that.

Fixes: 61522196c715 ("* Merge in cygwin-64bit-branch.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
20 months agoCygwin: Fix type mismatch on sys/cpuset.h
Mark Geisert [Tue, 14 Mar 2023 08:56:01 +0000 (01:56 -0700)]
Cygwin: Fix type mismatch on sys/cpuset.h

Addresses https://cygwin.com/pipermail/cygwin/2023-March/253220.html

Take the opportunity to follow FreeBSD's and Linux's lead in recasting
macro inline code as calls to static inline functions.  This allows the
macros to be type-safe.  In addition, added a lower bound check to the
functions that use a cpu number to avoid a potential buffer underrun on
a bad argument.  h/t to Corinna for the advice on recasting.

Fixes: 362b98b49af5 ("Cygwin: Implement CPU_SET(3) macros")
20 months agoCygwin: ctty: Add missing fixup_after_{exec,fork}() call.
Takashi Yano [Mon, 6 Mar 2023 15:13:55 +0000 (00:13 +0900)]
Cygwin: ctty: Add missing fixup_after_{exec,fork}() call.

Previously, fixup_after_{exec,fork}() calls for CTTY were missing.
This patch fixes that.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
21 months agoCygwin: dsp: Fix SNDCTL_DSP_{POST,SYNC} ioctl() behaviour.
Takashi Yano [Sat, 25 Feb 2023 01:28:34 +0000 (10:28 +0900)]
Cygwin: dsp: Fix SNDCTL_DSP_{POST,SYNC} ioctl() behaviour.

Previously, SNDCTL_DSP_POST and SNDCTL_DSP_SYNC were implemented
wrongly. Due to this issue, module-oss of pulseaudio generates
choppy sound when SNDCTL_DSP_POST is called. This patch fixes that.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
21 months agoCygwin: dumper: also link with libzstd, as libbfd may require it
Jon Turney [Tue, 14 Feb 2023 13:52:39 +0000 (13:52 +0000)]
Cygwin: dumper: also link with libzstd, as libbfd may require it

Also allow that linkage to be dynamic, as libzstd-devel doesn't
currently provide a static library.

21 months agobump DLL version to 3.4.7
Corinna Vinschen [Tue, 14 Feb 2023 11:44:38 +0000 (12:44 +0100)]
bump DLL version to 3.4.7

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
21 months agoCygwin: get_posix_access: Make mode_t parameter mandatory cygwin-3.4.6
Corinna Vinschen [Thu, 9 Feb 2023 20:55:18 +0000 (21:55 +0100)]
Cygwin: get_posix_access: Make mode_t parameter mandatory

Avoid the mistake fixed in the preceeding commit by passing
the mode_t argument by reference.  This also affects a couple
other functions calling get_posix_access in turn.

Fixes: bc444e5aa4ca ("Reapply POSIX ACL changes.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
21 months agoCygwin: chmod: don't drop default ACEs from directory ACLs
Corinna Vinschen [Thu, 9 Feb 2023 20:47:15 +0000 (21:47 +0100)]
Cygwin: chmod: don't drop default ACEs from directory ACLs

commit bc444e5aa4ca introduced a call to get_posix_access()
with a NULL pointer for the mode_t parameter because the value
is not needed later on... entirely ignoring the fact that the
mode_t bits are checked for the object being a directory.

In turn, the get_posix_access() call never checked for default
ACEs and returned only the standard ACEs.  Thus, every chmod call
on a directory dropped the default ACEs from its permissions, as
well as the default NULL deny-ACE used to store specific bits.
It got also impossible to set the sgid bit on directories.

Fixes: bc444e5aa4ca ("Reapply POSIX ACL changes.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
21 months agoCygwin: mkdir: use correct default permissions filtered by umask
Corinna Vinschen [Thu, 9 Feb 2023 20:25:03 +0000 (21:25 +0100)]
Cygwin: mkdir: use correct default permissions filtered by umask

Older coreutils created directories with mode bits filtered through
umask.  Newer coreutils creates directories with full permissions,
0777 by default.

This new coreutils behaviour uncovered the fact that default ACEs for
newly created directories were not filtered by umask starting with
commit bc444e5aa4ca.

Fix it by applying umask on the default ACEs.

Fixes: bc444e5aa4ca ("Reapply POSIX ACL change.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
21 months agosetlocale: create LC_ALL string when changing locale
Corinna Vinschen [Mon, 6 Feb 2023 10:27:44 +0000 (11:27 +0100)]
setlocale: create LC_ALL string when changing locale

This patch is for the sake of gnulib.

gnulib implements some form of a thread-safe setlocale variant
called setlocale_null_r, which is supposed to return the locale
strings in a thread-safe manner.  This only succeeds if the system's
setlocale already handles this thread-safe, otherwise gnulib adds
some locking on its own.

Newlib's setlocale always writes the global string array holding the
LC_ALL value anew on each invocation of setlocale(LC_ALL, NULL).
Since that doesn't allow to call setlocale(LC_ALL, NULL) in a
thread-safe manner, so locking in gnulib is required.

And here's the problem...

The lock is decorated as dllexport when building for Cygwin.  This
collides with the default behaviour of ld to export all symbols.
If it finds one decorated symbol, it will only export this symbol
to the DLL import lib.

Change setlocale so that it writes the global string array
holding the LC_ALL value at the time the locale gets changed.
On setlocale(LC_ALL, NULL), just return the pointer to the
global LC_ALL string array, just as in GLibc.  The burden of
doing so is negligibly for all targets, but adds thread-safety
for gnulib's setlocal_null_r() function, and gnulib can drop
the lock entirely when building for Cygwin.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: dsp: Fix hang on close() if another thread calls write().
Takashi Yano [Wed, 25 Jan 2023 09:30:50 +0000 (18:30 +0900)]
Cygwin: dsp: Fix hang on close() if another thread calls write().

fhandler_dev_dsp (OSS) has a problem that waitforallsent(), which is
called from close(), falls into infinite loop if another thread calls
write() accidentally after close(). This patch fixes the issue.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
22 months agoCygwin: mount: differ allowed server name chars from allowed share name chars
Corinna Vinschen [Mon, 23 Jan 2023 13:01:43 +0000 (14:01 +0100)]
Cygwin: mount: differ allowed server name chars from allowed share name chars

The list of invalid chars for server names differs from the
list of invalid chars for share names.  Apart from that,
we don't allow control chars in both kinds of names.

Fixes: 6338d2f24a60 ("Cygwin: mount: allow any valid character in UNC paths")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: mount: allow any valid character in UNC paths
Corinna Vinschen [Sun, 22 Jan 2023 19:11:59 +0000 (20:11 +0100)]
Cygwin: mount: allow any valid character in UNC paths

The current code only allows server and share names to
start with ASCII chars [a-zA-Z0-9],, which is not correct.
Rather, check for a valid share character.

Fixes: 1fd5e000ace55 ("import winsup-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: fsync: Fix EINVAL for block device.
Takashi Yano [Sat, 21 Jan 2023 12:33:03 +0000 (21:33 +0900)]
Cygwin: fsync: Fix EINVAL for block device.

The commit af8a7c13b516 has a problem that fsync returns EINVAL for
block device. This patch treats block devices as a special case.
https://cygwin.com/pipermail/cygwin/2023-January/252916.html

Fixes: af8a7c13b516 ("Cygwin: fsync: Return EINVAL for special files.")
Reported-by: Yano Ray <yanorei@hotmail.co.jp>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
22 months agoCygwin: tape: tapes are character devices, not block devices
Corinna Vinschen [Sat, 21 Jan 2023 17:25:56 +0000 (18:25 +0100)]
Cygwin: tape: tapes are character devices, not block devices

Fixes: 727a81f4d93f ("* devices.h (device::exists_func): Redefine field.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: bump DLL version to 3.4.6
Corinna Vinschen [Thu, 19 Jan 2023 17:42:38 +0000 (18:42 +0100)]
Cygwin: bump DLL version to 3.4.6

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: Add 3.4.5 release message cygwin-3.4.5
Corinna Vinschen [Thu, 19 Jan 2023 17:33:40 +0000 (18:33 +0100)]
Cygwin: Add 3.4.5 release message

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: fix build of cygcheck and strace
Corinna Vinschen [Thu, 19 Jan 2023 17:24:15 +0000 (18:24 +0100)]
Cygwin: fix build of cygcheck and strace

adding <target>_LDFLAGS overrides AM_LDFLAGS and thus fails to
build cygcheck and strace statically.  Fix it.

Fixes: 8d318bf142f7 ("Cygwin: disable high-entropy VA for cygcheck and strace")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agobump DLL version to 3.4.5
Corinna Vinschen [Thu, 19 Jan 2023 16:14:46 +0000 (17:14 +0100)]
bump DLL version to 3.4.5

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: dsp: Fix a problem that fcntl() does not take effect. cygwin-3.4.4
Takashi Yano [Thu, 19 Jan 2023 13:02:47 +0000 (22:02 +0900)]
Cygwin: dsp: Fix a problem that fcntl() does not take effect.

Previously, fhandler_dev_dsp (OSS) has a problem that fcntl() does
not take effect at all. This patch fixes the issue.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: open_shared: always bump next_address
Corinna Vinschen [Wed, 18 Jan 2023 18:59:48 +0000 (19:59 +0100)]
Cygwin: open_shared: always bump next_address

The new loop in open_shared has a subtil performance problem.
Next_address is bumped only if mapping at this address
failed.  Every subsequent call to open_shared has a high probability
having to call MapViewOfFileEx twice, because next_address is still
set to the address of the last successful mapping.

Avoid this by bumping next_address every time.

While at it, fix a comment.

Conflict: Missing backport of 31302b267b86 ("Cygwin: drop fixed addresses for standard shared regions")
Fixes: dc0fe7742b8c ("Cygwin: open_shared: try harder allocating a shared region")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: disable high-entropy VA for cygcheck and strace
Corinna Vinschen [Tue, 17 Jan 2023 16:43:21 +0000 (17:43 +0100)]
Cygwin: disable high-entropy VA for cygcheck and strace

It's not a good idea to enable high-entropy VA for tools loading the
Cygwin DLL dynamically.  The addresses used by HEVA tend to collide with
fixed address areas managed by Cygwin.

Fixes: 60675f1a7eb2 ("Cygwin: decouple shared mem regions from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: open_shared: try harder allocating a shared region
Corinna Vinschen [Tue, 17 Jan 2023 09:18:51 +0000 (10:18 +0100)]
Cygwin: open_shared: try harder allocating a shared region

For fixed regions (cygwin/user/myself/shared console), try fixed
address first.  Fallback to non-fixed region.  Don't even try fixed
address if the Cygwin DLL gets dynamically loaded.

For non-fixed regions, try to allocate in a loop within the area
from SHARED_REGIONS_ADDRESS_LOW to SHARED_REGIONS_ADDRESS_HIGH.

Fixes: 60675f1a7eb2 ("Cygwin: decouple shared mem regions from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: Move shared regions, rename PINFO... to MYSELF_REGION_ADDRESS
Corinna Vinschen [Mon, 16 Jan 2023 21:20:48 +0000 (22:20 +0100)]
Cygwin: Move shared regions, rename PINFO... to MYSELF_REGION_ADDRESS

Fix comments accordingly.

This is in preparation for a change in open_shared, handling shared
regions more cleanly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: open_shared: don't reuse shared_locations parameter as output
Corinna Vinschen [Mon, 16 Jan 2023 21:25:42 +0000 (22:25 +0100)]
Cygwin: open_shared: don't reuse shared_locations parameter as output

For ages, open_shared uses the shared_locations parameter as
output to indicate if the mapping for a shared region has been
created or just opened.  Split this into two parameters.  Use
the shared_locations parameter as input only, return the creation
state of the mapping in a bool reference parameter.

Conflict: Simple collision due to missing backport of
  3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: /proc/cpuinfo: always print trailing empty line, as on Linux
Corinna Vinschen [Mon, 16 Jan 2023 20:40:59 +0000 (21:40 +0100)]
Cygwin: /proc/cpuinfo: always print trailing empty line, as on Linux

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: /proc/cpuinfo: Always print topology info
Corinna Vinschen [Mon, 16 Jan 2023 13:23:38 +0000 (14:23 +0100)]
Cygwin: /proc/cpuinfo: Always print topology info

vmstat from proc-ps-4.0.x prints "Unable to create system stat structure"
if the /proc/cpuinfo output fails to contain topology info.  While
Linux always prints topology info if the kernel has been built with
CONFIG_SMP, Cygwin only prints topology info if the CPU is known to
be multi-core (i. e., the HT feature flag is set).

Fix that by printing topology info all the time, even for single-core
CPUs.

Fixes: e0d48debedfa ("Fix /proc/cpuinfo topology and cache size info")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: cygheap: Initialize myself_pinfo before child_copy().
Takashi Yano [Tue, 10 Jan 2023 12:04:29 +0000 (21:04 +0900)]
Cygwin: cygheap: Initialize myself_pinfo before child_copy().

After the commit 30add3e6b3e3, the problem:
https://cygwin.com/pipermail/cygwin/2022-December/252759.html
occurs rarely. It seems that myself_pinfo should be initialized
where the timing before child_copy() and after cygheap allocation.
This patch moves the initialization there.

Fixes: 30add3e6b3e3 ("Cygwin: exec: don't access cygheap before it's
initialized")
Reported-by: Brian Inglis <Brian.Inglis@Shaw.ca>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
22 months agoCygwin: /proc/<PID>/status: avoid crash computing signal info
Corinna Vinschen [Tue, 10 Jan 2023 10:45:28 +0000 (11:45 +0100)]
Cygwin: /proc/<PID>/status: avoid crash computing signal info

The code computing the mask of pending signals used the per-queued
signal TLS pointer without checking it for NULL.  Fix this by using
the process-wide signal mask in that case.

Fixes: 195169186bfd5 ("Cygwin: wait_sig: allow to compute process-wide mask of pending signals")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
22 months agoCygwin: reinstantiate exporting _alloca
Corinna Vinschen [Mon, 9 Jan 2023 12:35:32 +0000 (13:35 +0100)]
Cygwin: reinstantiate exporting _alloca

This basically reverts commit 1556b96b1b3b03112f271dfe30e043ed538354fd.

Turns out that _alloca is actually used, for instance, by clang.

23 months agoCygwin: devices: Make generic console devices invisible from pty.
Takashi Yano [Wed, 21 Dec 2022 01:06:10 +0000 (10:06 +0900)]
Cygwin: devices: Make generic console devices invisible from pty.

The devices /dev/conin,conout,console were wrongly visible from ptys,
though they are inaccessible. This is because fhandler_console::exists()
returns true due to existing invisible console. This patch makes these
devices invisible from ptys.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
23 months agoCygwin: console: Fix hangup of less on quit after the window is resized.
Takashi Yano [Thu, 22 Dec 2022 11:25:22 +0000 (20:25 +0900)]
Cygwin: console: Fix hangup of less on quit after the window is resized.

https://cygwin.com/pipermail/cygwin/2022-December/252737.html

If the less is started from non-cygwin shell and window size is
changed, it will hang-up when quitting. The cause of the proglem is
that less uses longjump() in signal handler. If the signal handler
is called while cygwin is acquiring the mutex, cygwin loses the
chance to release mutex. With this patch, the mutex is released
just before calling kill_pgrp() and re-acquired when kill_pgrp()
returns.

Reported-by: Gregory Mason <grmason@epic.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
23 months agoCygwin: path_conv: make sure sym.path_flags is always initialized
Corinna Vinschen [Wed, 21 Dec 2022 12:08:39 +0000 (13:08 +0100)]
Cygwin: path_conv: make sure sym.path_flags is always initialized

Commit c1023ee353705 introduced a split between mount flags and
path flags.  It didn't initialize symlink_info::path_flags in
path_conv::check, because that's done in symlink_info::check.

However, there are two code paths expecting symlink_info::path_flags
being already initialized and both skip symlink_info::check.

Make sure symlink_info::path_flags is initalized to 0 early in
path_conv::check.

Fixes: c1023ee353705 ("Cygwin: path_conv: decouple path_types from mount types")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
23 months agobump DLL version to 3.4.4
Jon Turney [Fri, 16 Dec 2022 13:30:55 +0000 (13:30 +0000)]
bump DLL version to 3.4.4

23 months agoCygwin: Update 3.4.3 release note cygwin-3.4.3
Jon Turney [Fri, 16 Dec 2022 10:34:38 +0000 (10:34 +0000)]
Cygwin: Update 3.4.3 release note

23 months agoRevert "Cygwin: x86_64: add wmemset assembler entry point"
Jon Turney [Fri, 16 Dec 2022 10:21:13 +0000 (10:21 +0000)]
Revert "Cygwin: x86_64: add wmemset assembler entry point"

This reverts commit 188d5f6c9ad5cbbd6f0fcb9aaf15bc9870597910.

23 months agoCygwin: path handling: never substitute virtual drive with target path
Corinna Vinschen [Mon, 12 Dec 2022 20:56:14 +0000 (21:56 +0100)]
Cygwin: path handling: never substitute virtual drive with target path

Move the drive substitution code after the call to
GetFinalPathNameByHandleW into a local function revert_virtual_drive
and add code to handle non-remote virtual drives, i. e., those
created with the subst command.  (Try to) make sure that virtual
drives are never treated like symlinks.

Fixes: 19d59ce75d53 ("Cygwin: path_conv: Rework handling native symlinks as inner path components")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
23 months agoCygwin: add release message for latest path handling patch
Corinna Vinschen [Wed, 14 Dec 2022 10:57:36 +0000 (11:57 +0100)]
Cygwin: add release message for latest path handling patch

5ba5e09b9d39 ("Cygwin: path handling: never substitute virtual drive with target path")

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
23 months agoCygwin: Makefile: build new-cygwin1.dll in a single step
Corinna Vinschen [Tue, 13 Dec 2022 12:28:16 +0000 (13:28 +0100)]
Cygwin: Makefile: build new-cygwin1.dll in a single step

The complicated build routine was only required because we needed
the .cygheap section at the end of the file, and the debug sections
broke this.  Now that the cygheap is out of the way, we really don't
have to do this anymore, and the build can just generate a DLL with
integrated debug info.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
23 months agoCygwin: Makefile: only regenerate cygwin_version.c if it changes
Corinna Vinschen [Tue, 13 Dec 2022 12:25:06 +0000 (13:25 +0100)]
Cygwin: Makefile: only regenerate cygwin_version.c if it changes

Make sure to create a new cygwin_version.c if it either doesn't
exist yet, or if it would be different from the former file.
This avoids unnecessary DLL rebuilding.

Fixes: 97eb64b909bc ("Cygwin: uname: generate default release string from git as well")
Fixes: 4949a82cde98 ("Cygwin: uname: fix building in non-git source dir")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
23 months agobump DLL version to 3.4.3
Corinna Vinschen [Sun, 11 Dec 2022 12:12:27 +0000 (13:12 +0100)]
bump DLL version to 3.4.3

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
23 months agoCygwin: add 3.4.2 release notes cygwin-3.4.2
Corinna Vinschen [Sun, 11 Dec 2022 10:45:30 +0000 (11:45 +0100)]
Cygwin: add 3.4.2 release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This page took 0.082222 seconds and 5 git commands to generate.