Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
Previsouly, FLUSHO did not work correctly.
1) Even when FLUSHO is set, read() returns with undesired data in
the pipe if select() is called in advance.
2) FLUSHO is toggled even in the case pseudo console enabled.
Due to these problems, read data in the pty master was partially
lost when Ctrl-O is pressed.
With this patch, the mask_flusho flag, that was introduced by the
commit 9677efcf005a and caused the issue 1), has been dropped and
select() and read() for pty master discards the pipe data instead
if FLUSHO flag is set. In addition, FLUSHO handling in the case
pseudo console activated is disabled.
Addresses: https://cygwin.com/pipermail/cygwin/2025-August/258717.html
Fixes: 2cab4d0bb4af ("Cygwin: pty, console: Refactor the code processing special keys.")
Fixes: 9677efcf005a ("Cygwin: pty: Make FLUSHO and Ctrl-O work.")
Reported-by: Reported-by: Thomas Wolff <towo@towo.net>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
The vector ilogb routines, including the ones inlined into fmod, had a bug
in which the conditional masks were not properly applied, causing the value of
one lane to be affected by conditional choices of another lane. The problem
was not immediately obviously because all values were calculated correctly when
no lane contained a subnormal input.
The problem is fixed by proper use of VECTOR_COND_MOVE and VECTOR_WHILE.
|
|
The commit adding OFD locks changed from comparing just the F_POSIX and
F_LOCK flags to comparing the entire flags value in order to make sure
the locks are of the same type. However, the F_WAIT flag may or may not
be set, and result in that comparison not matching. Mask the F_WAIT
flag when attempting to compare the types of the locks.
This fixes the "many_locks" stc.
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
Fixes: a66ed519884d ("Cygwin: fcntl: implement Open File Description (OFD) locks")
|
|
The commit implementing OFD locks dropped the F_GETLK case from the
switch in fhandler_base::lock, replacing it with F_OFD_GETLK. This
appears to have been an oversight, as F_OFD_SETLK was added as an
additional case above.
This resulted in the winsup.api/ltp/fcntl05 test failing.
Fixes: a66ed519884d ("Cygwin: fcntl: implement Open File Description (OFD) locks")
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
|
|
The class child_info_spawn has two constructors: one without arguments
and one with two arguments. The former does not initialize any members.
Commit 1f836c5f7394 used the latter to ensure that the local ch_spawn
(i.e., ch_spawn_local) would be properly initialized. However, this was
insufficient - it initialized only the base child_info members, not the
fields specific to child_info_spawn. This led to the issue reported in
https://cygwin.com/pipermail/cygwin/2025-August/258660.html.
This patch introduces a new constructor to properly initialize member
variable 'ev', etc., which were referred without initialization, and
switches ch_spawn_local to use it. 'subproc_ready', which may not be
initialized, is also initialized in the constructor of the base class
child_info.
Addresses: https://cygwin.com/pipermail/cygwin/2025-August/258660.html
Fixes: 1f836c5f7394 ("Cygwin: spawn: Make system() thread-safe")
Reported-by: Denis Excoffier <cygwin@Denis-Excoffier.org>
Reviewed-by: Jeremy Drake <cygwin@jdrake.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
The _arc4random_getentropy_fail() function does not return. Mark it as
such.
|
|
The end condition on this loop, unlike all the other similar loops, is
"i >= 0", which is a problem because "i <<= 1" can go negative and then zero if
you continue shifting, and so back to true, again. This isn't a problem for
the loop in the scalar implementation, but it means we need to mask the shift
in the vector implementation.
This fixes GCC PR#121392.
|
|
|
|
|
|
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
|
|
Partially quoting the LINUX man page:
Open file description locks are advisory byte-range locks whose opera‐
tion is in most respects identical to the traditional record locks de‐
scribed above.
The principal difference between the two lock types is that whereas tra‐
ditional record locks are associated with a process, open file descrip‐
tion locks are associated with the open file description on which they
are acquired, much like locks acquired with flock(2). Consequently (and
unlike traditional advisory record locks), open file description locks
are inherited across fork(2) (and clone(2) with CLONE_FILES), and are
only automatically released on the last close of the open file descrip‐
tion, instead of being released on any close of the file.
Conflicting lock combinations (i.e., a read lock and a write lock or two
write locks) where one lock is an open file description lock and the
other is a traditional record lock conflict even when they are acquired
by the same process on the same file descriptor.
Just like traditional advisory record locks, OFD locks do not conflict
with BSD file locks acquired with flock(2).
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
This will be used by a followup patch to denote OFD locks per POSIX.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
This is in preparation for implementing OFD locks per POSIX.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
So far, not setting a lock variant (F_POSIX/F_FLOCK) defaulted to
F_POSIX locks. Adding OFD locks in a followup patch may lead to
confusion, so make sure that the lock variant is always set in the
calling functions (fcntl, flock, lockf). Bail out with EINVAL if
no lock variant is set.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Linux and POSIX-1.2024 define operations to create OFD (Open
File Description) locks.
OFD locks are like POSIX record locks, but bound to the file descriptor,
not bound to the process. As such, they are also inherited via fork(2)
and dup(2), just like BSD flock(2) locks.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
This prevents memory corruption if a newer app or dll is used with an
older cygwin dll. This is an unsupported scenario, but it's still a
good idea to avoid corrupting memory if possible.
Fixes: 7d5c55faa1 ("Cygwin: add wrappers for newer new/delete overloads")
Co-authored-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
|
|
This patch adds missing function declarations in several m68k-specific
libgloss source files. This helps avoid implicit declaration compiler
warnings / errors and ensures better portability.
Tested by building newlib for m68k-elf with GCC.
|
|
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
|
|
A sized delete (with a std::size_t parameter) was added in C++14 (but
doesn't combine with nothrow_t)
An aligned new/delete (with a std::align_val_t parameter) was added in
C++17, and combinations with the sized delete and nothrow_t variants.
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
|
|
Based on https://sourceware.org/pipermail/cygwin-patches/2025q3/014154.html
suggestion, this patch implements +/-4GB relocations for AArch64 in the mkimport
script by using adrp and ldr instructions. This change required update
in winsup/cygwin/mm/malloc_wrapper.cc where those instructions are
decoded to get target import address.
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
|
|
This patch is returning back support for AArch64 ILP32 ABI that was
removed in de479a54e22e8fcb6262639a8e67fe8b00a27c37 commit but is needed
to ensure source code compatibility with GCC 14.
The change in newlib/libc/machine/aarch64/asmdefs.h makes it
out-of-the-sync with the current upstream implementation in
https://github.com/ARM-software/optimized-routines repository.
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
|
|
This was what I was using locally before Radek Bartoň
<radek.barton@microsoft.com> had his version of the patch. Revert in
favor of his final version.
Revert 70c5505766ad4ae62e4d045835ed2a6b928d5760
|
|
ilp32 support was removed prematurely. It is still in GCC 15 which is
the latest GCC release.
From: <radek.barton@microsoft.com>
Date: Thu, 5 Jun 2025 11:32:08 +0200
Subject: [PATCH] newlib: libc: update asmdefs.h compatible with Cygwin AArch64
This patch synchronizes newlib/libc/machine/aarch64/asmdefs.h header with
version from https://github.com/ARM-software/optimized-routines/commit/4352245388a55a836f3ac9ac5907022c24ab8e4c
commit that added support for AArch64 Cygwin.
This version of the header removed PTR_ARG and SIZE_ARG macros as ILP32 was
deprecated which introduced changes in many .S files so the patch contains
removal of usages of those macros.
On top of that, setjmp.S and rawmemchr.S were refactored to use
ENTRY/ENTRY_ALIGN and END macros. `
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
|
|
Previously, process_fd failed to correctly handle fhandlers using an
archetype. This was due to the missing PATH_OPEN flag in path_conv,
which caused build_fh_pc() to skip archetype initialization. The
root cause was a bug where open() did not set the PATH_OPEN flag
for fhandlers using an archetype.
This patch introduces a new method, path_conv::set_isopen(), to
explicitly set the PATH_OPEN flag in path_flags in fhandler_base::
open_with_arch().
Addresses: https://cygwin.com/pipermail/cygwin/2025-May/258167.html
Fixes: 92ddb7429065 ("(build_pc_pc): Use fh_alloc to create. Set name from fh->dev if appropriate. Generate an archetype or point to one here.")
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Add a FIXME comment to the conversion of private use area bytes to
"normal" bytes in _sys_wcstombs detailing the conversion difference
between _sys_wcstombs and standard wcstombs. It might be a good idea
to drop the conversion to gather compatibility with wcstombs.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
When a 4 byte utf-8 sequence has an invalid 4th byte, it's actually
an invalid 3 byte sequence. In this case we already generated the
high surrogate and only realize the problem when byte 4 doesn't
match.
At this point _sys_mbstowcs transposes the invalid 4th byte into the
private use area.
This is wrong. The invalid byte sequence here is the 3 byte sequence
already converted to a high surrogate, not the trailing 4th byte.
Fix this by backtracking to the start of the broken sequence and
overwrite the already written high surrogate with a sequence of
the original three bytes transposed to the private use area. Reset
the mbstate and restart normal conversion at the non-matching
4th byte, which might start a new multibyte sequence.
The resulting wide-char string can be converted back to multibyte
and back again to wide-char, and the result will be identical, even
if the multibyte sequence differs from the original sequence.
Fixes: e44b9069cd227 ("* strfuncs.cc (sys_cp_mbstowcs): Treat src as unsigned char *. Convert failure of f_mbtowc into a single malformed utf-16 value.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
UTF-16"
This reverts commit b374973d14ac7969b10ba719feedc709f6971c0d.
Turns out this patch breaks mbrtowc. Example:
--- SNIP ---
void mb(unsigned char c)
{
wchar_t wc;
int ret = mbrtowc(&wc, &c, 1, 0);
printf("%02X -> %04X : %d\n", c, wc, ret);
}
void main ()
{
setlocale (LC_CTYPE, "");
mb(0xF0);
mb(0x9F);
mb(0x98);
mb(0x8E);
}
--- SNAP ---
Output before commit b374973d14ac:
F0 -> 0000 : -2
9F -> 0000 : -2
98 -> D83D : 1
8E -> DE0E : 1
Output after commit b374973d14ac:
F0 -> 0000 : -2
9F -> 0000 : -2
98 -> 0000 : -2
8E -> D83D : 3
By using mbrtowc(), the high surrogate is only emitted after byte 4, and
there's no way to recover the low surrogate. The byte count is also incorrect.
Conclusion: We have to emit the high surrogate already after byte 3
to be able to emit the low surrogate after byte 4.
Reported-by: Thomas Wolff <towo@towo.net>
Addresses: https://cygwin.com/pipermail/cygwin/2025-July/258513.html
Fixes: b374973d14ac ("mbrtowc: fix handling invalid UTF-8 4 byte sequences if wchar_t == UTF-16")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
|
|
POSIX states system() shall be thread-safe, however, it is not in
current cygwin. This is because ch_spawn is a global and is shared
between threads. With this patch, system() uses ch_spawn_local
instead which is local variable. popen() has the same problem, so
it has been fixed in the same way.
Addresses: https://cygwin.com/pipermail/cygwin/2025-June/258324.html
Fixes: 1fd5e000ace5 ("import winsup-2000-02-17 snapshot")
Reported-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
...completion in child process because the cygheap should not be
changed to avoid mismatch between child_info::cygheap_max and
::cygheap_max. Otherwise, child_copy() might copy cygheap being
modified by other process.
In addition, to avoid deadlock, move close_all_files() for non-
Cygwin processes after unlocking cygheap, since close_all_files()
calls cfree(), which attempts to lock cygheap even when it's already
locked.
Fixes: 977ad5434cc0 ("* spawn.cc (spawn_guts): Call refresh_cygheap before creating a new process to ensure that cygheap_max is up-to-date.")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
...so that cygheap can be locked/unlocked from outside of mm/cygheap.cc.
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
|
|
The macro was not protecting properly its first parameter, which caused
it to silently return an invalid value when passing a composed
parameter, ie.
__builtin_is_aligned(src | dst | len, 32);
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
|
|
This reverts commit bb2c338520b9da9fd3ac067438e9aeeffc0b122a.
Accidental push.
|
|
This reverts commit 3b97a5ec67a5a52c130158bb143949cd842de305.
|
|
Signed-off-by: Christian Franke <christian.franke@t-online.de>
|
|
This patch adds configure options allowing to disable build of cygserver
and Cygwin utilities. This is useful when one needs to build only
cygwin1.dll and crt0.o with stage1 compiler that is not yet capable of
linking executables as it is missing cygwin1.dll and crt0.o.
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
|
|
This patch introduces dummy implementation of fegetprec and fsetprec for Cygwin
build as those symbols are being exported by cygwin1.dll and AArch64 do not support
changing floating point precision at runtime.
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
|
|
Systems prior to W10 1803 don't have the leapsecs registry key
HKLM\SYSTEM\CurrentControlSet\Control\LeapSecondInformation and
don't handle leap seconds at all.
Given that new leap seconds are a rather seldom, irregular event,
drop reading from /usr/share/zoneinfo/leapseconds. Just read the
same leap second records from a file /etc/leapsecs as stored in
the LeapSeconds registry value on newer systems instead.
As a sidenote, the code reading from /usr/share/zoneinfo/leapseconds
was wrong anyway, because it didn't take the timestamps into account.
Given IERS publishes new leap seconds about 6 months before they
occur, CLOCK_TAI would have been one second off for up to 6 months.
/etc/leapsecs doesn't exist yet, so we just default to 37 secs. If
new leap seconds get provided for newer systems, make sure to provide
the /etc/leapsecs file as part of the Cygwin distro with identical
entries.
Fixes: 2abb929f0ad2 ("Cygwin: clocks: Implement CLOCK_TAI")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
Long-standing bug in the sys/termios.h file which, for some reason,
has never been encountered before.
STC:
#include <sys/termios.h>
int main()
{
struct winsize win;
tcgetwinsize (0, &win);
}
Result with gcc 12.4.0:
termios-bug.c: In function ‘main’:
termios-bug.c:7:20: warning: passing argument 2 of ‘tcgetwinsize’ from incompatible pointer type [-Wincompatible-pointer-types]
7 | tcgetwinsize (0, &win);
| ^~~~
| |
| struct winsize *
In file included from termios-bug.c:1:
/usr/include/sys/termios.h:304:42: note: expected ‘struct winsize *’ but argument is of type ‘struct winsize *’
304 | int tcgetwinsize(int fd, struct winsize *winsz);
| ~~~~~~~~~~~~~~~~^~~~~
This warning apparently becomes an error with C23.
The reason is that struct winsize is defined in sys/termios.h after
using it as argument type in function declarations. From the compil;er
perspective it's now a different type , regardless of having the same
name.
Move declaration of struct winsize up so it's defined before being used.
Reported-by: Zachary Santer <zsanter@gmail.com>
Suggested-by: Zachary Santer <zsanter@gmail.com>
Addresses: https://cygwin.com/pipermail/cygwin/2025-July/258474.html
Fixes: 1fd5e000ace55 ("import winsup-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
The commit cited below introduced changes which included
conditionals strictly on __mips__. This ignored tailoring
for any environment on MIPS except that targeted by the
author of the change. This patch just fixes this code for
RTEMS.
commit 467a2bdf17ad376dafada9f1734784f4611fa6fd
Author: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>
Date: Wed Jun 11 10:11:33 2025 +0200
mips: Implement MIPS HAL and UHI
Implement abstract interface for MIPS, including unified hosting
interface (UHI).
Signed-off-by: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>
|
|
This commit changes the return type of the read() and write() syscalls for
nvptx to ssize_t. This would allow large files to be handled properly by
these syscalls in situations where the read/write buffer length exceeds
INT_MAX, for example. This also makes the syscall signatures fully complaint
with their current POSIX specifications.
We additionally define two macros: '_READ_WRITE_RETURN_TYPE' as _ssize_t and
'_READ_WRITE_BUFSIZE_TYPE' as __size_t in libc/include/sys/config.h under
__nvptx__ for consistency.
Signed-off-by: Arijit Kumar Das <arijitkdgit.official@gmail.com>
|
|
Windows 10 1803 introduced leap seconds support in 2018. The OS always
starts at 37 leap secs. Additional leap second timestamps are added to
the registry key HKLM\SYSTEM\CurrentControlSet\Control\LeapSecondInformation,
value LeapSeconds.
If the key exists, read the leap second timestamps from this value,
otherwise fallback to reading /usr/share/zoneinfo/leapseconds.
Note that we might change the file we read from yet, but that's no part
of this patch.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
This patch is required for a followup patch fetching the leap seconds
info from the registry starting with Windows 10 1803.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|
|
This patch ports `winsup/utils/mingw/cygcheck.cc` to AArch64:
- Adds arch=aarch64 to packages API URL.
- Ports dll_info function.
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
|
|
This patch synchronizes newlib/libc/machine/aarch64/asmdefs.h header with
version from https://github.com/ARM-software/optimized-routines/commit/4352245388a55a836f3ac9ac5907022c24ab8e4c
commit that added support for AArch64 Cygwin.
This version of the header removed PTR_ARG and SIZE_ARG macros as ILP32 was
deprecated which introduced changes in many .S files so the patch contains
removal of usages of those macros.
On top of that, setjmp.S and rawmemchr.S were refactored to use
ENTRY/ENTRY_ALIGN and END macros. `
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
|
|
This is a mingw program meant to demonstrate loading the Cygwin dll in a
non-Cygwin process, but the Cygwin dll still initializes the cygheap on
load in that case. Without --disable-high-entropy-va, Windows may
occasionally locate the PEB, TEB, and/or stacks in the address space
that Cygwin tries to reserve for the cygheap, resulting in a failure.
Fixes: 60675f1a7eb2 ("Cygwin: decouple shared mem regions from Cygwin DLL")
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
|
|
CLOCK_TAI is like CLOCK_REALTIME ignoring leap secs. Right now,
2025, it has a positive 37 secs offset from CLOCK_REALTIME.
Given the unpredictability of adding leap secs by the IERS
(International Earth Rotation and Reference Systems Service),
we also add a mechanism to read the current leap secs offset from
/usr/share/zoneinfo/leapseconds, part of the tzdata package.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
|