]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
2 weeks agoCygwin: console: Re-fix open() failure on exec() by console owner
Takashi Yano [Wed, 6 Nov 2024 01:19:59 +0000 (10:19 +0900)]
Cygwin: console: Re-fix open() failure on exec() by console owner

Previous fix (commit df0953aa298c) fixes only a part of the problem.
Since exec() overrides the cygwin pid of the caller process, it makes
console owner handling complex. This patch makes console use Windows
pid as the owner pid (con.owner) instead of cygwin pid to make the
handling simpler.

Fixes: df0953aa298c ("Cygwin: console: Fix open() failure when the console owner calls exec().")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2 weeks agoCygwin: pipe: Fix incorrect write length in raw_write()
Takashi Yano [Wed, 6 Nov 2024 05:06:58 +0000 (14:06 +0900)]
Cygwin: pipe: Fix incorrect write length in raw_write()

If the write length is more than the pipe space in non-blocking
mode, the write length is wrongly set to 65536. This causes access
violation. This patch fixes that.

Fixes: 7ed9adb356df ("Cygwin: pipe: Switch pipe mode to blocking mode by default")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2 weeks agoCygwin: console: Fix open() failure when the console owner calls exec().
Takashi Yano [Tue, 5 Nov 2024 11:20:21 +0000 (20:20 +0900)]
Cygwin: console: Fix open() failure when the console owner calls exec().

Currently, open() tries to attach to the console which is owned by
the console owner process. However, when the owner process calls
exec(), AttachConsole() to dwProcessId may sometimes fail due to
unlucky timing. With this patch, open() tries to attach also to
exec_dwProcessId if attaching to dwProcessId fails. That is, open()
tries to attach to both the stub process and target process to
prevent the above situation.

Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2 weeks agoReplace references to C2x with C23
Lenard Mollenkopf [Fri, 1 Nov 2024 14:06:36 +0000 (15:06 +0100)]
Replace references to C2x with C23

Signed-off-by: Lenard Mollenkopf <newlib@lenardmollenkopf.de>
2 weeks agosys/features.h: Use _ISOC23_SOURCE instead of _ISOC23_SOURCE and remap _ISOC2x_SOURCE...
Lenard Mollenkopf [Fri, 1 Nov 2024 14:06:35 +0000 (15:06 +0100)]
sys/features.h: Use _ISOC23_SOURCE instead of _ISOC23_SOURCE and remap _ISOC2x_SOURCE to _ISOC23_SOURCE

Signed-off-by: Lenard Mollenkopf <newlib@lenardmollenkopf.de>
3 weeks agoCygwin: sigfe: Fix a bug that signal handler destroys fpu states
Takashi Yano [Sat, 12 Oct 2024 22:41:40 +0000 (07:41 +0900)]
Cygwin: sigfe: Fix a bug that signal handler destroys fpu states

Previously, sigfe had a bug that the signal handler destroys fpu state.
This is caused by fninit instruction in sigdelayed. With this patch,
saving/restoring the FPU/SIMD state is done using fxsave/fxrstor or
xsave/xrstor rather than fnstcw/fldcw, stmxcsr/ldmxcsr and push/pop
xmm0-xmm15. Since xsave/xrstor is used, not only x87/MMX/SSE states
but also AVX/AVX2/AVX-512 states can be maintained unlike before.
Addresses: https://cygwin.com/pipermail/cygwin/2024-October/256503.html

Fixes: ed89fbc3ff11 ("* gendef (sigdelayed (x86_64)): Save and restore FPU control word.")
Reported-by: Christian Franke <Christian.Franke@t-online.de>
Suggested-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
3 weeks agoCygwin: pipe: Switch pipe mode to blocking mode by default
Takashi Yano [Thu, 5 Sep 2024 02:36:27 +0000 (11:36 +0900)]
Cygwin: pipe: Switch pipe mode to blocking mode by default

Previously, cygwin read pipe used non-blocking mode although non-
cygwin app uses blocking-mode by default. Despite this requirement,
if a cygwin app is executed from a non-cygwin app and the cygwin
app exits, read pipe remains on non-blocking mode because of the
commit fc691d0246b9. Due to this behaviour, the non-cygwin app
cannot read the pipe correctly after that. Similarly, if a non-
cygwin app is executed from a cygwin app and the non-cygwin app
exits, the read pipe mode remains on blocking mode although cygwin
read pipe should be non-blocking mode.

These bugs were provoked by pipe mode toggling between cygwin and
non-cygwin apps. To make management of pipe mode simpler, this
patch has re-designed the pipe implementation. In this new
implementation, both read and write pipe basically use only blocking
mode and the behaviour corresponding to the pipe mode is simulated
in raw_read() and raw_write(). Only when NtQueryInformationFile
(FilePipeLocalInformation) fails for some reasons, the raw_read()/
raw_write() cannot simulate non-blocking access. Therefore, the pipe
mode is temporarily changed to non-blocking mode.

Moreover, because the fact that NtSetInformationFile() in
set_pipe_non_blocking(true) fails with STATUS_PIPE_BUSY if the pipe
is not empty has been found, query handle is not necessary anymore.
This allows the implementation much simpler than before.

Addresses: https://github.com/git-for-windows/git/issues/5115
Fixes: fc691d0246b9 ("Cygwin: pipe: Make sure to set read pipe non-blocking for cygwin apps.");
Reported-by: isaacag, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>, Ken Brown <kbrown@cornell.edu>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
3 weeks agoCygwin: pipe: fix shift value
Corinna Vinschen [Thu, 31 Oct 2024 10:52:26 +0000 (11:52 +0100)]
Cygwin: pipe: fix shift value

The expression computing the next-less-power of 2 for the next write
when the pipe buffer is getting filled up allows negative shift values.
This works on Intel CPUs because the shift expression only evaluates the
5 LSBs, but it's undefined behaviour per the C standard.  Use the
correct expression to get a positive shift value.

Fixes: 170e6badb621 ("Cygwin: pipe: improve writing when pipe buffer is almost full")
Reported-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 weeks agoCygwin: console: Inherit pcon hand over from parent pty
Takashi Yano [Thu, 31 Oct 2024 02:11:33 +0000 (11:11 +0900)]
Cygwin: console: Inherit pcon hand over from parent pty

There was a long-standing issue that pseudo console ownership could
not hand over from the process whose ctty is /dev/cons* rather than
/dev/pty*. This problem happens when a cygwin app starts non-cygwin
app in a pty, then the non-cygwin app starts multiple cygwin apps,
and the non-cygwin app ends before the second cygwin apps end.
In this case, the stub process of the non-cygwin app hands over the
ownership of pcon to one of the second cygwin apps, however, this
app does not hand over the ownership of pcon to another second
cygwin app. This is due to the fact that the hand-over feature is
implemented only in fhandler_pty_slave but not in fhandler_console.

With this patch, the second cygwin apps check if their console device
is inside a pseudo console, and if so, it tries to hand over the
ownership of the pseudo console to anther process that is attached
to the same pseudo console.

Addresses: https://cygwin.com/pipermail/cygwin/2024-February/255388.html
Fixes: 253352e796ff ("Cygwin: pty: Allow multiple apps to enable pseudo console simultaneously.")
Reported-by: lmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>, Hossein Nourikhah <hossein@libreoffice.org>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
3 weeks agoCygwin: lockf: Make lockf() return ENOLCK when too many locks
Takashi Yano [Sat, 19 Oct 2024 16:54:00 +0000 (01:54 +0900)]
Cygwin: lockf: Make lockf() return ENOLCK when too many locks

Previously, lockf() printed a warning message when the number of locks
per file exceeds the limit (MAX_LOCKF_CNT). This patch makes lockf()
return ENOLCK in that case rather than printing the warning message.

Addresses: https://cygwin.com/pipermail/cygwin/2024-October/256528.html
Fixes: 31390e4ca643 ("(inode_t::get_all_locks_list): Use pre-allocated buffer in i_all_lf instead of allocating every lock. Return pointer to start of linked list of locks.")
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>
3 weeks agoCygwin: lockf: Fix adding a new lock over multiple locks
Takashi Yano [Sat, 19 Oct 2024 15:59:51 +0000 (00:59 +0900)]
Cygwin: lockf: Fix adding a new lock over multiple locks

Previously, adding a new lock by lockf() over multiple existing locks
failed. This is due to a bug that lf_setlock() tries to create a lock
that has already been created. This patch fixes the issue.

Addresses: https://cygwin.com/pipermail/cygwin/2024-October/256528.html
Fixes: a998dd705576 ("* flock.cc: Implement all advisory file locking 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>
3 weeks agosys/features.h: Spelling _ISOC2x_SOURCE is not C11
Lenard Mollenkopf [Mon, 28 Oct 2024 11:40:39 +0000 (12:40 +0100)]
sys/features.h: Spelling _ISOC2x_SOURCE is not C11

4 weeks agoCygwin: timer_delete: Fix return value
Christian Franke [Wed, 23 Oct 2024 10:24:06 +0000 (12:24 +0200)]
Cygwin: timer_delete: Fix return value

timer_delete() always returned failure.  This issue has been
detected by 'stress-ng --hrtimers 1'.

Fixes: 229ea3f23c015 ("Cygwin: posix timers: reimplement using OS timer")
Signed-off-by: Christian Franke <christian.franke@t-online.de>
4 weeks agocygwin: pread/pwrite: prevent EBADF error after fork()
Christian Franke [Wed, 23 Oct 2024 09:44:34 +0000 (11:44 +0200)]
cygwin: pread/pwrite: prevent EBADF error after fork()

If the parent process has already used pread() or pwrite(), these
functions fail with EBADF if used on the inherited fd.  Ensure that
fix_after_fork() is called to invalidate the prw_handle.  This issue
has been detected by 'stress-ng --pseek 1'.

Fixes: c36cd56c548a ("* fhandler.cc (fhandler_base::open): Drop local create_options variable.")
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2 months agopowf: Fixed another precision bug in powf() (FreeBSD)
Fabian Schriever [Wed, 11 Sep 2024 14:06:46 +0000 (16:06 +0200)]
powf: Fixed another precision bug in powf() (FreeBSD)

Fixed another precision bug in powf(). This one is in the computation
[t=p_l+p_h High]. We multiply t by lg2_h, and want the result to be
exact. For the bogus float case of the high-low decomposition trick, we
normally discard the lowest 12 bits of the fraction for the high part,
keeping 12 bits of precision. That was used for t here, but it doesnt't
work because for some reason we only discard the lowest 9 bits in the
fraction for lg2_h.  Discard another 3 bits of the fraction for t to
compensate.

This bug gave wrong results like:

powf(0.9999999, -2.9999995) = 1.0000002 (should be 1.0000001)
hex values: 3F7FFFFF C03FFFFE 3F800002 3F800001

As explained in the log for the previous commit, the bug is normally
masked by doing float calculations in extra precision on i386's, but is
easily detected by ucbtest on systems that don't have accidental extra
precision.

Reference: https://github.com/freebsd/freebsd-src/commit/5f20e5ce7f396ad064bfc1f45b8075ea1c0580f9
Original Author: Bruce Evans

2 months agopowf: Fixed 2 bugs in the computation /* t_h=ax+bp[k] High */. (FreeBSD)
Fabian Schriever [Wed, 11 Sep 2024 14:06:45 +0000 (16:06 +0200)]
powf: Fixed 2 bugs in the computation /* t_h=ax+bp[k] High */. (FreeBSD)

(1) The bit for the 1.0 part of bp[k] was right shifted by 4.  This
    seems to have been caused by a typo in converting e_pow.c to
    e_powf.c.
(2) The lower 12 bits of ax+bp[k] were not discarded, so t_h was
    actually plain ax+bp[k].  This seems to have been caused by a logic
    error in the conversion.

These bugs gave wrong results like:

    powf(-1.1, 101.0) = -15158.703 (should be -15158.707)
      hex values: BF8CCCCD 42CA0000 C66CDAD0 C66CDAD4

Fixing (1) gives a result wrong in the opposite direction
(hex C66CDAD8), and fixing (2) gives the correct result.

ucbtest has been reporting this particular wrong result on i386 systems
with unpatched libraries for 9 years.  I finally figured out the extent
of the bugs.  On i386's they are normally hidden by extra precision.
We use the trick of representing floats as a sum of 2 floats (one much
smaller) to get extra precision in intermediate calculations without
explicitly using more than float precision.  This trick is just a
pessimization when extra precision is available naturally (as it always
is when dealing with IEEE single precision, so the float precision part
of the library is mostly misimplemented).  (1) and (2) break the trick
in different ways, except on i386's it turns out that the intermediate
calculations are done in enough precision to mask both the bugs and
the limited precision of the float variables (as far as ucbtest can
check).

ucbtest detects the bugs because it forces float precision, but this
is not a normal mode of operation so the bug normally has little effect
on i386's.

On systems that do float arithmetic in float precision, e.g., amd64's,
there is no accidental extra precision and the bugs just give wrong
results.

Reference: https://github.com/freebsd/freebsd-src/commit/12be4e0d5a54a6750913aee2564d164baa71f0dc
Original Author: Bruce Evans

2 months agopowf: Fix the hi+lo decomposition for 2/(3ln2) (FreeBSD)
Fabian Schriever [Wed, 11 Sep 2024 14:06:44 +0000 (16:06 +0200)]
powf: Fix the hi+lo decomposition for 2/(3ln2) (FreeBSD)

The decomposition needs to be into 12+24 bits of precision for extra-
precision multiplication, but was into 13+24 bits. On i386 with -O1 the
bug was hidden by accidental extra precision, but on amd64, in 2^32
trials the bug caused about 200000 errors of more than 1 ulp, with a
maximum error of about 80 ulps. Now the maximum error in 2^32 trials
on amd64 is 0.8573 ulps. It is still 0.8316 ulps on i386 with -O1.

The nearby decomposition of 1/ln2 and the decomposition of 2/(3ln2) in
the double precision version seem to be sub-optimal but not broken.

Reference: https://github.com/freebsd/freebsd-src/commit/b4437c3d322a0f6d23d12b6f76d2fc72d2ff0ec2
Original Author: Bruce Evans

2 months agoMake sure mallinfo structure matches newlib's malloc.h
Jeff Johnston [Mon, 16 Sep 2024 23:21:46 +0000 (19:21 -0400)]
Make sure mallinfo structure matches newlib's malloc.h

2 months agoReplace __restrict with __restrict_arr in regex.h
yang.zhang [Thu, 29 Aug 2024 03:08:04 +0000 (11:08 +0800)]
Replace __restrict with __restrict_arr in regex.h

when a C++ source file include this header file, it would build fail.

Signed-off-by: yang.zhang <zhangyang01@kylinos.cn>
2 months agonewlib: esp: add dirent.h header file
Alexey Lapshin [Fri, 30 Aug 2024 09:37:36 +0000 (09:37 +0000)]
newlib: esp: add dirent.h header file

Support dirent in *-esp-* toolchains

2 months agonewlib: xtensa: remove sys/xtensa. use machine/xtensa
Alexey Lapshin [Fri, 30 Aug 2024 09:35:24 +0000 (09:35 +0000)]
newlib: xtensa: remove sys/xtensa. use machine/xtensa

Remove sys/xtensa that is actually duplicate newlib's code.
Move used code to machine/xtensa or to libgloss

2 months agoCygwin: pipe: Fix a regression that raw_write() slows down
Takashi Yano [Sat, 31 Aug 2024 19:31:03 +0000 (04:31 +0900)]
Cygwin: pipe: Fix a regression that raw_write() slows down

After the commit 7f3c22532577, writing to pipe extremely slows down.
This is because cygwait(select_sem, 10, cw_cancel) is called even
when write operation is already completed. With this patch, the
cygwait() is called only if the write operation is not completed.

Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256398.html
Fixes: 7f3c22532577 ("Cygwin: pipe: handle signals explicitely in raw_write")
Reported-by: Jim Reisert AD1C <jjreisert@alum.mit.edu>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2 months agoCygwin: console: Disable cons_master_thread in win32-input-mode
Takashi Yano [Sat, 31 Aug 2024 09:32:00 +0000 (18:32 +0900)]
Cygwin: console: Disable cons_master_thread in win32-input-mode

When win32-input-mode (which is supported by Windows Termainal) is
set by "\033[?9001h", cons_master_thread does not work properly and
consumes larger and larger memory space. This is because sending
event by WriteConsoleInput() is translated into the sequence that
is used by win32-input-mode. Due to this behaviour, write-back
of the INPUT_RECORDs does not work as expected. With this patch,
cons_master_thread is disabled on win32-input-mode where the signal
keys such as Ctrl-C, Ctrl-Z etc. never comes.

Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256380.html
Fixes: ff4440fcf768 ("Cygwin: console: Introduce new thread which handles input signal.")
Reported-by: Adamyg Mob <adamyg.mob@gmail.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
3 months agoCygwin: add release message for latest pipe changes
Corinna Vinschen [Thu, 22 Aug 2024 19:24:35 +0000 (21:24 +0200)]
Cygwin: add release message for latest pipe changes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agoCygwin: Add locale patches to release message
Corinna Vinschen [Thu, 22 Aug 2024 19:22:41 +0000 (21:22 +0200)]
Cygwin: Add locale patches to release message

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agolocales: Fix definition of lc_messages_T::codeset
Corinna Vinschen [Thu, 22 Aug 2024 19:21:51 +0000 (21:21 +0200)]
locales: Fix definition of lc_messages_T::codeset

nl_langinfo_l accesses lc_messages_T::codeset as soon as
__HAVE_LOCALE_INFO__ is defined, but codeset only exists
if __HAVE_LOCALE_INFO_EXTENDED__ is defined.

Fix this by defining lc_messages_T::codeset depending on
__HAVE_LOCALE_INFO__.

Fixes: ac7f1d5e931c ("Get rid of LCID, reformat type definitions in setlocale.h")
Reported-by: Inglis <Brian.Inglis@SystematicSW.ab.ca>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agonl_langinfo_l: drop erroneus messages::codeset entry
Corinna Vinschen [Thu, 22 Aug 2024 19:15:44 +0000 (21:15 +0200)]
nl_langinfo_l: drop erroneus messages::codeset entry

The nl_ext array contains offsets into the extended info of
locale structures, the index being equivalent to the nl_item
values in langinfo.h.

For the lc_messages_T struct, nl_ext erroneusly contains an
entry for the codeset member, which is in fact not part of the
extended info in nl_item.  However, due to that, the offsets for
subsequent entries are off by one.

Fix this by dropping the messages::codeset entry from nl_ext.

Fixes: d47d5b850bed ("Extend locale support to maintain wide char values of native strings")
Reported-by: Brian Inglis <Brian.Inglis@systematicsw.ab.ca>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agoarc64: Add port for Synopsys DesignWare ARCv3 ISA
Yuriy Kolerov [Wed, 21 Aug 2024 13:32:03 +0000 (16:32 +0300)]
arc64: Add port for Synopsys DesignWare ARCv3 ISA

Synopsys ARCv3 ISA includes 32-bit ARC HS5x targets and
64-bit ARC HS6x targets. Both CPU families are placed
in "arc64" subdirectories as it done for GCC port.
Target name arc64 is used for historical reasons and
Synopsys ARCv3 baremetal toolchains contain multilib
configurations both for 32-bit and 64-bit families.
arc32 target name is reserved for 32-bit ARC HS5x
targets in case of non-multilib 32-bit builds.

Note that libgloss libraries for ARCv3 are compatible with
libgloss for ARCv1/2. Thus, Makefile.inc for libgloss uses
sources from libgloss/arc directory except crtX.S files.

Co-authored-by: Shahab Vahedi <list@vahedi.org>
Co-authored-by: Claudiu Zissulescu <claziss@gmail.com>
Co-authored-by: Bruno Mauricio <brunoasmauricio@gmail.com>
Co-authored-by: Luis Silva <luis.m.silva99@hotmail.com>
Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
3 months agoUpdate config.sub to GCC master branch version
Yuriy Kolerov [Wed, 21 Aug 2024 13:32:02 +0000 (16:32 +0300)]
Update config.sub to GCC master branch version

New config.sub contains support of Synopsys ARCv3 targets. It's
necessary for further porting Newlib for ARCv3.

config.guess has not been updated yet in GCC.

Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
3 months agoUse ldflags instead of LDFLAGS in newlib.exp
Claudiu Zissulescu [Tue, 20 Aug 2024 11:11:28 +0000 (14:11 +0300)]
Use ldflags instead of LDFLAGS in newlib.exp

This variable was accidentally renamed earlier. It must be
ldflags according to DejaGNU documentation.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
3 months agoAdd new version of Synopsys license.
Jeff Johnston [Tue, 20 Aug 2024 22:30:52 +0000 (18:30 -0400)]
Add new version of Synopsys license.

3 months agoarc: libgloss: Prepare for porting to ARCv3
Yuriy Kolerov [Tue, 20 Aug 2024 12:10:43 +0000 (15:10 +0300)]
arc: libgloss: Prepare for porting to ARCv3

There are 3 families of Synopsys DeisgnWare ARC processors:
ARCompact/ARCv1 (32-bit), ARCv2 (32-bit) and ARCv3 (32-bit
and 64-bit targets). Upstream Newlib supports only ARCv1/2.
This commit prepares ARCv1/2 libgloss port to be reused by
ARCv3 port (except crt* files). Note that __ARC64__ macro
stands for all ARCv3 targets.

Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
3 months agoarc: libgloss: Use exit code in _exit_halt for nSIM
Yuriy Kolerov [Tue, 20 Aug 2024 12:10:42 +0000 (15:10 +0300)]
arc: libgloss: Use exit code in _exit_halt for nSIM

nSIM simulator supports exit codes. However, it's necessary
to pass an exit code to _exit_halt, otherwise it's undefined.

Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
3 months agoarc: libgloss: Accommodate MetaWare's standard symbol names
Alexey Brodkin [Tue, 20 Aug 2024 12:10:41 +0000 (15:10 +0300)]
arc: libgloss: Accommodate MetaWare's standard symbol names

It makes it usable with standard symbol names defined in default
linker scripts of the MetaWare toolchain.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
3 months agoarc: Remove @ from symbol references in assembly
Alexey Brodkin [Tue, 20 Aug 2024 12:10:40 +0000 (15:10 +0300)]
arc: Remove @ from symbol references in assembly

There's no semantic change, it's only to make the same code
compilable with MetaWare toolchian, which actually assumes
@x as a full name, not omitting @.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
3 months agoarc: Use __ARC_UNALIGNED__ compiler macro
Claudiu Zissulescu [Tue, 20 Aug 2024 12:10:39 +0000 (15:10 +0300)]
arc: Use __ARC_UNALIGNED__ compiler macro

Replace __ARC_ALIGNED_ACCESS__ macro with the compiler defined
macro __ARC_UNALIGNED__ and improve file comments.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
3 months agoarc: libgloss: Clean MetaWare hostlink documentation
Yuriy Kolerov [Tue, 20 Aug 2024 12:10:38 +0000 (15:10 +0300)]
arc: libgloss: Clean MetaWare hostlink documentation

Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
3 months agoarc: libgloss: Switch from .balign to .align
Alexey Brodkin [Tue, 20 Aug 2024 12:10:37 +0000 (15:10 +0300)]
arc: libgloss: Switch from .balign to .align

.align is supported by both GCC & MetaWare compiler for ARC,
yet implements the same semantics as .balign which only works
with GCC.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
3 months agoarc: libgloss: Fix define guard in nsim-syscall.h
Yuriy Kolerov [Tue, 20 Aug 2024 12:10:36 +0000 (15:10 +0300)]
arc: libgloss: Fix define guard in nsim-syscall.h

Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
3 months agoFix glob() function
Jordi Sanfeliu [Tue, 20 Aug 2024 12:07:27 +0000 (14:07 +0200)]
Fix glob() function

Fixed glob() function to return GLOB_NOMATCH if pattern does
not match any existing pathname (and GLOB_NOCHECK was not set in flags).

3 months agonewlib/libc/include/sys/tree.h: Add deprecation warning
Joel Sherrill [Fri, 16 Aug 2024 18:37:18 +0000 (13:37 -0500)]
newlib/libc/include/sys/tree.h: Add deprecation warning

3 months agolibc/include/sys/tree.h: Re-add sys/tree.h
Joel Sherrill [Fri, 16 Aug 2024 18:37:17 +0000 (13:37 -0500)]
libc/include/sys/tree.h: Re-add sys/tree.h

Reverts 1339af44679aee0895fe311cfad89d38cfc2b919

3 months agoCygwin: pipe: do short writes only once in nonblocking case too
Corinna Vinschen [Mon, 19 Aug 2024 09:51:14 +0000 (11:51 +0200)]
Cygwin: pipe: do short writes only once in nonblocking case too

If a nonblocking write requires short writes, just try it once
as in the blocking case.  After all, we are nonblocking, so
don't loop unnecessarily.

Fixes: 170e6badb621 ("Cygwin: pipe: improve writing when pipe buffer is almost full")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agoCygwin: pipe: fix comparison
Corinna Vinschen [Mon, 19 Aug 2024 09:44:42 +0000 (11:44 +0200)]
Cygwin: pipe: fix comparison

There's no reason to overwrite len1 with align if they are the same value.

Fixes: 170e6badb621 ("Cygwin: pipe: improve writing when pipe buffer is almost full")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agoCygwin: pipe: improve writing when pipe buffer is almost full
Corinna Vinschen [Sun, 18 Aug 2024 20:07:16 +0000 (22:07 +0200)]
Cygwin: pipe: improve writing when pipe buffer is almost full

So far fhandler_pipe_fifo::raw_write always returns -1/EINTR
if a signal arrived.  Linux does not do that if there's still
space left in the pipe buffer.

The Linux buffer handling can't be emulated by Cygwin, but we
can do something similar which makes it much more likely to still
write successfully even if the buffer is almost full.

Utilize pipe_data_available to return valid pipe buffer usage
to raw_write, allowing a more sophisticated way to fill the
buffer while maintaining comaptibility with non-Cygwin pipes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agoCygwin: select: set pipe writable only if PIPE_BUF bytes left
Corinna Vinschen [Sun, 18 Aug 2024 19:55:52 +0000 (21:55 +0200)]
Cygwin: select: set pipe writable only if PIPE_BUF bytes left

Linux select(2) returns the pipe as writable if at least one
free page (4K onl most systems) is left in a page-oriented buffer
handling. This is the same as PIPE_BUF.

Emulate this behaviour by only returning the pipe as writable
if at least 4K space is left in the buffer.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agoCygwin: pipe: handle signals explicitely in raw_write
Corinna Vinschen [Sun, 18 Aug 2024 19:40:51 +0000 (21:40 +0200)]
Cygwin: pipe: handle signals explicitely in raw_write

The simple cygwait call in fhandler_pipe_fifo::raw_write doesn't
take the SA_RESTART setting into account. Move handling the
signal into raw_write.

Fixes: 4b25687ea3ee2 ("Cygwin: fhandler_pipe: add raw_read and raw_write")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agostdlib.h: define __itoa/__utoa while building newlib
Corinna Vinschen [Thu, 15 Aug 2024 18:50:06 +0000 (20:50 +0200)]
stdlib.h: define __itoa/__utoa while building newlib

This avoids a `__utoa undefined' warning when building newlib
for Cygwin.  We still need to export the symbols for backward
compatibility.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agoCygwin: getopt.h: fix a comment
Corinna Vinschen [Thu, 15 Aug 2024 18:50:40 +0000 (20:50 +0200)]
Cygwin: getopt.h: fix a comment

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agoFix POSIX guards for POSIX.1-2024 extensions
Corinna Vinschen [Thu, 15 Aug 2024 16:27:28 +0000 (18:27 +0200)]
Fix POSIX guards for POSIX.1-2024 extensions

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agofeatures.h: support POSIX.1-2024
Corinna Vinschen [Thu, 15 Aug 2024 15:40:06 +0000 (17:40 +0200)]
features.h: support POSIX.1-2024

TBD: Align _GNU_SOURCE, too?

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agofeatures.h: fix whitespace
Corinna Vinschen [Thu, 15 Aug 2024 15:36:54 +0000 (17:36 +0200)]
features.h: fix whitespace

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agoCygwin: Avoid use-after-free warnings in __set_lc_time_from_win() etc.
Jon Turney [Sun, 4 Aug 2024 16:15:50 +0000 (17:15 +0100)]
Cygwin: Avoid use-after-free warnings in __set_lc_time_from_win() etc.

Rewrite to avoid new use-after-free warnings about realloc(), seen with
gcc 12, e.g.:

> In function ‘void rebase_locale_buf(const void*, const void*, const char*, const char*, const char*)’,
>     inlined from ‘int __set_lc_time_from_win(const char*, const lc_time_T*, lc_time_T*, char**, wctomb_p, const char*)’ at ../../../../src/winsup/cygwin/nlsfuncs.cc:705:25:
> ../../../../src/winsup/cygwin/nlsfuncs.cc:338:24: error: pointer ‘new_lc_time_buf’ may be used after ‘void* realloc(void*, size_t)’ [-Werror=use-after-free]
>   338 |       *ptrs += newbase - oldbase;
>       |                ~~~~~~~~^~~~~~~~~
> ../../../../src/winsup/cygwin/nlsfuncs.cc: In function ‘int __set_lc_time_from_win(const char*, const lc_time_T*, lc_time_T*, char**, wctomb_p, const char*)’:
> ../../../../src/winsup/cygwin/nlsfuncs.cc:699:44: note: call to ‘void* realloc(void*, size_t)’ here
>   699 |               char *tmp = (char *) realloc (new_lc_time_buf, len);

Technically, it's UB to later refer to the realloced pointer (even just
for offset computations, without deferencing it), so switch to using
malloc() to create the resized copy.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
3 months agoCygwin: Fix warnings about narrowing conversions of socket ioctls
Jon Turney [Sun, 4 Aug 2024 16:02:00 +0000 (17:02 +0100)]
Cygwin: Fix warnings about narrowing conversions of socket ioctls

Fix gcc 12 warnings about narrowing conversions of socket ioctl constants
when used as case labels, e.g:

> ../../../../src/winsup/cygwin/net.cc: In function ‘int get_ifconf(ifconf*, int)’:
> ../../../../src/winsup/cygwin/net.cc:1940:18: error: narrowing conversion of ‘2152756069’ from ‘long int’ to ‘int’ [-Wnarrowing]

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
3 months agoCygwin: asm/socket.h: drop outdated casts
Corinna Vinschen [Wed, 7 Aug 2024 15:09:44 +0000 (17:09 +0200)]
Cygwin: asm/socket.h: drop outdated casts

The _IOR anbd _IOW macros cast the sizeof of their third arg
uselessly to long. The _IO definitions have been taken from BSD
in 1995 and never changed again.  The fact that the sizeof() gets
cast to long is probably a remnant from the past when the stuff
was supposed to be used on 16 bit machines, but the value was
supposed to be 32 bit.

Given that the values are not supposed to be ever bigger than 32 bit,
we drop the (long) cast.  Compare with current FreeBSD, which does
not cast at all.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 months agoCygwin: Fix warning about narrowing conversions in tape options
Jon Turney [Sun, 4 Aug 2024 16:01:38 +0000 (17:01 +0100)]
Cygwin: Fix warning about narrowing conversions in tape options

Fix a gcc 12 warning about a narrowing conversion in case labels for
tape options.

> In file included from /wip/cygwin/src/winsup/cygwin/include/sys/mtio.h:14,
>                  from ../../../../src/winsup/cygwin/fhandler/tape.cc:13:
> ../../../../src/winsup/cygwin/fhandler/tape.cc: In member function ‘int mtinfo_drive::set_options(HANDLE, int32_t)’:
> ../../../../src/winsup/cygwin/fhandler/tape.cc:965:12: error: narrowing conversion of ‘4026531840’ from ‘unsigned int’ to ‘int’ [-Wnarrowing]

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
3 months agoCygwin: Fix warning about address known to be non-NULL in /proc/locales
Jon Turney [Sun, 4 Aug 2024 15:37:44 +0000 (16:37 +0100)]
Cygwin: Fix warning about address known to be non-NULL in /proc/locales

Fix a gcc 12 warning about an address known to be non-NULL in
format_proc_locale_proc().

> ../../../../src/winsup/cygwin/fhandler/proc.cc: In function ‘BOOL format_proc_locale_proc(LPWSTR, DWORD, LPARAM)’:
> ../../../../src/winsup/cygwin/fhandler/proc.cc:2156:11: error: the address of ‘iso15924’ will never be NULL [-Werror=address]
>  2156 |       if (iso15924)
>       |           ^~~~~~~~
> ../../../../src/winsup/cygwin/fhandler/proc.cc:2133:11: note: ‘iso15924’ declared here
>  2133 |   wchar_t iso15924[ENCODING_LEN + 1] = { 0 };
>       |           ^~~~~~~~

Fixes: c42b98bdc665f ("Cygwin: introduce /proc/codesets and /proc/locales")
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
3 months agoCygwin: Fix warnings about narrowing conversions of NTSTATUS constants
Jon Turney [Sun, 4 Aug 2024 15:30:16 +0000 (16:30 +0100)]
Cygwin: Fix warnings about narrowing conversions of NTSTATUS constants

Fix warnings with gcc 12 about narrowing conversions of NTSTATUS
constants when used as case labels, e.g:

> ../../../../src/winsup/cygwin/exceptions.cc: In static member function ‘static int exception::handle(EXCEPTION_RECORD*, void*, CONTEXT*, PDISPATCHER_CONTEXT)’:
> ../../../../src/winsup/cygwin/exceptions.cc:670:10: error: narrowing conversion of ‘-1073741682’ from ‘NTSTATUS’ {aka ‘int’} to ‘unsigned int’ [-Wnarrowing]

See also: c5bdf60ac46401a51a7e974333d9622966e22d67

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
3 months agoCygwin: Suppress array-bounds warning from NtCurrentTeb()
Jon Turney [Sun, 4 Aug 2024 14:51:07 +0000 (15:51 +0100)]
Cygwin: Suppress array-bounds warning from NtCurrentTeb()

This disables a warning seen with gcc 12 caused by intrinsics used by
the inline implementation of NtCurrentTeb() inside w32api headers.

> In function ‘long long unsigned int __readgsqword(unsigned int)’,
>     inlined from ‘_TEB* NtCurrentTeb()’ at /usr/include/w32api/winnt.h:10020:86,
> [...]
> /usr/include/w32api/psdk_inc/intrin-impl.h:838:1: error: array subscript 0 is outside array bounds of ‘long long unsigned int [0]’ [-Werror=array-bounds]

See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523#c6

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
3 months agostdatomic: make atomics compatible with GCC-14
Alexey Lapshin [Mon, 8 Jul 2024 07:24:55 +0000 (14:24 +0700)]
stdatomic: make atomics compatible with GCC-14

https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631525.html
brings c_atomic and cxx_atomic definitions into GCC.
This patch makes atomics type detection correct for GCC.

https://github.com/freebsd/freebsd-src/commit/680f40f38343de118d5b973129683804e496faaf

4 months agoCygwin: fhandler/proc.cc(format_proc_cpuinfo): Linux 6.10 flags resync
Brian Inglis [Thu, 18 Jul 2024 16:27:50 +0000 (10:27 -0600)]
Cygwin: fhandler/proc.cc(format_proc_cpuinfo): Linux 6.10 flags resync

Linux 6.10 changed the content of cpufeatures.h to require explicit
quoted flag names for output in comments, instead of requiring a null
quoted string "" at the start of comments to suppress flag name output.
As a result, some flags (not all for output) were renamed and others moved:

- change dts to ds; move intel_ppin down; swap ibpd and ibrs;
- change some flag names and descriptions that are not output.

Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
4 months agoCygwin: fhandler/proc.cc(format_proc_cpuinfo): add newlines
Brian Inglis [Thu, 18 Jul 2024 16:27:49 +0000 (10:27 -0600)]
Cygwin: fhandler/proc.cc(format_proc_cpuinfo): add newlines

Linux cpuinfo follows output for each processor with a blank line,
so we output newlines to get a blank line:
- newline after power management feature flags if printed;
- newline to give blank line after each processor output.

Reported-by: Achim Gratz https://cygwin.com/pipermail/cygwin/2024-July/256223.html
Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
4 months agoCygwin: fhandler/proc.cc(format_proc_cpuinfo): Linux 6.10 flags added
Brian Inglis [Thu, 18 Jul 2024 16:27:48 +0000 (10:27 -0600)]
Cygwin: fhandler/proc.cc(format_proc_cpuinfo): Linux 6.10 flags added

0x8000000a EDX 18 x2avic      virtual x2apic
0x80000022 EAX  2 amd_lbr_pmc_freeze AMD last br rec and perf mon ctrs freeze

Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
4 months agonewlib: Add more FreeBSD files for non LDBL_EQ_DBL support
Kito Cheng [Wed, 10 Jul 2024 09:44:59 +0000 (17:44 +0800)]
newlib: Add more FreeBSD files for non LDBL_EQ_DBL support

For RISC-V, AArch64, i386, and x86_64

- k_tanl.c is required for tanl; the linker will report `__kernel_tanl`
  not found when tanl is called.
- s_cospil.c and s_sinpil.c are added for cospil and sinpil, which are already
  available for ld80 but not for ld128.

4 months agosys/tree.h: Removed
Joel Sherrill [Tue, 18 Jun 2024 15:50:22 +0000 (10:50 -0500)]
sys/tree.h: Removed

This file was from a specific older FreeBSD version. There have been
multiple changes to this file with FreeBSD 14 including breaking
changes to the file. Including this file as part of newlib results
in not always having the correct version of sys/tree.h for any
specific software. RTEMS will manage its use of this file outside
of newlib.

4 months agolibc/arm: add missing .cfi_sections
Clément Chigot [Mon, 10 Jun 2024 12:37:57 +0000 (14:37 +0200)]
libc/arm: add missing .cfi_sections

The modifications added by the series "M-profile PACBTI-enablement"
(see 9d6b00511e50a54d2472d11f75f7c0f2b4a98b24) have introduced a couple
of .cfi_* instructions.

Like for e6459123e497409a9e3d845c39829a9602ba55a4, these instructions
create object files which contain .eh_frame sections.  However, ARM uses
its own unwind info format, not .eh_frame, which is generated by
ARM-specific directives, not .cfi_*. The .eh_frame sections are useless,
but also not removed by strip and may be harmful with some linker
scripts.

Adding ".cfi_sections .debug_frame" (as in glibc) moves the generated
directives towards .debug_frame instead of .eh_frame. Making them easier
to handle.

            * libc/machine/arm/aeabi_memmove-thumb2.S: Use .cfi_sections
            .debug_frame.
            * libc/machine/arm/aeabi_memset-thumb2.S: Likewise.
            * libc/machine/arm/memchr.S: Likewise.
            * libc/machine/arm/memcpy-armv7m.S: Likewise.
            * libc/machine/arm/setjmp.S: Likewise.
            * libc/machine/arm/strlen-armv7.S: Likewise.
            * libc/machine/arm/strlen-thumb2-Os.S: Likewise.

4 months agolibc/include/sys/resource.h: Add RUSAGE_THREAD
Joel Sherrill [Mon, 8 Jul 2024 22:22:44 +0000 (17:22 -0500)]
libc/include/sys/resource.h: Add RUSAGE_THREAD

4 months agosys: Remove $FreeBSD$: two-line .h pattern
Warner Losh [Wed, 16 Aug 2023 17:54:11 +0000 (11:54 -0600)]
sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/

4 months agospdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
Warner Losh [Wed, 10 May 2023 15:40:58 +0000 (09:40 -0600)]
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix

4 months agosys/stdatomic.h: be nicer to c++
Konstantin Belousov [Sun, 27 Mar 2022 21:16:15 +0000 (00:16 +0300)]
sys/stdatomic.h: be nicer to c++

Use of stdatomic.h is undefined in C++, even the C++ 2020 standard does not
list stdatomic.h as a C library header supported by the language.  More,
there are some subtle differences between the <atomic> C++ header, and
C11+ stdatomic.h provided features.

Nonetheless, it is a quality of the implementation aspect, so let mis-users
mis-use stdatomic.h as they want, by making a compat shim for _Bool.

PR: 262683
Reported by: yuri
Reviewed by: dim, emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34686

4 months agosys/sys: further adoption of SPDX licensing ID tags.
Pedro F. Giffuni [Mon, 27 Nov 2017 15:01:59 +0000 (15:01 +0000)]
sys/sys: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

4 months agoCygwin: console: Fix for GNU screen/tmux in ConEmu
Takashi Yano [Mon, 8 Jul 2024 14:09:12 +0000 (23:09 +0900)]
Cygwin: console: Fix for GNU screen/tmux in ConEmu

If the master process of GNU screen or tmux is started in ConEmu
and ConEmu is closed, reattaching to the GNU screen/tmux in another
console will not work correctly. This is because the ConEmu master
process was already closed even though some console APIs are hooked
by ConEmuHk64.dll to communicate with ConEmu master process. With
this patch, to make them unhooked, DllMain() of ConEmuHk64.dll is
called with DLL_PROCESS_DETACH.

Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
4 months agoCygwin: console: Fix race issue on allocating console simultaneously.
Takashi Yano [Sat, 6 Jul 2024 15:34:44 +0000 (00:34 +0900)]
Cygwin: console: Fix race issue on allocating console simultaneously.

Previously, if two or more processes request to allocate a console at
the same time, the same device number could be accidentally allocated.
This patch fixes the issue by creating a named mutex (input_mutex) and
checking if GetLastError() is ERROR_ALREADY_EXIST or not to ensure
the unit number will be allocated in an atomic way. Thanks to this,
EnumWindow() is not necessary anymore to scan console units.

This also makes minor device numbers unique and console devices visible
across sessions. This disallows duplicated device number for different
sessions, so the MAX_CONS_DEV has been increased from 64 to 128.

Additionally, the console allocation and scanning will be faster as
a side effect of eliminating EnumWindows().

Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
4 months agoCygwin: console: Bug fix for the last console code change
Takashi Yano [Sat, 6 Jul 2024 15:16:29 +0000 (00:16 +0900)]
Cygwin: console: Bug fix for the last console code change

The commit baf2764dca43 has a serious bug that shared_info_state is
common for all console devices despite it should be individual for
each console device. This patch fixes that.

Fixes: baf2764dca43 ("Cygwin: console: Fixes an issue that tmux can not run on the console.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
4 months agoCygwin: console: Fixes an issue that tmux can not run on the console.
Takashi Yano [Sat, 6 Jul 2024 04:50:51 +0000 (13:50 +0900)]
Cygwin: console: Fixes an issue that tmux can not run on the console.

After the commit c77a5689f7bd, tmux can not run on the console.
This patch replaces the countermeasure for the race issue between
console setup and close with another mechanism using a mutex.

Fixes: c77a5689f7bd ("Cygwin: console: Do not unmap shared console memory belonging to ctty.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
4 months agoCygwin: console: Fix conflict on shared names between sessions.
Takashi Yano [Wed, 3 Jul 2024 13:35:20 +0000 (22:35 +0900)]
Cygwin: console: Fix conflict on shared names between sessions.

Previously, shared names in the console were created using get_minor().
However, get_minor() was not unique to the console across sessions.
This is because EnumWindows(), which is used to look for console windows,
cannot enumerate windows across sessions. This causes conflict on the
shared names between sessions (e.g. sessions of different users,
different services, a service and a user session, etc.).

With this patch, GetConsoleWindow() is used instead of get_minor().
GetConsoleWindow() has been used for the name of shared memory, which
should be unique to each console.

Addresses: https://cygwin.com/pipermail/cygwin/2024-April/255893.html
Fixes: ff4440fcf768 ("Cygwin: console: Introduce new thread which handles input signal.");
Reported-by: Johannes Khoshnazar-Thoma <johannes@johannesthoma.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
4 months agolibc/include/complex.h: Add CMPLX, CMPLXF, and CMPLXL
Joel Sherrill [Mon, 1 Jul 2024 20:51:24 +0000 (15:51 -0500)]
libc/include/complex.h: Add CMPLX, CMPLXF, and CMPLXL

4 months agolibc/include/sys/_default_fcntl.h: O_RSYNC and O_DSYNC are POSIX
Joel Sherrill [Sat, 29 Jun 2024 20:57:57 +0000 (15:57 -0500)]
libc/include/sys/_default_fcntl.h: O_RSYNC and O_DSYNC are POSIX

These should not be in a Cygewin conditional.

4 months agoarm: Fix fma & fmaf implementations
Mickaël Thomas [Sat, 29 Jun 2024 20:44:34 +0000 (22:44 +0200)]
arm: Fix fma & fmaf implementations

The vfma.f32|64 z, x, y instruction performs the operation
z += x * y without intermediate rounding.

The register used for z is both read and written by the instruction.
The inline assembly must therefore use the "+" constraint modifier.

4 months agoCygwin: pty: Avoid client deadlock when pty master stops to read.
Takashi Yano [Mon, 1 Jul 2024 08:44:53 +0000 (17:44 +0900)]
Cygwin: pty: Avoid client deadlock when pty master stops to read.

Previsouly, the following commands hangs:
  mintty -e timeout 1 dash -c 'yes aaaaaaaaaaaaaaaaaaaaaaaaa | cat'

The mechanism is as follows.

When the child process (timeout) is terminated, mintty seems to stop
reading pty master even if yes or cat still alive.

If the the pipe used to transfer output from pty slave to pty master
is full due to lack of master reader, WriteFile() to the pipe is
blocked. WriteFile() cannot be canceled by cygwin signal, therefore,
pty slave hangs.

This patch avoids hanging by checking pipe space before calling
WriteFile() and prevents writing data more than space.

Addresses: https://cygwin.com/pipermail/cygwin/2024-June/256178.html
Reported-by: jojelino <jojelino@gmail.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
4 months agoCygwin: console: Add debug print on thread_sync_event creation error
Takashi Yano [Sat, 29 Jun 2024 23:38:11 +0000 (08:38 +0900)]
Cygwin: console: Add debug print on thread_sync_event creation error

Fixes: 55baaac2ef5f ("Cygwin: console: Add error handling for thread_sync_event")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
4 months agoCygwin: console: Add error handling for thread_sync_event
Takashi Yano [Sat, 29 Jun 2024 10:03:20 +0000 (19:03 +0900)]
Cygwin: console: Add error handling for thread_sync_event

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
4 months agoCygwin: dsp: Fix incorrect openflags when opening multiple /dev/dsp
Takashi Yano [Fri, 28 Jun 2024 04:42:03 +0000 (13:42 +0900)]
Cygwin: dsp: Fix incorrect openflags when opening multiple /dev/dsp

Previously, the following steps failed with error:
  1) Open /dev/dsp with O_RDONLY
  2) Open /dev/dsp with O_WRONLY
  3) Issue SNDCTL_DSP_GETOSPACE ioctl() for 2)
This is because IS_WRITE() returns false for 2) due to incorrect
openflags handling in archetype instance. This patch fixes the
issue by adding open_setup() to fhandler_dev_dsp to set openflags
correctly for each instance.

Fixes: 92ddb7429065 ("* fhandler_dsp.cc (fhandler_dev_dsp::open): Remove archetype handling.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
4 months agolibc: sh: add missing prototypes and change functions from K&R to ANSI
Pietro Monteiro [Mon, 24 Jun 2024 23:08:38 +0000 (19:08 -0400)]
libc: sh: add missing prototypes and change functions from K&R to ANSI

The SuperH target doesn't build on GCC 14.1 because of missing
function prototypes or because some function declarations use the
deprecated K&R style.  This patch adds missing prototypes on the files
the functions are used and convert K&R declarations to ANSI-style.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
4 months agoarm: emit .type %function directive in FUNC_START macro
Christophe Lyon [Wed, 19 Jun 2024 15:48:30 +0000 (15:48 +0000)]
arm: emit .type %function directive in FUNC_START macro

The linker needs to know whether a symbol is STT_FUNCTION when
deciding which farcall stub to emit (if needed), this patch adds this
to the FUNC_START macro which is used in crt0.

5 months agoCygwin: suppress a warning generated with w32api >= 12.0.0
Jon Turney [Fri, 7 Jun 2024 16:29:10 +0000 (17:29 +0100)]
Cygwin: suppress a warning generated with w32api >= 12.0.0

w32api 12.0.0 adds the returns_twice attribute to RtlCaptureContext().
There's some data-flow interaction with using it inside a while loop
which causes a maybe-uninitialized warning.

../../../../winsup/cygwin/exceptions.cc: In member function 'int _cygtls::call_signal_handler()':
../../../../winsup/cygwin/exceptions.cc:1720:33: error: '<anonymous>' may be used uninitialized in this function [-Werror=maybe-uninitialized]

5 months agonewlib: libm: skip "long double" complex functions if long double != double
Pietro Monteiro [Tue, 4 Jun 2024 01:35:47 +0000 (21:35 -0400)]
newlib: libm: skip "long double" complex functions if long double != double

The rest of "long double" functions aren't compiled with long double
and double are not the same.  Do the same for all complex functions.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
5 months agoCygwin: disable high-entropy VA for ldh
Jeremy Drake via Cygwin-patches [Tue, 28 May 2024 17:19:22 +0000 (10:19 -0700)]
Cygwin: disable high-entropy VA for ldh

If ldd is run against a DLL which links to the Cygwin DLL, ldh will end
up loading the Cygwin DLL dynamically, much like cygcheck or strace.

Addresses: https://cygwin.com/pipermail/cygwin/2024-May/255991.html
Fixes: 60675f1a7eb2 ("Cygwin: decouple shared mem regions from Cygwin DLL")
Reviewed-by: Ken Brown <kbrown@cornell.edu>, Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
5 months agoCygwin: pthread: Fix a race issue introduced by the commit 2c5433e5da82
Takashi Yano [Wed, 29 May 2024 10:12:09 +0000 (19:12 +0900)]
Cygwin: pthread: Fix a race issue introduced by the commit 2c5433e5da82

To avoid race issues, pthread::once() uses pthread_mutex. This caused
the handle leak which was fixed by the commit 2c5433e5da82. However,
this fix introduced another race issue, i.e., the mutex may be used
after it is destroyed. This patch fixes the issue. Special thanks to
Bruno Haible for discussing how to fix this.

Addresses: https://cygwin.com/pipermail/cygwin/2024-May/255987.html
Reported-by: Bruno Haible <bruno@clisp.org>
Fixes: 2c5433e5da82 ("Cygwin: pthread: Fix handle leak in pthread_once.")
Reviewed-by: Ken Brown <kbrown@cornell.edu>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
5 months agoCygwin: mixer: Fix volume control for no WAVECAPS_LRVOLUME device
Takashi Yano [Sat, 1 Jun 2024 06:23:37 +0000 (15:23 +0900)]
Cygwin: mixer: Fix volume control for no WAVECAPS_LRVOLUME device

Currently, if the device does not have capability WAVECAPS_LRVOLUME,
the volume control does not work properly. This patch fixes that.

Fixes: 2a4af3661470 ("Cygwin: Implement sound mixer device.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
6 months agoarc: libgloss: Add build rules for new boards
Yuriy Kolerov [Tue, 21 May 2024 09:56:58 +0000 (10:56 +0100)]
arc: libgloss: Add build rules for new boards

Add build rules to support packages for development boards and
nSIM hostlink.

Makefile.in is generated this way:

    $ autoconf --version
    autoconf (GNU Autoconf) 2.69
    $ automake --version
    automake (GNU automake) 1.15.1
    $ cd libgloss
    $ autoreconf -i

Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
6 months agoarc: libgloss: Add support of EM Starter Kit board
Yuriy Kolerov [Tue, 21 May 2024 09:56:57 +0000 (10:56 +0100)]
arc: libgloss: Add support of EM Starter Kit board

These specs files are introduced for EMSK board:

    * emsk1_em4.specs - EMSKv1 with EM4 core, everything in
      ICCM/DCCM memory
    * emsk1_em6.specs - EMSKv1 with EM6 core, everything in
      ICCM/DCCM memory
    * emsk1_em6_ram.specs - EMSKv1 with EM6 core, startup code
      in ICCM and everything else in RAM
    * emsk2.1_em5d.specs - EMSKv2.1 with EM5D core, everything
      in ICCM/DCCM memory
    * emsk2.1_em7d.specs - EMSKv2.1 with EM7D core, everything
      in ICCM/DCCM memory
    * emsk2.1_em7d_ram.specs - EMSKv2.1 with EM7D core, startup
      code in ICCM and everything else in RAM
    * emsk2.2_em7d.specs - EMSKv2.2+ with EM7D core, everything
      in ICCM/DCCM memory
    * emsk2.2_em7d_ram.specs - EMSKv2.2+ with EM7D core, startup
      code in ICCM and everything else in RAM
    * emsk2.2_em9d.specs - EMSKv2.2+ with EM9D core, everything
      in ICCM/DCCM memory
    * emsk2.2_em9d_ram.specs - EMSKv2.2+ with EM9D core, startup
      code in ICCM and everything else in RAM
    * emsk2.2_em11d.specs - EMSKv2.2+ with EM11D core, everything
      in ICCM/DCCM memory
    * emsk2.2_em11d_ram.specs - EMSKv2.2+ with EM11D core, startup
      code in ICCM and everything else in RAM

An example of building an application:

    $ arc-elf32-gcc -mcpu=em -specs=emsk2.2_em11d_ram.specs main.c -o main

Signed-off-by: Vladimir Isaev <vvisaev@gmail.com>
Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
6 months agoarc: libgloss: Add support of EM SDP board
Yuriy Kolerov [Tue, 21 May 2024 09:56:56 +0000 (10:56 +0100)]
arc: libgloss: Add support of EM SDP board

These specs files are introduced for EM SDP board:

    * emsdp1.1.specs - EM SDP 1.1, everything in ICCM/DCCM memory
    * emsdp1.1_ram.specs - EM SDP 1.1, startup code in ICCM
      memory and everything else in RAM
    * emsdp1.2.specs - EM SDP 1.2, everything in ICCM/DCCM memory
    * emsdp1.2_ram.specs - EM SDP 1.2, startup code in ICCM
      memory and everything else in RAM

An example of building an application:

    $ arc-elf32-gcc -mcpu=em -specs=emsdp1.1_ram.specs main.c -o main

Signed-off-by: Vladimir Isaev <vvisaev@gmail.com>
Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
6 months agoarc: libgloss: Add support of HS Development Kit board
Yuriy Kolerov [Tue, 21 May 2024 09:56:55 +0000 (10:56 +0100)]
arc: libgloss: Add support of HS Development Kit board

An example of building an application:

    $ arc-elf32-gcc -mcpu=hs -specs=hsdk.specs main.c -o main

Signed-off-by: Vladimir Isaev <vvisaev@gmail.com>
Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
6 months agoarc: libgloss: Add support of IoT Development Kit board
Yuriy Kolerov [Tue, 21 May 2024 09:56:54 +0000 (10:56 +0100)]
arc: libgloss: Add support of IoT Development Kit board

An example of building an application:

    $ arc-elf32-gcc -mcpu=em -specs=iotdk.specs main.c -o main

Signed-off-by: Vladimir Isaev <vvisaev@gmail.com>
Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
6 months agoarc: libgloss: Add a linker script common for all boards
Yuriy Kolerov [Tue, 21 May 2024 09:56:53 +0000 (10:56 +0100)]
arc: libgloss: Add a linker script common for all boards

Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
6 months agoarc: libgloss: Add UART 8250 library
Yuriy Kolerov [Tue, 21 May 2024 09:56:52 +0000 (10:56 +0100)]
arc: libgloss: Add UART 8250 library

This library implements libgloss input/output and setup
routines for UART 8250 devices of ARC development boards:

    * EM Starter Kit
    * HS Development Kit
    * EM Software Development Platform
    * IoT Development Kit

_uart_8250_setup function with proper parameteres must be called
to setup UART 8250 device for a particular board (refer to
a board's documentation).

Signed-off-by: Vladimir Isaev <vvisaev@gmail.com>
Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
6 months agoarc: libgloss: Clean registers before any use
Yuriy Kolerov [Tue, 21 May 2024 09:56:51 +0000 (10:56 +0100)]
arc: libgloss: Clean registers before any use

Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
6 months agoarc: libgloss: Use atexit to setup fini routines
Claudiu Zissulescu [Tue, 21 May 2024 09:56:50 +0000 (10:56 +0100)]
arc: libgloss: Use atexit to setup fini routines

Use atexit funtion to setup fini routines to be called on exit
instead of filling in __atexit structures manually.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
6 months agoarc: libgloss: Introduce hostlink interface
Vladimir Isaev [Tue, 21 May 2024 09:56:49 +0000 (10:56 +0100)]
arc: libgloss: Introduce hostlink interface

There is a special interface built in ARC simulators (such as
nSIM) called MetaWare hostlink IO which can be used to implement
system calls. This commit adds support for this interface to the
ARC port of libgloss.

Here is an example of using this interface:

    $ arc-elf32-gcc -mcpu=hs -specs=hl.specs main.c -o main
    $ nsimdrv -tcf $NSIM_HOME/etc/tcf/templates/hs48_full.tcf main
    Hello, World!

Signed-off-by: Vladimir Isaev <vvisaev@gmail.com>
This page took 0.081683 seconds and 5 git commands to generate.