Commit Graph

13309 Commits

Author SHA1 Message Date
Corinna Vinschen fcb32b7374 Cygwin: configure: disable i686 builds
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 13:42:54 +02:00
Corinna Vinschen d02421e7f7 Cygwin: switch to _REENT_GLOBAL_STDIO_STREAMS
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 13:41:13 +02:00
Sebastian Huber 01c823efb7 Make cleanup_glue() static
Remove cleanup_glue from the list of symbols exported by Cygwin.
2022-05-13 12:47:29 +02:00
Matt Joyce 8b96542ed1 Add global __sglue object for all configurations
Added a new global __sglue object for all configurations.
Decouples the global file object list from the _GLOBAL_REENT
structure by using this new object instead of the __sglue member
of _GLOBAL_REENT in __sfp() and _fwalk_sglue().
2022-05-13 12:41:10 +02:00
Sebastian Huber 3941c8a88a stdio: Replace _fwalk_reent() with _fwalk_sglue()
Replaced _fwalk_reent() with _fwalk_sglue(). The change adds an
extra __sglue object as a parameter, which will allow the passing
of a global __sglue object separate from the __sglue member of
struct _reent. The global __sglue object will be added in a
follow-on patch.
2022-05-13 12:40:10 +02:00
Matt Joyce 26747c47bc Add stdio_exit_handler()
Add a dedicated stdio exit handler to avoid using _GLOBAL_REENT in exit().
2022-05-13 12:35:00 +02:00
Corinna Vinschen 7c804d160d Cygwin: Implement GSO/GRO support
- getsockopt (SOL_UDP, UDP_SEGMENT)
- setsockopt (SOL_UDP, UDP_SEGMENT)
- getsockopt (SOL_UDP, UDP_GRO)
- setsockopt (SOL_UDP, UDP_GRO)
- sendmsg with SOL_UDP/UDP_SEGMENT control message
- recvmsg, convert Winsock UDP_COALESCED_INFO (DWORD) control message to
  Linux compatible SOL_UDP/UDP_GRO (uint16_t)
2022-05-13 11:11:38 +02:00
Corinna Vinschen 34a9570ff8 Cygwin: socket.h: add socket options added in recent Windows releases
Add new socket options equivalent to their Linux counterpart.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-12 11:33:29 +02:00
Sebastian Huber 6238b1877d Cygwin: signal.cc: Include <unistd.h>
Include <unistd.h> for sleep() and usleep() declarations.  Fix return type of
usleep().
2022-05-12 11:21:08 +02:00
Brian Inglis 437d0a8f88 fhandler_process.cc(format_process_stat): fix /proc/pid/stat issues
fix tty_nr maj/min bits, vmmaxrss units, and x86 format mismatch:
ctty maj is 31:16, min is 15:0; tty_nr s/b maj 15:8, min 31:20, 7:0;
vmmaxrss s/b bytes not pages;
times all 64 bit - change formats of first two instances from %lu to %U;
realign sprintf formats and variables/values in more logical groups
2022-05-11 09:57:52 +02:00
Takashi Yano 92b576dcc1 Cygwin: pty: Avoid script command crash in console.
- Previously, script command sometimes crashes by Ctrl-C in Win 7
  if it is running in console, and non-cygwin app is foreground.
  This patch fixes the issue.
2022-05-09 20:32:05 +09:00
Takashi Yano a19161a6d3 Cygwin: pty: Not to change code page of parent console.
- The recent commit "Cygwin: pty: Fix timing of creating invisible
  console." breaks the feature added by commit 72770148, which
  prevents pty from changing code page of parent console. This patch
  restores that.
2022-05-09 12:53:28 +09:00
Takashi Yano a6d06056e1 Cygwin: pty: Add missing attach_mutex guard. 2022-05-09 00:54:35 +09:00
Takashi Yano cc94490f6e Cygwin: pty: Avoid deadlock when pcon is started on console.
- Previously, "env SHELL=cmd script" command in console caused
  deadlock when starting cmd.exe. This patch fixes the issue.
2022-05-09 00:19:47 +09:00
Takashi Yano aea6940043 Cygwin: pty: Change the condition to send Ctrl-C event.
- Previously, non-cygwin app started by "script -c <non-cygwin app>"
  receives Ctrl-C twice. This patch fixes the issue.
2022-05-08 22:04:38 +09:00
Takashi Yano 67f12b2ea0 Cygwin: pty: Fix timing of creating invisible console.
- Previously, invisible console was created in fixup_after_exec().
  However, actually this should be done in fixup_after_fork(). this
  patch fixes the issue.
2022-05-08 19:47:05 +09:00
Takashi Yano b29fd96cac Cygwin: pty: Fix acquiring attach_mutex timing.
- When temporarily attaching a console, the timing of acquiring
  attach_mutex was not appropriate. This sometimes caused master
  forwarding thread to crash on Ctrl-C in Windows 7. This patch
  fixes the issue.
2022-05-08 19:45:31 +09:00
Takashi Yano aa9b5262f2 Cygwin: sigproc: Avoid segfault caused by signal just after fork().
- The commit "Cygwin: always add sigmask to child info" also tries
  to fix this issue, however, did not fix enough. This patch fixes
  that.
2022-05-05 21:35:04 +09:00
Sebastian Huber ad51d0006a Remove _global_impure_ptr indirection
Remove the pointer indirection through the read-only _global_impure_ptr and
directly use a externally visible _impure_data object of type struct _reent.
This enables the static initialization of global data structures in a follow up
patch.  In addition, we get rid of a machine-specific file.
2022-05-04 17:31:04 +02:00
Corinna Vinschen a404165959 Revert "sys/types.h: Don't include sys/_stdint.h"
This reverts commit 4232d171a6.
2022-05-04 15:08:44 +02:00
Corinna Vinschen 4232d171a6 sys/types.h: Don't include sys/_stdint.h
By including sys/_stdint.h, all types from stdint.h are
exposed even if stdint.h isn't pulled in explicitely. Include
<machine/_default_types.h instead. Fix up newlib and Cygwin
files which rely on stdint.h types, too.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-03 18:58:18 +02:00
Corinna Vinschen 5a6de512ab Cygwin: always add sigmask to child info
Even after fork, we might need the parent sigmask without having
access to the real _main_tls. There's a short time at process startup,
when _main_tls points to the system-allocated stack, but wait_sig is
already running. If we can't lock _main_tls, because find_tls can't
find it yet, we now access the parent's sigmask via child_info.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-03 15:16:18 +02:00
Corinna Vinschen 28970dae34 Cygwin: move x86_64 thread stack area
The x86_64 thread stack area collides with the share user data in
recent versions of Windows. Let's get ourselvels get out of the
way and move the thread stack area in the former slack space
between DLL area and heap, from 0x6:00000000 to 0x8:00000000.
That quadruplicates the stack area, so allow bigger maximum stack
sizes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-03 15:10:24 +02:00
Corinna Vinschen b827d4d36a Cygwin: simplify create_new_main_thread_stack
Originally the function was designed to be used in forked
processes as well, but it has never been used this way. Drop
the parameter only required for forkees.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-03 14:39:28 +02:00
Jon Turney 01c734b0d7
Cygwin: Fix typo KERB_S4U_LOGON_FLAG_IDENTITY -> IDENTIFY 2022-04-27 15:02:46 +01:00
Jon Turney 0b44b06b05
Cygwin: Fix build with w32api 10.0.0
> ../../../../src/winsup/cygwin/sec_auth.cc:1240:16: error: redefinition of ‘struct _MSV1_0_S4U_LOGON’
>  1240 | typedef struct _MSV1_0_S4U_LOGON
>       |                ^~~~~~~~~~~~~~~~~
> In file included from ../../../../src/winsup/cygwin/ntsecapi.h:10,
>                  from ../../../../src/winsup/cygwin/sec_auth.cc:13:
> /usr/include/w32api/ntsecapi.h:1425:18: note: previous definition of ‘struct _MSV1_0_S4U_LOGON’
>  1425 |   typedef struct _MSV1_0_S4U_LOGON {
>       |                  ^~~~~~~~~~~~~~~~~
> ../../../../src/winsup/cygwin/sec_auth.cc:1246:3: error: conflicting declaration ‘typedef int MSV1_0_S4U_LOGON’
>  1246 | } MSV1_0_S4U_LOGON, *PMSV1_0_S4U_LOGON;
>       |   ^~~~~~~~~~~~~~~~
> In file included from ../../../../src/winsup/cygwin/ntsecapi.h:10,
>                  from ../../../../src/winsup/cygwin/sec_auth.cc:13:
> /usr/include/w32api/ntsecapi.h:1430:5: note: previous declaration as ‘typedef struct _MSV1_0_S4U_LOGON MSV1_0_S4U_LOGON’
>  1430 |   } MSV1_0_S4U_LOGON, *PMSV1_0_S4U_LOGON;
>       |     ^~~~~~~~~~~~~~~~
> ../../../../src/winsup/cygwin/sec_auth.cc:1246:22: error: conflicting declaration ‘typedef int* PMSV1_0_S4U_LOGON’
>  1246 | } MSV1_0_S4U_LOGON, *PMSV1_0_S4U_LOGON;
>       |                      ^~~~~~~~~~~~~~~~~
> In file included from ../../../../src/winsup/cygwin/ntsecapi.h:10,
>                  from ../../../../src/winsup/cygwin/sec_auth.cc:13:
> /usr/include/w32api/ntsecapi.h:1430:24: note: previous declaration as ‘typedef struct _MSV1_0_S4U_LOGON* PMSV1_0_S4U_LOGON’
>  1430 |   } MSV1_0_S4U_LOGON, *PMSV1_0_S4U_LOGON;
2022-04-27 15:02:44 +01:00
Mark Geisert 23a3ec3392 Cygwin: Fix "0x0x" in gmondump and ssp man pages
A recent patch fixed gmondump to stop printing "0x0x" as an address
prefix.  It turns out the Cygwin User's Guide and the gmondump and
ssp man pages (all from utils.xml) have examples of the same error.
2022-04-27 11:40:09 +02:00
Takashi Yano 0a67adb0f5 Cygwin: pty: Fix Ctrl-C behaviour in latest GDB.
- In the latest GDB (11.2-1), Ctrl-C behaviour is broken a bit for
  non-cygwin inferior. For example, Ctrl-C on GDB prompt is not sent
  to GDB but to the inferior. This patch fixes the issue.
2022-04-18 20:07:48 +09:00
Takashi Yano 98b6f23d98 Cygwin: pty: Fix deadlock caused by Ctrl-C in setup_pseudoconsole().
- If Ctrl-C is pressed just after setup_pseudoconsole() is called,
  mintty stops to respond a while when CPU load is high. This patch
  fixes the issue.

Addresses: https://cygwin.com/pipermail/cygwin/2022-April/251272.html
2022-04-18 19:56:14 +09:00
Takashi Yano b58b5a9660 Cygwin: pty: Do not set internal handles in HPCON inheritable.
- The internal handles in HPCON should not be inheritable, however,
  the current code duplicates them as inheritable when handing over
  ownership of the pseudo console. This patch fixes the issue.

Addresses: https://cygwin.com/pipermail/cygwin/2022-April/251222.html
2022-04-12 01:27:13 +09:00
Takashi Yano 45cfcfbd71 Cygwin: pty: Close pseudo console only if the process is the owner.
- Currently, close_pseudoconsole() is called unconditionally from
  fhandler_termios::process_sigs() on Ctrl-C. This causes deadlock
  if Ctrl-C is pressed while setup_pseudoconsole() is called. With
  this patch, close_pseudoconsole() is called only if the master
  process is the owner of the nat-pipe to avoid the deadlock.
2022-04-09 12:59:54 +09:00
Takashi Yano e9c96f0a6d Cygwin: pipe: Avoid deadlock for non-cygwin writer.
- As mentioned in commit message of the commit b531d6b0, if multiple
  writers including non-cygwin app exist, the non-cygwin app cannot
  detect pipe closure on the read side when the pipe is created by
  system account or the the pipe creator is running as service.
  This is because query_hdl which is held in write side also is a
  read end of the pipe, so the pipe is still alive for the non-cygwin
  app even after the reader is closed.

  To avoid this problem, this patch lets all processes in the same
  process group close query_hdl using newly introduced internal signal
  __SIGNONCYGCHLD when non-cygwin app is started.

  Addresses: https://cygwin.com/pipermail/cygwin/2022-March/251097.html
2022-04-02 01:03:15 +09:00
Brian Inglis 3e3ccfaee6 fhandler_proc.cc(format_proc_cpuinfo): add Linux Superb Owl cpuinfo flags
0x00000007:1 EBX:0  intel_ppin	Intel Protected Processor Inventory Number
0x00000006:0 EAX:19 hfi		Hardware Feedback Interface
0x00000007:0 EDX:20 ibt		Intel Indirect Branch Tracking
2022-04-01 14:53:43 +02:00
Sebastian Huber 7a5903078d Replace _fwalk() calls with _fwalk_reent()
Remove the _fwalk() implementation to avoid duplicated code with
_fwalk_reent().
2022-03-31 07:54:04 +02:00
Takashi Yano 49a00a0673 Cygwin: pty: Fix crash on master close in Windows 7.
- The 4th parameter of WriteFile() cannot be NULL especially in
  Windows 7 as mentioned in Microsoft documentation. This patch
  fixes that.

Addresses: https://cygwin.com/pipermail/cygwin/2022-March/251162.html
2022-03-30 12:46:08 +09:00
Takashi Yano 090797e3d3 Cygwin: console: Do not use memcmp() to compare INPUT_RECORD.
- Using memcmp() to compare structure such as INPUT_RECORD is not
  correct manner because padding may not be initialized. This patch
  stops to use memcmp() for comparison of INPUT_RECORD.
2022-03-19 09:21:04 +09:00
Takashi Yano 92519e3d0c Cygwin: console: Ignore dwControlKeyState in event comparison.
- dwControlKeyState also may be null'ed on WriteConsoleInputW().
  Therefore ignore it in event comparison as well as wVirtualKeyCode
  and wVirtualScanCode.
2022-03-19 08:43:24 +09:00
Takashi Yano 8d3271b7fa Cygwin: console: Add attach_mutex guard that was not added. 2022-03-18 23:28:36 +09:00
Takashi Yano fcb182387a Cygwin: console: Fix typeahead key swapping which still occurs.
- The commit "Cygwin: console: Improve the code to avoid typeahead
  key swapping." did not solve the problem enough. Two unexpected
  things happen.
  (1) wVirtualKeyCode and wVirtualScanCode of readback key event may
      be null'ed even if they are not zero on WriteConsoleInputW().
      Therefore, memcmp() may report the event sequence is not equal.
  (2) WriteConsoleInputW() may not be atomic. The event sequence
      which is written by WriteConsoleInputW() may be inserted by
      key input in the middle of the sequence. Current code gives
      up to fix in this situation.
  This patch should fix that issue.
2022-03-18 22:47:01 +09:00
Mark Geisert 48c9ef6780 Cygwin: document recent gmondump formatting fix 2022-03-17 10:14:38 +01:00
Mark Geisert 3976513b99 Cygwin: Fix gmondump formatting goofs
The rewrite of %X to %p was malhandled.  Fix that/them.
2022-03-17 10:14:23 +01:00
Mike Frysinger 461a28a566 winsup: disable fortify source
When using a compiler that automatically enables -D_FORTIFY_SOURCE,
building winsup fails with errors like below.  Since winsup is not
setup to compile itself with _FORTIFY_SOURCE, disable it for now.

make[4]: Entering directory '.../x86_64-pc-cygwin/winsup/cygwin'
  CC       libc/minires-os-if.o
In file included from .../newlib/newlib/libc/include/ssp/strings.h:34,
                 from .../newlib/newlib/libc/include/strings.h:77,
                 from .../newlib/newlib/libc/include/string.h:24,
                 from ../../../../../winsup/cygwin/string.h:12,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/guiddef.h:154,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/winnt.h:635,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/minwindef.h:163,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/windef.h:9,
                 from /usr/x86_64-pc-cygwin/usr/include/windows.h:69,
                 from ../../../../../winsup/cygwin/winlean.h:56,
                 from ../../../../../winsup/cygwin/winsup.h:84,
                 from ../../../../../winsup/cygwin/libc/minires-os-if.c:13:
.../newlib/winsup/cygwin/include/ssp/socket.h:9:1: error: conflicting types for 'recv';
  have 'ssize_t(int,  void *, size_t,  int)' {aka 'long int(int,  void *, long unsigned int,  int)'}
    9 | __ssp_redirect0(ssize_t, recv, \
      | ^~~~~~~~~~~~~~~
In file included from /usr/x86_64-pc-cygwin/usr/include/w32api/ws2tcpip.h:17,
                 from ../../../../../winsup/cygwin/libc/minires-os-if.c:14:
/usr/x86_64-pc-cygwin/usr/include/w32api/winsock2.h:1022:34: note: previous declaration of 'recv' with
  type 'int(SOCKET,  char *, int,  int)' {aka 'int(long long unsigned int,  char *, int,  int)'}
 1022 |   WINSOCK_API_LINKAGE int WSAAPI recv(SOCKET s,char *buf,int len,int flags);
      |                                  ^~~~
In file included from .../newlib/newlib/libc/include/ssp/strings.h:34,
                 from .../newlib/newlib/libc/include/strings.h:77,
                 from .../newlib/newlib/libc/include/string.h:24,
                 from ../../../../../winsup/cygwin/string.h:12,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/guiddef.h:154,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/winnt.h:635,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/minwindef.h:163,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/windef.h:9,
                 from /usr/x86_64-pc-cygwin/usr/include/windows.h:69,
                 from ../../../../../winsup/cygwin/winlean.h:56,
                 from ../../../../../winsup/cygwin/winsup.h:84,
                 from ../../../../../winsup/cygwin/libc/minires-os-if.c:13:
.../newlib/winsup/cygwin/include/ssp/socket.h:13:1: error: conflicting types for 'recvfrom';
  have 'ssize_t(int,  void *, size_t,  int,  struct sockaddr *, socklen_t *)' {aka 'long int(int,  void *, long unsigned int,  int,  struct sockaddr *, int *)'}
   13 | __ssp_redirect0(ssize_t, recvfrom, \
      | ^~~~~~~~~~~~~~~
In file included from /usr/x86_64-pc-cygwin/usr/include/w32api/ws2tcpip.h:17,
                 from ../../../../../winsup/cygwin/libc/minires-os-if.c:14:
/usr/x86_64-pc-cygwin/usr/include/w32api/winsock2.h:1023:34: note: previous declaration of 'recvfrom' with
  type 'int(SOCKET,  char *, int,  int,  struct sockaddr *, int *)' {aka 'int(long long unsigned int,  char *, int,  int,  struct sockaddr *, int *)'}
 1023 |   WINSOCK_API_LINKAGE int WSAAPI recvfrom(SOCKET s,char *buf,int len,int flags,struct sockaddr *from,int *fromlen);
      |                                  ^~~~~~~~
make[4]: *** [Makefile:1930: libc/minires-os-if.o] Error 1
  CC       gmon.o
../../../../../winsup/cygwin/gmon.c:60: error: "bzero" redefined [-Werror]
   60 | #define bzero(ptr,size) memset (ptr, 0, size);
      |
In file included from .../newlib/newlib/libc/include/strings.h:77,
                 from .../newlib/newlib/libc/include/string.h:24,
                 from ../../../../../winsup/cygwin/string.h:12,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/guiddef.h:154,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/winnt.h:635,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/minwindef.h:163,
                 from /usr/x86_64-pc-cygwin/usr/include/w32api/windef.h:9,
                 from /usr/x86_64-pc-cygwin/usr/include/windows.h:69,
                 from ../../../../../winsup/cygwin/winlean.h:56,
                 from ../../../../../winsup/cygwin/winsup.h:84,
                 from ../../../../../winsup/cygwin/gmon.h:69,
                 from ../../../../../winsup/cygwin/gmon.c:47:
.../newlib/newlib/libc/include/ssp/strings.h:43: note: this is the location of the previous definition
   43 | #define bzero(dst, len) \
      |
cc1: all warnings being treated as errors
2022-03-16 22:03:33 -04:00
Mike Frysinger 96bc16f6b2 newlib: libc: merge build up a directory
Convert all the libc/ subdir makes into the top-level Makefile.  This
allows us to build all of libc from the top Makefile without using any
recursive make calls.  This is faster and avoids the funky lib.a logic
where we unpack subdir archives to repack into a single libc.a.  The
machine override logic is maintained though by way of Makefile include
ordering, and source file accumulation in libc_a_SOURCES.

There's a few dummy.c files that are no longer necessary since we aren't
doing the lib.a accumulating, so punt them.

The winsup code has been pulling the internal newlib ssp library out,
but that doesn't exist anymore, so change that to pull the objects.
2022-03-16 21:18:25 -04:00
Takashi Yano ed32020682 Cygwin: Add description of fsync() fix to 3.3.5 release notes. 2022-03-15 08:15:29 +09:00
Takashi Yano 0dad577b4b Cygwin: path: Convert type of variable 'remlen' to DWORD.
- Variable remlen stores the return value of QueryDosDeviceW(), so
  it is better to be DWORD.
2022-03-14 21:56:03 +09:00
Takashi Yano 7df94e3b4f Cygwin: path: Add fallback for DFS mounted drive.
- If UNC path for DFS is mounted to a drive with drive letter, the
  error "Too many levels of symbolic links" occurs when accessing
  to that drive. This is because GetDosDeviceW() returns unexpected
  string such as "\Device\Mup\DfsClient\;Z:000000000003fb89\dfsserver
  \dfs\linkname" for the mounted UNC path "\??\UNC\fileserver\share".
  This patch adds a workaround for this issue.

  Addresses: https://cygwin.com/pipermail/cygwin/2022-March/250979.html
2022-03-14 20:29:23 +09:00
Takashi Yano af8a7c13b5 Cygwin: fsync: Return EINVAL for special files.
- Unlike linux, fsync() calls FlushFileBuffers() even for special
  files. This causes the problem reported in:
    https://cygwin.com/pipermail/cygwin/2022-March/251022.html
  This patch fixes the issue.
2022-03-14 19:38:49 +09:00
Takashi Yano b1743c94e2 Cygwin: console, pty: Fix segfault in child_info_spawn::worker().
- After the commit "Cygwin: pty, console: Fix handle leak which
  occurs on exec() error.", startxwin cannot start X due to the
  error "Failed to activate virtual core keyboard: 2". The problem
  is access violation in the code retrieving the pgid of the ctty.
  This patch fixes the issue.

  Addresses: https://cygwin.com/pipermail/cygwin/2022-March/251013.html
2022-03-10 20:38:20 +09:00
Takashi Yano 9e1b329431 Cygwin: update 3.3.5 release notes 2022-03-05 18:21:09 +09:00
Takashi Yano 33dda55d14 Cygwin: add 3.3.5 release notes 2022-03-05 11:19:20 +09:00