Commit Graph

20972 Commits

Author SHA1 Message Date
Corinna Vinschen 53ea7b2d5a Cygwin: drop unused local declaration of fopen64
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-08 13:04:03 +01:00
Corinna Vinschen 4949a82cde Cygwin: uname: fix building in non-git source dir
commit 97eb64b909 broke building outside of a git dir, because
the git describe command would fail.  Fix this by checking if
we're in a git tree at all and just generate an empty string
as version string.  Use this in uname_x to generate a fallback
version.

Fixes: 97eb64b909 ("Cygwin: uname: generate default release
string from git as well"
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-07 22:22:38 +01:00
Corinna Vinschen 97eb64b909 Cygwin: uname: generate default release string from git as well
When building a release with cygport, we get uname version info
from cygport, which in turn gets version info from `git describe'.

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

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

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-07 21:30:23 +01:00
Corinna Vinschen 792b1c6a6d Cygwin: add missing pragma
Add missing "#pragma GCC diagnostic push" to the pragma bracket
guarding the srandom call.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-07 21:18:24 +01:00
Alexey Lapshin 0b09753a3f libc: fix fropen/fwopen compile warnings
This patch fixes warnings that appears when compiling:

#define fwopen(__cookie,__fn) funopen(__cookie, (int (*)())0, __fn,
(fpos_t (*)())0, (int (*)())0)
Expands to:

funopen(__null, (int (*)())0, &app_printf, (fpos_t (*)())0, (int
(*)())0)
argument of type "int (*)()" is incompatible with parameter of type
"int (*)(void *__cookie, char *__buf, int __n)"C/C++(167)
invalid conversion from 'fpos_t (*)()' {aka 'long int (*)()'} to
'fpos_t (*)(void*, fpos_t, int)' {aka 'long int (*)(void*,

Discussion is here:
https://github.com/espressif/arduino-esp32/issues/7407
2022-12-07 13:10:24 +01:00
Corinna Vinschen 95f5b0a620 Cygwin: link mcountFunc.o to libgmon.a
Commit 188d5f6c9a erroneously moved the mcountFunc.S file to the
TARGET_FILES target, rather than keeping it in GMON_FILES.  The
result is that the __fentry__ entry point is now entirely undefined,
so `gcc -pg' is broken.

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

Fixes: 188d5f6c9a ("Cygwin: x86_64: add wmemset assembler entry point")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-07 12:28:33 +01:00
Corinna Vinschen e9d843ec74 Cygwin: Add 3.5.0 release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-07 12:19:49 +01:00
Corinna Vinschen a3ae2a7348 Cygwin: don't autoload some kernel32 functions
DiscardVirtualMemory, PrefetchVirtualMemory and
GetSystemTimePreciseAsFileTime are available since
Windows 8.1.  Merge PseudoConsole functions into
kernel32 function block.

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

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

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

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

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

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen ae2829a226 Cygwin: drop wincap::mmap_storage_high
Only required for Windows 7 and Windows 8.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen 8af023a357 Cygwin: drop wincap::cons_need_small_input_record_buf
Only required for Windows 7.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen 08cd9cfc5c Cygwin: drop wincap::has_broken_attach_console
Only required for Windows 7.

This in turn allows to drop the helper_pid and related
methods from fhandler_pty_common.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen 4e40b21464 Cygwin: drop wincap::has_query_process_handle_info
Only required for Windows 7.

This allows to remove fhandler_pipe::get_query_hdl_per_system(),
too.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen c3c71e39f9 Cygwin: drop wincap::has_broken_whoami
Unused for some time. Was only required for Windows 7 anyway.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen 5478c5a9ec Cygwin: drop wincap::has_microsoft_accounts
Only required for Windows 7.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen 70d77662f5 Cygwin: drop wincap::has_precise_system_time
Only required for Windows 7.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen 48953788b3 Cygwin: drop wincap::needs_query_information
Only required for Windows 7 and 8.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 14:01:41 +01:00
Corinna Vinschen b541558b7a Cygwin: bump DLL version to 3.5.0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-04 13:51:30 +01:00
Corinna Vinschen 07a9a6c21a Cygwin: add release message for commit previous commit 8d138c3f66
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-03 16:36:49 +01:00
Corinna Vinschen 8d138c3f66 Cygwin: fix LC_CTYPE in global locale to be a real C.UTF-8 locale
https://cygwin.com/pipermail/cygwin/2022-December/252571.html

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

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

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

Fixes: a6a477fa81 ("POSIX-1.2008 per-thread locales, groundwork part 1")
Co-Authored-By: Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-03 16:16:30 +01:00
Corinna Vinschen b6fcdd03ed Cygwin: add latest primary group changes to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-03 16:12:49 +01:00
Corinna Vinschen cf65cbcea4 Cygwin: FAQ: convert ulinks to FAQ to xrefs
Using ulinks here makes the result work on cygwin.com only, while
xrefs to FAQs are creating realtive links.  Add xreflabel where
appropriate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-02 22:38:47 +01:00
Corinna Vinschen 08f33e5b6a Cygwin: FAQ: describe test releases, deprecate developer snapshots
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-02 21:54:19 +01:00
Corinna Vinschen a5bcfe616c Cygwin: uinfo: don't special case current user
fetch_account_from_windows shortcuts the current user in that
it takes the user's domain SID and just adds the matching RID
from the token's primary group to create a group SID.

How wrong this is can be very simply reproduced:

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

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

Fixes: 6cc7c925ce ("(pwdgrp::fetch_account_from_windows): Default primary group for the
current user to primary group from user token.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-02 16:49:47 +01:00
Corinna Vinschen dc7b67316d Cygwin: uinfo: prefer token primary group
internal_getlogin overwrites the process token primary group if it
differs from the primary group as stored in the passwd DB.

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

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

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

Fixes: 6cc7c925ce ("(internal_getlogin): Give primary group
from user token more weight.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-02 16:37:33 +01:00
Corinna Vinschen 3b37a11870 Cygwin: uinfo: Drop long disabled nss_prefix and nss_separator
Originally the code was written to allow three ways of prefixing
accounts and to freely define a domain/account separator.  This code
has been disabled even before being officially released, and it was
never re-enabled. Given there has been no complaints for eight years
now, drop this code eventually.  Just add a macro to define the
domain/account separator statically.

Fixes: cc332c9e27 ("(cygheap_pwdgrp::nss_init_line): Disable db_prefix
and db_separator settings.  Add comment")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-02 16:35:31 +01:00
Corinna Vinschen 30add3e6b3 Cygwin: exec: don't access cygheap before it's initialized
This is a long-standing thinko.

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

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

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

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

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

--> SEGV

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

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

Fixes: 3de7be4c1d ("* DevNotes: Add entry cgf-000007. [...]")
Fixes: 2f9b8ff00c ("Cygwin: decouple cygheap from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-01 22:34:53 +01:00
Corinna Vinschen e358f8d12f Cygwin: multiple_cygwin_problem: drop obsolete check for "cygheap"
After decoupling cygheap from the DLL loading address, the check
for a different _cygheap_start has gone.  So the matching string
check in multiple_cygwin_problem is obsolete now.

Fixes: 2f9b8ff00c ("Cygwin: decouple cygheap from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-01 21:20:53 +01:00
Carlo Bramini a263fe0b26 Cygwin: serial: Fix a copy-paste error in DTR setup
In commit 2dab880c96 I did a mistake when
I copied the new fhandler_serial::switch_modem_lines() from my modified
3.3.6 branch to the current master and I left a copy paste error. This
patch fixes that error.

Fixes: 2dab880c96 ("Cygwin: fix TIOCMBIS/TIOCMBIC not working when using usbser.sys")
2022-11-29 11:47:27 +01:00
Jon Turney 17761a8ef4
Cygwin: Update some mentions of x86 in documentation 2022-11-28 15:55:42 +00:00
Jon Turney 8080c85630
Cygwin: Fix typo in FAQ
The consonant in 'debug' is doubled in 'debuggee' just as it is in
'debugger'.

Fixes: 8c68a8a4
2022-11-28 15:17:52 +00:00
Takashi Yano 2e4ecbb3f0 Cygwin: pty: Rename fhandler/tty.cc to fhandler/pty.cc.
- Previously, we have two tty.cc, one is winsup/cygwin/tty.cc and
  the other is winsup/cygwin/fhandler/tty.cc. This is somewhat
  confusing. This patch renames fhandler/tty.cc to fhandler/pty.cc.
2022-11-25 09:33:27 +09:00
Corinna Vinschen afa957ae5b Cygwin: uname: allow to specify external release info
When creating regular Cygwin test releases we need a way to
automate unambiguous version information based on the output
of `git describe'.  Allow to inject a release string via a
preprocessor macro CYGPORT__RELEASE_INFO.  Change the default
release info to recognize a local, non-distro build.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-11-24 20:49:35 +01:00
Corinna Vinschen 244be41a1f Cygwin: drop snapshot handling
We're going to switch to regular test releases, rather than the
old, handcrafted snapshots method.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-11-24 12:20:50 +01:00
Tobias Burnus b7aca332ce amdgcn: Use __builtin_gcn_ in libc/machine/amdgcn/getreent.c
Call __builtin_gcn_get_stack_limit and __builtin_gcn_first_call_this_thread_p
to reduce dependency on some register/layout assumptions by using the new
GCC mainline (GCC 13) builtins, if they are available. If not, the existing
code is used.
2022-11-22 18:05:34 -05:00
Tobias Burnus b9898fc993 amdgcn: Replace asm("s8") by __builtin_gcn_kernarg_ptr if existing
Check whether __builtin_gcn_kernarg_ptr is available and, if it is,
call it instead using the hard-coded 'asm("s8")' in:
* newlib/libc/machine/amdgcn/exit-value.h (exit_with_int)
* newlib/libc/machine/amdgcn/mlock.c (sbrk)
* newlib/libc/sys/amdgcn/write.c (write)

 newlib/libc/machine/amdgcn/exit-value.h |  6 ++++++
 newlib/libc/machine/amdgcn/mlock.c      | 10 +++++++---
 newlib/libc/sys/amdgcn/write.c          |  4 ++++
 3 files changed, 17 insertions(+), 3 deletions(-)
2022-11-21 13:10:29 +01:00
Takashi Yano 32d6a6cb5f Cygwin: pty, console: Encapsulate spawn.cc code related to pty/console.
- The codes related to pty and console in spawn.cc have been moved
  into the new class fhandler_termios::spawn_worker, and make spawn.cc
  call them. The functionality has not been changed at all.
2022-11-20 10:37:37 +09:00
Jon Turney c03f0c3062
makedocbook: Fix false report of unhandled texinfo command
During 'make man', makedocbook falsely reports "texinfo command
'@modifier' remains in output" while processing the setlocal(3) manpage,
which contains that literal string.

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

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

Now we don't have false positives, we can make unrecognized texinfo
commands fatal to manpage generation, rather than leaving them verbatim
in the generated manpage.
2022-11-12 14:09:11 +00:00
Jon Turney 999925b253
makedocbook: Adjust inline whitespace to fix flake8 warnings 2022-11-12 14:09:10 +00:00
Jon Turney 2521dd48d8
makedocbook: Drop stray semicolons
This isn't written in C :)
2022-11-12 14:09:08 +00:00
Jon Turney 8b6c4249e2
makedocbook: Use sys.exit()
Use sys.exit() to write a message to stderr and terminate with a
non-zero exit code.
2022-11-12 14:09:07 +00:00
Jon Turney 2432d77099
makedocbook: Use raw strings for regexes
Use raw strings for regexes. This is best practice, and fixes a number
of "W605 invalid escape sequence" flakes.
2022-11-12 14:09:05 +00:00
Corinna Vinschen bd4bed1254 Cygwin: document bugfix for USB CDC devices
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-11-11 13:09:45 +01:00
Carlo Bramini 2dab880c96 Cygwin: fix TIOCMBIS/TIOCMBIC not working when using usbser.sys
In winsup/cygwin/fhandler/serial.cc, the function
fhandler_serial::switch_modem_lines() is called when TIOCMBIS/TIOCMBIC
are used in an ioctl() call.

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

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

However, it is also possible to drive the RTS/DTR signals by writing
their state with SetCommState(), which proved to be working fine all
types of connection.  This is also a better solution for handling these
signals since RTS/DTR can be set at the same time rather than having two
separate calls with a visible delay between them.
2022-11-11 13:01:23 +01:00
Sebastian Huber 5c79aa4b22 powerpc/setjmp: Fix 64-bit buffer alignment
The rlwinm is a word-size instruction which clears the remaining 32 bits of a
64-bit register.  Use clrrdi in 64-bit configurations.
2022-11-10 16:05:17 +01:00