Commit Graph

21462 Commits

Author SHA1 Message Date
Jon Turney 1db6fb03e7
Cygwin: CI: Take note of the testsuite status 2023-09-02 16:55:42 +01:00
Brian Inglis c4aa56bbf2 Cygwin: cpuinfo: Linux 6.5 additions
add AMD 0x8000001f EAX 14 debug_swap SEV-ES full debug state swap

Signed-off-by: Brian Inglis <Brian.Inglis@Shaw.ca>
2023-09-01 20:40:54 +02:00
Takashi Yano 2a4af36614 Cygwin: Implement sound mixer device.
This patch adds implementation of OSS-based sound mixer device. This
allows applications to change the sound playing volume.

NOTE: Currently, the recording volume cannot be changed.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-09-01 21:33:38 +09:00
Corinna Vinschen 3daedf267d Cygwin: document latest sys/cpuset.h fix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-09-01 12:42:10 +02:00
Corinna Vinschen ac4699fdf3 Cygwin: sys/cpuset.h: use internal base types
Use __size_t and __pid_t instead of size_t and pid_t to avoid
further dependencies to external headers.

Reported-by: Brian Inglis <Brian.Inglis@Shaw.ca>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-09-01 12:38:52 +02:00
Corinna Vinschen d27e9fb29a Cygwin: sys/cpuset.h: add cpuset-specific external functions
The latest incarnation of sys/cpuset.h broke building coreutils.
The reason is the inclusion of stdlib.h and string.h and hence
premature requests for datatypes not yet defined in the include
chain.

Avoid this by defining __cpuset_alloc and __cpuset_free as external
functions, now defined in sched.cc.  Linux is doing this too, just
using different names for the functions. Redefine  __cpuset_zero_s
to use __builtin_memset only on compilers supporting it, otherwise
using a simple loop. Drop the stdlib.h and string.h includes.

Fixes: 3f2790e044 ("Cygwin: Make gcc-specific code in <sys/cpuset.h> compiler-agnostic")
Reported-by: Denis Excoffier <cygwin@Denis-Excoffier.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-09-01 12:38:52 +02:00
Takashi Yano cc4ff714ff Cygwin: dsp: Fix a few trivial bugs.
Signed-off-by: Takashi Yano <takashi.yanao@nifty.ne.jp>
2023-09-01 11:32:51 +09:00
Pekka Seppänen 31eb43efa7 libc/stdlib/nano-mallocr.c, typo in variable name
Nano malloc uses `size' in assertation whereas the correct variable would be
`s'.  Given this has existed ever since nano malloc support was added, based
on the context ("returned payload area of desired size does not exceed the
actual allocated chunk") I presume that indeed `s' (user input) and not
`r->size' (computed) shall be used.
2023-08-29 14:33:27 +02:00
Corinna Vinschen ca2a4ec243 Cygwin: execve: drop argument size limit
Before commit 44f73c5a62 ("Cygwin: Fix segfalt when too many command
line args are specified.") we had no actual argument size limit, except
for the fact that the child process created another copy of the argv
array on the stack, which could result in a stack overflow and a
subsequent SEGV.  Commit 44f73c5a62 changed that by allocating the
additional argv array via malloc, and it introduced a new SC_ARG_MAX
limit along the lines of the typical Linux limit.

However, this new limit is artificial. Cygwin allocates all argument
and environment data on the cygheap.  We only run out of ARG_MAX space
if we're out of memory resources.

Change argument size handling accordingly:
- Drop the args size check from  child_info_spawn::worker.
- Return -1 from sysconf (SC_ARG_MAX), i. e., the argument size limit
  is undefined.
- Change argv handling in class av, so that a failing cmalloc is not
  fatal.  This allows the parent process to return E2BIG if it's out
  of cygheap resources.
- In the child, add a check around the new malloc call, so that it
  doesn't result in a SEGV if the child process gets unexpectedly into
  an ENOMEM situation at this point. In this (unlikely) case, proceed
  with the original __argv array instead.  Add comment to explain why.

Fixes: 44f73c5a62 ("Cygwin: Fix segfalt when too many command line args are specified.")
Tested-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-29 14:17:04 +02:00
Alexey Lapshin 42eb6e5ddf newlib: fix 'sed' for sys headers path prefix
Precisely remove the prefix from the filepath.
2023-08-29 13:42:27 +02:00
Takashi Yano 44f73c5a62 Cygwin: Fix segfalt when too many command line args are specified.
Previously, the number of command line args was not checked for
cygwin process. Due to this, segmentation fault was caused if too
many command line args are specified.
https://cygwin.com/pipermail/cygwin/2023-August/254333.html

Since char *argv[argc + 1] is placed on the stack in dll_crt0_1(),
STATUS_STACK_OVERFLOW occurs if the stack does not have enough
space.

With this patch, char *argv[] is placed in heap instead of stack
and ARG_MAX is increased from 32000 to 2097152 which is default
value of Linux. The argument length is also compared with ARG_MAX
and spawnve() returns E2BIG if it is too long.

Reported-by: Ed Morton
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-08-29 00:17:30 +09:00
Takashi Yano 50ff7901a5 Cygwin: termios: Refactor the function is_console_app().
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-08-28 18:20:57 +09:00
Corinna Vinschen eb1584b491 Revert "Cygwin: autoload: introduce LoadDLLfunc_pfx_only"
This reverts commit 0e711d6cc9.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-27 14:40:22 +02:00
Corinna Vinschen a841911ea4 Revert "Cygwin: select: workaround FD_WRITE network event handling"
This reverts commit dedbbd74d0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-27 14:40:22 +02:00
Corinna Vinschen 384e572f41 Cygwin: document disabling mknod/mkfifo on NFS
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-25 14:50:48 +02:00
Corinna Vinschen d085592daa Cygwin: mknod: disable creating special files on NFS
This simply doesn't work (yet?) but leaves unusable files behind.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-25 14:39:04 +02:00
Corinna Vinschen 6407da947d Cygwin: doc: add new API calls in 3.5
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-25 11:11:32 +02:00
Alexey Lapshin 42fc2fa37c libgloss: add Xtensa port
Supported esp32 and esp32s2 boards:
https://github.com/espressif/esp-toolchain-docs/blob/main/gcc/build-and-run-native-app.md
2023-08-24 10:52:36 -04:00
Takashi Yano 90d3b16d2b Cygwin: pty: Fix failure to clear switch_to_nat_pipe flag.
After the commit fbfea31dd9, switch_to_nat_pipe is not cleared
properly when non-cygwin app is terminated in the case where the
pseudo console is disabled. This is because get_winpid_to_hand_over()
sometimes returns PID of cygwin process even though it should return
only PID of non-cygwin process. This patch fixes the issue by adding
a new argument which requests only PID of non-cygwin process to
get_console_process_id().

Fixes: fbfea31dd9 ("Cygwin: pty: Avoid cutting the branch the pty master is sitting on.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-08-19 14:53:10 +09:00
Alexey Lapshin 7ba103eb1a newlib: add Xtensa port 2023-08-17 18:14:15 -04:00
Takashi Yano 65d34484e9 Cygwin: shared: Fix access permissions setting in open_shared().
After the commit 93508e5bb8, the access permissions argument passed
to open_shared() is ignored and always replaced with (FILE_MAP_READ |
FILE_MAP_WRITE). This causes the weird behaviour that sshd service
process loses its cygwin PID. This triggers the failure in pty that
transfer_input() does not work properly.

This patch resumes the access permission settings to fix that.

Fixes: 93508e5bb8 ("Cygwin: open_shared: don't reuse shared_locations parameter as output")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signedd-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-08-16 22:11:17 +09:00
Takashi Yano 2ee8de782b Cygwin: pty: Add missing pinfo check in transfer_input().
The commit 10d083c745 has a bug that lacks a check for pinfo pointer
value for master_pid. This causes segmentation fault if the process
whose pid is master_pid no longer exists. This patch fixes the issue.

Fixes: 10d083c745 ("Cygwin: pty: Inherit typeahead data between two input pipes.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-08-16 08:33:47 +09:00
Corinna Vinschen 46c4a90724 Cygwin: cXXrtomb, mbrtcXX: use function-specific internal state
As described in the previous commit b5111e4642
("struct _reent: add state for unicode functions") every unicode
conversion function has to use their own state object, if the
state parameter is NULL.

Fixes: 4f258c55e8 ("Cygwin: Add ISO C11 functions c16rtomb, c32rtomb, mbrtoc16, mbrtoc32.")
Fixes: c49bc478b4 ("Cygwin: Add ISO C2X functions c8rtomb, mbrtoc8")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-15 22:34:29 +02:00
Corinna Vinschen b5111e4642 struct _reent: add state for unicode functions
C23 requires that the unicode functions c16rtomb, c8rtomb, mbrtoc16,
mbrtoc32 and mbrtoc8 use their own internal state object.  c32rtomb
only needs an internal state if the lib supports encoding with
shift states, but that's the case for newlib and Cygwin.

Only Cygwin implements these functions so add the states
objects only for Cygwin for now.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-15 22:30:59 +02:00
Jon Turney 1a646ad797
Cygwin: testsuite: Tweak lseek03 after addition of SEEK_HOLE
After addition of SEEK_HOLE, the whence of *4* is not an invalid
argument, causing the test to FAIL.

See ltp commit  423e636a4c8f ("lseek03: change to fix with the lseek syscall")
2023-08-11 14:38:25 +01:00
Jon Turney 7374b46bfd
Cygwin: testsuite: Add a small delay in kill01
Avoid transient failures by adding a small delay after fork()-ing to
allow the child to get into a state where it can recieve signals.

Also add same small delay to kill03 and kill04. kill02 has a more
elaborate setup where child processes write to a pipe to indicate they
have started.
2023-08-11 14:38:23 +01:00
Alexey Lapshin 3550d74823 Add wildcard support to recurse into sys include directories 2023-08-10 14:16:05 -04:00
Corinna Vinschen adc7eafa76 Cygwin: fhandler_base::lseek: fix formatting
Fixes: edfa581d3c ("Cygwin: lseek: implement SEEK_DATA and SEEK_HOLE for files")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-09 18:08:45 +02:00
Corinna Vinschen 9939aa7d09 Cygwin: add SEEK_DATA/SEEK_HOLE addition to release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-09 17:21:54 +02:00
Corinna Vinschen edfa581d3c Cygwin: lseek: implement SEEK_DATA and SEEK_HOLE for files
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-09 17:18:14 +02:00
Corinna Vinschen b6fbe0fc2e Cygwin: lseek: propagate new SEEK_DATA and SEEK_HOLE to fhandler
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-09 16:56:40 +02:00
Corinna Vinschen 5b53633b5d Cygwin: clipboard: Only SEEK_SET and SEEK_CUR are supported
Make sure of that, especially given the addition of
SEEK_DATA and SEEK_HOLE.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-09 16:56:02 +02:00
Corinna Vinschen 07092a52e9 sys/unistd.h: define GNU extensions SEEK_DATA and SEEK_HOLE
SEEK_DATA and SEEK_HOLE are GNU nonstandard extensions also present
in Solaris, FreeBSD, and DragonFly BSD; they are proposed for inclusion
in the next POSIX revision (Issue 8).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-09 16:51:57 +02:00
Torbjörn SVENSSON b9e867d088 Add stub for getentropy
Example test case that fails with undefined reference to getentropy:

Testing g++.robertl/eb77.C,  -std=c++20
doing compile
Executing on host: /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++  /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C  -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output   -fmessage-length=0  -std=c++20 -pedantic-errors -Wno-long-long        -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat   -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe    (timeout = 800)
spawn -ignore SIGHUP /build/gcc-13-2709-g9ac9fde961f/bin/arm-none-eabi-g++ /build/src/gcc/gcc/testsuite/g++.old-deja/g++.robertl/eb77.C -mthumb -march=armv6s-m -mcpu=cortex-m0 -mfloat-abi=soft -fdiagnostics-plain-output -fmessage-length=0 -std=c++20 -pedantic-errors -Wno-long-long -Wl,--start-group -lc -lm -Wl,--end-group --specs=nosys.specs -Wl,--allow-multiple-definition -Wl,-u,_isatty,-u,_fstat -Wl,-wrap,exit -Wl,-wrap,_exit -Wl,-wrap,main -Wl,-wrap,abort -Wl,g++_tg.o -lm -o ./eb77.exe
pid is 28414 -28414
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)':
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): in function `_rs_stir':
(.text._rs_stir+0x8): undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
pid is -1
close result is 28414 exp6 0 1
output is /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::(anonymous namespace)::__libc_getentropy(void*)':
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libstdc++.a(random.o): in function `std::random_device::_M_init(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
/build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/bin/ld: /build/gcc-13-2709-g9ac9fde961f/bin/../lib/gcc/arm-none-eabi/13.0.0/../../../../arm-none-eabi/lib/thumb/v6-m/nofp/libc.a(libc_a-arc4random.o): in function `_rs_stir':
(.text._rs_stir+0x8): undefined reference to `getentropy'
collect2: error: ld returned 1 exit status
 status 1
compiler exited with status 1
FAIL: g++.old-deja/g++.robertl/eb77.C  -std=c++20 (test for excess errors)
Excess errors:
(.text._ZNSt12_GLOBAL__N_117__libc_getentropyEPv+0x8): undefined reference to `getentropy'
(.text._ZNSt13random_device7_M_initERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x58): undefined reference to `getentropy'
(.text._rs_stir+0x8): undefined reference to `getentropy'
UNRESOLVED: g++.old-deja/g++.robertl/eb77.C  -std=c++20 compilation failed to produce executable

Contributed by STMicroelectronics

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2023-08-09 11:38:03 +02:00
Jon Turney cbe7543cdf
Cygwin: CI: XFAIL umask03
umask03 fails in CI due to some not understood weirdness.
2023-08-08 14:15:40 +01:00
Jon Turney edda3aeaf5
Cygwin: testsuite: Fix cygload test
Use cygrun to isolate the cygload test from the current DLL, which
allows it to pass.
2023-08-08 14:15:39 +01:00
Jon Turney 718f37823d
Cygwin: testsuite: Update README
v2:
Polish instructions on adding a test

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-08-08 14:15:38 +01:00
Jon Turney c88ac48eab
Cygwin: testsuite: Add '-notimeout' option to cygrun
Add '-notimeout' option for cygrun.  This is very useful when using it
to run a test standalone and under a debugger.

Also: warn about excess arguments
2023-08-08 14:15:36 +01:00
Corinna Vinschen 2e7332d6bd Cygwin: fix build failure due to redefinition of __restrict in sys/cdefs.h
Commit 3c75fac130 fixed the __restrict definition in sys/cdefs.h,
but uncovered a problem in the definition of lio_listio in Cygwin's
aio.h.  It uses the C99 extension of using the restrict keyword
to define non-overlapping arrays. However, this is not allowed in
C++.

Use the newly defined __restrict_arr from commit e66c63be6b
("sys/cdefs.h: introduce __restrict_arr, as in glibc")

Fixes: 3c75fac130 ("sys/cdefs.h: fix for use __restrict in C++"
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-07 16:04:32 +02:00
Corinna Vinschen e66c63be6b sys/cdefs.h: introduce __restrict_arr, as in glibc
C99 allows to define arrays as non-overlappiung using the restrict
keyword.  This is supported by GCC 3.1 and later, but it's not
allowed in C++.

This is in preparation of fixing a Cygwin build problem introduce by
commit 3c75fac130.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-07 15:59:42 +02:00
Sebastian Huber 3c75fac130 sys/cdefs.h: fix for use __restrict in C++
Newlib shares large parts of <sys/cdefs.h> with FreeBSD and received
this bug report:

https://sourceware.org/pipermail/newlib/2023/020400.html

As an extension, GCC and clang offer C99-style restricted pointers in
C++ mode:
https://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html

We notice that this extension is broken when including newlib headers:
restricted pointers are treated as ordinary pointers.

We traced this to the following section of
newlib/libc/include/sys/cdefs.h:

  /*
   * GCC 2.95 provides `__restrict' as an extension to C90 to support the
   * C99-specific `restrict' type qualifier.  We happen to use `__restrict' as
   * a way to define the `restrict' type qualifier without disturbing older
   * software that is unaware of C99 keywords.
   */
  #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
  #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901
  #define	__restrict
  #else
  #define	__restrict	restrict
  #endif
  #endif

While the GCC __restrict extension was indeed introduced in GCC 2.95, it
is not limited to this version; the extension is also not limited to
C90:
https://gcc.gnu.org/gcc-2.95/c++features.html

Rewrite the logic in the header so that __restrict is kept alone when
available.

PR:	272723
MFC after:	1 week
2023-08-07 13:45:21 +02:00
John Baldwin b12934540f <sys/cdefs.h>: Decay expression passed to fallback
version of __generic()

This ensures that __generic() more closely matches _Generic() when
using the fallback version when _Generic() is not available (such as
GCC).

Co-authored by:	jrtc27
Reviewed by:	jrtc27
Differential Revision:	https://reviews.freebsd.org/D38215
2023-08-07 13:45:03 +02:00
Takashi Yano 3b4f6217c3 Cygwin: pty: Fix thread safety of readahead buffer handling in pty master.
Previously, though readahead buffer handling in pty master was not
fully thread-safe, accept_input() was called from peek_pipe() thread
in select.cc. This caused the problem reported in:
https://cygwin.com/pipermail/cygwin/2023-July/253984.html

The mechanism of the problem is:
1) accept_input() which is called from peek_pipe() thread calls
   eat_readahead(-1) before reading readahead buffer. This allows
   writing to the readahead buffer from another (main) thread.
2) The main thread calls fhandler_pty_master::write() just after
   eat_readahead(-1) was called and before reading the readahead
   buffer by accept_input() called from peek_pipe() thread. This
   overwrites the readahead buffer.
3) The read result from readahead buffer which was overwritten is
   sent to the slave.

This patch makes readahead buffer handling fully thread-safe using
input_mutex to resolve this issue.

Fixes: 7b03b0d8ce ("select.cc (peek_pipe): Call flush_to_slave whenever we're checking for a pty master.")
Reported-by: Thomas Wolff <towo@towo.net>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-08-04 17:49:29 +09:00
Takashi Yano ab78bd2d22 newlib: gdtoa: Suppress compiler warning.
Fixes: 5ac83ea47a ("newlib: Fix memory leak regarding gdtoa-based _ldtoa_r().")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-08-04 17:45:59 +09:00
Jon Turney 57e3e3d3ab
Cygwin: CI: don't run on both main and master refs 2023-08-02 17:25:50 +01:00
Corinna Vinschen c49bc478b4 Cygwin: Add ISO C2X functions c8rtomb, mbrtoc8
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-02 16:56:24 +02:00
Corinna Vinschen 290b56a879 sys/features.h: Define _ISOC2X_SOURCE and __ISO_C_VISIBLE
Add feature test for C2X code. Add matching definitions
_ISOC2X_SOURCE for requesting sources and __ISO_C_VISIBLE
to be used in headers.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-02 16:56:24 +02:00
Corinna Vinschen 8fbbc668a0 Cygwin: uchar.h: fix definition of uchar16_t and uchar32_t
Per C++11, uchar16_t and uchar32_t are defined the same as
uint_least16_t and uint_least32_t.  Also, check for the C++
version to make sure that the types are not colliding with
predefined c++ types.

Fixes: 4f258c55e8 ("Cygwin: Add ISO C11 functions c16rtomb, c32rtomb, mbrtoc16, mbrtoc32.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-02 16:56:24 +02:00
Takashi Yano 5ac83ea47a newlib: Fix memory leak regarding gdtoa-based _ldtoa_r().
After the commit a4705d387f, printf() for floating-point values
causes a memory leak. The legacy _ldtoa_r() assumed the char pointer
returned will be free'ed by Bfree(). However, gdtoa-based _ldtoa_r()
returns the pointer returned by gdtoa() which should be free'ed by
freedtoa(). Due to this issue, the caller of _ldtoa_r() fails to free
the allocated char buffer. This is the cause of the said memory leak.
https://cygwin.com/pipermail/cygwin/2023-July/254054.html

This patch makes rv_alloc()/freedtoa() allocate/free the buffer in
a compatible way with legacy _ldtoa_r().

Fixes: a4705d387f ("ldtoa: Import gdtoa from OpenBSD.")
Reported-by: natan_b <natan_b@libero.it>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-08-02 15:00:56 +09:00
Corinna Vinschen dedbbd74d0 Cygwin: select: workaround FD_WRITE network event handling
The FD_WRITE event is a false friend.  It indicates ready to write
even if the next send fails with WSAEWOULDBLOCK.  *After* the fact,
FD_WRITE will be cleared until sending is again possible, but that
is too late for a select/write loop.

Workaround that by using the WinSock select function when peeking
at a socket and FD_WRITE gets indicated. WinSock select fortunately
indicates writability correctly.

Fixes: 70e476d27b ("(peek_socket): Use event handling for peeking socket.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-01 14:22:55 +02:00