Corinna Vinschen [Wed, 22 Feb 2023 23:22:56 +0000 (00:22 +0100)]
Cygwin: locale(1): drop using LCID, use Windows locale names
LCIDs are deprecated since Windows Vista. Worse, lots of new locales
have been added in the meantime which have no LCID attached. They
are only available by locale name.
As first step, rearrange the locale(1) tool to use Windows locale
names, rather than LCIDs, so we can now enumerate *all* locales
available in more recent Windows versions.
Hau Hsu [Wed, 22 Feb 2023 01:59:07 +0000 (09:59 +0800)]
RISC-V: Use the new libm code if possible
Set __OBSOLETE_MATH_DEFAULT to 0 if 'd' extension is supported (i.e.
__riscv_flen == 64).
Base on the comment for __OBSOLETE_MATH_DEFAULT:
> ... it assumes that the toolchain has ISO C99 support (hexfloat
> literals, standard fenv semantics), the target has IEEE-754 conforming
> binary32 float and binary64 double (not mixed endian) representation,
> standard SNaN representation, double and single precision arithmetics
> has similar latency and it has no legacy SVID matherr support, only
> POSIX errno and fenv exception based error handling.
Most locales using latin characters ignore case while sorting.
This is what wcscoll does (correctly so). However, there's an
internal order of collating sequences compared to the base
character, which is case-sensitive, at least in GLibc.
There's no way to express this in Windows, because CompareString
and LCMapString *always* use case-insensitivity in those locales,
even if none of the *IGNORECASE sorting flags are used.
We want to follow glibc's behaviour more closely, so we add an
extra check for the case and make sure upper and lower cased
letters don't comapre as identical.
Corinna Vinschen [Wed, 22 Feb 2023 09:47:54 +0000 (10:47 +0100)]
Cygwin: glob: perform ignore_case_with_glob on input
Rather than converting single chars on the fly to lowercase
in case ignore_case_with_glob is set, perform the conversion
on the entire input (pattern and filenames).
Corinna Vinschen [Mon, 20 Feb 2023 21:47:17 +0000 (22:47 +0100)]
Cygwin: glob: convert internal character datatype to wint_t
uint_fast64_t doesn't allow easy string handling, so convert
the internal "Char" type to wint_t. Given that UTF-32 only
needs 21 bits, we're well off with 28 usable character bits.
Corinna Vinschen [Mon, 20 Feb 2023 21:38:41 +0000 (22:38 +0100)]
Cygwin: nlsfuncs.cc: introduce collating elements and helper functions
lc_collelem.h: autogenerated table of collating element, taken
from glibc
is_unicode_coll_elem: Check if a UTF-32 string is a collating element
next_unicode_char: return length of prefix from a string constituting
a complete character in the current locale, taking
collating elements into acocunt.
After FreeBSD eventually picked up the bugreport from within
only 5 years, rename __collate_range_cmp to __wcollate_range_cmp
as suggested all along, and make it type safe (wint_t instead of
wchar_t for hopefully obvious reasons...)
While at it, drop __collate_load_error and fix the checks for
it in glob and fnmatch.
Takashi Yano [Tue, 14 Feb 2023 13:55:10 +0000 (22:55 +0900)]
Cygwin: dsp: Fix SNDCTL_DSP_GET[IO]SPACE before read()/write().
Even with the commit 3a4c740f59c0, SNDCTL_DSP_GET[IO]SPACE ioctl()
does not return the fragment set by SNDCTL_DSP_SETFRAGMENT if it
is issued before read()/write(). This patch fixes the issue.
Corinna Vinschen [Wed, 15 Feb 2023 21:00:39 +0000 (22:00 +0100)]
Cygwin: is_unicode_equiv: implement Unicode equivalence class check
is_unicode_equiv compares two UTF-32 values and returns 1 if
both are member of the same Unicode equivalence class, 0 otherwise.
Note that this function only works with precomposed characters
per Unicode normalization form C. It doesn't handle decomposed
characters, just like its counterpart in glibc. I.e., equivalence
class comparison using decomposed chars won't work. Example:
Corinna Vinschen [Wed, 15 Feb 2023 13:11:45 +0000 (14:11 +0100)]
Cygwin: glob: handle named character classes
Handle [:<character-class>:] expressions in range brackets.
TODO: Collating symbols [.<collsym>'.] and Equivalence class
expressions [=<equiv-class>=] are recognized but skipped as if
they are not present at all.
Corinna Vinschen [Tue, 14 Feb 2023 19:22:54 +0000 (20:22 +0100)]
Cygwin: fnmatch: handle named character classes
Handle [:<character-class>:] expressions in range brackets.
TODO: Collating symbols [.<collsym>'.] and Equivalence class
expressions [=<equiv-class>=] are recognized but skipped as if
they are not present at all.
So far the input to __collate_range_cmp was handled as a wchar_t.
Change that to handle it as wint_t holding a UTF-32 value and
add creating surrogate pairs for the call to wcscoll.
Corinna Vinschen [Tue, 14 Feb 2023 11:20:20 +0000 (12:20 +0100)]
Cygwin: mbrtowi: define replacement for mbrtowc, returning UTF-32 value
Given how UTF-16 isn't capable to hold all Unicode chars in a single
wchar_t, we need a function returning a wint_t value representing
a UTF-32 value for comparison functions. Fortunately the important
wide character functions like towupper/towlower, isw<class>, iswctype,
etc, already take wint_t values and newlib handles them as UTF-32.
If only we had switched wchar_t to 32 bit way back when... sigh.
Corinna Vinschen [Sat, 11 Feb 2023 11:53:34 +0000 (12:53 +0100)]
Cygwin: cygcheck: fix dependency search
Spaces are filtered out by PathMatchSpecA so they can't
be used as pattern anchors. Overwrite all spaces with
commas and fix the search expresion accordingly.
Cygwin: get_posix_access: Make mode_t parameter mandatory
Avoid the mistake fixed in the preceeding commit by passing
the mode_t argument by reference. This also affects a couple
other functions calling get_posix_access in turn.
Cygwin: chmod: don't drop default ACEs from directory ACLs
commit bc444e5aa4ca introduced a call to get_posix_access()
with a NULL pointer for the mode_t parameter because the value
is not needed later on... entirely ignoring the fact that the
mode_t bits are checked for the object being a directory.
In turn, the get_posix_access() call never checked for default
ACEs and returned only the standard ACEs. Thus, every chmod call
on a directory dropped the default ACEs from its permissions, as
well as the default NULL deny-ACE used to store specific bits.
It got also impossible to set the sgid bit on directories.
Cygwin: mkdir: use correct default permissions filtered by umask
Older coreutils created directories with mode bits filtered through
umask. Newer coreutils creates directories with full permissions,
0777 by default.
This new coreutils behaviour uncovered the fact that default ACEs for
newly created directories were not filtered by umask starting with
commit bc444e5aa4ca.
setlocale: create LC_ALL string when changing locale
This patch is for the sake of gnulib.
gnulib implements some form of a thread-safe setlocale variant
called setlocale_null_r, which is supposed to return the locale
strings in a thread-safe manner. This only succeeds if the system's
setlocale already handles this thread-safe, otherwise gnulib adds
some locking on its own.
Newlib's setlocale always writes the global string array holding the
LC_ALL value anew on each invocation of setlocale(LC_ALL, NULL).
Since that doesn't allow to call setlocale(LC_ALL, NULL) in a
thread-safe manner, so locking in gnulib is required.
And here's the problem...
The lock is decorated as dllexport when building for Cygwin. This
collides with the default behaviour of ld to export all symbols.
If it finds one decorated symbol, it will only export this symbol
to the DLL import lib.
Change setlocale so that it writes the global string array
holding the LC_ALL value at the time the locale gets changed.
On setlocale(LC_ALL, NULL), just return the pointer to the
global LC_ALL string array, just as in GLibc. The burden of
doing so is negligibly for all targets, but adds thread-safety
for gnulib's setlocal_null_r() function, and gnulib can drop
the lock entirely when building for Cygwin.
When compiling Newlib for arm targets with GCC 12.1 onward, the
passing of architecture extension information to the assembler is
automatic, making the use of .fpu and .arch_extension directives
in assembly files redundant.
With older versions of GCC, however, these directives must be
hard-coded into the `arm/setjmp.S' file to allow the assembly of
instructions concerning the storage and subsequent reloading of the
floating point registers to/from the jump buffer, respectively.
This patch conditionally adds the `.fpu vfpxd' and `.arch_extension
mve' directives based on compile-time preprocessor macros concerning
GCC version and target architectural features, such that both the
assembly and linking of setjmp.S succeeds for older versions of
Newlib.
dumper: avoid linker problem when `libbfd` depends on `libsframe`
A recent binutils version introduced `libsframe` and made it a
dependency of `libbfd`. This caused a linker problem in the MSYS2
project, and once Cygwin upgrades to that binutils version it would
cause the same problems there.
Let's preemptively detect the presence of `libsframe` and if detected,
link to it in addition to `libbfd`.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Corinna Vinschen [Sun, 29 Jan 2023 13:13:25 +0000 (14:13 +0100)]
Cygwin: cygcheck: package info / available package search, take 2
- if the user has no perms to write to /etc/setup, don't try
to fetch user homedir from Cygwin (crashes galore). Use
LOCALAPPDATA path instead.
- info is more rpm like
- print info of installed package
- added info selectors --inst, --curr, --prev, --test
- add installation date
TODO:
- Human-readable filesize
- url and license needs to be added to setup.ini yet
-
RISC-V: Fix floating-point environment support for soft float
We don't have floating-point exception or non-default rounding mode
support for the RISC-V soft-float environment, `feraiseexcept' and
`fesetround' do nothing unless the `__riscv_flen' macro has been set.
Therefore following ISO C language requirements[1] only define macros
for soft float that correspond to actually supported floating-point
environment features, removing failures from GCC testing such as:
FAIL: gcc.dg/torture/fp-int-convert-timode-3.c -O0 execution test
FAIL: gcc.dg/torture/fp-int-convert-timode-4.c -O0 execution test
References:
[1] "Programming languages -- C", ISO/IEC 9899:2023, working draft --
September 3, 2022, Section 7.6 "Floating-point environment <fenv.h>"
Fixes: 7040b2de0883 ("Add RISC-V port for libm") Signed-off-by: Maciej W. Rozycki <macro@embecosm.com>
Takashi Yano [Wed, 25 Jan 2023 09:30:50 +0000 (18:30 +0900)]
Cygwin: dsp: Fix hang on close() if another thread calls write().
fhandler_dev_dsp (OSS) has a problem that waitforallsent(), which is
called from close(), falls into infinite loop if another thread calls
write() accidentally after close(). This patch fixes the issue.
Corinna Vinschen [Mon, 23 Jan 2023 13:01:43 +0000 (14:01 +0100)]
Cygwin: mount: differ allowed server name chars from allowed share name chars
The list of invalid chars for server names differs from the
list of invalid chars for share names. Apart from that,
we don't allow control chars in both kinds of names.
Fixes: 6338d2f24a60 ("Cygwin: mount: allow any valid character in UNC paths") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Corinna Vinschen [Sun, 22 Jan 2023 19:11:59 +0000 (20:11 +0100)]
Cygwin: mount: allow any valid character in UNC paths
The current code only allows server and share names to
start with ASCII chars [a-zA-Z0-9],, which is not correct.
Rather, check for a valid share character.
Takashi Yano [Sat, 21 Jan 2023 12:33:03 +0000 (21:33 +0900)]
Cygwin: fsync: Fix EINVAL for block device.
The commit af8a7c13b516 has a problem that fsync returns EINVAL for
block device. This patch treats block devices as a special case.
https://cygwin.com/pipermail/cygwin/2023-January/252916.html
Fixes: af8a7c13b516 ("Cygwin: fsync: Return EINVAL for special files.") Reported-by: Yano Ray <yanorei@hotmail.co.jp> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Thomas Schwinge [Thu, 19 Jan 2023 17:24:50 +0000 (18:24 +0100)]
nvptx: In offloading execution, map '_exit' to 'abort' [GCC PR85463]
This is still not properly resolving <https://gcc.gnu.org/PR85463>
'[nvptx] "exit" in offloaded region doesn't terminate process', but is
one step into that direction, and allows for simplifying some GCC code.
Thomas Schwinge [Wed, 21 Sep 2022 16:58:34 +0000 (18:58 +0200)]
nvptx: Remove newlib ELIX level 1 restriction
Such a hard-coded ELIX level restriction is only being applied for nvptx
newlib -- but we'd actually like higher levels' functions available there,
too. (Users continue to be able to override this via newlib 'configure',
as for every other newlib target.)
This already enables GCC test cases that currently FAIL due to
'unresolved symbol strndup' ('gcc.dg/builtin-dynamic-object-size-0.c'), or
'unresolved symbol mempcpy' ('gcc.dg/torture/pr45636.c'), for example.
Co-authored-by: Andrew Stubbs <ams@codesourcery.com>
Thomas Schwinge [Tue, 11 Oct 2022 21:34:19 +0000 (23:34 +0200)]
nvptx: Don't use global constructor for SSP setup
Given that nvptx newlib currently restricts itself to ELIX level 1, this
is not already a problem. However, in the following we'd like to lift
that restriction, and then run into:
[...]/newlib/libc/ssp/stack_protector.c: In function ‘__stack_chk_init’:
[...]/newlib/libc/ssp/stack_protector.c:31:1: sorry, unimplemented: global constructors not supported on this target
31 | }
| ^
GCC patch "nvptx: Support global constructors/destructors via 'collect2'"
has been posted, but not yet accepted. Until that is resolved, use the
same manual SSP setup as for GCN.
Corinna Vinschen [Wed, 18 Jan 2023 18:59:48 +0000 (19:59 +0100)]
Cygwin: open_shared: always bump next_address
The new loop in open_shared has a subtil performance problem.
Next_address is bumped only if mapping at this address
failed. Every subsequent call to open_shared has a high probability
having to call MapViewOfFileEx twice, because next_address is still
set to the address of the last successful mapping.
This implements a set of vectorized math routines to be used by the
compiler auto-vectorizer. Versions for vectors with 2 lanes up to
64 lanes (in powers of 2) are provided.
These routines are based on the scalar versions of the math routines in
libm/common, libm/math and libm/mathfp. They make extensive use of the GCC
C vector extensions and GCN-specific builtins in GCC.
Corinna Vinschen [Wed, 18 Jan 2023 12:16:50 +0000 (13:16 +0100)]
Cygwin: drop fixed addresses for standard shared regions
With the previous commit 9ddd48ee1b8d ("Cygwin: /proc/<PID>/maps:
print real shared region addresses"), the real addresses of
the standard shared regions (cygwin, user, myself, shared console)
are read from the printed process itself. We don't need fixed
addresses anymore, so drop the definitions and simplify open_shared.
Corinna Vinschen [Tue, 17 Jan 2023 20:58:06 +0000 (21:58 +0100)]
Cygwin: /proc/<PID>/maps: print real shared region addresses
So far, the addresses printed for the shared regions of a process
were faked. The assumption was that the shared regions are always
in the same place in all processes, so we just printed the addresses
of the current process. This is no safe bet. The only safe bet is
the address of the cygheap. So keep track of the addresses in the
cygheap and read the addresses from the cygheap of the observed
processes. Add output for the shared console.
Corinna Vinschen [Tue, 17 Jan 2023 16:43:21 +0000 (17:43 +0100)]
Cygwin: disable high-entropy VA for cygcheck and strace
It's not a good idea to enable high-entropy VA for tools loading the
Cygwin DLL dynamically. The addresses used by HEVA tend to collide with
fixed address areas managed by Cygwin.
Fixes: 60675f1a7eb2 ("Cygwin: decouple shared mem regions from Cygwin DLL") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Corinna Vinschen [Tue, 17 Jan 2023 09:18:51 +0000 (10:18 +0100)]
Cygwin: open_shared: try harder allocating a shared region
For fixed regions (cygwin/user/myself/shared console), try fixed
address first. Fallback to non-fixed region. Don't even try fixed
address if the Cygwin DLL gets dynamically loaded.
For non-fixed regions, try to allocate in a loop within the area
from SHARED_REGIONS_ADDRESS_LOW to SHARED_REGIONS_ADDRESS_HIGH.
Fixes: 60675f1a7eb2 ("Cygwin: decouple shared mem regions from Cygwin DLL") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Corinna Vinschen [Mon, 16 Jan 2023 21:25:42 +0000 (22:25 +0100)]
Cygwin: open_shared: don't reuse shared_locations parameter as output
For ages, open_shared uses the shared_locations parameter as
output to indicate if the mapping for a shared region has been
created or just opened. Split this into two parameters. Use
the shared_locations parameter as input only, return the creation
state of the mapping in a bool reference parameter.
Corinna Vinschen [Mon, 16 Jan 2023 13:23:38 +0000 (14:23 +0100)]
Cygwin: /proc/cpuinfo: Always print topology info
vmstat from proc-ps-4.0.x prints "Unable to create system stat structure"
if the /proc/cpuinfo output fails to contain topology info. While
Linux always prints topology info if the kernel has been built with
CONFIG_SMP, Cygwin only prints topology info if the CPU is known to
be multi-core (i. e., the HT feature flag is set).
Fix that by printing topology info all the time, even for single-core
CPUs.
Corinna Vinschen [Sat, 14 Jan 2023 16:46:55 +0000 (17:46 +0100)]
Cygwin: newgrp: first full version
- add '-' option
- make group argument optional
- drop ability to take a numerical group argument
- simplify usage output to bare minimum
- Add manpage and documentation
Corinna Vinschen [Fri, 13 Jan 2023 19:59:07 +0000 (20:59 +0100)]
Cygwin: add very simple newgrp(1) tool
This tool allows to change the primary group for a child process.
The new primary group MUST be part of the supplementary group list
of newgrp's user token.
The command started as child process is specified on the command line.
If it's missing, start the user's default shell with the new primary
group.
TODO: Implement '-' option.
Add command description to documentation.
Jon Turney [Thu, 1 Sep 2022 13:07:26 +0000 (14:07 +0100)]
Cygwin: CI: Run cygserver for tests
Note that cygserver must be run using the same cygwin1.DLL as test
programs, as they communicate over a named pipe whose name contains the
'installation key' (which is a hash of the cygwin1.dll's path).
We run cygserver via 'cmd' to avoid the special code which handles a
cygwin parent process starting a cygwin child process, which assumes the
same version of cygwin in both.