Commit Graph

21196 Commits

Author SHA1 Message Date
Jennifer Averett 742b8db95d Move signgm.c from libc/reent to libm/math 2023-05-05 14:49:48 -04:00
Biswapriyo Nath 3bee68248f
Cygwin: Fix compiling with w32api-headers v11.0.0
This solves redefinition of FILE_CS_FLAG_CASE_SENSITIVE_DIR in winnt.h
and fixes the following compiler errors

ntdll.h:523:3: error: expected identifier before numeric constant
  523 |   FILE_CS_FLAG_CASE_SENSITIVE_DIR                       = 0x01
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ntdll.h:522:1: note: to match this ‘{’
  522 | {
      | ^
2023-05-01 11:40:52 +01:00
Jon Turney d160bcd4aa
Cygwin: doc: Upate a link from gitweb to cgit
Also, reword 'considerable patch' to be more idomatic.
2023-05-01 11:29:15 +01:00
Sebastian Huber e301a74a6f Fix _REENT_EMERGENCY() if TLS is enabled
If the thread-local storage (TLS) support was enabled, the _REENT_EMERGENCY()
object had the wrong size.  It must be a buffer of length _REENT_EMERGENCY_SIZE
and not just a single character.
2023-04-26 08:23:04 +02:00
Corinna Vinschen c3798a2f7d Cygwin: locales: drop unused has_modifier macro
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-24 22:41:41 +02:00
Corinna Vinschen 48ae24fd81 Cygwin: locales: ignore @cjkwide and @cjksingle just like @cjknarrow
When the @cjkwide and @cjksingle modifiers have been added, the
patches missed to add checks for the new modifiers in the Cygwin
locale code.  Along the same lines, commit c3e7f7609e forgot to
add a test for @cjksingle.

Merge check for cjk* modifiers into a macro set andf use that
throughout. Fix comments.

Fixes: f92f048528 ("Locale modifier @cjkwide to adjust ambiguous-width in non-CJK locales")
Fixes: c8204b1069 ("Locale modifier "@cjksingle" to enforce single-width CJK width.")
Fixes: c3e7f7609e ("Cygwin: locales: fix behaviour for @cjk* and @euro locales")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-24 22:41:41 +02:00
Sebastian Huber fd26d4b4b6 RTEMS: Add __m68k_read_tp() to crt0.c
This is required to build libgomp.
2023-04-24 10:21:42 +02:00
Corinna Vinschen da40bd6eaf Cygwin: posix_spawnp: don't fallback to sh
Per the discussion starting with
https://cygwin.com/pipermail/cygwin/2023-April/253495.html
stop falling back to sh if the file given to posix_spawnp
is no executable.

This is not necessarily the last word on it, given
https://www.austingroupbugs.net/view.php?id=1674, but for now,
opt for following the proposal in the Austin Group bug entry,
as well as PASSing the GNULIB test-posix_spawnp-script test.

Fixes: c7c1a1ca1b ("Add support for new posix_spawn function.")
Fixes: 3fbfcd11fb ("Cygwin: posix_spawn: add Cygwin-specific code fixing process synchronisation")
Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-19 21:08:48 +02:00
Corinna Vinschen 3124d8b436 posix_spawn_file_actions_addfchdir_np: return EBADF on negative fd
FreeBSD and Musl implement posix_spawn_file_actions_addfchdir_np
so that it checks the incoming descriptor for being negative, and,
if so, return with EBADF.  The POSIX proposal defining
posix_spawn_file_actions_addfchdir follows this behaviour, see
https://www.austingroupbugs.net/view.php?id=1208

Fixes: 7e03fc35f5 ("Add posix_spawn_file_actions_add{f}chdir_np")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-19 20:48:14 +02:00
David McFarland 53f7fb20a0 Cygwin: mbrtowi: fix segfault when pwi is NULL
mbrtowi was missing null-checks on pwi, but NULL is passed from
regex/engine.c:173.

In a git repo with sendemail.smtpserver set, this results in a segfault when
using git-send-email, which calls:

git config --get-regexp '^sende?mail[.]'

Fixes: 60c25da90d ("Cygwin: mbrtowi: define replacement for mbrtowc, returning UTF-32 value")
Signed-off-by: David McFarland <corngood@gmail.com>
2023-04-19 10:14:46 +02:00
Corinna Vinschen c743751aaf Cygwin: Export posix_spawn_file_actions_add{f}chdir_np
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-19 00:34:36 +02:00
Corinna Vinschen 7e03fc35f5 Add posix_spawn_file_actions_add{f}chdir_np
These are defined as _np functions and available in glibc, musl, macOS,
FreeBSD, Solaris ≥ 11.3

They are likely to be standardized without the _np suffix as a result of
Austin Group issue 1208. if so, both names will be kept as aliases.

Introduce HAVE_CHDIR and HAVE_FCHDIR to allow building on systems not
providing these calls.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18 23:47:28 +02:00
Corinna Vinschen d30a5917a9 Cygwin: align renameat2 to Linux behaviour
In contrast to rename default behaviour, Linux' renameat2 returns -1
with errno set to EEXIST, if oldfile and newfile refer to the same
file, and the RENAME_NOREPLACE flag is set.

Follow suit, given this is a Linux-only function anyway.

Fixes: f665b1cef3 ("cygwin: Implement renameat2")
Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18 18:18:27 +02:00
Corinna Vinschen fa84aa4dd2 Cygwin: fix errno values set by readlinkat
readlinkat(fd, "", ...) is supposed to return ENOENT per POSIX,
but Cygwin returns EBADF.

At the same time, we have to maintain the special feature of
glibc that readlinkat(fd, "", ...) operates on fd, if fd is pointing
at a symlink opened with O_PATH|O_NOFOLLOW.

And, while fixing that, readlinkat(fd, path, ...) *still* has to set errno
to EBADF, if fd is an invalid descriptor *and* path is a relative path.

This required to change the evaluation order in the helper function
gen_full_path_at.

Last but not least, in case of the aforementioned glibc-like special
handling for symlink descriptors, we have to make sure that errors from
gen_full_path_at are not spilled into that special handling.

Fixes: 6cc05784e1 ("Cygwin: readlinkat: allow pathname to be empty")
Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18 13:52:50 +02:00
Corinna Vinschen 2fbb06d3cb Cygwin: fix return value of ilogbl(NaN)
Fixes: 792e51b721 ("Add missing long double functions to Cygwin")
Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18 13:43:06 +02:00
Corinna Vinschen 836d04d98c Cygwin: add release text for previous commit
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-18 10:12:03 +02:00
David McFarland a14a0e542d Cygwin: cygheap: fix fork error after heap has grown
2f9b8ff0 introduced a problem where forks would sometimes fail with:

child_copy: cygheap read copy failed, 0x0..0x80044C750, done 0, windows pid 14032, Win32 error 299

When cygheap_max was > CYGHEAP_STORAGE_INITIAL, commit_size would be set to
allocsize(cygheap_max), which is an address, not a size.  VirtualAlloc would be
called to commit commit_size bytes, which would fail, and then child_copy would
be called with zero as the base address.

Fixes: 2f9b8ff00c ("Cygwin: decouple cygheap from Cygwin DLL")
Signed-off-by: David McFarland <corngood@gmail.com>
2023-04-18 10:06:53 +02:00
Takashi Yano e5fcc5837c Cygwin: pty: Fix reading CONIN$ when stdin is not a pty.
Previously, the pty master sends inputs to the pipe for cygwin app
even when pseudo console is activated if stdin is not the pty.
This causes the problem that key input is not sent to non cygwin
app even if the app opens CONIN$. This patch sets switch_to_nat_pipe
to true regardless whether stdin is the pty or not to allow that case.

https://cygwin.com/pipermail/cygwin/2023-April/253424.html

Reported-by: Wladislav Artsimovich <cygwin@frost.kiwi>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-04-14 11:22:33 +09:00
Andoni Arregi ef75abddc7 Replace always true if with else 2023-04-13 13:36:11 -04:00
Andoni Arregi 9e89e66729 Compare j as unsigned
j is int32_t and thus j<<31 is undefined if j==1.

Taken from FreeBSD commit bdd8abc6d6a93ce3ab8ad5db716222ee3110c4a3
2023-04-13 13:34:57 -04:00
Andoni Arregi e5a36e6af7 Fix x close to 1, y between 2^31 and 2^64
E.g. known errors:
x = 0x1.000002c5e2e99p+0, y = 0x1.c9eee35374af6p+31 had an error of 639
ULP and is now correctly rounded.
x = 0x1.fffffd2e3e669p-1, y = 0x1.344c9823eb66cp+32 had an error of 428
ULP and is now correctly rounded.
2023-04-13 13:33:46 -04:00
Andoni Arregi 5a961061de Fix missing sign for overflow/underflow where x is negative and y is large odd integer 2023-04-13 13:32:47 -04:00
Corinna Vinschen be2749cd4e Cygwin: chattr: fix description of requirements for casesensitive directories
Preconditions of WSL or empty directories dependent on Windows
versions was totally screwed up.  Drop the description from
--help, describe the preconditions for case-sensitive dirs in the
man page instead.

Fixes: fc6e89c937 ("Cygwin: chattr: clarify requirements for casesensitive directories")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-04-03 22:41:07 +02:00
Johannes Schindelin cc8404039f Respect `db_home` setting even for SYSTEM/Microsoft accounts
We should not blindly set the home directory of the SYSTEM account (or
of Microsoft accounts) to `/home/<name>`, especially
`/etc/nsswitch.conf` defines `db_home: env`, in which case we want to
respect the `HOME` variable.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-04-03 18:17:43 +02:00
Tobias Burnus 544aa97f86 Bump newlib version in the manual to 4.3.0
While commit 9e09d6ed8 (tag: newlib-4.3.0) bumped the newlib version to 4.3.0,
this commit updates the version/date in the libc/libm manuals to match.
2023-03-30 14:09:30 +02:00
Corinna Vinschen 93b05a87c2 Cygwin: doc: fix description of new "env" schema for /etc/nsswitch.conf
Fixes: 27376c60a9 ("Allow deriving the current user's home directory via the HOME variable")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-29 10:34:30 +02:00
Corinna Vinschen 2898a359b8 Cygwin: dirname: fix handling of leading slashes
Per https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/xbd_chap04.html:

  "A pathname that begins with two successive slashes may be interpreted
   in an implementation-defined manner, although more than two leading
   slashes shall be treated as a single slash."

So more than 2 leading slashes are supposed to be folded into one,
which our dirname neglected.  Fix that.

Fixes: 24e8fc6872 ("* cygwin.din (basename): Export.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-29 10:23:05 +02:00
Johannes Schindelin 27376c60a9 Allow deriving the current user's home directory via the HOME variable
This patch hails from Git for Windows (where the Cygwin runtime is used
in the form of a slightly modified MSYS2 runtime), where it is a
well-established technique to let the `$HOME` variable define where the
current user's home directory is, falling back to `$HOMEDRIVE$HOMEPATH`
and `$USERPROFILE`.

The idea is that we want to share user-specific settings between
programs, whether they be Cygwin, MSYS2 or not.  Unfortunately, we
cannot blindly activate the "db_home: windows" setting because in some
setups, the user's home directory is set to a hidden directory via an
UNC path (\\share\some\hidden\folder$) -- something many programs
cannot handle correctly, e.g. `cmd.exe` and other native Windows
applications that users want to employ as Git helpers.

The established technique is to allow setting the user's home directory
via the environment variables mentioned above: `$HOMEDRIVE$HOMEPATH` or
`$USERPROFILE`.  This has the additional advantage that it is much
faster than querying the Windows user database.

Of course this scheme needs to be opt-in.  For that reason, it needs
to be activated explicitly via `db_home: env` in `/etc/nsswitch.conf`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2023-03-28 12:18:14 +02:00
Corinna Vinschen fc6e89c937 Cygwin: chattr: clarify requirements for casesensitive directories
- Windows 10 requires WSL
- Windows 11 only allows enabling casesensitivity if dir is empty

Fixes: 0d4b39d37b ("Cygwin: Add lsattr and chattr tools")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-27 20:39:26 +02:00
Corinna Vinschen 80cea27942 Cygwin: /proc/locales: filter out useless explicit utf8 locales
Fixes: c42b98bdc6 ("Cygwin: introduce /proc/codesets and /proc/locales")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-26 14:12:13 +02:00
Corinna Vinschen 2d5492453a Cygwin: locales: fix behaviour for @euro locales
Latest Windows supports more EU locales than GLibc, so some of the
@euro locales are not covered by checking the GLibc locale defaults.
Those locales have no long history, they are all UTF-8.  So just
check for @euro in the UTF-8 case and set them to ISO-8859-15.

Fixes: 2483e54be8 ("Cygwin: locale: Set default charset from Linux locale -> codeset mapping")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-26 13:06:38 +02:00
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
Corinna Vinschen 606373e7d2 newlocale: set errno to ENOENT if __loadlocale fails
__loadlocale never sets errno, but newlocale is supposed to
return ENOENT if the locale isn't valid.

Fixes: aefd8b5b51 ("Implement newlocale, freelocale, duplocale, uselocale")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-03-24 12:44:52 +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