Add locking to the random(3) family of functions to gain
thread-safety per POSIX. Use NetBSD version of the file as
role-model.
Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Previously, fprintf() on a wide-oriented stream crashes or outputs
garbage. This is because a narrow char string which can be odd bytes
in length is cast into a wide char string which should be even
bytes in length in __sprint_r/__sfputs_r based on the __SWID flag.
As a result, if the length is odd bytes, the reading buffer runs over
the buffer length, which causes a crash. If the length is even bytes,
garbage is printed.
With this patch, any output to the stream which is set to different
orientation fails with error just like glibc. Note that it behaves
differently from other libc implementations such as BSD, musl and
Solaris.
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
The new directory '/dev/disk/by-partuuid' provides symlinks for each
MBR or GPT disk partition:
'MBR_SERIAL-OFFSET' -> '../../sdXN'
'GPT_GUID' -> '../../sdXN'
Signed-off-by: Christian Franke <christian.franke@t-online.de>
The new directory '/dev/disk/by-id' provides symlinks for each
disk and its partitions:
'BUSTYPE-[VENDOR_]PRODUCT_SERIAL[-partN]' -> '../../sdX[N]'.
This is based on strings provided by STORAGE_DEVICE_DESCRIPTOR.
If this information is too short, a 128-bit hash of the
STORAGE_DEVICE_UNIQUE_IDENTIFIER raw data is added.
Administrator privileges are not required.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
The exception handling inside of Cygwin functions marked as SIGFE
covers exceptions and lets the library code handle them gracefully.
If these functions want to raise an exception, they have to send a
signal explicitely via raise(3).
That's not what we want in feraiseexcept(). It triggers a floating
point exception explicitely by calling the i387 op "fwait". Being
marked as SIGFE, this exception will be suppressed and the normal
exception handling won't kick in.
Fix this by moving feraiseexcept into the NOSIGFE realm.
Fixes: 0f81b5d4bc ("* Makefile.in (DLL_OFILES): Add new fenv.o module.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
cwdstuff::set has a code snippet handling the case where a process
can't create a handle to a directory, e. g., due to permissions.
Commit 88443b0a22 ("cwdstuff: Don't leave from setting the CWD
prematurely on init") introduced a special case to handle this
situation at process initialization. It also introduces an early
mutex release, which is not required, but ok, because we're in the
init phase. Releasing the mutex twice is no problem since the mutexes
are recursive.
Fast forward to commit 0819679a7a ("Cygwin: cwd: use SRWLOCK
instead of muto"). The mechanical change from a recursive mutex
to a non-recursive SRWLOCK failed to notice that this very specific
situation will release the SRWLOCK twice.
Remove the superfluous release action. While at it, don't set dir to
NULL, but h, since dir will get the value of h anyway later on.
Setting h to NULL may not be necessary, but better safe than sorry.
Reported-by: tryandbuy >tryandbuy@proton.me>
Fixes: 88443b0a22 ("cwdstuff: Don't leave from setting the CWD prematurely on init")
Fixes: 0819679a7a ("Cygwin: cwd: use SRWLOCK instead of muto")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The commit 322c7150b2 restricts buffer size with a fixed length,
however, the minimum buffer size should be varied by the sample rate.
With this patch, it is estimated using sample rate, sample width
and number of channels so that the buffer length is not less than
80 msec which is almost the minimum value of Win MME to work.
Fixes: 322c7150b2 ("Cygwin: dsp: Avoid setting buffer that is too small.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
configure.ac files use [] for quoting by default, not "", which
means the "" are passed through as literals. We don't want that
for these comments, so change the "..." to [...].
Use the same C preprocessor expressions to define FE_RMODE_MASK and
__RISCV_HARD_FLOAT.
The problem was noticed on GCC 10 which does not define __riscv_f.
The check incorrectly results in catan returning nan + inf i when real part is +/- 1 and
imaginary part is 0. The same occurs for real 0.8 and imaginary 0.6.
The change ends up matching glibc behaviour.
Import memrchr.S for AArch64 from:
https://github.com/ARM-software/optimized-routines
commit 0cf84f26b6b8dcad8287fe30a4dcc1fdabd06560
Author: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Thu Jul 27 17:14:57 2023 +0200
string: Fix corrupt GNU_PROPERTY_TYPE (5) size
For ELF32 the notes alignment is 4 and not 8.
Update AArch64 assembly string routines from:
https://github.com/ARM-software/optimized-routines
commit 0cf84f26b6b8dcad8287fe30a4dcc1fdabd06560
Author: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Thu Jul 27 17:14:57 2023 +0200
string: Fix corrupt GNU_PROPERTY_TYPE (5) size
For ELF32 the notes alignment is 4 and not 8.
Add license and copyright information to COPYING.NEWLIB as entry (56).
The buffer size that is too small causes choppy sound. That is not
practical at all. With this patch, the minimum value of the buffer
size (i.e. fragstotal * fragsize) is restricted to 16384 bytes.
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Attempt to always provide _Thread_local in <sys/reent.h> by including
<sys/cdefs.h>. The C specific keyword _Thread_local is not available
unless targetting a suitable C version.
Conditionally provide default __getreent() implementation only if
_REENT_THREAD_LOCAL is not defined. If struct _reent is replaced by
dedicated thread-local objects neither the structure nor _impure_ptr is
available.
Use _REENT_ERRNO() macro to access errno. This encapsulation is
required, as errno might be either _errno member of struct _reent,
_tls_errno or any such implementation detail.
If specified, set version timestamp to this value.
Enable deterministic archives for ar and ranlib.
Set cygwin1.dll PE and export table header timestamps to zero.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Given the downsides of NFS symlinks as FIFOs, drop the code
added to recognize them as such.
Fixes: 622fb0776e ("Cygwin: enable usage of FIFOs on NFS")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Creating real NFS symlinks for device files has a major downside:
The way we store device info requires to change the symlink target
in case of calling chmod(2). This falls flat in two ways:
- It requires to remove and recreate the symlink, so it doesn't
exist for a short period of time, and
- removing fails badly if there's another open handle to the symlink.
Therefore, change this to create FIFOs as shortcut files, just as on
most other filesystems. Make sure to recognize these new shortcuts
on NFS (for devices only) in path handling and readdir.
Fixes: 622fb0776e ("Cygwin: enable usage of FIFOs on NFS")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
MSFT NFSv3 fakes DOS attributes based on file type and permissions.
Rather than just faking FILE_ATTRIBUTE_DIRECTORY for dirs, fetch the
"real" DOS attributes returned by NFS.
This allows to handle the "R/O" attribute on shortcut files and thus
reading and creating device shortcut files on NFS.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Add a missing "void" to the prototype for __cpuset_zero_s().
Reported-by: Marco Mason <marco.mason@gmail.com>
Addresses: https://cygwin.com/pipermail/cygwin/2023-September/254423.html
Signed-off-by: Mark Geisert <mark@maxrnd.com>
Fixes: c6cfc99648d6 (Cygwin: sys/cpuset.h: add cpuset-specific external functions)
fhandler_base::fchown casts any fhandler landing here to a
fhandler_disk_file. That's ugly and dangerous. Duplicate
the path_conv info into an explicitly create fhandler_disk_file
instead and call fchmod on that.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
By handling native NFS FIFOs as actual FIFOs, chmod on a FIFO
suddenly called fhandler_base::fchmod, which is insufficient
to handle FIFO files on any filesystem.
Note that this does not fix Cygwin FIFOs on NFS or AFS yet.
Fixes: 622fb0776e ("Cygwin: enable usage of FIFOs on NFS")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
With this patch, the response time of select()/poll() has been
improved by utilizing semaphore (select_sem) just like pipe and
fifo. In addition, notification of exceptional conditions has
been added.
Fixes: 2c06014f12 ("Cygwin: dsp: Implement select()/poll().")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Previously, sound device /dev/dsp did not support select()/poll().
These have been implemented with this patch.
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
FIFOs on NFS were never recogized as such in path handling.
stat(2) indicated native FIFOs as FIFOs but the path handling
code didn't set the matching values in the inner symlink checking
code, so the followup behaviour was wrong.
Basically for the same reason, Cygwin-created FIFOs were just treated
as symlinks with weird content by stat(2) as well as path handling.
Add code to enable both types of FIFOs on NFS as Cygwin FIFOs.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
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>