Jon Turney [Fri, 7 Jun 2024 16:29:10 +0000 (17:29 +0100)]
Cygwin: suppress a warning generated with w32api >= 12.0.0
w32api 12.0.0 adds the returns_twice attribute to RtlCaptureContext().
There's some data-flow interaction with using it inside a while loop
which causes a maybe-uninitialized warning.
../../../../winsup/cygwin/exceptions.cc: In member function 'int _cygtls::call_signal_handler()':
../../../../winsup/cygwin/exceptions.cc:1720:33: error: '<anonymous>' may be used uninitialized in this function [-Werror=maybe-uninitialized]
If ldd is run against a DLL which links to the Cygwin DLL, ldh will end
up loading the Cygwin DLL dynamically, much like cygcheck or strace.
Addresses: https://cygwin.com/pipermail/cygwin/2024-May/255991.html Fixes: 60675f1a7eb2 ("Cygwin: decouple shared mem regions from Cygwin DLL") Reviewed-by: Ken Brown <kbrown@cornell.edu>, Takashi Yano <takashi.yano@nifty.ne.jp> Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
Takashi Yano [Wed, 29 May 2024 10:12:09 +0000 (19:12 +0900)]
Cygwin: pthread: Fix a race issue introduced by the commit 2c5433e5da82
To avoid race issues, pthread::once() uses pthread_mutex. This caused
the handle leak which was fixed by the commit 2c5433e5da82. However,
this fix introduced another race issue, i.e., the mutex may be used
after it is destroyed. This patch fixes the issue. Special thanks to
Bruno Haible for discussing how to fix this.
Addresses: https://cygwin.com/pipermail/cygwin/2024-May/255987.html Reported-by: Bruno Haible <bruno@clisp.org> Fixes: 2c5433e5da82 ("Cygwin: pthread: Fix handle leak in pthread_once.") Reviewed-by: Ken Brown <kbrown@cornell.edu> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Yuriy Kolerov [Tue, 21 May 2024 09:56:57 +0000 (10:56 +0100)]
arc: libgloss: Add support of EM Starter Kit board
These specs files are introduced for EMSK board:
* emsk1_em4.specs - EMSKv1 with EM4 core, everything in
ICCM/DCCM memory
* emsk1_em6.specs - EMSKv1 with EM6 core, everything in
ICCM/DCCM memory
* emsk1_em6_ram.specs - EMSKv1 with EM6 core, startup code
in ICCM and everything else in RAM
* emsk2.1_em5d.specs - EMSKv2.1 with EM5D core, everything
in ICCM/DCCM memory
* emsk2.1_em7d.specs - EMSKv2.1 with EM7D core, everything
in ICCM/DCCM memory
* emsk2.1_em7d_ram.specs - EMSKv2.1 with EM7D core, startup
code in ICCM and everything else in RAM
* emsk2.2_em7d.specs - EMSKv2.2+ with EM7D core, everything
in ICCM/DCCM memory
* emsk2.2_em7d_ram.specs - EMSKv2.2+ with EM7D core, startup
code in ICCM and everything else in RAM
* emsk2.2_em9d.specs - EMSKv2.2+ with EM9D core, everything
in ICCM/DCCM memory
* emsk2.2_em9d_ram.specs - EMSKv2.2+ with EM9D core, startup
code in ICCM and everything else in RAM
* emsk2.2_em11d.specs - EMSKv2.2+ with EM11D core, everything
in ICCM/DCCM memory
* emsk2.2_em11d_ram.specs - EMSKv2.2+ with EM11D core, startup
code in ICCM and everything else in RAM
An example of building an application:
$ arc-elf32-gcc -mcpu=em -specs=emsk2.2_em11d_ram.specs main.c -o main
Signed-off-by: Vladimir Isaev <vvisaev@gmail.com> Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
Yuriy Kolerov [Tue, 21 May 2024 09:56:56 +0000 (10:56 +0100)]
arc: libgloss: Add support of EM SDP board
These specs files are introduced for EM SDP board:
* emsdp1.1.specs - EM SDP 1.1, everything in ICCM/DCCM memory
* emsdp1.1_ram.specs - EM SDP 1.1, startup code in ICCM
memory and everything else in RAM
* emsdp1.2.specs - EM SDP 1.2, everything in ICCM/DCCM memory
* emsdp1.2_ram.specs - EM SDP 1.2, startup code in ICCM
memory and everything else in RAM
An example of building an application:
$ arc-elf32-gcc -mcpu=em -specs=emsdp1.1_ram.specs main.c -o main
Signed-off-by: Vladimir Isaev <vvisaev@gmail.com> Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
Vladimir Isaev [Tue, 21 May 2024 09:56:49 +0000 (10:56 +0100)]
arc: libgloss: Introduce hostlink interface
There is a special interface built in ARC simulators (such as
nSIM) called MetaWare hostlink IO which can be used to implement
system calls. This commit adds support for this interface to the
ARC port of libgloss.
Here is an example of using this interface:
$ arc-elf32-gcc -mcpu=hs -specs=hl.specs main.c -o main
$ nsimdrv -tcf $NSIM_HOME/etc/tcf/templates/hs48_full.tcf main
Hello, World!
Yuriy Kolerov [Tue, 21 May 2024 09:56:46 +0000 (10:56 +0100)]
arc: libc, libgloss: Remove .file directive from .S files
Assembler for ARCv2 always extends the name provided by
.file directive to an absolute form.
On ARCv3 targets .file directive forces assembler to put
a provided string to DW_AT_name field as is without
extending to an absolute path. Then GDB cannot find
source files because of it.
The best way to fix this issue is just delete lines
with .file directive in .S files and let the compiler
to decide what DW_AT_name must contain. Particularly,
the compiler fills this filed by an absolute path to
a .S file because only absolute paths are used in
toolchain's build process.
ARC supports a restricted register file with 16 registers.
However, optimized routines support only a full register
file. Thus, fallback on default implementation in case
of 16-entry register file.
arc: libgloss: Use long calls attribute for exit_halt
According to GCC documentation for ARC, a function marked with
the long_call attribute is always called using register-indirect
jump-and-link instructions, thereby enabling the called function
to be placed anywhere within the 32-bit address space.
exit_halt function is provided by crt0.S and it's used
in nsim-syscalls.c. Thus, we want to ensure that a linkage
issue will not arise.
Dimitar Dimitrov [Tue, 21 May 2024 17:02:02 +0000 (20:02 +0300)]
pru: Do not define MISSING_SYSCALL_NAMES for pru
- The PRU newlib port is supposed to implement case #2 as described in
newlib/libc/include/reent.h . Thus drop the defining of
MISSING_SYSCALL_NAMES.
- libgloss/configure: Regenerate.
- libgloss/libnosys/acinclude.m4: Do not define
MISSING_SYSCALL_NAMES for pru.
Neal Frager [Mon, 13 May 2024 06:24:19 +0000 (07:24 +0100)]
libgloss: microblaze: fix read and _write declarations
This patch resolves the following build error which occurs with gcc 14.1.0:
../../.././libgloss/microblaze/linux-outbyte.c: In function 'outbyte':
../../.././libgloss/microblaze/linux-outbyte.c:3:9: error: implicit declaration of function '_write' [-Wimplicit-function-declaration]
3 | _write(1, &c, 1);
The envp paramter is currently NULL when crt0.S calls main.
With this patch the envp parameter should now be set correctly.
Tested with riscv32 and riscv64: both gdb/sim and qemu do work.
While commit 0321fb573654 ("Cygwin: glob: convert wchar_t to wint_t")
switched the entire glob mechanism from wchar_t to wint_t, the globify
function calling glob on a DOS command line did not catch up and only
checked for the next character constituting a 16 bit wchar_t. This
broke reading surrogate pairs from incoming DOS command lines if the
string had to go through glob(3).
Check for an entire 32 bit unicode char instead.
Fixes: 0321fb573654 ("Cygwin: glob: convert wchar_t to wint_t") Reported-by: David Allsopp <david@tarides.com> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Cygwin: fhandler_virtual::exists: always set fileid
Commit a0a25849f9dd ("Cygwin: fhandler_virtual: move fileid to path_conv
member") broke `ls -l /proc/<PID>'. Turns out, the commit forgot to set
the fileid in case of a virtual root dir (i. e., returning virt_rootdir)
in fhandlers utilizing fileid. This crashed opendir() due to a random
fileid.
In file included from [...]/newlib/libc/include/stdio.h:60,
from [...]:
[...]/newlib/libc/include/sys/reent.h:911:1: error: expected declaration before '}' token
Cygwin: fhandler_virtual: move fileid to path_conv member
Commit 80f722e97cf7 ("Cygwin: opendir(3): move ENOTDIR check into main
function") introduced a bug in fhandler_virtual handling. While the
assertion that path_conv::check() already calls exists() and sets
FILE_ATTRIBUTE_DIRECTORY accordingly, the exists() function is called
on a fhandler_virtual object created for just this code snippet. The
side effect of this is that the fileid member in the calling
fhandler_virtual object is not set after path_conv::check().
Move the fhandler_virtual::fileid member to path_conv::_virt_fileid
and create matching path_conv::virt_fileid() and fhandler_virtual::fileid()
methods.
Let path_conv::check() propagate the fileid set in the local
fhandler_virtual::exists() call to its own _virt_fileid.
Use new fhandler_virtual::fileid() method throughout.
Fixes: 80f722e97cf7 ("Cygwin: opendir(3): move ENOTDIR check into main function") Reported-by: Bruce Jerrick <bmj001@gmail.com> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Andrew Stubbs [Fri, 22 Mar 2024 14:53:30 +0000 (14:53 +0000)]
amdgcn: Implement proper locks
This should prevent printf output from multiple threads getting garbled.
I don't know why IO ever worked properly -- probably it was always a bit
broken -- but the GFX11 devices have a different cache architecture and
trying to print from many threads at once corrupted the FILE buffers.
Corinna Vinschen [Fri, 22 Mar 2024 14:34:29 +0000 (15:34 +0100)]
Cygwin: //server: check existence of server with getaddrinfo
Checking server existence by trying to enumerate its shares
may result in 2 minutes delay until some internal timeout is hit.
In the light that every network is an IP network anyway these
days, let's try with a simple getaddrinfo() call. This is usually
back in 3 secs even if the server doesn't exist, and it's usually
back in 8 secs if the DNS server can't be connected. This is the
fastest method I found to check server existence yet.
Corinna Vinschen [Wed, 20 Mar 2024 21:59:37 +0000 (22:59 +0100)]
Cygwin: tzmap-from-unicode.org: drop support for Vista/2008
Commit b794f2c6038f ("Cygwin: drop support for systems not supporting
RFC 4646 locales") erroneously changed tzmap.h manually. Change
the script accordingly.
Fixes: b794f2c6038f ("Cygwin: drop support for systems not supporting RFC 4646 locales") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Corinna Vinschen [Wed, 20 Mar 2024 11:34:51 +0000 (12:34 +0100)]
Cygwin: opendir(3): move ENOTDIR check into main function
So far the check for a directory is in the fhandler::opendir
methods. Given that path_conv::check sets FILE_ATTRIBUTE_DIRECTORY
on virtual files either, we can move the check up into the
opendir(3) function. This avoids calling exists() twice when
calling opendir(3).
Corinna Vinschen [Tue, 19 Mar 2024 15:22:40 +0000 (16:22 +0100)]
Cygwin: readdir(3): stop support for pre-Cygwin 1.5.0 apps
We're filling dirent::__d_internal1 with the inode number to
support apps built under Cygwin 1.3 and earlier. This doesn't
make sense anymore. Drop this to free up __d_internal1 for
other TBD use.
Brian Inglis [Sat, 16 Mar 2024 16:44:00 +0000 (10:44 -0600)]
winsup/cygwin/fhandler/proc.cc: format_proc_cpuinfo() Linux 6.8 cpuinfo flags
add Linux 6.8 cpuinfo flags:
Intel 0x00000007:1 eax:17 fred Flexible Return and Event Delivery;
AMD 0x8000001f eax:4 sev_snp SEV secure nested paging;
document unused and some unprinted bits that could look like omissions;
fix typos and misalignments;
Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
Dumb thinko on my part. What was supposed to be an optimization
actually broke caseinsensitive globbing in that the entire input
of globbed expressions were downcased.
Drop the unused CCHAR() macro nevertheless.
Fixes: a51147467e6cf ("Cygwin: glob: perform ignore_case_with_glob on input") Reported-by: Michael Goldshteyn <mgold10000@gmail.com> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Takashi Yano [Mon, 11 Mar 2024 13:08:00 +0000 (22:08 +0900)]
Cygwin: pipe: Make sure to set read pipe non-blocking for cygwin apps.
If pipe reader is a non-cygwin app first, and cygwin process reads
the same pipe after that, the pipe has been set to bclocking mode
for the cygwin app. However, the commit 9e4d308cd592 assumes the
pipe for cygwin process always is non-blocking mode. With this patch,
the pipe mode is reset to non-blocking when cygwin app is started.
Since commit 15e82eef3a40b ("Cygwin: getgrent: fix local SAM enumeration
on domain member machines") we skip enumerating local BUILTIN accounts
if we also enumerate AD. However, there are two local accounts which
are only available in local SAM, not in AD. Don't skip enumerating
those.
Fixes: 15e82eef3a40b ("Cygwin: getgrent: fix local SAM enumeration on domain member machines") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Example failure without this change:
$ arm-none-eabi-g++ .../pr100611.C -std=c++20 --specs=nosys.specs -o /dev/null --specs=nano.specs
.../ld: .../libc_nano.a(libc_a-svfwprintf.o): in function `_svfwprintf_r':
(.text._svfwprintf_r+0xd8): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x834): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x85c): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x8a8): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x8dc): undefined reference to `__ssputws_r'
.../ld: .../libc_nano.a(libc_a-svfwprintf.o):(.text._svfwprintf_r+0x900): more undefined references to `__ssputws_r' follow
collect2: error: ld returned 1 exit status
Cygwin: get/set security descriptors using FILE_OPEN_NO_RECALL
Add FILE_OPEN_NO_RECALL to NtOpenFile calls trying to fetch
or write file security descriptors so as not to recall them
from offline storage inadvertently.
Chances are high that Cygwin recalls offline files from remote
storage, even if the file is only accessed during stat(2) or
readdir(3).
To avoid this
- make sure Cygwin is placeholder-aware,
- open files in path_conv handling, as well as in stat(2)/readdir(3)
scenarios with FILE_OPEN_NO_RECALL, and
- during symlink checking or testing for executablility, don't even
try to open the file if one of the OFFLINE attributes is set.
Reported-by: Marcin Wisnicki <mwisnicki@gmail.com> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Cygwin: move EXPORT_ALIAS expressions to end of source
This isn't strictly required, but it avoids confusion in ctags.
Ctags fails to record the next function or method following the
EXPORT_ALIAS expression.
Takashi Yano [Tue, 5 Mar 2024 14:34:21 +0000 (23:34 +0900)]
Cygwin: pipe: Simplify chhecking procedure of query_hdl.
This patch eliminates verbose NtQueryObject() calls in the procedure
to get query_hdl by storing pipe name into fhandler_base::pc when
the pipe is created. fhandler_pipe::temporary_query_hdl() uses the
storedpipe name rather than the name retrieved by NtQueryObject().
Takashi Yano [Sun, 3 Mar 2024 04:44:17 +0000 (13:44 +0900)]
Cygwin: pipe: Give up to use query_hdl for non-cygwin apps.
Non-cygwin app may call ReadFile() for empty pipe, which makes
NtQueryObject() for ObjectNameInformation block in fhandler_pipe::
get_query_hdl_per_process. Therefore, do not to try to get query_hdl
for non-cygwin apps.
Takashi Yano [Mon, 4 Mar 2024 02:32:34 +0000 (11:32 +0900)]
Cygwin: console: Fix a race issue between close() and open().
The open() call for console sometimes fails if the console owner
process is closing the console by close() at the same time. This
is due to mismatch state of con.owner variable and attaching state
to the console. With this patch, checking con.owner and attaching
to con.owner sequence in open(), and resetting con.owner and freeing
console sequence in close() are guarded by output_mutex to avoid
such a race issue.
Addresses: https://cygwin.com/pipermail/cygwin/2024-March/255575.html
Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.") Reported-by: Kate Deplaix <kit-ty-kate@outlook.com> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Cygwin: posix_getdents: do not clear attached DIR structure at fork(2)
The upcoming POSIX issue 8 will require that posix_getdents after
fork() will pick up at the right spot, independently of being
called in the parent or in the child process. Remove the expression
clearing out the attached DIR after fork.
Transfer code lseeking on posix_getdents() directory descriptor
into its own static function and rework it so SEEK_END, SEEK_DATA
and SEEK_HOLE work here as expected, too.
Takashi Yano [Fri, 1 Mar 2024 10:05:36 +0000 (19:05 +0900)]
Cygwin: console: Do not unmap shared console memory belonging to ctty.
In the condition that console setup for CTTY and close run at the
sametime, accessing shared console memory which is already unmapped
may occur. With this patch, to avoid this race issue, shared console
memory which belongs to contorolling terminal (CTTY) is kept mapped
as before.
Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255561.html
Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.") Reported-by: Kate Deplaix <kit-ty-kate@outlook.com> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Christian Franke [Tue, 27 Feb 2024 16:21:45 +0000 (17:21 +0100)]
Cygwin: set ENOSHARE and ECASECLASH _sys_errlist[] entries to empty
These errno values are no longer used by Cygwin. Change the entries
to empty strings instead of NULL to avoid crashes in existing
binaries directly accessing the table. Enhance strerror_worker()
such that empty strings also result in "Unknown error ..." messages.
Also add a static_assert check for the _sys_errlist[] size.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Christian Franke [Fri, 23 Feb 2024 18:01:09 +0000 (19:01 +0100)]
Cygwin: Map ERROR_NO_SUCH_DEVICE and ERROR_MEDIA_CHANGED to ENODEV
If a removable (USB) device is disconnected after opening its raw
device, R/W attempts fail with ERROR_NO_SUCH_DEVICE(433). If the
raw device of a partition is used, ERROR_MEDIA_CHANGED(1110) is
returned instead. Both are mapped to ENODEV(19) because <errno.h>
does not offer a value which better matches ERROR_MEDIA_CHANGED.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Corinna Vinschen [Sat, 24 Feb 2024 11:59:28 +0000 (12:59 +0100)]
Cygwin: newgrp: only allow group from supplementary group list
Windows only allows to set the primary group to a group already
present in the TOKEN_GROUP list. Cygwin OTOH fakes success at
setgid() time, to allow a subsequent call to setuid() to do
the actual account switching. To have a sane behaviour in the
command line tool, check group membership and disallow to switch
to groups other than those already present in the user token.
Fixes: 8bd56ec873453 ("Cygwin: newgrp: first full version") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Sebastian Huber [Mon, 12 Feb 2024 19:10:26 +0000 (20:10 +0100)]
RTEMS: Define ssize_t for <dirent.h>
This fixes the following build issue:
newlib/libc/include/dirent.h:84:1: error: unknown type name 'ssize_t'; did you mean '_ssize_t'?
84 | ssize_t posix_getdents(int, void *, size_t, int);
| ^~~~~~~
| _ssize_t
Corinna Vinschen [Wed, 21 Feb 2024 18:54:20 +0000 (19:54 +0100)]
Cygwin: strptime: fix am/pm handling
The %p format specifier is handled immediately. It requires
that tm_hour is already set. This falls flat in case the am/pm
marker preceeds the time specification. Locales with am/pm
marker preceeding time spec by default exist (e. g. ko_KR).
Also, the code expects that tm_hour might be set to an invalid
value because the %p specifier is used in conjunction with %H.
But this usage is invalid in itself and now catched as error
condition after commit 343a2a558153 ("Cygwin: strptime: make
sure to fail on invalid input digits").
Change the %H/%I/%p handling according to GLibC, i. e.
- fix tm_hour for pm only if the time value has been specified
as 12 hour time %I, and
- perform the fixup only after the entire input has been scanned.
This decouples the fixup from the %p position relativ to %I.
Corinna Vinschen [Tue, 20 Feb 2024 22:51:33 +0000 (23:51 +0100)]
Cygwin: getgrent: fix local SAM enumeration on domain member machines
Don't skip output of local SAM groups on domain member machines.
They can have valid, user-defined groups in their SAM. Just
skip builtin groups if we're enumerating AD as well.
Corinna Vinschen [Tue, 20 Feb 2024 16:25:23 +0000 (17:25 +0100)]
Cygwin: passwd/group: drop Capability SIDs
Capability SIDs (S-1-15-3-...) have been introduced with
Windows 10 1909. They don't resolve with LookupAccountSid.
We don't need them and they don't map gracefully into out
POSIX account namespace. Also, add code to make sure to
filter them out *iff* they become resolvable at one point.
While at it, slightly reorder code for non-resolving SIDs
by authority values.
Previously, three similar callback fuctions were used in console
code. This patch unifies these functions to ease maintenance cost.
Fixes: 8aad3a7edeb2 ("Cygwin: console: Fix a problem that minor ID is incorrect in ConEmu.") Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>