Commit Graph

13577 Commits

Author SHA1 Message Date
Takashi Yano 3b7df69aaa Cygwin: ctty: Add comments for the special values: -1 and -2.
_pinfo::ctty has two special values other than the device id of
the allocated ctty:
-1: CTTY is not initialized yet. Can be associated with the TTY
    which is associated with the session leader.
-2: CTTY has been released by setsid(). Can be associate only with
    new TTY which is not associated with any other session as CTTY,
    but cannot be associate with the TTYs already associated with
    other sessions.
This patch adds the comments in some source files.

Suggested-by: Corinna Vinschen <corinna@vinschen.de>
Signedoff-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-01-10 22:04:40 +09:00
Takashi Yano 8e77725f31 Cygwin: pinfo: Additional fix for CTTY behavior.
The commit 25c4ad6ea5 did not fix the CTTY behavior enough. For
example, in the following test case, TTY will be associated as
a CTTY on the second open() call even though the TTY is already
CTTY of another session. This patch fixes the issue.

  #include <unistd.h>
  #include <sys/fcntl.h>

  int main()
  {
    if (fork () == 0) {
      char *tty = ttyname(0);
      int fd;
      setsid();
      fd = open(tty, O_RDWR);
      close(fd);
      fd = open(tty, O_RDWR);
      usleep (60000000L);
    }
    return 0;
  }

Fixes: 25c4ad6ea5 ("Cygwin: pinfo: Align CTTY behavior to the
statement of POSIX.")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-01-10 21:35:35 +09:00
Takashi Yano a81fef51cf Cygwin: cygheap: Initialize myself_pinfo before child_copy().
After the commit 30add3e6b3, 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: 30add3e6b3 ("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>
2023-01-10 21:04:29 +09:00
Corinna Vinschen 7c14e5a10a 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: 195169186b ("Cygwin: wait_sig: allow to compute process-wide mask of pending signals")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-10 11:48:02 +01:00
Jon Turney 1a9f95d894
Cygwin: Run testsuite against the just-built DLL
Since 4e7817498e, we're just running the tests against the installed
DLL.  We're arranging to put the build directory on the path, but since
it doesn't contain cygwin1.dll (since it's built with a different name
and renamed on installation), that doesn't have any effect.

Arrange to place the just-built DLL into a directory which the testsuite
can place on it's path (while running the test, but not while compiling
it).

Also fix any remaining references to cygwin0.dll in testsuite,
documentation and comments.

Fixes: 4e7817498e ("Cygwin: Makefile: Drop all the "test dll" considerations")
2023-01-10 10:27:13 +00:00
Corinna Vinschen 9ee1e1b693 Cygwin: /proc/<PID>/status: simplify code generating signal info
The code generating the signal info in _pinfo::siginfo() and in
commune_process() are doing the same thing.  Create a local static
function commune_process_siginfo() to have the code in one place
only.  Remove a useless sigpending() call.

Fixes: 9a3c058f66 ("Cygwin: /proc/<PID>/status: Fill SigPnd, SigBlk and SigIgn values with life")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-09 18:02:14 +01:00
Corinna Vinschen 7886327fbf Cygwin: reinstantiate exporting _alloca
This basically reverts commit 1556b96b1b.

Turns out that _alloca is actually used, for instance, by clang.
2023-01-09 13:42:53 +01:00
Brian Inglis 8a003605c1 fhandler/proc.cc(format_proc_cpuinfo): add Linux 6.1 cpuinfo
Intel 0x00000007:1 EAX:26 lam	Linear Address Masking (& recent entries)
2022-12-23 10:03:23 +01:00
Takashi Yano d0bad6996d Cygwin: Add release message for latest console change.
3721a756b0 ("Cygwin: console: Make the console accessible from other
terminals.")

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 23:20:52 +09:00
Takashi Yano 3721a756b0 Cygwin: console: Make the console accessible from other terminals.
Previously, the console device could not be accessed from other terminals.
Due to this limitation, GNU screen and tmux cannot be opened in console.
With this patch, console device can be accessed from other TTYs, such as
other consoles or ptys. Thanks to this patch, screen and tmux get working
in console.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 21:05:31 +09:00
Takashi Yano 043b6089e2 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>
2022-12-22 20:57:29 +09:00
Takashi Yano 25c4ad6ea5 Cygwin: pinfo: Align CTTY behavior to the statement of POSIX.
POSIX states "A terminal may be the controlling terminal for at most
one session."
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap11.html

However, in cygwin, multiple sessions could be associated with the
same TTY. This patch aligns CTTY behavior to the statement of POSIX.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 20:57:17 +09:00
Takashi Yano f6e4e98d30 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>
2022-12-22 20:38:08 +09:00
Jon Turney 4e7817498e
Cygwin: Makefile: Drop all the "test dll" considerations
After 90236c3a2c, the testsuite is failing, as the cygwin0.dll
referenced by the implib that testsuite programs are linked with doesn't
exist anymore.

We don't need to make and link the testsuite with a specially named DLL,
as the cygwin DLL (since 526b0fbca3) takes into consideration the path
it's executing from to define separate "Cygwin installations", which
don't interact.

Fixes: 90236c3a2c ("Cygwin: Makefile: build new-cygwin1.dll in a single step")
2022-12-21 17:43:11 +00:00
Corinna Vinschen 09cb4cd294 Cygwin: path_conv: make sure sym.path_flags is always initialized
Commit c1023ee353 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: c1023ee353 ("Cygwin: path_conv: decouple path_types from mount types")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-21 13:13:24 +01:00
Jon Turney 1b5fc91a1d
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.
2022-12-21 11:39:28 +00:00
Jon Turney 87968453dd
Cygwin: FAQ: Mention configure options to build with reduced dependencies 2022-12-21 11:39:26 +00:00
Corinna Vinschen 2af7dd9567 Cygwin: x86_64: import swab.S from NetBSD
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:19:23 +01:00
Corinna Vinschen 43743ed754 Cygwin: x86_64: import latest NetBSD bcopy.S
Tweak slightly to allow implementing entire {w}mem{p}{cpy,move}
family:

Add WIDE macro processing for wmem* and POST macro processing for
memp* functions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Corinna Vinschen b09617a828 Cygwin: x86_64: import memchr.S from NetBSD
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Corinna Vinschen 3830325502 Cygwin: x86_64: import new memset.S from NetBSD
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Corinna Vinschen 8e83ca675f Cygwin: add local machine/asm.h header
This header supports including BSD assembler sources.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Corinna Vinschen a25730119c Cygwin: use .S suffix for assembler files
Automake generates different recipies for .s.o vs. .S.o rules.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Corinna Vinschen fd3ce87f73 Cygwin: check_reparse_point_target: fix comment format
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Jon Turney 8fdc201ec3
Cygwin: Update 3.4.3 release note
(cherry picked from commit 5366b3403c)
2022-12-16 13:36:22 +00:00
Jon Turney 242a2a5971
Revert "Cygwin: x86_64: add wmemset assembler entry point"
This reverts commit 188d5f6c9a.

(cherry picked from commit 98fa366cb6)
2022-12-16 13:36:06 +00:00
Corinna Vinschen 489300c89d Cygwin: add release message for latest path handling patch
5ba5e09b9d ("Cygwin: path handling: never substitute virtual drive with target path")

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-14 11:58:08 +01:00
Corinna Vinschen 90236c3a2c 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>
2022-12-13 14:16:13 +01:00
Corinna Vinschen f34db341fc 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: 97eb64b909 ("Cygwin: uname: generate default release string from git as well")
Fixes: 4949a82cde ("Cygwin: uname: fix building in non-git source dir")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-13 14:16:13 +01:00
Corinna Vinschen 5ba5e09b9d 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: 19d59ce75d ("Cygwin: path_conv: Rework handling native symlinks as inner path components")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-12 21:56:14 +01:00
Corinna Vinschen 45794e0d66 Cygwin: add 3.4.2 release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-11 11:45:36 +01:00
Takashi Yano faac79783c Cygwin: pty: Use GetTickCount64() instead of GetTickCount().
Suggested-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-09 21:01:42 +09:00
Takashi Yano be635ebc2f Cygwin: pipe: Fix performance degradation for non-cygwin pipe.
https://cygwin.com/pipermail/cygwin/2022-December/252628.html

After the commit 9e4d308cd5, 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: 9e4d308cd5 ("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>
2022-12-09 21:01:29 +09:00
Corinna Vinschen 3a910b624a 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>
2022-12-09 12:41:54 +01:00
Corinna Vinschen 55de3fdd0e 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 2902b3a09e ("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 0f376ae220 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: 0f376ae220 ("Cygwin: rename __sFILE to __sFILE64 for backward
compatibility")
Fixes: 2902b3a09e ("Cygwin: drop requirement to build newlib's stdio64")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-08 17:16:20 +01:00
Corinna Vinschen 6429a7a7f6 Cygwin: add __sFILE64 fix to 3.4.1 release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-08 14:19:22 +01:00
Corinna Vinschen 0f376ae220 Cygwin: rename __sFILE to __sFILE64 for backward compatibility
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 2902b3a09e ("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.

Fix this by redefining __sFILE to __sFILE64.  The type name is very much
internal, so it doesn't really matter, except for the fact that it needs
to stay backward compatible so as not to break building against C++ libs
built under older versions of Cygwin.

Fixes: 2902b3a09e ("Cygwin: drop requirement to build newlib's stdio64")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-08 13:58:37 +01:00
Corinna Vinschen 53ea7b2d5a Cygwin: drop unused local declaration of fopen64
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-08 13:04:03 +01:00
Corinna Vinschen 4949a82cde Cygwin: uname: fix building in non-git source dir
commit 97eb64b909 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: 97eb64b909 ("Cygwin: uname: generate default release
string from git as well"
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-07 22:22:38 +01:00
Corinna Vinschen 97eb64b909 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>
2022-12-07 21:30:23 +01:00
Corinna Vinschen 792b1c6a6d Cygwin: add missing pragma
Add missing "#pragma GCC diagnostic push" to the pragma bracket
guarding the srandom call.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-07 21:18:24 +01:00
Corinna Vinschen 95f5b0a620 Cygwin: link mcountFunc.o to libgmon.a
Commit 188d5f6c9a 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: 188d5f6c9a ("Cygwin: x86_64: add wmemset assembler entry point")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-07 12:28:33 +01:00
Corinna Vinschen e9d843ec74 Cygwin: Add 3.5.0 release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-07 12:19:49 +01:00
Corinna Vinschen a3ae2a7348 Cygwin: don't autoload some kernel32 functions
DiscardVirtualMemory, PrefetchVirtualMemory and
GetSystemTimePreciseAsFileTime are available since
Windows 8.1.  Merge PseudoConsole functions into
kernel32 function block.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:03:07 +01:00
Corinna Vinschen 7d2c5efffa Cygwin: drop special handling for SID authority 18
This was only required up to Windows 8.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:03:02 +01:00
Corinna Vinschen df680fb62d Cygwin: flock: drop checking for artificial console handles
They have been used up to Windows 7 only.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen a3af720dee Cygwin: fix a few comments mentioning Windows 7 or 8
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen 6951d258eb Cygwin: simplify FAST_CWD access
Dropping Windows 7 and 8 also drops the need to handle three
different FAST_CWD structures.  Simplify code accordingly.

While at it, use dynamic allocation of the FAST_CWD structure
based on the length of the CWD path.  This may help in future
to enable working with systems and native apps with long paths
enabled (Win 10 1607 and later), see
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry#enable-long-paths-in-windows-10-version-1607-and-later

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen 21d098eab1 Cygwin: drop wincaps for Windows 7 and Windows 8
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen ef741db52b Cygwin: drop wincap::def_guard_pages
Only required for Windows 7.  Define constant value
DEFAULT_GUARD_PAGE_COUNT instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00