Commit Graph

21388 Commits

Author SHA1 Message Date
Jon Turney 127166f707
Cygwin: Add '--names-only' flag to cygcheck
Add '--names-only' flag to cygcheck, to output just the bare package
names.
2023-11-29 14:34:10 +00:00
Kuan-Wei Chiu 5f15d7c581 RISC-V: Fix timeval conversion in _gettimeofday()
Replace multiplication with division for microseconds calculation from
nanoseconds in _gettimeofday function.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
2023-11-29 10:14:55 +01:00
Mike Frysinger dab15f6740 newlib: filter out versions from newlib.h to simplify autoreconf
We've been manually editing newlib.hin after generating it with
autoheader to drop the version defines that we keep in the separate
_newlib_version.h header.  This is confusing for people, and is an
easy source of mistakes/errors.

Since we're already running sed on newlib.h during configure to
filter out defines we don't want to expose, add the version macros
there too.  This way we don't have to manually edit newlib.hin.

This simplifies the autoreconf step in exchange for a slightly more
complicated configure+sed step, but seems worth the trade-off.
2023-11-28 12:50:44 -05:00
Corinna Vinschen 65831f88d6 Cygwin: fallocate(2): handle FALLOC_FL_PUNCH_HOLE and FALLOC_FL_ZERO_RANGE
Split fhandler_disk_file::fallocate into multiple methods, each
implementing a different aspect of fallocate(2), thus adding
FALLOC_FL_PUNCH_HOLE and FALLOC_FL_ZERO_RANGE handling.

For more correctly implementing posix_fallocate(3) semantics, make
sure to re-allocate holes in the given range if the file is sparse.

While at it, change the way checking when to make a file sparse.
The rule is now, make file sparse if the hole created by the action
spans at least one sparse block, taking the allocation granularity
of sparse files into account.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:55:38 +01:00
Corinna Vinschen f64f3eced8 Cygwin: pwrite(2): sparsify file
write(2) sparsifies a file after an lseek far enough beyond EOF.

Let pwrite(2) sparsify as well if offset is far enough beyond EOF.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:55:38 +01:00
Corinna Vinschen 114f89caff Cygwin: fallocate(2): fix evaluating return value
fallocate is not supposed to return an errno code, it has to
return -1 and set errno.

Fixes: dd90ede40510 ("Cygwin: introduce fallocate(2)")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:55:38 +01:00
Corinna Vinschen 7f9caa4a36 Cygwin: open(2): reset sparseness on O_TRUNCated files
open(2) implements O_TRUNC by just reducing the size of the file
to 0, to make sure EAs stay available.

Turns out, file sparseness is not removed this way either, so add
code to do just that.

Fixes: 603ef545bd ("* fhandler.cc (fhandler_base::open): Never open files with  FILE_OVERWITE/FILE_OVERWRITE_IF.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:55:33 +01:00
Corinna Vinschen e01c50c7b0 Cygwin: introduce fallocate(2)
First cut of the new, Linux-specific fallocate(2) function.
Do not add any functionality yet, except of basic handling
of FALLOC_FL_KEEP_SIZE.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:52:05 +01:00
Corinna Vinschen 23e9b5cf3c Cygwin: fcntl.h: Use cdefs.h macros
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:52:05 +01:00
Corinna Vinschen f3554bf890 Cygwin: fhandler: rename ftruncate method to fallocate
also, take mode flags parameter instead of just a bool.
Introduce __FALLOC_FL_TRUNCATE mode flag as internal flag to
indictae being called from ftruncate(2).

This is in preparation of an upcoming change introducing the
Linx-specific fallocate(2) call.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:52:05 +01:00
Corinna Vinschen fedd7fae77 Cygwin: posix_fallocate: return ENODEV
The fhandler method ftruncate returns either EISDIR if it has been
called on directories, or EINVAL if called on files other than
regular files.  This matches what ftruncate(2) is supposed to return,
but it doesn't match posix_fallocate(3), which is supposed to return
ENODEV in both cases.

To accomplish that, return ENODEV from fhandler_base::ftruncate()
and convert it to EINVAL in ftruncate(2). In posix_fallocate(3),
convert EISDIR to ENODEV.

Fixes: 7636b58590 ("* autoload.cc (NtSetInformationFile): Define.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28 10:51:47 +01:00
Corinna Vinschen d5dcb484c7 Cygwin: lseek: check for file sparseness, not for mount point sparseness
The code introducing the lseek(2) code for the GNU extensions
SEEK_DATA and SEEK_HOLE accidentally checks if the mount point
has the "sparse" flag set and, if not, emulates SEEK_DATA/SEEK_HOLE
per the Linux specs.

However, the mount point "sparse" flag only determines whether
files should be made sparse or not.  Files may be sparse independently
of that, obviously.

Fix that by checking for the FILE_ATTRIBUTE_SPARSE_FILE attribute
instead.

Fixes: edfa581d3c ("Cygwin: lseek: implement SEEK_DATA and SEEK_HOLE for files")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-25 18:07:23 +01:00
Takashi Yano 0e961f582a newlib: nl_langinfo: Fix a bug of time stuff.
Previously, e.g. nl_langinfo(_NL_TIME_WMONTH_1) returns "February"
due to the bug. Similarly, nl_langinfo(_NL_TIME_WWDAY_1) returns
"Mon". This occurs because wide char month and weekday arrays are
pointed off-by-one (e.g. the array wmon[12] is reffered as wmon[1-12]
rather than wmon[0-11]). This patch fixes that.

Fixes: d47d5b850b ("Extend locale support to maintain wide char values of native strings")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-11-24 09:53:11 +09:00
Christian Franke 3ef4bb1861 Cygwin: /dev/disk: Append '#N' if the same name appears more than once
No longer drop ranges of identical link names.  Append '#0, #1, ...'
to each name instead.  Enhance charset allowed in label names.
No longer ignore null volume serial numbers.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-21 19:40:37 +01:00
Sebastian Huber 3cacedbbac aarch64: Remove duplicated optimized memmove()
The optimized aarch64/memcpy.S already provides a memmove() implementation.
2023-11-21 10:48:43 +01:00
Corinna Vinschen 61e52c4d60 stdio: drop unnecessary calls to ORIENT
Now that the low-level functions set and test stream orientation,
a few calls in API functions are redundant.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-20 20:59:47 +01:00
Corinna Vinschen c190063f96 stdio: set and test stream orientation in low-level input function __srget_r
This allows to set and test orientation correctly if input is only
using macros from stdio.h.  Wide-char-oriented functions must call
__srefill_r directly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-20 20:59:13 +01:00
Corinna Vinschen 09119463a1 stdio: split byte- and wide-char-oriented low-level output functions
Introduce function __swbufw_r and macros/inline-functions called
__swputc_r.  Call these functions/macros exclusively from wide-char
functions.

This allows to set and test the stream orientation correctly even if
output is only performed using byte-oriented macros from stdio.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-20 20:59:13 +01:00
Takashi Yano bc986b7ff6 stdio: Fix bugs in commit 3d94e07c49
The commit 3d94e07c49 has a few bugs which cause testsuite failure
in libstdc++. This is due to excess orientation check in __srefill_r()
and _ungetc_r(). Further, sscanf() family also calls ssvfscanf() family
with fp->_file == -1. This causes undesired orientation set/check for
sscanf() family. This patch fixes these problems.

Also, as in GLibC, do not set orientation in ungetc, and only set, but
do not check orientation in ungetwc.

Fixes: 3d94e07c49 ("newlib: libc: Fix crash on fprintf to a wide-oriented stream.")
Reported-by: Christophe Lyon <christophe.lyon@linaro.org>
Reported-by: Joel Sherrill <joel@rtems.org>
Co-developed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-20 20:59:12 +01:00
Christian Franke d36b4f3f06 Cygwin: /dev/disk/by-uuid: Fix NTFS serial number print format
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-20 20:59:12 +01:00
Chris Johns 37e67d1595 Reclaim _REENT_MP_P5S in _reclaim_reent
The _REENT_MP_P5S blocks are allocated using Balloc via i2b and linked in the
pow5mult call. As a result these blocks are not on the freelist managed by the
Bfree call. This change fixes a memory leak in threads that clean up using
_reclaim_reent.

RTEMS: Closes #4967
2023-11-20 10:49:39 +01:00
Christian Franke 643275ed18 Cygwin: Document /dev/disk/by-* subdirectories
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-17 20:37:29 +01:00
Christian Franke 41e13e4d9d Cygwin: Add /dev/disk/by-label and /dev/disk/by-uuid symlinks
The new directories '/dev/disk/by-label' and '/dev/disk/by-uuid'
provide symlinks for each disk related volume label and serial
number:
'VOLUME_LABEL' -> '../../sdXN'
'VOLUME_SERIAL' -> '../../sdXN'

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-17 17:09:42 +01:00
Corinna Vinschen 6ccbfe6a3d __sfvwrite_r: call __sputc_r rather than putc in __SCLE case
__sfvwrite_r is called under lock.  There's no reason to call
putc, locking the file recursively.  Add a comment that locking
is required when calling __sfvwrite_r.

Fixes: 49d64538cd ("* libc/include/stdio.h (FILE): define __SCLE for "convert line endings" for Cygwin.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-17 17:09:42 +01:00
Corinna Vinschen 61ccd3f94f v{fs}printf/v{fs}wprintf: create external output helpers
So far, the printf family of functions has two output helper functions
called __sprint_r and __sfputs_r.  Both are called from all variants of
vfprintf as well as vfwprintf.  There are also analogue helper functions
 for the string-creating functions vsprintf/vswprintf called __ssprint_r
and __ssputs_r.

However, the helpers are built once when building vfprintf/vsprintf with
the INTEGER_ONLY flag, and then they are part of the vfiprintf.c and
vsiprintf.c files.

The problem is this:

Even if a process only calls vfwprintf or the non-INTEGER_ONLY vfprintf
it will always have to include the INTEGER_ONLY vfiprintf. Otherwise the
helper functions are undefined.  Analogue for the string-creating
functions.

That's a useless waste of space by including one (or two) big, unused
function, if newlib is linked in statically.

Create new files to define the printf output helpers separately and
split them into byte-oriented and wide-char-oriented functions.  This
allows to link only the required functions.

Also, simplify the string output helpers and fix a potential (but
unlikely) buffer overflow in __ssprint_r.

Fixes: 8a0efa53e4 ("import newlib-2000-02-17 snapshot")
Fixes: 6121968b19 ("* libc/include/stdio.h (__VALIST): Guard against multiple definition.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-17 13:10:20 +01:00
Corinna Vinschen 7e4840bc45 newlib.hin: regenerate
The last two patches to configure.ac missed regeneration of newlib.hin.

Fixes: 64a11fded1 ("Fix problem with _newlib_version.h not being filled in correctly")
Fixes: 39f734a857 ("newlib: fix AC_DEFINE quoting style with version macros")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-17 13:10:20 +01:00
Christian Franke 2cc109be1d Cygwin: Add /dev/disk/by-drive and /dev/disk/by-voluuid symlinks
The new directory '/dev/disk/by-drive' provides symlinks for each
disk related drive letter:
'x' -> '../../sdXN'
The new directory '/dev/disk/by-voluuid' provides symlinks for each
disk related storage volume:
'MBR_SERIAL-OFFSET' -> '../../sdXN'
'VOLUME_GUID' -> '../../sdXN'
Both directories provide Windows specific information and do not
exist on Linux.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-17 13:10:20 +01:00
Corinna Vinschen 324ace778f Cygwin: rand(3): implement in terms of random(3)
This makes rand(3) ISO C compliant and adds locking to avoid
race conditions.

Reported-by: Bruno Haible <bruno@clisp.org>
Fixes: 8a0efa53e4 ("import newlib-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-14 17:52:48 +01:00
Mark Geisert c4008b8bc0 Fix profiler error() definition and usage
Minor updates to profiler and gmondump, which share some code:
- fix operation of error() so it actually works as intended
- resize 4K-size auto buffer reservations to BUFSIZ (==1K)
- remove trailing '\n' from 2nd arg on error() calls everywhere
- provide consistent annotation of Windows error number displays

Fixes: 9887fb27f6126 ("Cygwin: New tool: profiler")
Fixes: 087a3d76d7335 ("Cygwin: New tool: gmondump")
Signed-off-by: Mark Geisert <mark@maxrnd.com>
2023-11-14 11:48:11 +01:00
Corinna Vinschen d223f09590 Add release text for random(3) fix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-13 20:01:54 +01:00
Corinna Vinschen e9c4a281e5 Cygwin: random: drop unused function srandomdev()
Also drop includes only required for srandomdev().

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-13 19:50:15 +01:00
Corinna Vinschen 06e463223b Cygwin: random: make random(3) functions thread-safe
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>
2023-11-13 19:49:06 +01:00
Takashi Yano 3d94e07c49 newlib: libc: Fix crash on fprintf to a wide-oriented stream.
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>
2023-11-10 00:36:41 +09:00
Christian Franke 7863c07a92 Cygwin: /dev/disk/by-id: Remove leading spaces from identify fields
Various drives align the serial number to the right of the fixed
length field.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-08 20:28:44 +01:00
Christian Franke 7236f22f71 Cygwin: Document /dev/disk/by-id and /dev/disk/by-partuuid
Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-11-07 16:15:12 +01:00
Christian Franke 1ebef73c59 Cygwin: Add /dev/disk/by-partuuid symlinks
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>
2023-11-07 13:12:04 +01:00
Christian Franke c8cf1933ba Cygwin: Add /dev/disk/by-id symlinks
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>
2023-11-05 17:01:43 +01:00
Andrew Stubbs 12e3bac3ce amdgcn: remove unnecessary scalar cache flush
The exit code isn't actually written via the scalar cache so the cache flush
is not actually needed.
2023-10-31 13:36:45 +01:00
Corinna Vinschen 2ef627c46e Cygwin: let feraiseexcept actually raise an exception
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>
2023-10-31 13:27:51 +01:00
Corinna Vinschen 60d1eeac6c Cygwin: cwd: avoid releasing the cwdstuff SRW Lock twice
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>
2023-10-30 19:40:31 +01:00
Takashi Yano d56d58ace2 Cygwin: dsp: Improve minimum buffser size estimation.
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>
2023-10-30 19:58:38 +09:00
Mike Frysinger 39f734a857 newlib: fix AC_DEFINE quoting style with version macros
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 [...].
2023-10-15 15:10:52 +05:45
Sebastian Huber fbc5496e40 sparc: Improve setjmp()
Flush the windows in setjmp().  This helps if the stack is changed after
the setjmp() and we want to jump back to the original stack using
longjmp().
2023-10-12 17:04:38 +02:00
Sebastian Huber 696c282cf3 riscv: Fix fenv.h support
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.
2023-10-12 16:46:21 +02:00
Joseph Faulls dcb2b7d7b8 Delete check in catan, catanf, and catanl functions.
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.
2023-10-10 15:18:54 -04:00
Sebastian Huber fe5886a500 aarch64: Import memrchr.S
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.
2023-10-05 14:16:59 +02:00
Sebastian Huber 96ec8f868e aarch64: Sync with ARM-software/optimized-routines
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).
2023-10-05 14:16:57 +02:00
Torbjörn SVENSSON a9e8e3d1cb newlib: Add missing prototype for _getentropy 2023-09-25 18:20:25 -04:00
Alexey Lapshin 55485616ba Bring back libsim.a for riscv 2023-09-18 22:49:15 -04:00
Alexey Lapshin 6e5676a915 newlib: Fix header install 2023-09-18 18:45:34 +02:00