Commit Graph

13628 Commits

Author SHA1 Message Date
Corinna Vinschen 1e428bee1c Cygwin: mount_info::get_mounts_here: alloc temp mountpoint info on cygheap
That *should* be slightly faster than allocating on the user heap.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-05 12:01:45 +02:00
Corinna Vinschen d097a96e6e Cygwin: drop last usage of RtlCreateUnicodeStringFromAsciiz
This function is just bad.  It really only works for ASCII
chars, everything else is broken after the conversion.

Introduce new helper function sys_mbstouni to replace
RtlCreateUnicodeStringFromAsciiz in hash_path_name.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-05 11:45:49 +02:00
Takashi Yano 249f42d07a Cygwin: pty: Fix a small bug in is_console_app().
- Previsouly, there was potential risk of buffer over run in
  is_console_app(). This patch fixes the issue.
2022-08-05 17:59:40 +09:00
Corinna Vinschen 58e981a5a4 Cygwin: use locale-aware conversion to UNICODE_STRING checking mount points
mount_info::get_mounts_here used RtlCreateUnicodeStringFromAsciiz
which translates bytes into wide chars verbatim.

Create a new function sys_mbstouni_alloc which can be used from
mount_info::get_mounts_here to convert multibyte mount point
strings to UNICODE_STRINGS in a locale-aware way.

For symmetry, create a function mount_info::free_mounts_here,
so the knwoledge how to free the UNICODE_STRING buffers is
encapsulated in the same class.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 23:48:19 +02:00
Corinna Vinschen 35c5017438 Cygwin: drop all usages of NTAPI
and drop unused prototypes from ntdll.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 22:13:59 +02:00
Corinna Vinschen b28edc7b86 Cygwin: drop all usages of WINAPI
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 22:13:59 +02:00
Corinna Vinschen 73aefcb5c2 Cygwin: clock.cc: Drop redundant Windows prototypes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 22:13:59 +02:00
Corinna Vinschen e71628b889 Cygwin: drop obsolete _cygwin_noncygwin_dll_entry entry point
This was obsoleted more than 22 years ago. Time to drop it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 22:13:59 +02:00
Ken Brown c2aa5b6d74 Cygwin: syscalls.cc: remove ".dll" from blessed_executable_suffixes
This reverts commit d9e9c7b5a7.  The latter added ".dll" to the
blessed_executable_suffixes array because on 32-bit Windows, the
GetBinaryType function would report that a 64-bit DLL is an
executable, contrary to the documentation of that function.

That anomaly does not exist on 64-bit Windows, so we can remove ".dll"
from the list.  Reverting the commit does, however, change the
behavior of the rename(2) syscall in the following unlikely situation:
Suppose we have an executable foo.exe and we make the call

  rename ("foo", "bar.dll");

Previously, foo.exe would be renamed to bar.dll.  So bar.dll would
then be an executable without the .exe extension.  The new behavior is
that foo.exe will be renamed to bar.dll.exe.  [Exception: If there
already existed an executable (not a DLL!) with the name bar.dll, then
.exe will not be appended.]
2022-08-04 15:51:39 -04:00
Corinna Vinschen 288788f91e Cygwin: Drop outdated IsWow64Process2 prototype
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 20:55:52 +02:00
Corinna Vinschen 12a3b696a4 Cygwin: drop outdated __MINGW64_VERSION_MAJOR checks
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 20:55:25 +02:00
Corinna Vinschen 7073ef4e8f Cygwin: drop __stdcall usage
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 20:54:09 +02:00
Corinna Vinschen 7718cb70d4 Cygwin: syscalls.cc: drop masking macros for standard IO functions
The actual reason for these wrappers are lost in time, there's no
hint even in the pre-2000 ChangeLog files.  Apparently they were
masking the prototypes or, alternatively, macros from newlib to
clash with the definitions in syscalls.cc.

They are not needed anymore, so just drop them.

This uncovered that the buffer pointer to pwrite is erronously
non-const.  Fix this on the way out.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 20:32:49 +02:00
Corinna Vinschen 9f6057d203 Cygwin: Drop export aliases and masking macros for stdio64 functions
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 17:30:48 +02:00
Corinna Vinschen cc88ef77e7 Cygwin: create sparse errmap array
To avoid linear searches for error codes, autogenerate errmap as
simple array of errno values indexed by Windows error codes.
Restrict to the first 9000 Windows error codes, we don't care for
most of them anyway.

Define errmap in its own file errmap.h to clean up errno.cc.

Change geterrno_from_win_error accordingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 15:16:48 +02:00
Markus Mützel ab31794e8a cacosh: Use approximation for large input.
Signed-off-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 12:55:52 +02:00
Markus Mützel d939b16adc casinh: Use approximation for large input.
Signed-off-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 12:55:17 +02:00
Corinna Vinschen 70c7e8c1ba Cygwin: net.cc: convert wsock_errmap into a simple array of error codes
Avoid linear searches for error codes by converting wsock_errmap
to a ordered array, indexed by WinSock error code (subtracted by
WSABASEERR.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 11:45:58 +02:00
Corinna Vinschen a8c1dd2ce0 Cygwin: net.cc: create own type host_errmap_t for host_errmap
This decouples host_errmap from the errmap_t definition which is
about to be changed in a followup patch.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 11:37:58 +02:00
Corinna Vinschen 8053ccd44b Cygwin: net.cc: constify gai_errmap
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 11:36:24 +02:00
Corinna Vinschen f418195dc9 Cygwin: fix/drop a few comments
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 18:14:39 +02:00
Corinna Vinschen b226e4228a Cygwin: __WORDSIZE: Drop 32 bit considerations
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 17:48:20 +02:00
Corinna Vinschen 7ad791c1ee Cygwin: drop macro and code for CYGWIN_VERSION_DLL_EPOCH
fix a comment in check_sanity_and_sync() on the way

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 16:16:14 +02:00
Corinna Vinschen c41f0e700a Cygwin: drop unused CYGWIN_VERSION_CYGWIN_CONV macro
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 16:09:00 +02:00
Corinna Vinschen dad3dd33ab Cygwin: version.h: document API_VERSION of the first 64 bit build
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 16:04:42 +02:00
Corinna Vinschen 12360f10ff Cygwin: drop macro and code for CYGWIN_VERSION_USE_PSEUDO_RELOC_IN_DLL
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 16:01:29 +02:00
Corinna Vinschen c874161ec5 Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:59:37 +02:00
Corinna Vinschen fee7b24beb Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:57:30 +02:00
Corinna Vinschen 57c3ca8d51 Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:53:41 +02:00
Corinna Vinschen 741f9a61c6 Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_USING_ANCIENT_MSGHDR
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:52:07 +02:00
Corinna Vinschen dcd78ece45 Cygwin: drop unused CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES macro
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:50:52 +02:00
Corinna Vinschen c2743614bf Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:48:56 +02:00
Corinna Vinschen 7de1be0472 Cygwin: drop unused CYGWIN_VERSION_CHECK_FOR_S_IEXEC macro
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:39:14 +02:00
Corinna Vinschen 8883f0ea39 Cygwin: drop macro and code for CYGWIN_VERSION_OLD_STDIO_CRLF_HANDLING
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:38:11 +02:00
Corinna Vinschen efa6611982 Cygwin: drop macro and code for CYGWIN_VERSION_DLL_MALLOC_ENV
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:35:34 +02:00
Corinna Vinschen 02b273a688 Cygwin: drop macro and code for CYGWIN_VERSION_DLL_IS_OLD_TERMIOS
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:35:29 +02:00
Corinna Vinschen 2902b3a09e Cygwin: drop requirement to build newlib's stdio64
Given that 64 bit Cygwin defines all file access types (off_t,
fpos_t, and derived types) as 64 bit anyway, there's no reason
left to rely on the stdio64 part of newlib.  Use base functions
and base types.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 13:41:35 +02:00
Takashi Yano 8b502d8635 Cygwin: path: Make some symlinks to /cygdrive/* work.
- Previously, some symbolic links to /cygdrive/* (e.g. /cygdrive/C,
  /cygdrive/./c, /cygdrive//c, etc.) did not work. This patch fixes
  the issue.
  Addresses: https://cygwin.com/pipermail/cygwin/2022-July/251994.html
2022-08-03 13:36:09 +09:00
Takashi Yano bfee9c6ab0 Cygwin: console: Modify ConEmu cygwin connector hook.
- Previously, LoadLibraryA() is hooked for ConEmu cygwin connector.
  With this patch, GetProcAddress() for "RequestTermConnector" is
  hooked instead which is more essential for ConEmu cygwin connector.
2022-08-02 07:52:52 +09:00
Takashi Yano d5229f8211 Cygwin: pty: Treat *.bat and *.cmd as a non-cygwin console app.
- If *.bat or *.cmd is executed directly from cygwin shell, pty
  failed to switch I/O pipe to that for native apps. This patch
  fixes the issue.
2022-07-31 17:55:42 +09:00
Takashi Yano 8d564b62b7 Cygwin: console: Avoid accessing NULL pointer via cygheap->ctty.
- Recent commit "Cygwin: console: Add missing input_mutex guard."
  has a problem that causes NULL pointer access if cygheap->ctty
  is NULL. This patch fixes the issue.
2022-07-29 21:59:11 +09:00
Jon Turney d4689b99c6
Cygwin: Set threadnames with SetThreadDescription()
gdb master recently learnt how to use GetThreadDescription() [1], so set
threadnames using SetThreadDescription() [available since Windows 10
1607] as well.

This is superior to using a special exception to indicate the thread
name to the debugger, because the thread name isn't missed if you don't
have a debugger attached at the time it's set.

It's not clear what the encoding of a thread name string is, we assume
UTF8 for the moment.

For the moment, continue to use the old method as well, for the benefit
of older gdb versions etc.

[1] https://sourceware.org/pipermail/gdb-patches/2022-April/187833.html
2022-07-29 11:58:43 +01:00
Corinna Vinschen f145174f80 Cygwin: uname: drop useless support for unsupported CPU arches
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-29 12:19:54 +02:00
Corinna Vinschen 87a9ca4a95 Cygwin: gmon.h: drop 32 bit considerations
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-29 12:19:18 +02:00
Corinna Vinschen 20adacdca2 Cygwin: profile.c: drop i686 register access
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-29 12:17:43 +02:00
Corinna Vinschen 7f42498be6 Cygwin: rename __cygwin_environ and drop env redirection via cur_environ()
Back in early Cygwin development a function based access to the
environment was exported, the internal environ in Cygwin was called
__cygwin_environ and cur_environ() was used to access the environment
indirectly .  The history of that necessity is not documented,
but kept in i686 for backward compatibility.

The x86_64 port eventually used __cygwin_environ directly and exported
it as DATA under the usual name environ.

We don't need the i686 workaround anymore, so just rename
__cygwin_environ to environ, drop the cur_environ() macro and
simply export environ under its own name.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-28 22:00:40 +02:00
Corinna Vinschen cea26c7570 Cygwin: perl scripts: drop support for i686
- rename "is64bit" to "is_x86_64"
- Always set sym_prefix to empty string and add a FIXME
- speclib: rename uscore to sym_prefix and fix bug in string handling

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-28 20:28:45 +02:00
Takashi Yano f2e39d5230 Cygwin: console: Add workaround for ConEmu cygwin connector.
- ConEmu cygwin connector conflicts with cons_master_thread since
  it does not use read() to read console input. With this patch,
  cons_master_thread is disabled in ConEmu cygwin connector.
2022-07-28 23:56:42 +09:00
Takashi Yano d4aacd50e6 Cygwin: console: Add missing input_mutex guard.
- Setting con.disable_master_thread flag should be guarded by
  input_mutex, however, it was not. This patch fixes that.
2022-07-28 23:56:34 +09:00
Corinna Vinschen 33395637a1 Cygwin: Fix previous attempt to drop i386 targets from hookapi
Somehow this patch looks like it was pushed before having been
finished.  Let's try again...

Fixes: e46f15c2d1 ("Cygwin: hookapi: drop handling i386 targets")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-28 16:38:01 +02:00
Corinna Vinschen 5192d5ea51 Cygwin: _dll_crt0: minimize target-specific conditional code
Only the assembler snippet is really x86_64-specific, so minimize the
conditional code block to this snippet.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 20:08:58 +02:00
Corinna Vinschen e46f15c2d1 Cygwin: hookapi: drop handling i386 targets
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 20:06:09 +02:00
Corinna Vinschen 1f962581ff Cygwin: fix or delete a few comments to drop 32 bit references
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 18:32:53 +02:00
Corinna Vinschen 4ce1a1ddc4 Cygwin: drop cyglsa.h. LSA subauth is not supported anymore
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 12:48:39 +02:00
Corinna Vinschen cb4b49470f Cygwin: drop 32 bit target from linker script
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 12:33:21 +02:00
Corinna Vinschen f25e61dfea Cygwin: drop tmpfile export alias for 32 bit systems
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 11:41:01 +02:00
Matt Joyce f89ce35d83 Add _REENT_CLEANUP(ptr)
Add a _REENT_CLEANUP() macro to encapsulate access to the
__cleanup member of struct reent. This will help to replace the
struct member with a thread-local storage object in a follow up
patch.
2022-07-13 06:55:46 +02:00
Matt Joyce f3b8138239 Add _REENT_ERRNO(ptr)
Add a _REENT_ERRNO() macro to encapsulate the access to the
_errno member of struct reent. This will help to replace the
structure member with a thread-local storage object in a follow
up patch.

Replace uses of __errno_r() with _REENT_ERRNO().  Keep __errno_r() macro for
potential users outside of Newlib.
2022-07-13 06:55:41 +02:00
Jon Turney 56d5a57e5f
Update FAQs which are out of date on the details of setup UI 2022-07-12 13:58:59 +01:00
Jon Turney b441bad182
Update FAQs for removal of 32-bit Cygwin
Update FAQs for removal of 32-bit Cygwin
Also update FAQs for dropping support for Windows Vista/Server 20008
2022-07-12 13:58:58 +01:00
Takashi Yano 9193f6efde Cygwin: clipboard: Add workaround for setting clipboard failure.
- OpenClipboard() just after CloseClipboard() sometimes fails. Due
  to this, /dev/clipboard sometimes fails to set CF_UNICODETEXT
  data. This patch add a workaround for this issue.
2022-07-12 19:59:38 +09:00
Takashi Yano 421dcf72fb Cygwin: console: Fix an issue which causes when realloc() fails. 2022-07-09 14:43:24 +09:00
Ken Brown 5d4f405d3b Cygwin: redefine some macros for Linux compatibility
Define FD_SETSIZE (<sys/select.h>) to be 1024 by default, and define
NOFILE (<sys/param.h>) to be OPEN_MAX (== 3200) by default.

Remove the comment in <sys/select.h> that FD_SETSIZE should be >=
NOFILE.

Bump API minor.

Addresses: https://cygwin.com/pipermail/cygwin/2022-July/251839.html
2022-07-07 08:22:40 -04:00
Christian Franke d908a30fdc winsup/doc/faq-setup.xml: align help text with setup 2.919 2022-07-07 13:10:46 +02:00
Takashi Yano fc74dbf22f Cygwin: spawn: Treat empty path as the current directory.
- With this patch, the empty path (empty element in PATH or PATH is
  absent) is treated as the current directory as Linux does. This
  feature is added for Linux compatibility, but it is deprecated.
  POSIX notes that a conforming application shall use an explicit
  pathname to specify the current working directory.
Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251730.html
2022-07-05 13:44:56 +09:00
Takashi Yano b3e25f0bc1 Cygwin: console: Fix issue of pasting very long text input again.
- The recent commit "Cygwin: console: Allow pasting very long text
  input." did not fix the issue enough. This patch adds fixes for
  that.
2022-07-05 11:48:40 +09:00
Ken Brown 72f855f32b Cygwin: implement getfacl(1) for socket files
Do this by defining the acl_get method for the fhandler_socket_local
and fhandler_socket_unix classes.  Also define acl_set for these
classes.

Partially addresses: https://cygwin.com/pipermail/cygwin/2022-July/251768.html
2022-07-04 18:55:19 -04:00
Ken Brown 1503d14af1 Cygwin: stdio: don't try again to read after EOF
This reverts commit 1f8f7e2d54, "* libc/stdio/refill.c (__srefill):
Try again after EOF on Cygwin."  If EOF is set on a file, the stdio
input functions will now immediately return EOF rather than trying
again to read.  This aligns Cygwin's behavior to that of Linux.

Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251672.html
2022-07-04 18:55:08 -04:00
Takashi Yano 2c2c2b631b Cygwin: console: Fix new bugs in cons_master_thread().
- The previous commit for console introduced new bugs in error
  handling in cons_master_thread(). This patch fixes that.
2022-07-03 11:02:28 +09:00
Takashi Yano 746c8116dd Cygwin: console: Allow pasting very long text input.
- Currently, if the text longer than 1024 byte is pasted in console,
  some of the text is discarded. This patch fixes the issue.
Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251764.html
2022-07-02 11:24:11 +09:00
Takashi Yano 54930ae7d7 Cygwin: poll: Fix a bug on inquiring same fd with different events.
- poll() has a bug that it returns event which is not inquired if
  events are inquired in multiple pollfd entries on the same fd at
  the same time. This patch fixes the issue.
Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251732.html
2022-06-27 10:54:24 +09:00
Takashi Yano fe10e8f03a Cygwin: console: Handle setting very long window title correctly.
- Previously, the console code could not handle escape sequence
  setting window title longer than 256 byte correctly. This patch
  fixes the issue.
  Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251662.html
2022-06-19 18:02:09 +09:00
Takashi Yano fdbd153932 Cygwin: console: Retain ENABLE_VIRTUAL_TERMIANL_PROCESSING flag.
- Currently, ENABLE_VIRTUAL_TERMINAL_PROCESSING flag is disabled
  unconditionally when exiting from cygwin. This causes ANSI escape
  sequence disabled in Windows Terminal where it is enables by
  default. This patch retains that flag if it is originally enabled.
2022-06-14 21:11:56 +09:00
Ken Brown ddce45112d Cygwin: restore one more '#ifdef __x86_64__' 2022-06-11 08:56:08 -04:00
Ken Brown bbfe79fb72 Cygwin: restore '#ifdef __x86_64__' for CPU-specific code
Commit e1ce752a1d, "Cygwin: remove miscellaneous 32-bit code", removed
most occurrences of '#ifdef __x86_64__'.  Restore those occurrences
that guarded code specific to the AMD64 processor, and #error out if
the processor is different.  This will make it easier to find
AMD64-specific code if we ever want to add support for a different
64-bit processor (e.g., ARM64).
2022-06-10 16:38:34 -04:00
Sebastian Huber b0cb9f85ca Use global stdio streams for all configurations
The _REENT_GLOBAL_STDIO_STREAMS was introduced by commit
668a4c8722 in 2017.  Since then it was enabled by
default for RTEMS.  Recently, the option was enabled for Cygwin which
previously used an alternative implementation to use global stdio streams.

In Newlib, the stdio streams are defined to thread-specific pointers
_reent::_stdin, _reent::_stdout and _reent::_stderr.  If the option is disabled
(the default for most systems), then these pointers are initialized to
thread-specific FILE objects which use file descriptors 0, 1, and 2,
respectively.  There are at least three problems with this:

(1) The thread-specific FILE objects are closed by _reclaim_reent().  This
    leads to problems with language run-time libraries that provide wrappers to
    the C/POSIX stdio streams (for example C++ and Ada), since they use the
    thread-specific FILE objects of the initialization thread.  In case the
    initialization thread is deleted, then they use freed memory.

(2) Since thread-specific FILE objects are used with a common output device via
    file descriptors 0, 1 and 2, the locking at FILE object level cannot ensure
    atomicity of the output, e.g. a call to printf().

(3) There are resource managment issues, see:

    https://sourceware.org/pipermail/newlib/2022/019558.html

    https://bugs.linaro.org/show_bug.cgi?id=5841

This patch enables the _REENT_GLOBAL_STDIO_STREAMS behaviour for all Newlib
configurations and removes the option.  This removes a couple of #ifdef blocks.
2022-06-10 20:13:52 +02:00
Mark Geisert aa460cc0ca Cygwin: Have gmondump support ssp-generated gmon.out
Cygwin tool ssp generates gmon.out files with different address
resolution than other tools do. Two address bytes per bucket rather than
the usual four address bytes. Gprof can deal with the difference but
gmondump can't because the latter's gmon.out header validation fails.

- Remove the offending portion of the header validation code.
- Make sure all code can handle differing address resolutions.
- Display address resolution in verbose data dumps.
- Change "rawarc" to "struct rawarc" in certain sizeof expressions to
  avoid buffer overrun faults.
- When "-v" (verbose) is specified, note when there is missing bucket
  data or rawarc data.
2022-06-10 12:12:26 +02:00
Ken Brown 07cf763095 Cygwin: restore two instances of __stdcall
In the previous commit, __stdcall was removed from _dll_crt0 in
winsup.h and dcrt0.cc but not in lib/cygwin_crt0.c.  For consistency,
restore the first two occurrences of __stdcall.  We could instead
remove it from the declaration in lib/cygwin_crt0.c, but this might
appear to affect binary compatibility, even though it really doesn't.
2022-06-07 13:46:31 -04:00
Ken Brown 30c5411d07 Cygwin: remove most occurrences of __stdcall and __cdecl
These have no effect on x86_64.  Retain a few occurrences of __cdecl
in files imported from other sources.

Also retain all occurrences of WINAPI, even though the latter is
simply a macro that expands to __stdcall.  Most of these occurrences
are associated with Windows API functions, and removing them might
make the code confusing instead of simpler.
2022-06-06 12:00:45 -04:00
Ken Brown cb4b4548c8 Cygwin: remove ntsecapi.h
This was a wrapper for w32api/ntsecapi.h.  It was introduced to fix a
bug that only affected 32-bit Cygwin, so it is no longer needed.
2022-06-06 10:44:01 -04:00
Ken Brown 1f8235f6ba Cygwin: child_info.h: remove declaration of init_child_info
The function was removed long ago, but its declaration remained.
2022-06-06 10:16:48 -04:00
Jon Turney f36dd40275
Cygwin: Drop use of loadlib.h in regtool
Link directly with RegDeleteKeyExW(), available since Vista.

(It's unclear the LoadLibrary wrapper was ever doing anything useful
here, as (i) DLL lookup in PATH was avoided as advapi32 is already
loaded into the process, and (ii) advapi32 is a 'known DLL' which is
only ever loaded from system directory)
2022-06-06 11:21:44 +01:00
Jon Turney f344134a19
Cygwin: Drop pointless loadlib.h includes in utilities
These utilities used to LoadLibrary()/GetProcAddress(), but don't
anymore.
2022-06-06 11:21:43 +01:00
Ken Brown e1ce752a1d Cygwin: remove miscellaneous 32-bit code 2022-05-29 17:54:32 -04:00
Ken Brown b1e304cbd3 Cygwin: remove 32-bit only clipboard code 2022-05-29 17:45:52 -04:00
Ken Brown f6bb8bfaa0 Cygwin: remove some 32-bit only environment code 2022-05-29 17:45:52 -04:00
Ken Brown 3e917daec1 Cygwin: remove some 32-bit only path conversion functions 2022-05-29 17:45:52 -04:00
Ken Brown 2126f966ae Cygwin: remove regparm.h
This file defines the macros __reg1, __reg2, and __reg3, which are
defined to be empty on 64-bit Cygwin.  Remove all occurrences of these
macros.
2022-05-29 17:45:52 -04:00
Ken Brown 2d9b48760c Cygwin: simplify some function names
Remove "32" or "64" from each of the following names: acl32,
aclcheck32, aclfrommode32, aclfrompbits32, aclfromtext32, aclsort32,
acltomode32, acltopbits32, acltotext32, facl32, fchown32, fcntl64,
fstat64, _fstat64, _fstat64_r, ftruncate64, getgid32, getgrent32,
getgrgid32, getgrnam32, getgroups32, getpwuid32, getpwuid_r32,
getuid32, getuid32, initgroups32, lseek64, lstat64, mknod32, mmap64,
setegid32, seteuid32, setgid32, setgroups32, setregid32, setreuid32,
setuid32, stat64, _stat64_r, truncate64.

Remove prototypes and macro definitions of these names.

Remove "#ifndef __INSIDE_CYGWIN__" from some headers so that the new
names will be available when compiling Cygwin.

Remove aliases that are no longer needed.

Include <unistd.h> in fhandler_clipboard.cc for the declarations of
geteuid and getegid.
2022-05-29 17:45:52 -04:00
Ken Brown 7c0de0af97 Cygwin: remove some 32-bit-only function definitions
Remove the definitions of the following: acl, aclcheck, aclfrommode,
aclfrompbits, aclfromtext, aclsort, acltomode, acltopbits, acltotext,
chown, fchown, _fcntl, fstat, _fstat_r, ftruncate, getegid, geteuid, getgid,
getgrent, getgrgid, getgrnam, getgroups, getpwduid, getpwuid,
getpwuid_r, getuid, initgroups, lacl, lacl32, lchown, lseek, lstat,
mknod, mmap, setegid, seteuid, setgid, setgroups, setregid, setreuid,
setuid, stat, _stat_r, truncate.

[For most of these, the corresponding 64-bit entry points are obtained
by exporting aliases.  For example, acl is an alias for acl32, and
truncate is an alias for truncate64.]

Remove the following structs and all code using them (which is 32-bit
only): __stat32, __group16, __flock32, __aclent16_t.

Remove the typedefs of __blkcnt32_t __dev16_t, __ino32_t, which are
used only in code that has been removed.

Put the typedefs of __uid16_t and __gid16_t in one header, instead of
one header if __INSIDE_CYGWIN__ is defined and a different header
otherwise.
2022-05-29 17:45:52 -04:00
Ken Brown 98180795de Cygwin: document last bug fix 2022-05-29 17:42:06 -04:00
Takashi Yano 871ca7ba64 Cygwin: cygheap: Fix the issue of cygwin1.dll in the root directory.
- After the commit 6d898f43, cygwin fails to start if cygwin1.dll
  is placed in the root directory. This patch fixes the issue.
Addresses: https://cygwin.com/pipermail/cygwin/2022-May/251548.html
2022-05-28 23:16:21 +09:00
Brian Inglis 9af21ada23 fhandler_proc.cc(format_proc_cpuinfo): add Linux 5.18 cpuinfo flags
0x80000008:0 EBX:31 brs		AMD Branch Sampling available
0x80000022:0 EAX:0  perfmon_v2	AMD ExtPerfMonAndDbg Performance Monitoring Version 2
0x00000021:0 EBX|EDX|ECX=="IntelTDX    " tdx_guest Intel Trust Domain Extensions- Guest Support
2022-05-25 13:11:40 -04:00
Ken Brown 2f8ba40046 Cygwin: fix mknod (64-bit only)
The current definition of mknod in syscalls.cc has a third argument of
type __dev16_t instead of dev_t.  Fix this on 64-bit Cygwin by making
the existing mknod 32-bit only and then exporting mknod as an alias
for mknod32.  (No fix is needed on 32-bit because mknod is redirected
to mknod32 via NEW_FUNCTIONS in Makefile.am.)

Addresses: https://cygwin.com/pipermail/cygwin-developers/2022-May/012589.html
2022-05-23 08:16:40 -04:00
Corinna Vinschen 1b86dd7d8c Cygwin: make sure exec'ed process exists early in process list
killpg(pgid, 0) (or kill_pgrp(pgid, si_signo=0), in signal.cc)
fails (returns -1) even when there is a process in the process
group pgid, if the process is in the middle of spawnve(), see

  https://cygwin.com/pipermail/cygwin/2022-May/251479.html

When exec'ing a process the assumption is that the exec'ed process creates its
own symlink (in pinfo::thisproc() in pinfo.cc). If the exec'ing process
calls NtClose on it's own winpid symlink, but the exec'ed process didn't
progress enough into initialization, there's a slim chance that neither
the exec'ing process, nor the exec'ed process has a winpid symlink
attached.

Always create the winpid symlink in spawn.cc, even for exec'ed Cygwin
processes.  Make sure to dup the handle into the new process, and stop
creating the winpid symlink in exec'ed processes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-19 10:46:41 +02:00
Takashi Yano 1559f7f458 Cygwin: Use two pass parse for tlsoffsets generation.
- The commit "Cygwin: fix new sigfe.o generation in optimized case"
  fixed the wrong tlsoffsets generation by adding -O0 to compile
  options. Current gentls_offsets expects entry of "start_offset"
  is the first entry in the assembler code. However, without -O0,
  entry of "start_offset" goes to the last entry for some reason.
  Currently, -O0 can prevents assembler code from reversing the
  order of the entries, however, there is no guarantee that it will
  retain the order of the entries in the future.

  This patch makes gentls_offsets parse the assembler code in the
  two pass to omit -O0 option dependency.
2022-05-19 04:03:16 +09:00
Sebastian Huber 4a00cbcefe Cygwin: Enable backward binary compatibility 2022-05-18 07:45:09 +02:00
Corinna Vinschen 93bea9f538 Cygwin: drop i686 exception handling
Leave x86_64 CPU-specific code and #error out when trying to build
for another target. Access special registers CPU-agnostic.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-17 14:12:32 +02:00
Corinna Vinschen 830a9b707c Cygwin: drop PROCESSOR_ARCHITECTURE_INTEL from uname
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-16 18:17:06 +02:00
Corinna Vinschen 83f8e24f0b Cygwin: document why we can't drop the _pei386_runtime_relocator dummy
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-16 18:17:06 +02:00
Corinna Vinschen b3b9e231de Cygwin: drop i386 refs from header files where source isn't affected
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-16 18:17:06 +02:00
Corinna Vinschen 866ae2c254 Cygwin: drop 32 bit considerations in crt0 code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-16 18:17:06 +02:00
Takashi Yano b79d60b7d2 Cygwin: add 3.3.6 release notes 2022-05-16 20:15:17 +09:00
Takashi Yano faf1e11592 Cygwin: pty: Fix script command crash on console in Win7.
- Previously, the command "cmd /c script -c cmd" in console of Win7
  crashes. This seems to be due to a bug (?) of AttachConsole().
  This patch adds workaround for this issue.

  Currently, pty reattaches to the console of the process which is
  predetermined by ConsoleProcessList() after temporarily attaching
  to another console. After that, the console output handle opened
  with the name "CONOUT$" may not be accessible in Win7.
  This seems to happen when the attached process does not have the
  same handle even if the console attached is the same. With this
  patch, cygwin-console-helper which is started when pty master is
  opened in console, is utilized to be a target process to which
  pty reattaches if the OS is Win7.
2022-05-15 07:25:56 +09:00
Corinna Vinschen 8f66bc28ae Cygwin: fix new sigfe.o generation in optimized case
Commit 0597c84b9b ("Cygwin: revamp TLS offsets computation")
introduced a really weird problem when building Cygwin with
optimization.

First of all, the tlsoffsets file is broken with -O2.  This
can easily be fixed by running the compiler with -O0 when called
from the gentls_offsets script.

But it gets worse:

When creating sigfe.o with optimization, the generated machine code
uses incorrect offsets: For some reason the assembler codes using
_cygtls.stackptr as offset value are assembled into machine code
using _cygtls.pstackptr as offsets.

And as if that isn't already absurd enough, renaming _cygtls.pstackptr
to, say, _cygtls.blurb, fixes the assembled machine code expressions;
they use the value of _cygtls.stackptr again.

So I changed gentls_offsets and gendef to use _cygtls.foo_p rather
than _cygtls.pfoo and that fixes the assembled code in the optimized
case.

No, I can't explain that.  There's no system in that behaviour.
It looks absolutely crazy.

Fixes: 0597c84b9b ("Cygwin: revamp TLS offsets computation")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 21:22:44 +02:00
Corinna Vinschen 4f034daba7 Cygwin: utils: drop unnecessary wow64 checks
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:34:20 +02:00
Corinna Vinschen d4df9c6de1 Cygwin: drop a few minor references to WOW64
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:32:21 +02:00
Corinna Vinschen 974163bc18 Cygwin: wincap: drop has_gaa_largeaddress_bug flag and related code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:31:29 +02:00
Corinna Vinschen bf6940a413 Cygwin: wincap: drop has_broken_prefetchvm flag and related code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:30:11 +02:00
Corinna Vinschen 24363cffef Cygwin: drop system_wow64_directory and related code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:28:49 +02:00
Corinna Vinschen ca313dd8f4 Cygwin: drop create_token and dependent functions
Given we only called create_token on W7 WOW64 anyway, we can now
drop this function and all other functions only called from there
entirely.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:21:52 +02:00
Corinna Vinschen a70a969c64 Cygwin: wincap: drop no_msv1_0_s4u_logon_in_wow64 flag and related code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:20:42 +02:00
Corinna Vinschen 0f4eb70ee7 Cygwin: wincap: set def_guard_pages to x86_64 value right away
Drop conditional code in wincapc::init.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:18:57 +02:00
Corinna Vinschen 2610b681a4 Cygwin: wincap: drop wow64 flag and all conditions depending on it
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:15:47 +02:00
Corinna Vinschen 0597c84b9b Cygwin: revamp TLS offsets computation
- convert gentls_offsets to a shell script, only running the target
  compiler and gawk.

- Simplify cygtls.h.  The new gentls_offsets script only requires two
  lines with the "public:" keyword as markers.  The comments are not
  used anymore, the output is a preprocesses file without comments.
  Align Makefile rules accordingly.

- Rather than generating perl variables and C #defines, just generate
  .ecu statements and .include the TLS offsets file right from the
  generated assembler file sigfe.s.  It's the only place we really
  need (some of) the offsets.

- Drop the target-specific name of the TLS offsets file and generate
  it on the fly in the build dir.  Fix configure and Makefile rules
  accordingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:11:58 +02:00
Corinna Vinschen c0d5bb262d Cygwin: configure: Define default valus for target specific variables
Define default values for DLL_ENTRY, DIN_FILE, and TLSOFFSETS_H
and drop them from the x86_64-specific branch.  Keep the mechanism
intact to allow other target CPUs if there ever will be.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 14:00:52 +02:00
Corinna Vinschen d4fa3b4abb Cygwin: config.h: stop including auto-generated tlsoffsets.h file
This was a hack to begin with.  Clean this mess up:

- Move definition of CYGTLS_PADSIZE to cygwin/config.h and drop
  local cygtls_padsize.h
- Rename CYGTLS_PADSIZE to __CYGTLS_PADSIZE__ to keep namespace
  clean.  Redefine as macro, rather than as const.
- Move struct _reent first in struct _cygtls to allow using
  __CYGTLS_PADSIZE__ as offset in __getreent().

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 13:58:39 +02:00
Corinna Vinschen 2aa37fed76 Cygwin: drop i686-only files
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 13:45:45 +02:00
Corinna Vinschen e0df580bf9 Cygwin: configure: drop unused DEF_DLL_ENTRY variable
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-13 13:42:54 +02:00
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
Takashi Yano 7c87cce6e2 Cygwin: pty: Adopt the variable name to the name generally used.
- Generally, '\n' is called "line feed" (not "new line"), so the
  variable name p_nl has been changed to p_lf.
2022-03-05 09:39:26 +09:00
Takashi Yano 6c622490a5 Cygwin: pty: Add several further comments to the pty code. 2022-03-05 08:39:05 +09:00
Takashi Yano 21860254da Cygwin: pty: Take account of CR+NL line feed in input.
- Currently, individual CR or NL is treated as line feed in
  accept_input() and transfer_input(). This patch takes account
  of CR+NL as well.
2022-03-05 00:29:11 +09:00
Takashi Yano 51095fe2ba Cygwin: pty: Fix a possible race issue in initialization of pcon.
- Currently, tty::pcon_start flag is cleared before transfer_input()
  in master::write(), however, the code in setup_pseudoconsole()
  waits for transfer_input() using tty::pcon_start. This possibly
  causes the race issue. The patch fixes this potential issue.
2022-03-04 22:23:39 +09:00
Takashi Yano 3d46583d4f Cygwin: pty: Update some comments in pty code. 2022-03-04 22:00:24 +09:00
Takashi Yano bb98c26e16 Cygwin: pty: Omit transfer_input() call where it is no longer needed.
- This patch removes the old code which calls transfer_input() but
  is no longer needed. These code was necessary indeed in the past,
  however, as a result of recent frequent code changes, it is no
  longer needed.
2022-03-04 20:04:24 +09:00
Takashi Yano e93c7cb571 Cygwin: pty: Rearrange reset_switch_to_nat_pipe() calls.
- Previously, reset_switch_to_nat_pipe() is called from many places
  in pty code. This patch reorganizes that. With this patch, it is
  called only from bg_check() and setpgid_aux(). The calls which
  does not have enough reason have been omitted.
2022-03-04 20:04:15 +09:00
Takashi Yano a263b94b5e Cygwin: pty: Treat both CR and NL as line feed in transfer_inpup().
- To make read() work properly in canonical mode, writing to the pty
  pipe should be done line by line. However, only CR was treated as
  line separator previously in transfer_input(). This patch fixes
  the issue.
2022-03-04 20:04:02 +09:00
Takashi Yano 261acf7318 Cygwin: pty: Stop to use PID_NEW_PG flag as a marker for GDB.
- Previously, the PID_NEW_PG flag was also used as a marker for GDB
  with non-cygwin inferior, unlike its original meaning. With this
  patch, the condition exec_dwProcessId == dwProcessId is used as a
  marker for that instead.
2022-03-04 03:18:30 +09:00
Takashi Yano efd153853c Cygwin: pty: Simplify the setup code for GDB a bit.
- This patch omits the unnecessary code path for setup for GDB.
2022-03-04 03:17:03 +09:00
Takashi Yano d6b778617d Cygwin: pty: Rename nat_pipe_owner_alive() to process_alive().
- The function nat_pipe_owner_alive() is used even for the process
  which is not a nat pipe owner, so, it is renamed to process_alive().
2022-03-04 03:16:52 +09:00
Corinna Vinschen 35ba7d147d Cygwin: getconf: align -a output to glibc getconf
glibc getconf doesn't print "undefined" for undefined values
in -a output.  It just prints the empty string.  Do it the
same way.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-02 22:15:02 +01:00
Corinna Vinschen fcec4830ab Cygwin: sysconf: don't set errno for unsupported options
We return -1 with errno set to EINVAL for sysconf options for
values required by POSIX, but not implemented on Cygwin.
This is incorrect.  Return -1, but don't set errno for these options.
Drop the "nsup" enum to indicate unsupported values, it's not
required anymore.

Fixes: 59e3b6ca7d (CVS import)
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-02 22:02:59 +01:00
Corinna Vinschen cf00bba99a Cygwin: sysconf: belatedly add correct return value for _SC_DELAYTIMER_MAX
When adding the timer_getoverrun function, DELAYTIMER_MAX was added
to limits.h, but the return value of sysconf(_SC_DELAYTIMER_MAX) wasn't
changed accordingly.  Fix that now.

Fixes: 9e295a8d19 ("Cygwin: posix timers: implement timer_getoverrun")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-02 22:02:44 +01:00
Takashi Yano 2b3a70d0a6 Cygwin: pty: Add still missing acquire/release_attach_mutex.
- transfer_input() function uses console api, so it should be guarded
  by attach_mutex. However, in most cases, it is missing. This patch
  fixes the issue.
2022-03-03 04:41:20 +09:00
Takashi Yano df24c3d3c6 Cygwin: pty: Communalize the code for temporary attach to console.
- This patch communalizes the code for attaching another console
  temporarily and resuming to the original attach state, because
  there were a plurality of similar codes throughout.
2022-03-02 21:35:40 +09:00
Takashi Yano 5f4e7b0368 Cygwin: console, pty: Revamp the acquire/release_attach_mutex timing.
- This patch revises the acquiring/releasing timing for attach_mutex
  to make the period in which it is being acquired shorter. Further,
  acquiring/releasing are added to where they are missing but needed.
2022-03-02 19:20:48 +09:00
Corinna Vinschen 42e23c5ad2 Cygwin: _pinfo::siginfo: fix sig_send call
Request __SIGPENDINGALL, not __SIGPENDING, when fetching signal info
for the calling process.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-02 09:48:01 +01:00
Takashi Yano 312dc2289c Cygwin: console: Fix a bug from comparison between int and DWORD. 2022-03-02 11:18:01 +09:00
Takashi Yano 020fa7ed7b Cygwin: console: Prevent special keys processing from drop.
- There was a potential risk to drop special key processing when
  process_input_messsage() is called intermittently. This patch
  fixes the issue.
2022-03-02 09:55:52 +09:00
Takashi Yano 2b4d4728f2 Cygwin: console: Stop to create struct instance which is not needed.
- In fhandler_console::cons_master_thread(), a struct which has
  only a static function is used. In this case, struct instance
  is not necessary. So with this patch, the static function is
  invoked without creating instance.
2022-03-02 08:47:03 +09:00
Corinna Vinschen 3e4dd6cc48 Cygwin: update 3.4 release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:27:10 +01:00
Corinna Vinschen 9a3c058f66 Cygwin: /proc/<PID>/status: Fill SigPnd, SigBlk and SigIgn values with life
So far the values of SigPnd and SigBlk were always 0 and SigIgn
was incorrectly set to the block mask of the current thread of
the calling process.

Fix that by adding a _pinfo::siginfo method and a PICOM_SIGINFO
message to allow to request actual signal info of any running process.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 195169186b Cygwin: wait_sig: allow to compute process-wide mask of pending signals
Add a signal __SIGPENDINGALL to allow computing the mask of all
currently pending signals.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 05e7a60dd7 Cygwin: add init_cygheap::compute_sigblkmask method
Add method to compute process-wide signal block mask

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 9551e617e7 Cygwin: Makefile: fix ctags --extras option
--extra is deprectated, use --extras

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen c78f149733 Cygwin: handle_sigprocmask: If new signal set is NULL, ignore "how"
The "how" value only makes sense if a new set is given.  If we
only read the current signal set, ignore the value of "how" per
POSIX:

"If set is a null pointer, the value of the argument how is not
significant"

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Corinna Vinschen 25937aa1d0 Cygwin: /proc/<PID>/status: fix format specifier
The format specifier used for the signal masks is incorrectly
assuming 32 bit values.  Fix it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 16:23:24 +01:00
Takashi Yano aec053c60c Cygwin: pty: Rename some functions/variables with the name *pcon*.
- With this patch, some pty functions/variables have been renamed
  so that the name *pcon* is not used for those that are called
  even when the pseudo console is not active.
2022-03-01 22:09:01 +09:00
Corinna Vinschen 3e11a002b3 Cygwin: sysconf: _SC_TZNAME_MAX: return -1 as valid value
sysconf incorrectly sets errno to EINVAL for _SC_TZNAME_MAX.
Don't do that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-03-01 11:43:52 +01:00
Takashi Yano 1e6c51d741 Cygwin: pty: Reorganize the code path of setting up and closing pcon.
- This patch reorganizes the code path of setting-up and cleaning-up
  of the pseudo console to improve readability and maintainability
  of pty code.
2022-03-01 19:40:55 +09:00
Takashi Yano fbfea31dd9 Cygwin: pty: Avoid cutting the branch the pty master is sitting on.
- When Ctrl-C terminates a non-cygwin process on a pseudo console,
  pty master attaches to the pseudo console first, and send
  CTRL_C_EVENT. If the non-cygwin process closes the pseudo console
  before the pty master calls FreeConsole(), the pty master process
  will crash. With this patch, pty master process takes over the
  ownership of the pseudo console, and closes it by myself.
2022-03-01 19:40:46 +09:00
Takashi Yano 95a28b1f9e Cygwin: pty: Isolate CTRL_C_EVENTs between ptys.
- With this patch, unique invisible consoles are created for each pty
  to isolate CTRL_C_EVENTs between ptys. This is necessary by Ctrl-C
  handling in fhandler_termios::process_sigs() for non-cygwin apps
  started in pty if the pseudo console is disabled.
2022-02-28 20:25:09 +09:00
Takashi Yano 8ff9f216fd Cygwin: console: Improve the code to avoid typeahead key swapping.
- The commit "Cygwin: console: Prevent the order of typeahead input
  from swapped." did not fully resolve the issue. If keys are typed
  during input buffer fix, the order of key event may be swapped.
  This patch fixes the issue again.
2022-02-28 20:17:12 +09:00
Takashi Yano f6db6f52ae Cygwin: pinfo: Fix exit code for non-cygwin apps which reads console.
- The recent commit "Cygwin: pinfo: Fix exit code when non-cygwin app
  exits by Ctrl-C." did not fix enough the issue. If a non-cygwin app
  is reading the console, it will not return STATUS_CONTROL_C_EXIT
  even if it is terminated by Ctrl-C. As a result, the previous patch
  does not take effect.
  This patch solves this issue by setting sigExeced to SIGINT in
  ctrl_c_handler(). In addition, sigExeced will be cleared if the app
  does not terminated within predetermined time period. The reason is
  that the app does not seem to be terminated by the signal sigExeced.
2022-02-28 20:10:02 +09:00
Takashi Yano 15a35758d8 Cygwin: termios: Ensure detection of GDB inferior in process_sigs().
- In some situations, some cygwin processes might wrongly identified
  as GDB inferior. This patch ensures the detection of GDB inferior.
2022-02-28 08:00:16 +09:00
Takashi Yano 33d8578feb Cygwin: termios: Add comments to the code refactored recently.
- This patch adds some comments to the source code whose intent may
  not be clear enough from the code which is refactored recently.
2022-02-27 20:50:53 +09:00
Takashi Yano d857df6f08 Cygwin: console: Correct the past fix for apps which open pty.
- The commit "Cygwin: console: Fix issues of apps which open pty."
  did not fix the second problem correctly. That commit looked to
  fix the issue, but the actual problem was that ctrl_c_handler()
  should be reregistered *AFTER* FreeConsole()/AttachConsole().
  This patch correct that.
2022-02-27 12:46:05 +09:00
Takashi Yano 696a713bf2 Cygwin: console: Revert experimental code mixed accidentally.
- The commit "Cygwin: console: Restore CTRL_BREAK_EVENT handling."
  was accidentally mixed with experimental code in exceptions.cc.
  Due to this, non-cygwin app receives CTRL_C_EVENT twice in the
  following scenario.
   1) Run 'sleep 10 | <non-cygwin app>'
   2) Hit Ctrl-C.
   3) The non-cygwin app receives CTRL_C_EVENT twice.
  This patch reverts the code with the problem.
2022-02-27 00:34:30 +09:00
Takashi Yano 95a60b7fdd Cygwin: console: Prevent the order of typeahead input from swapped.
- If a lot of keys are typed very quickly in the app which does
  not read console, the order of input keys in console input buffer
  occasionally swapped. Although this extremely rarely happens,
  is obviously a bug of cons_master_thread. This patch fixes the
  issue.
2022-02-26 15:59:54 +09:00
Takashi Yano e9d4341677 Cygwin: pty: Stop to send CTRL_C_EVENT if pcon activated.
- The commit "Cygwin: console: Redesign handling of special keys."
  removes special treatment for pty in with pseudo console activated,
  however, it is necessary on second thought. This is because sending
  CTRL_C_EVENT to non-cygwin apps will be done in pseudo console,
  therefore, sending it in fhandler_pty_master::write() duplicates
  that event for non-cygwin apps.
2022-02-26 15:59:32 +09:00
Takashi Yano 32401ad98e Cygwin: console: Fix issues of apps which open pty.
- After some recent changes for special keys handling break the
  apps which open pty (such as script command). If the app which
  opens pty is executed in console, the following issues occur.
    1) If the script command was started from non-cygwin shell
       (such as cmd.exe), another cygwin app started in pty slave
       cannot receive Ctrl-C.
    2) If non-cygwin app is executed in pty slave, the app which
       opened the pty (e.g. script command) crashes by Ctrl-C.
  This patch fixes these issues.
2022-02-26 15:59:20 +09:00
Takashi Yano 3a6b11c697 Cygwin: pinfo: Fix exit code when non-cygwin app exits by Ctrl-C.
- Previously, if non-cygwin app exits by Ctrl-C, exit code was
  0x00007f00. With this patch, the exit code will be 0x00000002,
  which means process exited by SIGINT.
2022-02-25 17:29:28 +09:00
Takashi Yano 5c4a0824e7 Cygwin: console: Restore CTRL_BREAK_EVENT handling.
- The recent change by the commit "Cygwin: console: Redesign handling
  of special keys." breaks the handling of CTRL_BREAK_EVENT. The login
  shell in console exits on Ctrl-Break key. This patch fixes the issue.
2022-02-24 17:35:21 +09:00
Takashi Yano 2f2b915505 Cygwin: pty, console: Add a workaround for GDB SIGINT handling.
- The inferior of the GDB cannot be continued after SIGINT even
  though nopass option is set. This seems because cygwin GDB does
  not support hooking cygwin signal. Therefore, a workaround for
  GDB is added. With this patch, only CTRL_C_EVENT is sent to the
  GDB inferior by Ctrl-C and sending SIGINT is omitted. Note that
  "handle SIGINT (no)pass" command does not take effect even with
  or without this patch.
2022-02-24 02:17:32 +09:00
Takashi Yano d2b14c303c Cygwin: console: Redesign handling of special keys.
- This patch rearranges the cooperation between cons_master_thread,
  line_edit, and ctrl_c_handler so that only one of them operates
  at the same time. Since these handle Ctrl-C individually, so the
  signal may be sent multiple times to the process. This patch fixes
  the issue.
2022-02-24 01:38:08 +09:00
Corinna Vinschen f2dc492df0 Cygwin: unlink: filter out virtual files and devices early on
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-22 13:33:06 +01:00
Johannes Schindelin 4ec08891a0 Cygwin: Implicitly support the /dev/fd symlink and friends
Bash has a very convenient feature that is called process substitution
(e.g. `diff -u <(seq 0 10) <(seq 1 11)`). To make this work, Bash
requires the `/dev/fd` symlink to exist, and Cygwin therefore creates
this symlink (together with the `stdin`, `stdout` and `stderr` ones)
upon start-up.

This strategy is incompatible with the idea of providing a subset of
Cygwin in a `.zip` file (because there is no standard way to represent
symlinks in `.zip` files, and besides, older Windows versions would
potentially lack support for them anyway).

That type of `.zip` file is what Git for Windows wants to use, though,
bundling a minimal subset for third-party applications in MinGit (see
https://github.com/git-for-windows/git/wiki/MinGit for details).

Let's side-step this problem completely by creating those symlinks
implicitly, similar to the way `/dev/` is populated with special
devices.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2022-02-22 13:33:00 +01:00
Corinna Vinschen 8bb6821c7a Cygwin: Adjust path to newlib libc.a, too
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-22 12:49:33 +01:00
Jon Turney 56ec1fcb0d Cygwin: Adjust path to newlib libm.a in builddir
Adjust path to newlib libm.a in builddir, changed by ac9f8c46
2022-02-22 12:49:33 +01:00
Matt Joyce 44b60f0c4b Make __sdidinit unused
Remove dependency on __sdidinit member of struct _reent to check
object initialization. Like __sdidinit, the __cleanup member of
struct _reent is initialized in the __sinit() function. Checking
initialization against __cleanup serves the same purpose and will
reduce overhead in the __sfp() function in a follow up patch.
2022-02-22 12:38:46 +01:00
Takashi Yano 054b00d96a Cygwin: pty: Encapsulate pty code in tty::setpgid().
- This patch hides complex pty codes in tty::setpgid() to transfer
  input into the class fhandler_pty_slave by encapsulating it.
2022-02-22 07:33:09 +09:00
Takashi Yano 0ddf19d6ca Cygwin: pty, console: Fix handle leak which occurs on exec() error.
- This patch fixes the handle leak which occurs when exec() fails
  with an error. The duplicated handles will be closed when the
  exec'ed process is terminated. However, if exec() fails, the code
  path does not reach to the code closing the duplicated handles.
  To implement this fix more appropriately, the setup, cleanup and
  closing pty codes which was previously located in spawn.cc are
  encapsulated into the fhandler_pty_slave class functions.
2022-02-22 07:26:34 +09:00
Takashi Yano fc26624377 Cygwin: console: Call fix_tab_position() only if having broken tabs.
- Calling fix_tab_position() is necessary in Windows 10 with xterm
  compatible mode enabled, because it has a problem that the tab
  positions will be broken when the window size is changed. Fortunately,
  this problem has been fixed in Windows 11. Therefore, with this patch,
  necessity of fix_tab_position() call is determined by referring to
  wincap.has_con_broken_tabs(), which is recently introduced.
2022-02-20 19:22:09 +09:00
Takashi Yano 29d8a83008 Cygwin: console: Rearrange set_(in|out)put_mode() calls.
- With this patch, all set_(in|out)put_mode() calls are rearranged
  as follows.

  1) Setup for cygwin apps, started from non-cygwin app, is done
     in fhandler_console::post_open_setup(), which overrides
     fhandler_base::post_open_setup() called from dtable.cc.
  2) Cleanup for cygwin app is done in fhandler_console::close().
  3) Setup for cygwin apps is also in fhandler_console::bg_check(),
     which overrides fhandler_termios::bg_check(). This is called
     on read(), write() and select() for console. It is necessary
     if cygwin and non-cygwin apps are started simultaneously in
     the same process group.
  4) Setup for non-cygwin apps is done in spawn.cc via
     fhandler_console::setup_console_for_non_cygwin_app().
  5) Cleanup for non-cygwin app is done in spawn.cc vid
     fhandler_console::cleanup_console_for_non_cygwin_app().
  6) Setup for non-cygwin app started by GDB is done in
     fhandler_console::set_console_mode_to_native().
  7) No explicit cleanup for non-cygwin app started by GDB, because
     console mode is automatically reset to tty::cygwin on read()/
     write() in GDB thanks to 3).
2022-02-20 19:22:02 +09:00
Takashi Yano 2cab4d0bb4 Cygwin: pty, console: Refactor the code processing special keys.
- This patch commonize the code which processes special keys in pty
  and console to improve maintanancibility. As a result, some small
  bugs have been fixed.
2022-02-20 19:21:51 +09:00
Takashi Yano 9f1930bf34 Cygwin: wincap: Add capabilities for Windows 11.
- The capability changes since Windows 11 have been reflected in
  wincap.cc. The capability has_con_broken_tabs is added, which is
  false since Windows 11.
2022-02-16 19:59:14 +09:00
Brian Inglis 97b8a93b3c fhandler_proc.cc(format_proc_cpuinfo): fix bad bits in last change
move Linux 5.16 Gobble Gobble flags to 5.17 Superb Owl correct positions:
0x00000007:1 Intel Advanced Matrix eXtensions:
		 EAX:22 amx_bf16 Brain Float 16 dot product
		 EAX:24 amx_tile Tile matrix multiply
		 EAX:25 amx_int8 Int 8 byte dot product
0x00000007:0 Intel Advanced Matrix eXtensions:
		 EDX:22 amx_bf16 Brain Float 16 dot product
		 EDX:24 amx_tile Tile matrix multiply
		 EDX:25 amx_int8 Int 8 byte dot product
2022-02-16 09:31:32 +01:00
Takashi Yano dd65342315 Cygwin: console: Set console mode even if stdin/stdout is redirected.
- When non-cygwin app is started in console, console mode is set to
  tty::native. However, if stdin is redirected, current code does not
  set the input mode of the console. In this case, if the app opens
  "CONIN$", the console mode will not be appropriate for non-cygwin
  app. This patch fixes the issue.

Addresses:
https://github.com/GitCredentialManager/git-credential-manager/issues/576
2022-02-13 23:55:59 +09:00
Takashi Yano cb0e392903 Cygwin: console: Fix console mode for non-cygwin inferior of GDB.
- Currently, there is no chance to change console mode for non-cygwin
  inferior of GDB. With this patch, the console mode is changed to
  tty::native in CreateProcess() and ContinueDebugEvent() hooked in
  fhandler_console.
2022-02-13 23:55:59 +09:00
Takashi Yano bed1add783 Cygwin: pty: Fix a bug in tty_min::segpgid().
- In tty_min::setpgid(), a pointer to fhandler instance is casted to
  fhandler_pty_slave and accessed even if terminal is not a pty slave.
  This patch fixes the issue.
2022-02-13 23:55:59 +09:00
Takashi Yano c4704c7c20 Cygwin: pty: Discard input in from_master_nat pipe on signal as well.
- Currently, pty discards input only in from_master pipe on signal.
  Due to this, if pty is started without pseudo console support and
  start a non-cygwin process from cmd.exe, type adhead input is not
  discarded on signals such as Ctrl-C. This patch fixes the issue.
2022-02-13 23:55:59 +09:00
Takashi Yano b958e1f03a Cygwin: pty: Revise the code to wait for completion of forwarding.
- With this patch, the code to wait for completion of forwarding of
  output from non-cygwin app is revised so that it can more reliably
  detect the completion.
2022-02-13 23:55:59 +09:00
Takashi Yano bddd9c1c41 Cygwin: pty: Prevent deadlock on echo output.
- If the slave process writes a lot of text output, doecho() can
  cause deadlock. This is because output_mutex is held in slave::
  write() and if WriteFile() is blocked due to pipe full, doecho()
  tries to acquire output_mutex and gets into deadlock. With this
  patch, the deadlock is prevented on the sacrifice of atomicity
  of doecho().
2022-02-13 23:55:59 +09:00
Takashi Yano b04aea00f1 Cygwin: pty: Pass Ctrl-Z (EOF) to non-cygwin apps with disable_pcon.
- Previously, non-cygwin app running in pty started without pseudo
  console support was suspended by Ctrl-Z rather than sending EOF.
  Even worse, suspended app could not be resumed by fg command. With
  this patch, Ctrl-Z (EOF for non-cygwin apps) is passed to non-cygwin
  app instead of suspending that app. This patch also handles Ctrl-\
  (QUIT) and Ctrl-D (EOF) as well.
2022-02-13 23:55:59 +09:00
Takashi Yano c05c36a7c8 Cygwin: pty, console: Fix Ctrl-C handling for non-cygwin apps.
- Currently, if cat is started from cmd.exe which is started in cygwin
  console, Ctrl-C terminates not only cat but also cmd.exe. This also
  happens in pty in which pseudo console is disabled. This patch fixes
  the issue.
2022-02-13 23:55:59 +09:00
Mitchell Hentges 8a95249d73 Cygwin: console: Maintain ENABLE_(INSERT|QUICK_EDIT)_MODE flags.
- Currently, ENABLE_INSERT_MODE and ENABLE_QUICK_EDIT_MODE are cleared
  if cygwin is started in console. These flags will not be recovered
  even when exiting from cygwin. Also note that if ENABLE_EXTENDED_FLAGS
  is once unset, then the flag ENABLE_QUICK_EDIT_MODE it's associated
  with will no longer be preserved. Unfortunately, we're accidentally
  stepping on this in fhandler_console::set_input_mode().

  This patch solves this by carrying forward these flags in the place
  where it had been ignoring them. Since the previous behaviour of
  leaving these flags unset would essentially maintain their existing
  state, adding the carry-over of the flags now should not alter console
  behaviour.
2022-02-11 09:07:30 +09:00
Takashi Yano 7e6422fd2a Cygwin: wincap: Add capabilities for Windows 10 2004 and newer.
- The capability changes since Windows 10 2004 have been reflected
  in wincap.cc. (has_con_broken_il_dl has been changed to false.)
2022-02-05 19:28:34 +09:00
Corinna Vinschen c3efc81658 Cygwin: drop dllfixdbg script
On second thought, we don't actually need this script.
Express the entire action as sufficiently simple Makefile rule.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-05 10:42:27 +01:00
Takashi Yano 44d8704179 Cygwin: console: Remove unnecessary (redundant) code. 2022-02-05 16:55:12 +09:00
Corinna Vinschen 899cf3c952 Cygwin: fix dependency to dllfixdbg script
Only the files created from cygwin0.dll depend on the script, not
cygwin0.dll as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-04 18:27:14 +01:00
Corinna Vinschen 820c736785 Cygwin: dllfixdbg: improve readability
- formatting
- use array pointer as argument rather than variable arguments
- syntactical fixes
- add comments
- drop unnecessary recomputation of all section VMAs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-04 18:27:14 +01:00
Corinna Vinschen 4aeba49016 Cygwin: dllfixdbg: honor Makefile verbositiy flag "V"
In Makefile.am, add the value of $(V) to the dllfixdbg call.
In dllfixdbg, if V=1, print what the script is doing.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-03 16:22:46 +01:00
Corinna Vinschen 7ae91f3b56 Cygwin: dllfixdbg: don't overwrite input DLL
Change dllfixdbg to keep the input DLL intact and just generate
a new DLL matching the debug file.  Fix Makefile rule accordingly.
The result is, cygwin0.dll is the original DLL created with full
debug sections and stays that way throughout the build process.
Only new-cygwin1.dll will become the stripped DLL matching with
the file containing the debug sections cygwin1.dbg.  This is ok,
because commit ba02fef995 ("Cygwin: Makefile.am: fix DLL build rule")
made new-cygwin1.dll the DLL to be installed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-03 16:22:46 +01:00
Takashi Yano 96646006a7 Cygwin: console: Fix IL/DL escape sequence on the last line.
- Currently, escape sequence IL/DL (CSI Ps L, CSI Ps M) does not
  work correctly at the last (bottom end) line. This patch fixes
  the issue.

Addresses:
  https://cygwin.com/pipermail/cygwin/2022-February/250736.html
2022-02-03 21:09:44 +09:00
Takashi Yano e5aca9ced9 Cygwin: path: Fix UNC path handling for SMB3 mounted to a drive.
- If an UNC path is mounted to a drive using SMB3.11, accessing to
  the drive fails with error "Too many levels of symbolic links."
  This patch fixes the issue.
2022-02-03 12:21:21 +09:00
Corinna Vinschen 4a70041dfd Cygwin: silence dllfixdbg
There's no good reason to print the objcopy generation rules

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-02 21:30:20 +01:00
Corinna Vinschen ba02fef995 Cygwin: Makefile.am: fix DLL build rule
A single Makefile rule creates three files in three steps, the second
and third one never showing up in dependencies.  The next step creating
the link lib only depends on the first of these files.  Even if the
second or third step in the DLL build rule fails, the next make
invocation never picks up on this and just goes ahead creating the
link lib.

Fix this by splitting the DLL build rule into three rules, with
every step on the way depending on the previous rule.  Also fix up
the names, TEST_DLL_NAME just doesn't cut it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-02-02 21:30:20 +01:00
Corinna Vinschen 047eaf9a6b Cygwin: drop autoloading kernel32 symbols available since Windows 7
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-28 10:36:54 +01:00
Corinna Vinschen d079ab4d37 Revert "Cygwin: fix permission problem when writing DAC info on Samba shares"
This reverts commit 0390cc8572.

There's no indication what exact situation this patch was supposed to
solve, and local testing doesn't show any such problems.  However, this
patch itself introduced a new problem, as outlined by
https://cygwin.com/pipermail/cygwin/2022-January/250629.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-27 15:31:25 +01:00
Corinna Vinschen f467a1da58 Cygwin: ACLs: don't set indicator for default ACEs prematurely
Commit a2bfe7cae6 introduced a change ignoring default ACEs on files
to come up with a valid POSIX ACL, reflecting the Windows ACEs actually
making sense on files.

However, if CREATOR OWNER or CREATOR GROUP ACEs - both only making sense
as default ACEs - are found in the ACL, a value indicating the presence
of default ACEs gets set, even on files.  This in turn breaks a
subsequent integrity check and get_posix_access returns EINVAL.

The code path handling default ACEs on directories sets this indicator
anyway, so don't set it just because one of the above SIDs are found.

Fixes: a2bfe7cae6 ("Cygwin: ACLs: ignore *_INHERIT flags in file ACLs")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-01-25 19:53:40 +01:00