Commit Graph

9978 Commits

Author SHA1 Message Date
Corinna Vinschen c3e7f7609e Cygwin: locales: fix behaviour for @cjk* and @euro locales
@cjknarrow and @cjkwide modifiers are newlib only, so they need
some tweaking in __set_charset_from_locale.

Fixes: 2483e54be8 ("Cygwin: locale: Set default charset from Linux locale -> codeset mapping")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-26 13:01:52 +02:00
Corinna Vinschen 68aea16d3f Cygwin: /proc/locales: use ENCODING_LEN to define array sizes
Fixes: c42b98bdc6 ("Cygwin: introduce /proc/codesets and /proc/locales")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-26 12:52:32 +02:00
Corinna Vinschen 4e578fad79 Cygwin: /proc/locales: use modifier when checking default codeset
Drop usage of newlocale/nl_langinfo_l/freelocale.
Call __set_charset_from_locale instead, and make sure to call it
with modifier, if any, otherwise suffer wrong results.

Fixes: c42b98bdc6 ("Cygwin: introduce /proc/codesets and /proc/locales")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-26 12:51:28 +02:00
Corinna Vinschen a97fbb58e2 Cygwin: locales: fix return value check of ResolveLocaleName
ResolveLocaleName does not simply return an error value if it
can't resolve a locale.  Rather, it returns an empty string and
the length of this string: 1.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-25 22:48:35 +01:00
Corinna Vinschen 7002f7f7c7 Revert "Cygwin: locales: drop supporting iso639 strings as valid locales"
This reverts commit 15898b9588.

The idea behind this patch was wrong.  Systems are supposed to
support iso639-only strings as settings for the locale environment
variables, and they are not necessarily available in the
/usr/share/locale/locale.alias file.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-25 22:30:15 +01:00
Corinna Vinschen b5b67a65f8 Cygwin: locales: implement own method to check locale validity
The Windows function ResolveLocaleName is next to useless to
convert a partial locale identifier into a full, supported
locale identifier.  It converts anything which vaguely resembles
a locale into some other locale it supports.

Bad examples are:
  "en-XY" gets converted to "en-US", and worse,
  "ff-BF" gets converted to "ff-Latn-SN", even though "ff-Adlm-BF"
  exists!

To check if a locale is supported, we have to enumerate all valid
Windows locales, and return the match, even if the locale in Windows
requires a script.  Implement resolve_locale_name() as replacement
function for ResolveLocaleName.

Fixes: e95a7a7955 ("Cygwin: convert Windows locale handling from LCID to ISO5646 strings")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24 12:50:59 +01:00
Corinna Vinschen 15898b9588 Cygwin: locales: drop supporting iso639 strings as valid locales
This was incorrect behaviour.  The only valid way to support those
is by adding them to /usr/share/locale/locale.alias.

Fixes: e95a7a7955 ("Cygwin: convert Windows locale handling from LCID to ISO5646 strings")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24 12:50:59 +01:00
Corinna Vinschen c53d0910e6 Cygwin: locales: set errno to ENOENT if locale is invalid
This allows newlocale to return with a valid errno if the
locale is invalid.

Fixes: e95a7a7955 ("Cygwin: convert Windows locale handling from LCID to ISO5646 strings")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24 12:50:59 +01:00
Corinna Vinschen 676796498d Cygwin: /proc/locales: fix "sr" locales
The sr_XY locales are supposed to default to cyrillic, but the code
always attached a @cyrillic, same reason as in the previous commit.

Special case "sr" further to workaround that issue.

Fixes: c42b98bdc6 ("Cygwin: introduce /proc/codesets and /proc/locales")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24 12:50:59 +01:00
Corinna Vinschen 9296f134fb Cygwin: /proc/locales: fix sd_IN locale
Due to the way locales are evaluated in Windows, we can't ask for
the script of the "sd-IN" locale, because Windows only knows the
"sd-Deva-IN" locale.  So asking for the script of the "sd" locale
returns "Arab;", because "sd" is converted to "sd-Arab-PK".

Special case "sd-IN" to workaround that issue.

Fixes: c42b98bdc6 ("Cygwin: introduce /proc/codesets and /proc/locales")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24 12:50:59 +01:00
Yoshinao Muramatsu 87ab6c7b26 Cygwin: log disabling posix semantics
Add log when workaround occurs

Signed-off-by: Yoshinao Muramatsu <ysno@ac.auone-net.jp>
2023-03-21 18:56:52 +01:00
Yoshinao Muramatsu 7666e248dd Cygwin: fix rename in container
Renaming files returns STATUS_INVALID_PARAMETE on a bind mounted file system
in hyper-v container with FILE_RENAME_POSIX_SEMANTICS.

Disable the use_posix_semantics flag and retry.

Signed-off-by: Yoshinao Muramatsu <ysno@ac.auone-net.jp>
2023-03-21 18:56:52 +01:00
Yoshinao Muramatsu 527dd1b407 Cygwin: fix unlink in container
Deleting files returns STATUS_INVALID_PARAMETE on a bind mounted file system
in hyper-v container with FILE_DISPOSITION_POSIX_SEMANTICS.
Therefore fall back to default method.

This code is suggested by Johannes Schindelin on github
and I change it more simple.

Signed-off-by: Yoshinao Muramatsu <ysno@ac.auone-net.jp>
2023-03-21 18:56:27 +01:00
Corinna Vinschen fe2545e9fa Cygwin: don't use unlink/rename POSIX semantics on certain NTFS
If a host NTFS is mapped into a Hyper-V isolated container, the
OPEN_BY_FILE_ID filesystem flag is missing, just as if that NTFS
is a remote drive.  However, NtQueryVolumeInformationFile claims
the drive is a local drive.

We can use this fact to learn that the process is running under
Hyper-V, and that the Hyper-V isolated process can't use rename/unlink
with POSIX semantics.  Strange enough, the POSIX_UNLINK_RENAME filesystem
flag is still set...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-21 18:29:59 +01:00
Corinna Vinschen 0a962aa2c2 Cygwin: fs_info::update: fix NTFS filesystem flags
These flags are used to check a remote filesystem.  Not all
flags supported by a local NTFS are available when checking
a remote NTFS.  Fix the flag set accordingly, otherwise
the remote NTFS will ba handled as CIFS.

Fixes: fcccdc4021 ("Cygwin: fs_info: update filesystem flags and check Windows 7 flags")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-21 18:02:49 +01:00
Corinna Vinschen 5924191333 Cygwin: regex: fix faulty check for valid range expression
Except for the "C" or "POSIX" locale, checking for start <= finish
is always wrong.  Range start must be <= range finish in terms of the
locale's collating order.  So make sure to call always wcscoll(), even
in the "C"/"POSIX" locale, which makes wcscoll equivalent to wcscmp
anyway.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-20 12:58:03 +01:00
Corinna Vinschen e914374383 Cygwin: regex: fix freeing g->charjump in low memory condition
computejumps() moves g->charjump to a position relativ to the value of
CHAR_MIN.  As such, g->charjump doesn't necessarily point to the address
actually allocated.  While regfree() takes that into account, the low
memory handling in regcomp_internal() doesn't.  Fix that by free'ing
the actually allocated address, as in regfree().

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-20 12:56:17 +01:00
Corinna Vinschen 271292b1fb Cygwin: unlink: drop unlink_nt/unlink_nt_shareable wrappers
Useless indirection.  Rename _unlink_nt back to unlink_nt
and call the function directly with `sharable' flag as needed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-20 12:55:30 +01:00
Corinna Vinschen fcccdc4021 Cygwin: fs_info: update filesystem flags and check Windows 7 flags
Update the list of filesystem flags to the flags supported since
Windows 7.  Make sure to use the new flags only with Windows
filesystems, not with 3rd party filesystems.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-20 12:55:30 +01:00
Corinna Vinschen 5da71b6059 Cygwin: add support for GB18030 codeset
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16 18:25:09 +01:00
Corinna Vinschen 2285cf0d1c Cygwin: regex: NONCHAR: re-add cast to int
wint_t is unsigned int and the test checks for a negative value.  Thus,
it's optimized out by gcc.  Add the cast from commit 44caccfca2 to
avoid this.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16 13:47:10 +01:00
Corinna Vinschen 0bdc764b42 Cygwin: regex: wgetnext: Re-add kludge to be more glibc compatible
Add comment to explain.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16 13:46:01 +01:00
Corinna Vinschen 585e7f9891 Cygwin: regex: convert wchar_t to wint_t throughout
...and use __wcollate_range_cmp.  This will have to be tweaked further
when supporting collation symbols...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16 13:45:37 +01:00
Corinna Vinschen 988c304ec2 Cygwin: regex: fix build errors
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16 12:50:08 +01:00
Corinna Vinschen 24f34edc2a Cygwin: replace regex with latest verbatim FreeBSD version
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-16 11:12:08 +01:00
Corinna Vinschen 3569e3577c Cygwin: kill(1): don't print spurious error message
Make kill -V and kill -l exit immediately, thus stopping to
print "not enough arguments" accidentally.

Fixes: ef48a2cad3 ("* kill.cc (prog_name) New global variable.")
Fixes: c49fa76263 ("* Makefile.in (kill.exe): Add as a specific target.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-15 22:08:04 +01:00
Corinna Vinschen 07b5d3726f Cygwin: signals: drop accidental spaces from real-time signal names
The signal names for the real-time signals contain spaces from
the beginning of their availability.  Fix that.

Fixes: 61522196c7 ("* Merge in cygwin-64bit-branch.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-15 21:44:52 +01:00
Mark Geisert dfd14093e3 Cygwin: Fix type mismatch on sys/cpuset.h
Addresses https://cygwin.com/pipermail/cygwin/2023-March/253220.html

Take the opportunity to follow FreeBSD's and Linux's lead in recasting
macro inline code as calls to static inline functions.  This allows the
macros to be type-safe.  In addition, added a lower bound check to the
functions that use a cpu number to avoid a potential buffer underrun on
a bad argument.  h/t to Corinna for the advice on recasting.

Fixes: 362b98b49a ("Cygwin: Implement CPU_SET(3) macros")
2023-03-14 11:26:13 +01:00
Takashi Yano 93f70d7849 Cygwin: ctty: Remove old 'kludge' code.
Remove old 'kludge' code which does not seem necessary anymore. The
comment of the 'kludge' is as follows.

  * syscalls.cc (setsid): On second thought, in the spirit of keeping
    things kludgy, set ctty to -2 here as a special flag, and...
    (open): ...only eschew setting O_NOCTTY when that case is detected.

Fixes: c38a2d8373
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-03-07 10:51:44 +09:00
Takashi Yano 13a84ac79b Cygwin: ctty: Replace ctty constant with more descriptive macros.
This patch replaces ctty constants with more descriptive macros
(CTTY_UNINITIALIZED and CTTY_RELEASED) rather than -1 and -2 as
well as checking sign with CTTY_IS_VALID().

Fixes: 3b7df69aaa (Cygwin: ctty: Add comments for the special values: -1 and -2.)
Suggested-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-03-07 10:51:29 +09:00
Takashi Yano ce979464f3 Cygwin: console: Suppress unnecessary open_shared_console() calls.
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-03-07 10:50:59 +09:00
Takashi Yano 523985b31e Cygwin: ctty: Add missing fixup_after_{exec,fork}() call.
Previously, fixup_after_{exec,fork}() calls for CTTY were missing.
This patch fixes that.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-03-07 10:14:25 +09:00
Corinna Vinschen 5ca1c57a82 Cygwin: is_unicode_equiv: fix comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-03 18:19:18 +01:00
Corinna Vinschen 6bc687e35d Cygwin: glob: fix conversion from UTF-32 to multibyte
The conversion function g_Ctoc missed to drop the flag
values from the wint_t value.  That wasn't noticable with
the original version because it used a 64 bit Char type
and the flags were in the upper 32 bit region.  So the
flag values were silently dropped when wcrtomb was called.
After converting Char to wint_t, we have to do drop the
flags explicitely.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-03 18:19:17 +01:00
Corinna Vinschen 68db1fa7ba Cygwin: define CHARCLASS_NAME_MAX
CHARCLASS_NAME_MAX isn't defined yet, accidentally.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-01 21:22:56 +01:00
Corinna Vinschen c0aba3141b Cygwin: add collating symbols support to release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-01 11:49:52 +01:00
Corinna Vinschen c36064bbd0 Cygwin: fnmatch: support collating symbols in [. .] brackets
This requires quite a few changes in how fnmatch operates.
It always operates on wint_t strings now, just like regex and glob,
and it always keeps a pointer on the character inside the string,
rather than operating on a single character.

As a result, just drop the ifdef's for Cygwin.  The code is
non-portable now anyway...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-01 10:54:52 +01:00
Corinna Vinschen 149cabea82 Cygwin: mbsnrtowci: like mbsnrtowcs, just for wint_t
Deviation from standard: If the input is broken, the output will be
broken.  I. e., we just copy the current byte over into the wint_t
destination and try to pick up on the next byte.  This is in line
with the way fnmatch works.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-01 10:54:52 +01:00
Corinna Vinschen 9870f1d1ff Cygwin: wcichr: add wint_t replacement for wcschr
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-01 10:54:52 +01:00
Corinna Vinschen b81969345d Cygwin: add wcipcpy and wcipncpy helper functions
wint_t replacements for wcpcpy and wcpncpy

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-01 10:54:52 +01:00
Corinna Vinschen 77883ac914 Cygwin: wcitoascii: move to wchar.h as inline function
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-01 10:54:52 +01:00
Corinna Vinschen 0d2ad77c40 Cygwin: fnmatch: drop static variable
fnmatch calls fnmatch1 with a static mbstate_t.  This breaks
calling fnmatch from multiple threads.  Fix it by folding
fnmatch1 into fnmatch and moving all mbstates to local variables.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-28 16:45:52 +01:00
Corinna Vinschen 6e75277b12 Cygwin: __wscollate_range_cmp: fix incorrect comment
The comment that the first arg must be the pattern was added
during development, before it turned out that __wscollate_range_cmp
can be implemented in an order independent way.

Better explain why this function uses pointers to strings.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-28 12:24:29 +01:00
Corinna Vinschen 5011c8cc48 Cygwin: fetch-lc-def-codesets-from-linux: fix locale name handling
As the former call to `locale -av' has the unwanted side effect
to shorten the locale name to <= 15 chars, don't use it.  Use
`locale -a' instead and fetch the codeset from another call to
`locale' for each locale.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-26 20:14:54 +01:00
Corinna Vinschen abd81bc01f Cygwin: locale: fix devanagari modifier
Effectively revert commit 57bac33359.  The fact that the
devanagari modifier was called devanagar (missing the trailing 'i')
is a result of `locale -av' shortening the locale name to a maximum
of 15 characters.

D'oh.  I guess we need a better way to do this...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-26 17:17:33 +01:00
Corinna Vinschen c42b98bdc6 Cygwin: introduce /proc/codesets and /proc/locales
So far locale(1) had to have knowledge how to construct, thus
duplicating the effort how Cygwin handles locale strings.

Move locale list and codeset list generation into Cygwin by
providing /proc/codesets and /proc/locales files.  /proc/locales
does not list aliases, those are still handled in locale(1).

locale(1) opens the files and ueses that info for printing,
like any other application can do now.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-26 17:07:06 +01:00
Corinna Vinschen a31d4039d0 Cygwin: fetch-lc-def-codesets-from-linux: speed up
Drop shell read loop in favor of performing the locale output
evaluation inside a single awk invocation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-25 20:15:53 +01:00
Corinna Vinschen 2483e54be8 Cygwin: locale: Set default charset from Linux locale -> codeset mapping
Generate lc_def_codeset.h header containing the default mapping from
locale to codeset on Linux.  Use this mapping in __set_charset_from_locale
in the first place.

For every locale not covered by this table, just map Windows codepages
to equivalent codesets used on Linux/Unix, getting rid of LCIDs entirely.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-25 16:12:51 +01:00
Corinna Vinschen 7b591704b8 Cygwin: locale: new script creating linux default codeset mapping
New script creating a mapping table from locale to default codeset
for this locale.  We use that in Cygwin now to generate the own
default codeset mapping based on Linux locale names.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-25 16:12:51 +01:00
Corinna Vinschen 57bac33359 Cygwin: locale: fix devanagar modifier
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-25 16:12:51 +01:00
Corinna Vinschen 2b052b3c50 Cygwin: fully support KOI8-T codeset
Commit 89eb4bce15 was pretty half-hearted, missing
the codepage character type tables and wctomb/mbtowc
mappings.

Fixes: 89eb4bce15 ("Cygwin: support KOI8-T codeset")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-25 16:12:51 +01:00
Takashi Yano 0ab22f0af9 Cygwin: dsp: Fix SNDCTL_DSP_{POST,SYNC} ioctl() behaviour.
Previously, SNDCTL_DSP_POST and SNDCTL_DSP_SYNC were implemented
wrongly. Due to this issue, module-oss of pulseaudio generates
choppy sound when SNDCTL_DSP_POST is called. This patch fixes that.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-02-25 10:28:34 +09:00
Corinna Vinschen e95a7a7955 Cygwin: convert Windows locale handling from LCID to ISO5646 strings
Since Windows Vista, locale handling is converted from using numeric
locale identifiers (LCID) to using ISO5646 locale strings.  In the
meantime Windows introduced new locales which don't even have a LCID
attached.  Those were unusable in Cygwin because locale information
for these locales required to call the new locale functions taking
a locale string.

Convert Cygwin to drop LCIDs and use Windows ISO5646 locales instead.

The last place using LCIDs is the __set_charset_from_locale function.
Checking numerically is easier and uslay faster than checking strings.
However, this function is clearly a TODO
2023-02-24 16:40:58 +01:00
Corinna Vinschen 89eb4bce15 Cygwin: support KOI8-T codeset
Used on Linux as default codeset for Tajik. There's no matching
Windows codepage, so fake it as CP103.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-24 16:40:58 +01:00
Corinna Vinschen 2229f42400 Cygwin: __wscollate_range_cmp: workaround wcscoll's case-insensitivity
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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-22 12:20:32 +01:00
Corinna Vinschen a51147467e 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).
2023-02-22 10:47:54 +01:00
Corinna Vinschen f3f20038c4 Cygwin: glob: perform correct utf-32 -> multibyte conversion
g_Ctoc, converting the UTF-32 filenames to multibyte, still
used UTF-16 to  multibyte conversion.  Introduce a wirtomb
helper and fix that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-22 10:03:03 +01:00
Corinna Vinschen 4349a1e4db Cygwin: glob: fix includes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-22 10:00:10 +01:00
Corinna Vinschen 4ab778df24 Cygwin: linux-locale-helpers: helper tools to generate locale data from Linux
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-20 23:00:04 +01:00
Corinna Vinschen ce5aa09807 Cygwin: glob: implement collating symbol support
Allow the [.<sym>.] expression

This requires a string comparision rather than a character
comparison.  Introduce and use __wscollate_range_cmp.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-20 22:50:17 +01:00
Corinna Vinschen 244faaea8e 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-20 22:47:17 +01:00
Corinna Vinschen 1eadb23887 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.
2023-02-20 22:38:52 +01:00
Corinna Vinschen ffba9604d1 Cygwin: add more UTF-32 helper functions
wcintowcs: convert UTF-16 to UTF-32 string
wcilen: return number of characters in a UTF-32 string
wcincmp: compare two fixed-size UTF-32 strings

Used in followup patches introducing collating symbols

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-20 22:29:37 +01:00
Corinna Vinschen 1cbe4b3dcc Cygwin: glob: sort in current locale's collating order
Follow glibc here.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-20 22:24:06 +01:00
Corinna Vinschen 064e4bb8bb Cygwin: convert __collate_range_cmp to __wcollate_range_cmp
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=179721

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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-19 14:40:29 +01:00
Corinna Vinschen f0417a6201 Cygwin: is_unicode_equiv: fix normalization
Change normalization to form KD and make room for longer
decomposed sequences.
2023-02-18 23:14:11 +01:00
Corinna Vinschen e4cc9e4846 Cygwin: is_unicode_equiv: fix comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-16 20:52:20 +01:00
Takashi Yano a9a17f5fe5 Cygwin: dsp: Fix SNDCTL_DSP_GET[IO]SPACE before read()/write().
Even with the commit 3a4c740f59, 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.

Fixes: 3a4c740f59 ("Cygwin: dsp: Implement SNDCTL_DSP_SETFRAGMENT ioctl().")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-02-16 20:14:13 +09:00
Corinna Vinschen c750a728bd add glob/fnmatch equivalence class support to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-15 22:37:32 +01:00
Corinna Vinschen 1df19b3cae Cygwin: glob: handle equivalence class expressions
Handle [=x=] expressions in range brackets.  Use the new
is_unicode_equiv() function to perform the check.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-15 22:34:46 +01:00
Corinna Vinschen 20162667de Cygwin: fnmatch: handle equivalence class expressions
Handle [=x=] expressions in range brackets.  Use the new
is_unicode_equiv() function to perform the check.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-15 22:31:49 +01:00
Corinna Vinschen b5f9b0241a 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:

  fnmatch("[=n=]", "ñ") == 0
  fnmatch("[=ñ=]", "n") == 0

but

  fnmatch("[=n=]", "n\x0303") == 1
  fnmatch("[=n\x0303=]", "n") == 1
  fnmatch("[=n\x0303=]", "n\x0303") == 1

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-15 22:00:39 +01:00
Corinna Vinschen be67844f5d Cygwin: Makefile.am: fix rule to create version from git describe
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-15 15:04:16 +01:00
Corinna Vinschen 65446dd4f0 Cygwin: add glob/fnmatch named class support to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-15 14:22:26 +01:00
Corinna Vinschen d6d4436145 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-15 14:11:45 +01:00
Corinna Vinschen 7faa646553 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-14 20:22:54 +01:00
Corinna Vinschen 1fc35f30bd Cygwin: mbrtowi: fix return type
bad typo: change wint_t to size_t

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-14 20:18:42 +01:00
Corinna Vinschen 588624da2b Cygwin: regex: convert wchar_t to wint_t
- call mbrtowi instead of mbrtowc
- drop Cygwin-only surrogate handling from wgetnext and xmbrtowc since
  it's encapsulated in mbrtowi.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-14 13:02:15 +01:00
Corinna Vinschen 0321fb5736 Cygwin: glob: convert wchar_t to wint_t
...thus handling all Unicode values sanely.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-14 12:48:31 +01:00
Corinna Vinschen 99da4956c5 Cygwin: fnmatch: convert wchar_t to wint_t
...thus handling all Unicode values sanely.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-14 12:48:31 +01:00
Corinna Vinschen eac830e0fe Cygwin: __collate_range_cmp: handle Unicode values >= 0x10000
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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-14 12:48:26 +01:00
Corinna Vinschen 60c25da90d 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-14 12:20:20 +01:00
Corinna Vinschen 210eca1b31 Cygwin: socket.h: define missing IPTOS_LOWCOST/IPTOS_MINCOST
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-12 21:42:26 +01:00
Corinna Vinschen 498fce80ef 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.

Fixes: bc444e5aa4 ("Reapply POSIX ACL changes.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-09 21:58:44 +01:00
Corinna Vinschen 9afd4c0558 Cygwin: chmod: don't drop default ACEs from directory ACLs
commit bc444e5aa4 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.

Fixes: bc444e5aa4 ("Reapply POSIX ACL changes.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-09 21:58:20 +01:00
Corinna Vinschen 283583c5f2 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 bc444e5aa4.

Fix it by applying umask on the default ACEs.

Fixes: bc444e5aa4 ("Reapply POSIX ACL change.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-02-09 21:58:07 +01:00
Takashi Yano 3a4c740f59 Cygwin: dsp: Implement SNDCTL_DSP_SETFRAGMENT ioctl().
Previously, SNDCTL_DSP_SETFRAGMENT was just a fake. In this patch,
it has been implemented to allow latency control in some apps.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-01-31 20:35:53 +09:00
Corinna Vinschen c061551c67 Cygwin: add new cygcheck capabilities to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-29 18:40:14 +01:00
Takashi Yano bf91542004 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.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-01-26 02:04:18 +09:00
Corinna Vinschen cad3913ed8 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: 6338d2f24a ("Cygwin: mount: allow any valid character in UNC paths")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-23 14:02:20 +01:00
Corinna Vinschen 6338d2f24a 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.

Fixes: 1fd5e000ac ("import winsup-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-22 20:15:37 +01:00
Takashi Yano bdb9f5b173 Cygwin: fsync: Fix EINVAL for block device.
The commit af8a7c13b5 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: af8a7c13b5 ("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>
2023-01-22 19:01:34 +09:00
Corinna Vinschen 3123fdeecb Cygwin: tape: tapes are character devices, not block devices
Fixes: 727a81f4d9 ("* devices.h (device::exists_func): Redefine field.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-21 18:25:56 +01:00
Corinna Vinschen 03bbde566a Cygwin: Add 3.4.5 release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-19 18:33:40 +01:00
Takashi Yano 9522166db1 Cygwin: dsp: Fix a problem that fcntl() does not take effect.
Previously, fhandler_dev_dsp (OSS) has a problem that fcntl() does
not take effect at all. This patch fixes the issue.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-19 22:54:12 +09:00
Corinna Vinschen 3c2ac163da Cygwin: fix two comments in heap.cc and memory_layout.h
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-18 20:13:38 +01:00
Corinna Vinschen e1fcd10b48 Cygwin: memory_init: initialize user heap here
Eventually move user heap initialization to memory_init.
The call order is not changed. Drop a now useless comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-18 20:13:38 +01:00
Corinna Vinschen 7e332208a0 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.

Avoid this by bumping next_address every time.

While at it, fix a comment.

Fixes: dc0fe7742b ("Cygwin: open_shared: try harder allocating a shared region")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-18 20:13:36 +01:00
Corinna Vinschen 31302b267b Cygwin: drop fixed addresses for standard shared regions
With the previous commit 9ddd48ee1b ("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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-18 13:16:50 +01:00
Corinna Vinschen 9ddd48ee1b 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-17 22:00:48 +01:00
Corinna Vinschen dc0fe7742b 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: 60675f1a7e ("Cygwin: decouple shared mem regions from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-17 18:41:10 +01:00
Corinna Vinschen 50cbbb1c0e Cygwin: Move shared regions, rename PINFO... to MYSELF_REGION_ADDRESS
Fix comments accordingly.

This is in preparation for a change in open_shared, handling shared
regions more cleanly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-17 17:07:11 +01:00
Corinna Vinschen 93508e5bb8 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-17 16:32:14 +01:00
Corinna Vinschen 77680cac94 Cygwin: autoload: clean up arguments to LoadDllFunc*
The number of args multiplied by 4 was only required for
32 bit x86 to construct the symbol name correctly.  Drop it.

In the assembler code, split the numerical values for "notimp"
and "err" into half words for cleaner layout.

Fix description accordingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-17 16:32:14 +01:00
Corinna Vinschen 49b52521f3 Cygwin: /proc/cpuinfo: always print trailing empty line, as on Linux
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-16 21:40:59 +01:00
Corinna Vinschen 75c375e86d 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.

Fixes: e0d48debed ("Fix /proc/cpuinfo topology and cache size info")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-16 14:23:38 +01:00
Corinna Vinschen 62b9c98f12 Cygwin: add newgrp(1) to release message for 3.5.0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-14 18:00:35 +01:00
Corinna Vinschen e5880bef39 Cygwin: wincap.h: clarify NO_COPY_RO usage
...and drop one unnecessary usage of NO_COPY_RO.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-12 10:51:39 +01:00
Corinna Vinschen e7d0f0eb41 Cygwin: wincap: make capability flags readonly
So far the capability bits were stored in the .cygwin_dll_common
R/W section because we overwrite the is_server bit.  Just don't.
Move the bit to class wincapc instead and define all wincaps
bitfields const.

Fixes: 8937c103ed ("* wincap.cc (all wincaps): Store in .cygwin_dll_common section same as wincap.  Add comment to explain why.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-12 10:34:32 +01:00
Takashi Yano 3b7df69aaa Cygwin: ctty: Add comments for the special values: -1 and -2.
_pinfo::ctty has two special values other than the device id of
the allocated ctty:
-1: CTTY is not initialized yet. Can be associated with the TTY
    which is associated with the session leader.
-2: CTTY has been released by setsid(). Can be associate only with
    new TTY which is not associated with any other session as CTTY,
    but cannot be associate with the TTYs already associated with
    other sessions.
This patch adds the comments in some source files.

Suggested-by: Corinna Vinschen <corinna@vinschen.de>
Signedoff-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-01-10 22:04:40 +09:00
Takashi Yano 8e77725f31 Cygwin: pinfo: Additional fix for CTTY behavior.
The commit 25c4ad6ea5 did not fix the CTTY behavior enough. For
example, in the following test case, TTY will be associated as
a CTTY on the second open() call even though the TTY is already
CTTY of another session. This patch fixes the issue.

  #include <unistd.h>
  #include <sys/fcntl.h>

  int main()
  {
    if (fork () == 0) {
      char *tty = ttyname(0);
      int fd;
      setsid();
      fd = open(tty, O_RDWR);
      close(fd);
      fd = open(tty, O_RDWR);
      usleep (60000000L);
    }
    return 0;
  }

Fixes: 25c4ad6ea5 ("Cygwin: pinfo: Align CTTY behavior to the
statement of POSIX.")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-01-10 21:35:35 +09:00
Takashi Yano a81fef51cf Cygwin: cygheap: Initialize myself_pinfo before child_copy().
After the commit 30add3e6b3, the problem:
https://cygwin.com/pipermail/cygwin/2022-December/252759.html
occurs rarely. It seems that myself_pinfo should be initialized
where the timing before child_copy() and after cygheap allocation.
This patch moves the initialization there.

Fixes: 30add3e6b3 ("Cygwin: exec: don't access cygheap before it's
initialized")
Reported-by: Brian Inglis <Brian.Inglis@Shaw.ca>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-01-10 21:04:29 +09:00
Corinna Vinschen 7c14e5a10a Cygwin: /proc/<PID>/status: avoid crash computing signal info
The code computing the mask of pending signals used the per-queued
signal TLS pointer without checking it for NULL.  Fix this by using
the process-wide signal mask in that case.

Fixes: 195169186b ("Cygwin: wait_sig: allow to compute process-wide mask of pending signals")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-10 11:48:02 +01:00
Jon Turney 1a9f95d894
Cygwin: Run testsuite against the just-built DLL
Since 4e7817498e, we're just running the tests against the installed
DLL.  We're arranging to put the build directory on the path, but since
it doesn't contain cygwin1.dll (since it's built with a different name
and renamed on installation), that doesn't have any effect.

Arrange to place the just-built DLL into a directory which the testsuite
can place on it's path (while running the test, but not while compiling
it).

Also fix any remaining references to cygwin0.dll in testsuite,
documentation and comments.

Fixes: 4e7817498e ("Cygwin: Makefile: Drop all the "test dll" considerations")
2023-01-10 10:27:13 +00:00
Corinna Vinschen 9ee1e1b693 Cygwin: /proc/<PID>/status: simplify code generating signal info
The code generating the signal info in _pinfo::siginfo() and in
commune_process() are doing the same thing.  Create a local static
function commune_process_siginfo() to have the code in one place
only.  Remove a useless sigpending() call.

Fixes: 9a3c058f66 ("Cygwin: /proc/<PID>/status: Fill SigPnd, SigBlk and SigIgn values with life")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-01-09 18:02:14 +01:00
Corinna Vinschen 7886327fbf Cygwin: reinstantiate exporting _alloca
This basically reverts commit 1556b96b1b.

Turns out that _alloca is actually used, for instance, by clang.
2023-01-09 13:42:53 +01:00
Brian Inglis 8a003605c1 fhandler/proc.cc(format_proc_cpuinfo): add Linux 6.1 cpuinfo
Intel 0x00000007:1 EAX:26 lam	Linear Address Masking (& recent entries)
2022-12-23 10:03:23 +01:00
Takashi Yano d0bad6996d Cygwin: Add release message for latest console change.
3721a756b0 ("Cygwin: console: Make the console accessible from other
terminals.")

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 23:20:52 +09:00
Takashi Yano 3721a756b0 Cygwin: console: Make the console accessible from other terminals.
Previously, the console device could not be accessed from other terminals.
Due to this limitation, GNU screen and tmux cannot be opened in console.
With this patch, console device can be accessed from other TTYs, such as
other consoles or ptys. Thanks to this patch, screen and tmux get working
in console.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 21:05:31 +09:00
Takashi Yano 043b6089e2 Cygwin: devices: Make generic console devices invisible from pty.
The devices /dev/conin,conout,console were wrongly visible from ptys,
though they are inaccessible. This is because fhandler_console::exists()
returns true due to existing invisible console. This patch makes these
devices invisible from ptys.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 20:57:29 +09:00
Takashi Yano 25c4ad6ea5 Cygwin: pinfo: Align CTTY behavior to the statement of POSIX.
POSIX states "A terminal may be the controlling terminal for at most
one session."
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap11.html

However, in cygwin, multiple sessions could be associated with the
same TTY. This patch aligns CTTY behavior to the statement of POSIX.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 20:57:17 +09:00
Takashi Yano f6e4e98d30 Cygwin: console: Fix hangup of less on quit after the window is resized.
https://cygwin.com/pipermail/cygwin/2022-December/252737.html

If the less is started from non-cygwin shell and window size is
changed, it will hang-up when quitting. The cause of the proglem is
that less uses longjump() in signal handler. If the signal handler
is called while cygwin is acquiring the mutex, cygwin loses the
chance to release mutex. With this patch, the mutex is released
just before calling kill_pgrp() and re-acquired when kill_pgrp()
returns.

Reported-by: Gregory Mason <grmason@epic.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-22 20:38:08 +09:00
Jon Turney 4e7817498e
Cygwin: Makefile: Drop all the "test dll" considerations
After 90236c3a2c, the testsuite is failing, as the cygwin0.dll
referenced by the implib that testsuite programs are linked with doesn't
exist anymore.

We don't need to make and link the testsuite with a specially named DLL,
as the cygwin DLL (since 526b0fbca3) takes into consideration the path
it's executing from to define separate "Cygwin installations", which
don't interact.

Fixes: 90236c3a2c ("Cygwin: Makefile: build new-cygwin1.dll in a single step")
2022-12-21 17:43:11 +00:00
Corinna Vinschen 09cb4cd294 Cygwin: path_conv: make sure sym.path_flags is always initialized
Commit c1023ee353 introduced a split between mount flags and
path flags.  It didn't initialize symlink_info::path_flags in
path_conv::check, because that's done in symlink_info::check.

However, there are two code paths expecting symlink_info::path_flags
being already initialized and both skip symlink_info::check.

Make sure symlink_info::path_flags is initalized to 0 early in
path_conv::check.

Fixes: c1023ee353 ("Cygwin: path_conv: decouple path_types from mount types")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-21 13:13:24 +01:00
Corinna Vinschen 2af7dd9567 Cygwin: x86_64: import swab.S from NetBSD
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:19:23 +01:00
Corinna Vinschen 43743ed754 Cygwin: x86_64: import latest NetBSD bcopy.S
Tweak slightly to allow implementing entire {w}mem{p}{cpy,move}
family:

Add WIDE macro processing for wmem* and POST macro processing for
memp* functions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Corinna Vinschen b09617a828 Cygwin: x86_64: import memchr.S from NetBSD
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Corinna Vinschen 3830325502 Cygwin: x86_64: import new memset.S from NetBSD
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Corinna Vinschen 8e83ca675f Cygwin: add local machine/asm.h header
This header supports including BSD assembler sources.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Corinna Vinschen a25730119c Cygwin: use .S suffix for assembler files
Automake generates different recipies for .s.o vs. .S.o rules.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Corinna Vinschen fd3ce87f73 Cygwin: check_reparse_point_target: fix comment format
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-20 10:13:59 +01:00
Jon Turney 8fdc201ec3
Cygwin: Update 3.4.3 release note
(cherry picked from commit 5366b3403c)
2022-12-16 13:36:22 +00:00
Jon Turney 242a2a5971
Revert "Cygwin: x86_64: add wmemset assembler entry point"
This reverts commit 188d5f6c9a.

(cherry picked from commit 98fa366cb6)
2022-12-16 13:36:06 +00:00
Corinna Vinschen 489300c89d Cygwin: add release message for latest path handling patch
5ba5e09b9d ("Cygwin: path handling: never substitute virtual drive with target path")

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-14 11:58:08 +01:00
Corinna Vinschen 90236c3a2c Cygwin: Makefile: build new-cygwin1.dll in a single step
The complicated build routine was only required because we needed
the .cygheap section at the end of the file, and the debug sections
broke this.  Now that the cygheap is out of the way, we really don't
have to do this anymore, and the build can just generate a DLL with
integrated debug info.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-13 14:16:13 +01:00
Corinna Vinschen f34db341fc Cygwin: Makefile: only regenerate cygwin_version.c if it changes
Make sure to create a new cygwin_version.c if it either doesn't
exist yet, or if it would be different from the former file.
This avoids unnecessary DLL rebuilding.

Fixes: 97eb64b909 ("Cygwin: uname: generate default release string from git as well")
Fixes: 4949a82cde ("Cygwin: uname: fix building in non-git source dir")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-13 14:16:13 +01:00
Corinna Vinschen 5ba5e09b9d Cygwin: path handling: never substitute virtual drive with target path
Move the drive substitution code after the call to
GetFinalPathNameByHandleW into a local function revert_virtual_drive
and add code to handle non-remote virtual drives, i. e., those
created with the subst command.  (Try to) make sure that virtual
drives are never treated like symlinks.

Fixes: 19d59ce75d ("Cygwin: path_conv: Rework handling native symlinks as inner path components")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-12 21:56:14 +01:00
Corinna Vinschen 45794e0d66 Cygwin: add 3.4.2 release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-11 11:45:36 +01:00
Takashi Yano faac79783c Cygwin: pty: Use GetTickCount64() instead of GetTickCount().
Suggested-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-09 21:01:42 +09:00
Takashi Yano be635ebc2f Cygwin: pipe: Fix performance degradation for non-cygwin pipe.
https://cygwin.com/pipermail/cygwin/2022-December/252628.html

After the commit 9e4d308cd5, the performance of read from non-cygwin
pipe has been degraded. This is because select_sem mechanism does not
work for non-cygwin pipe. This patch fixes the issue.

Fixes: 9e4d308cd5 ("Cygwin: pipe: Adopt FILE_SYNCHRONOUS_IO_NONALERT
flag for read pipe.")
Reported-by: tryandbuy <tryandbuy@proton.me>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2022-12-09 21:01:29 +09:00
Corinna Vinschen 3a910b624a Cygwin: improve release text for FILE issue
Add a note in terms of 3.4.0 compatibility.

Suggested-by: Markus Mützel <markus.muetzel@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-09 12:41:54 +01:00
Corinna Vinschen 55de3fdd0e Cygwin: define FILE as struct __sFILE64, not as __sFILE
Until Cygwin 3.3.6, we define __LARGE64_FILES unconditionally, so we
were using the type __sFILE64 even for 64 bit.  That was lazy and wrong.
so commit 2902b3a09e ("Cygwin: drop requirement to build newlib's
stdio64") tried to fix that.

Unfortunately this patch forgot to take the exposure of the typename
__sFILE64 in userspace into account.  This leads to trouble in C++ due
to name mangling.

Commit 0f376ae220 tried to fix this by just renaming __sFILE to
__sFILE64 by using a macro.  While __sFILE and __sFILE64 are the same
size, they are not exactly congruent.

To avoid backward compatibility problems, make sure to define FILE
as the  real __sFILE64, and make sure that __sFILE is not defined at
all on Cygwin.

Fixes: 0f376ae220 ("Cygwin: rename __sFILE to __sFILE64 for backward
compatibility")
Fixes: 2902b3a09e ("Cygwin: drop requirement to build newlib's stdio64")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-08 17:16:20 +01:00
Corinna Vinschen 6429a7a7f6 Cygwin: add __sFILE64 fix to 3.4.1 release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-08 14:19:22 +01:00
Corinna Vinschen 0f376ae220 Cygwin: rename __sFILE to __sFILE64 for backward compatibility
Until Cygwin 3.3.6, we define __LARGE64_FILES unconditionally, so we
were using the type __sFILE64 even for 64 bit.  That was lazy and wrong.
so commit 2902b3a09e ("Cygwin: drop requirement to build newlib's
stdio64") tried to fix that.

Unfortunately this patch forgot to take the exposure of the typename
__sFILE64 in userspace into account.  This leads to trouble in C++ due
to name mangling.

Fix this by redefining __sFILE to __sFILE64.  The type name is very much
internal, so it doesn't really matter, except for the fact that it needs
to stay backward compatible so as not to break building against C++ libs
built under older versions of Cygwin.

Fixes: 2902b3a09e ("Cygwin: drop requirement to build newlib's stdio64")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-12-08 13:58:37 +01:00
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
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