]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
15 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>
15 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>
15 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>
15 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>
15 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>
15 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>
16 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>
16 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>
16 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")
16 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>
16 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>
17 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.

17 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>
17 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>
17 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>
17 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>
17 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>
17 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>
17 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>
17 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>
17 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>
17 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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>
18 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.

18 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>
18 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>
18 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>
19 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

19 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

19 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.

19 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>
19 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>
19 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>
19 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>
19 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>
19 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>
19 months agoCygwin: uname: fix building in non-git source dir
Corinna Vinschen [Wed, 7 Dec 2022 21:22:38 +0000 (22:22 +0100)]
Cygwin: uname: fix building in non-git source dir

commit 97eb64b909bc broke building outside of a git dir, because
the git describe command would fail.  Fix this by checking if
we're in a git tree at all and just generate an empty string
as version string.  Use this in uname_x to generate a fallback
version.

Fixes: 97eb64b909bc ("Cygwin: uname: generate default release
string from git as well"
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: uname: generate default release string from git as well
Corinna Vinschen [Wed, 7 Dec 2022 20:14:27 +0000 (21:14 +0100)]
Cygwin: uname: generate default release string from git as well

When building a release with cygport, we get uname version info
from cygport, which in turn gets version info from `git describe'.

During development, the release info for local builds was not
that helpful yet.  Fix that, by creating version info from
`git describe' if CYGPORT_RELEASE_INFO isn't given.  Make sure to
always force rebuild of the version info to pick up source file
changes as well as git actions.

Rearrange code slightly to generate machine info first, release info
after that.  Use snprintf to generate release string safely.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoRevert "Cygwin: 3.4-only: uname: drop dot from external release info"
Corinna Vinschen [Sun, 11 Dec 2022 10:19:00 +0000 (11:19 +0100)]
Revert "Cygwin: 3.4-only: uname: drop dot from external release info"

This reverts commit b5eba8e972786275c76ea69a7ce6ef8d7c8279c3.

19 months agobump DLL version to 3.4.2
Corinna Vinschen [Sun, 11 Dec 2022 10:24:53 +0000 (11:24 +0100)]
bump DLL version to 3.4.2

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: pipe: Fix performance degradation for non-cygwin pipe. cygwin-3.4.1
Takashi Yano [Thu, 8 Dec 2022 13:02:43 +0000 (22:02 +0900)]
Cygwin: pipe: Fix performance degradation for non-cygwin pipe.

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

After the commit 9e4d308cd592, the performance of read from non-cygwin
pipe has been degraded. This is because select_sem mechanism does not
work for non-cygwin pipe. This patch fixes the issue.

Fixes: 9e4d308cd592 ("Cygwin: pipe: Adopt FILE_SYNCHRONOUS_IO_NONALERT
flag for read pipe.")
Reported-by: tryandbuy <tryandbuy@proton.me>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
19 months agoCygwin: improve release text for FILE issue
Corinna Vinschen [Fri, 9 Dec 2022 11:41:54 +0000 (12:41 +0100)]
Cygwin: improve release text for FILE issue

Add a note in terms of 3.4.0 compatibility.

Suggested-by: Markus Mützel <markus.muetzel@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: add __sFILE64 fix to 3.4.1 release notes
Corinna Vinschen [Thu, 8 Dec 2022 13:19:22 +0000 (14:19 +0100)]
Cygwin: add __sFILE64 fix to 3.4.1 release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: define FILE as struct __sFILE64, not as __sFILE
Corinna Vinschen [Thu, 8 Dec 2022 12:58:37 +0000 (13:58 +0100)]
Cygwin: define FILE as struct __sFILE64, not as __sFILE

Until Cygwin 3.3.6, we define __LARGE64_FILES unconditionally, so we
were using the type __sFILE64 even for 64 bit.  That was lazy and wrong.
so commit 2902b3a09e0a ("Cygwin: drop requirement to build newlib's
stdio64") tried to fix that.

Unfortunately this patch forgot to take the exposure of the typename
__sFILE64 in userspace into account.  This leads to trouble in C++ due
to name mangling.

Commit 0f376ae22036 tried to fix this by just renaming __sFILE to
__sFILE64 by using a macro.  While __sFILE and __sFILE64 are the same
size, they are not exactly congruent.

To avoid backward compatibility problems, make sure to define FILE
as the  real __sFILE64, and make sure that __sFILE is not defined at
all on Cygwin.

Fixes: 0f376ae22036 ("Cygwin: rename __sFILE to __sFILE64 for backward
compatibility")
Fixes: 2902b3a09e0a ("Cygwin: drop requirement to build newlib's stdio64")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: 3.4-only: uname: drop dot from external release info
Corinna Vinschen [Thu, 8 Dec 2022 17:48:45 +0000 (18:48 +0100)]
Cygwin: 3.4-only: uname: drop dot from external release info

Right now, the dot between the version and the machine info in
the release field is expected to come in from CYGPORT_RELEASE_INFO.
But that's just confusing and doesn't match what we now do in 3.5
since commit 97eb64b909bc ("Cygwin: uname: generate default release
string from git as well")

Add the dot when attaching the machine info.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: link mcountFunc.o to libgmon.a
Corinna Vinschen [Wed, 7 Dec 2022 11:20:26 +0000 (12:20 +0100)]
Cygwin: link mcountFunc.o to libgmon.a

Commit 188d5f6c9ad5 erroneously moved the mcountFunc.S file to the
TARGET_FILES target, rather than keeping it in GMON_FILES.  The
result is that the __fentry__ entry point is now entirely undefined,
so `gcc -pg' is broken.

Create new target-specific GMON_TARGET_FILES and move mcountFunc.S
into it.  Add $(GMON_TARGET_FILES) to GMON_FILES.

Fixes: 188d5f6c9ad5 ("Cygwin: x86_64: add wmemset assembler entry point")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agobump DLL version to 3.4.1
Corinna Vinschen [Sun, 4 Dec 2022 12:49:57 +0000 (13:49 +0100)]
bump DLL version to 3.4.1

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: add release message for commit previous commit 8d138c3f66c2 cygwin-3.4.0
Corinna Vinschen [Sat, 3 Dec 2022 15:36:49 +0000 (16:36 +0100)]
Cygwin: add release message for commit previous commit 8d138c3f66c2

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: fix LC_CTYPE in global locale to be a real C.UTF-8 locale
Corinna Vinschen [Sat, 3 Dec 2022 15:16:15 +0000 (16:16 +0100)]
Cygwin: fix LC_CTYPE in global locale to be a real C.UTF-8 locale

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

Cygwin's default locale is "C.UTF-8" as far as LC_CTYPE settings
are concerned.  However, while __global_locale contains fixed
mbtowc and wctomb pointers, the lc_ctype_T pointer is still pointing
to _C_ctype_locale, representing the standard "C" locale.

The problem with this is that the codeset name as well as MB_CUR_MAX
is wrong.

Fix this by introducing a new lc_ctype_T structure called
_C_utf8_ctype_locale, setting the default codeset to "UTF-8" and
MB_CUR_MAX to 6.  Use this as lc_ctype_T pointer in __global_locale
by default on Cygwin.

Fixes: a6a477fa8190 ("POSIX-1.2008 per-thread locales, groundwork part 1")
Co-Authored-By: Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: add latest primary group changes to release notes
Corinna Vinschen [Sat, 3 Dec 2022 15:12:49 +0000 (16:12 +0100)]
Cygwin: add latest primary group changes to release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: FAQ: convert ulinks to FAQ to xrefs
Corinna Vinschen [Fri, 2 Dec 2022 21:38:47 +0000 (22:38 +0100)]
Cygwin: FAQ: convert ulinks to FAQ to xrefs

Using ulinks here makes the result work on cygwin.com only, while
xrefs to FAQs are creating realtive links.  Add xreflabel where
appropriate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: FAQ: describe test releases, deprecate developer snapshots
Corinna Vinschen [Fri, 2 Dec 2022 20:54:19 +0000 (21:54 +0100)]
Cygwin: FAQ: describe test releases, deprecate developer snapshots

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: uinfo: don't special case current user
Corinna Vinschen [Fri, 2 Dec 2022 15:49:47 +0000 (16:49 +0100)]
Cygwin: uinfo: don't special case current user

fetch_account_from_windows shortcuts the current user in that
it takes the user's domain SID and just adds the matching RID
from the token's primary group to create a group SID.

How wrong this is can be very simply reproduced:

Assuming you run a native process, like cmd, with primary group
set to the Administrators builtin group.  Run Cygwin's id(1) as
child process.  id(1) will print a non-existent group as primary
group and also add it to the group list.

This can only be avoided by not special casing the current user
and thus not creating a group SID from partial information.

Fixes: 6cc7c925ce86 ("(pwdgrp::fetch_account_from_windows): Default primary group for the
current user to primary group from user token.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: uinfo: prefer token primary group
Corinna Vinschen [Fri, 2 Dec 2022 15:37:33 +0000 (16:37 +0100)]
Cygwin: uinfo: prefer token primary group

internal_getlogin overwrites the process token primary group if it
differs from the primary group as stored in the passwd DB.

However, this also overwrites the primary group of the process if
it has been deliberately changed by a former process (e. g., newgrp),
and the current process has a non-Cygwin process as parent.

Our docs claim we restrict overwriting the primary group to local,
non-domain user accounts anyway, and it was actually meant this way.

So check for exactly that before overwriting the primary group
in the token:  It's only allowed if the user is a local account
and the primary group in the token is still the default group
"None".

Fixes: 6cc7c925ce861 ("(internal_getlogin): Give primary group
from user token more weight.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: uinfo: Drop long disabled nss_prefix and nss_separator
Corinna Vinschen [Fri, 2 Dec 2022 14:13:24 +0000 (15:13 +0100)]
Cygwin: uinfo: Drop long disabled nss_prefix and nss_separator

Originally the code was written to allow three ways of prefixing
accounts and to freely define a domain/account separator.  This code
has been disabled even before being officially released, and it was
never re-enabled. Given there has been no complaints for eight years
now, drop this code eventually.  Just add a macro to define the
domain/account separator statically.

Fixes: cc332c9e271b ("(cygheap_pwdgrp::nss_init_line): Disable db_prefix
and db_separator settings.  Add comment")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: exec: don't access cygheap before it's initialized
Corinna Vinschen [Thu, 1 Dec 2022 20:33:14 +0000 (21:33 +0100)]
Cygwin: exec: don't access cygheap before it's initialized

This is a long-standing thinko.

When you exec a process, dll_crt0_0 in the child process calls
child_info_spawn::handle_spawn().  handle_spawn() initialises the
cygheap.

Now consider calling strace.  Strace is a non-Cygwin process dynamically
loading cygwin1.dll via LoadLibrary.  This in turn initializes the DLL:

- dll_crt0_0 finds that the process it attaches to has been exec'd, so
  child_info_spawn::handle_spawn() is called.

- If the DLL is being dynamically loaded, handle_spawn() calls
  child_info_spawn::get_parent_handle().  This in turn tries to set
  the moreinfo->myself_pinfo value inside the cygheap to NULL.

- However, at this time, the cygheap has not yet been initialized.  This
  only occurs in the cygheap_fixup_in_child() call after get_parent_handle()
  returns.

--> SEGV

This thinko never had a negative side effect, because the cygheap was
pre-allocated at DLL load time until commit 2f9b8ff00cce ("Cygwin:
decouple cygheap from Cygwin DLL").  With 2f9b8ff00cce, the cygheap
actually doesn't exist until after the call to cygheap_fixup_in_child().

Fix this problem by moving the assignment after the call to
cygheap_fixup_in_child().

Fixes: 3de7be4c1deb ("* DevNotes: Add entry cgf-000007. [...]")
Fixes: 2f9b8ff00cce ("Cygwin: decouple cygheap from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: multiple_cygwin_problem: drop obsolete check for "cygheap"
Corinna Vinschen [Thu, 1 Dec 2022 20:20:44 +0000 (21:20 +0100)]
Cygwin: multiple_cygwin_problem: drop obsolete check for "cygheap"

After decoupling cygheap from the DLL loading address, the check
for a different _cygheap_start has gone.  So the matching string
check in multiple_cygwin_problem is obsolete now.

Fixes: 2f9b8ff00cce ("Cygwin: decouple cygheap from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: serial: Fix a copy-paste error in DTR setup
Carlo Bramini [Tue, 29 Nov 2022 09:02:43 +0000 (10:02 +0100)]
Cygwin: serial: Fix a copy-paste error in DTR setup

In commit 2dab880c963ce0204c3513d664f610b587a3e6a6 I did a mistake when
I copied the new fhandler_serial::switch_modem_lines() from my modified
3.3.6 branch to the current master and I left a copy paste error. This
patch fixes that error.

Fixes: 2dab880c963c ("Cygwin: fix TIOCMBIS/TIOCMBIC not working when using usbser.sys")
19 months agoCygwin: Update some mentions of x86 in documentation
Jon Turney [Sun, 27 Nov 2022 13:50:19 +0000 (13:50 +0000)]
Cygwin: Update some mentions of x86 in documentation

19 months agoCygwin: Fix typo in FAQ
Jon Turney [Sat, 12 Nov 2022 14:16:36 +0000 (14:16 +0000)]
Cygwin: Fix typo in FAQ

The consonant in 'debug' is doubled in 'debuggee' just as it is in
'debugger'.

Fixes: 8c68a8a4
19 months agoCygwin: pty: Rename fhandler/tty.cc to fhandler/pty.cc.
Takashi Yano [Wed, 23 Nov 2022 23:30:16 +0000 (08:30 +0900)]
Cygwin: pty: Rename fhandler/tty.cc to fhandler/pty.cc.

- Previously, we have two tty.cc, one is winsup/cygwin/tty.cc and
  the other is winsup/cygwin/fhandler/tty.cc. This is somewhat
  confusing. This patch renames fhandler/tty.cc to fhandler/pty.cc.

19 months agoCygwin: uname: allow to specify external release info
Corinna Vinschen [Thu, 24 Nov 2022 11:23:09 +0000 (12:23 +0100)]
Cygwin: uname: allow to specify external release info

When creating regular Cygwin test releases we need a way to
automate unambiguous version information based on the output
of `git describe'.  Allow to inject a release string via a
preprocessor macro CYGPORT__RELEASE_INFO.  Change the default
release info to recognize a local, non-distro build.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoCygwin: drop snapshot handling
Corinna Vinschen [Thu, 24 Nov 2022 11:20:50 +0000 (12:20 +0100)]
Cygwin: drop snapshot handling

We're going to switch to regular test releases, rather than the
old, handcrafted snapshots method.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
19 months agoamdgcn: Use __builtin_gcn_ in libc/machine/amdgcn/getreent.c
Tobias Burnus [Tue, 22 Nov 2022 13:53:48 +0000 (14:53 +0100)]
amdgcn: Use __builtin_gcn_ in libc/machine/amdgcn/getreent.c

Call __builtin_gcn_get_stack_limit and __builtin_gcn_first_call_this_thread_p
to reduce dependency on some register/layout assumptions by using the new
GCC mainline (GCC 13) builtins, if they are available. If not, the existing
code is used.

19 months agoamdgcn: Replace asm("s8") by __builtin_gcn_kernarg_ptr if existing
Tobias Burnus [Fri, 18 Nov 2022 08:50:20 +0000 (09:50 +0100)]
amdgcn: Replace asm("s8") by __builtin_gcn_kernarg_ptr if existing

Check whether __builtin_gcn_kernarg_ptr is available and, if it is,
call it instead using the hard-coded 'asm("s8")' in:
* newlib/libc/machine/amdgcn/exit-value.h (exit_with_int)
* newlib/libc/machine/amdgcn/mlock.c (sbrk)
* newlib/libc/sys/amdgcn/write.c (write)

 newlib/libc/machine/amdgcn/exit-value.h |  6 ++++++
 newlib/libc/machine/amdgcn/mlock.c      | 10 +++++++---
 newlib/libc/sys/amdgcn/write.c          |  4 ++++
 3 files changed, 17 insertions(+), 3 deletions(-)

20 months agoCygwin: pty, console: Encapsulate spawn.cc code related to pty/console.
Takashi Yano [Sat, 19 Nov 2022 08:28:15 +0000 (17:28 +0900)]
Cygwin: pty, console: Encapsulate spawn.cc code related to pty/console.

- The codes related to pty and console in spawn.cc have been moved
  into the new class fhandler_termios::spawn_worker, and make spawn.cc
  call them. The functionality has not been changed at all.

20 months agomakedocbook: Fix false report of unhandled texinfo command
Jon Turney [Sat, 29 Oct 2022 15:43:50 +0000 (16:43 +0100)]
makedocbook: Fix false report of unhandled texinfo command

During 'make man', makedocbook falsely reports "texinfo command
'@modifier' remains in output" while processing the setlocal(3) manpage,
which contains that literal string.

Move the check for unrecognized texinfo commands to before processing
'@@' (an escaped '@') in the texinfo source, and teach it to ignore
them.

Improve that check slightly, so it catches non-alphabetic texinfo
commands, of which there are few.

Now we don't have false positives, we can make unrecognized texinfo
commands fatal to manpage generation, rather than leaving them verbatim
in the generated manpage.

20 months agomakedocbook: Adjust inline whitespace to fix flake8 warnings
Jon Turney [Tue, 1 Nov 2022 11:35:51 +0000 (11:35 +0000)]
makedocbook: Adjust inline whitespace to fix flake8 warnings

20 months agomakedocbook: Drop stray semicolons
Jon Turney [Tue, 1 Nov 2022 11:37:00 +0000 (11:37 +0000)]
makedocbook: Drop stray semicolons

This isn't written in C :)

20 months agomakedocbook: Use sys.exit()
Jon Turney [Tue, 1 Nov 2022 11:21:21 +0000 (11:21 +0000)]
makedocbook: Use sys.exit()

Use sys.exit() to write a message to stderr and terminate with a
non-zero exit code.

20 months agomakedocbook: Use raw strings for regexes
Jon Turney [Tue, 1 Nov 2022 11:15:25 +0000 (11:15 +0000)]
makedocbook: Use raw strings for regexes

Use raw strings for regexes. This is best practice, and fixes a number
of "W605 invalid escape sequence" flakes.

20 months agoCygwin: document bugfix for USB CDC devices
Corinna Vinschen [Fri, 11 Nov 2022 12:09:45 +0000 (13:09 +0100)]
Cygwin: document bugfix for USB CDC devices

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
20 months agoCygwin: fix TIOCMBIS/TIOCMBIC not working when using usbser.sys
Carlo Bramini [Fri, 11 Nov 2022 10:15:27 +0000 (11:15 +0100)]
Cygwin: fix TIOCMBIS/TIOCMBIC not working when using usbser.sys

In winsup/cygwin/fhandler/serial.cc, the function
fhandler_serial::switch_modem_lines() is called when TIOCMBIS/TIOCMBIC
are used in an ioctl() call.

This function uses EscapeCommFunction() for setting and resetting RTS
and DTR signals of a serial port.  Unfortunately, this function does not
work on USB CDC devices.

This is not a true bug of CYGWIN but an issue of the usbser.sys driver,
from Windows 2000 to the latest Windows 11.  Both 32bit and 64bit
versions of the operating system are affected.  Actually, I tested
EscapeCommFunction() also when using a real UART, based on the
traditional 16550 driver and it works fine.  Using thirdy party CDC
drivers, like the one provided by FTDI for their USB bridge chips,
probably also works.

However, it is also possible to drive the RTS/DTR signals by writing
their state with SetCommState(), which proved to be working fine all
types of connection.  This is also a better solution for handling these
signals since RTS/DTR can be set at the same time rather than having two
separate calls with a visible delay between them.

20 months agopowerpc/setjmp: Fix 64-bit buffer alignment
Sebastian Huber [Mon, 7 Nov 2022 13:33:42 +0000 (14:33 +0100)]
powerpc/setjmp: Fix 64-bit buffer alignment

The rlwinm is a word-size instruction which clears the remaining 32 bits of a
64-bit register.  Use clrrdi in 64-bit configurations.

20 months agoCygwin: Correct /proc/*/stat for processes without ctty
Andy Koppe [Wed, 9 Nov 2022 20:34:30 +0000 (20:34 +0000)]
Cygwin: Correct /proc/*/stat for processes without ctty

Report 0 instead of 268435455 (i.e. 0xFFFFFFF) in the tty field of
/proc/*/stat for processes without a controlling terminal. This is what
the procps utility expects when selecting or excluding such processes.

20 months agoGenerally make all 'long double complex' methods available in <complex.h>
Thomas Schwinge [Wed, 5 Oct 2022 20:11:41 +0000 (22:11 +0200)]
Generally make all 'long double complex' methods available in <complex.h>

..., not just '#if defined(__CYGWIN__)'.  (Exception: 'clog10l' which currently
indeed is for Cygwin only.)

This completes 2017-07-05 commit be3ca3947402827aa52709e677369bc7ad30aa1d
"Fixed warnings for some long double complex methods" after Aditya Upadhyay's
work on importing "Long double complex methods" from NetBSD.

For example, this changes GCC/nvptx libgfortran 'configure' output as follows:

    [...]
    checking for ccosf... yes
    checking for ccos... yes
    checking for ccosl... [-no-]{+yes+}
    [...]

..., and correspondingly GCC/nvptx 'nvptx-none/libgfortran/config.h' as
follows:

    [...]
     /* Define to 1 if you have the `ccosl' function. */
    -/* #undef HAVE_CCOSL */
    +#define HAVE_CCOSL 1
    [...]

Similarly for 'ccoshl', 'cexpl', 'cpowl', 'csinl', 'csinhl', 'ctanl', 'ctanhl',
'cacoshl', 'cacosl', 'casinhl', 'catanhl'.  ('conjl', 'cprojl' are not
currently being used in libgfortran.)

This in turn simplifies GCC/nvptx 'libgfortran/intrinsics/c99_functions.c'
compilation such that this files doesn't have to provide its own
"Implementation of various C99 functions" for those, when in fact they're
available in newlib libm.

20 months agoCygwin: Improve FAQ on early breakpoint for ASLR
Jon Turney [Tue, 1 Nov 2022 16:52:57 +0000 (16:52 +0000)]
Cygwin: Improve FAQ on early breakpoint for ASLR

gdb supports the 'disable-randomization' setting on Windows since [1]
(included in gdb 13).

https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=bcb9251f029da8dcf360a4f5acfa3b4211c87bb0;hp=8fea1a81c7d9279a6f91e49ebacfb61e0f8ce008

20 months agoCygwin: Handle out of order modules for module offsets in stackdump
Jon Turney [Tue, 1 Nov 2022 14:01:08 +0000 (14:01 +0000)]
Cygwin: Handle out of order modules for module offsets in stackdump

Improve address to module+offset conversion, to work correctly in the
presence of out-of-order elements in InMemoryOrderModuleList.

Fixes: d59651d4
20 months agostrftime/wcsftime: use STRLEN, not strlen
Corinna Vinschen [Sat, 29 Oct 2022 18:15:58 +0000 (20:15 +0200)]
strftime/wcsftime: use STRLEN, not strlen

Commit 737e2004a3bb accidentally introduced a call to strlen in
code used with wide character strings in case of wcsftime.  Use
STRLEN instead.

Fixes: 737e2004a3bb ("strftime.c(__strftime): add %q, %v, tests; tweak %Z doc")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
20 months agomakedocbook: Add explicit locking for PLY parser table generation
Jon Turney [Fri, 28 Oct 2022 16:56:09 +0000 (17:56 +0100)]
makedocbook: Add explicit locking for PLY parser table generation

Drop 'makedocbook --cache' (any dependency on the man-cache rule which
invokes that was dropped by the non-recursive make changes)

Instead, add some explicit locking which prevents processes colliding
over the file containing generated python code for the parser table.

20 months agoCygwin: Add loaded module base address list to stackdump
Jon Turney [Fri, 28 Oct 2022 12:35:13 +0000 (13:35 +0100)]
Cygwin: Add loaded module base address list to stackdump

This adds an extra section to the stackdump, which lists the loaded
modules and their base address.  This is perhaps useful as it makes it
immediately clear if RandomCrashInjectedDll.dll is loaded...

Future work: It seems like the 'InMemoryOrder' part of
'InMemoryOrderModuleList' is a lie?

> Loaded modules
000100400000 segv-test.exe
7FFF2AC30000 ntdll.dll
7FFF29050000 KERNEL32.DLL
7FFF28800000 KERNELBASE.dll
000180040000 cygwin1.dll
7FFF28FA0000 advapi32.dll
7FFF29F20000 msvcrt.dll
7FFF299E0000 sechost.dll
7FFF29B30000 RPCRT4.dll
7FFF27C10000 CRYPTBASE.DLL
7FFF28770000 bcryptPrimitives.dll

20 months agoCygwin: Add addresses as module offsets in .stackdump file
Jon Turney [Fri, 28 Oct 2022 11:26:56 +0000 (12:26 +0100)]
Cygwin: Add addresses as module offsets in .stackdump file

This adds an additional column to the stack trace in a .stackdump file,
which gives the stack frame return address as a module name+offset. This
makes it a possible to convert the address to a function name without
having to guess what module the address belongs to.

> Stack trace:
> Frame         Function     Args
0007FFFFCC30  0001004010E9 (000180048055000180046FA000000000000200018031E160) segv-test.exe+0x10E9
0007FFFFCD30  0001800480C1 (000000000000000000000000000000000000000000000000) cygwin1.dll+0x80C1
0007FFFFFFF0  000180045C86 (000000000000000000000000000000000000000000000000) cygwin1.dll+0x5C86
0007FFFFFFF0  000180045D34 (000000000000000000000000000000000000000000000000) cygwin1.dll+0x5D34
> End of stack trace

Loosely based on this patch [1] by Brian Dessent.

[1] https://cygwin.com/pipermail/cygwin-patches/2008q1/006306.html

20 months agoCygwin: Tidy up formatting of stackdump
Jon Turney [Fri, 28 Oct 2022 12:43:54 +0000 (13:43 +0100)]
Cygwin: Tidy up formatting of stackdump

Resize stackdump headers for b9e97f58
Consistently use \r\n line endings

20 months agoCygwin: cygheap: make bucket_val a static const array
Corinna Vinschen [Fri, 28 Oct 2022 15:02:05 +0000 (17:02 +0200)]
Cygwin: cygheap: make bucket_val a static const array

Every time the cygheap is initialized, that is, on each fork
or exec, cygheap_init() *again* computes the bucket size values
and stores them in the cgyheap, albeit they are always the
same values anyway.

Make bucket_val a local const array, statically initialized
instead.

Fixes: 61522196c715 ("* Merge in cygwin-64bit-branch.)"
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
20 months agoCygwin: document ASLR support topic/aslr_support github/topic/aslr_support
Corinna Vinschen [Fri, 28 Oct 2022 08:01:02 +0000 (10:01 +0200)]
Cygwin: document ASLR support

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
20 months agoCygwin: Enable dynamicbase on the Cygwin DLL by default
Corinna Vinschen [Fri, 28 Oct 2022 08:00:48 +0000 (10:00 +0200)]
Cygwin: Enable dynamicbase on the Cygwin DLL by default

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
20 months agoCygwin: /proc/<PID>/maps: output cygheap info
Corinna Vinschen [Fri, 28 Oct 2022 08:00:17 +0000 (10:00 +0200)]
Cygwin: /proc/<PID>/maps: output cygheap info

Now that the cygheap isn't part of the CYgwin DLL anymore, we have a
known memory location which is not known in maps output.  Fix that by
checking for cygheap address (same in all processes) and add to output.

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