Commit Graph

21462 Commits

Author SHA1 Message Date
Mike Frysinger b67114d7d8 Revert "Fix libgloss/newlib build to conditionally use top include dir"
This reverts commit 17ac400c11.

The build failures were due to incorrectly using $(INCLUDES) when
running $(AS).  Let's roll this back and drop $(INCLUDES) from the
$(AS) invocations.
2023-12-19 13:37:02 -05:00
Freddie Chopin 60c6397133 Remove curly braces in `@author` tag in .texi files
Curly braces cause documentation build failure with texinfo 7.1 (works fine
up to 7.0.3):
2023-12-19 13:28:18 -05:00
Jeff Law c2c9f05a05 libgloss fix for bfin port
gcc-14 will complain loudly both for calling a function without an in-scope
prototype or when the in scope prototype differs from the known signature.

"main" happens to be one of the functions the compiler knows about.  So not
only do we need to prototype it, we need to make sure the prototype matches
what GCC thinks it should be.

This fixes the bfin libgloss port to do the right thing for bfin-elf.
2023-12-18 21:29:51 -07:00
Jeff Law 57e311e0de Re: Fix moxie libgloss issues with c99
Two libgloss issues specific to moxie-elf that show up build with GCC trunk.

First, putnum.c uses "print" without a prototype.  So I added one based on the
function's definition in print.c.  Second sim-inbyte.c uses read, which comes
from unistd.h, so this adds a suitable #include.
2023-12-16 21:11:10 -07:00
Jeff Law 17a6aff334 Fix fr30 libgloss build
gcc-14 will default to c99 and as a result a fair amount of old code in newlib
(particularly libgloss) is failing to build.  I don't offhand know how many
patches will be necessary to fix the various failures. I'll just pick them off
one by one from my tree.

This particular patch works around the return-mismatch problem syscalls.c for
fr30.

That file is a bit odd in that most functions are declared as returning an
integer, but the implementations look like:

> int
> _read (file, ptr, len)
>      int    file;
>      char * ptr;
>      int    len;
> {
>   asm ("ldi:8 %0, r0" :: "i" (SYS_read) : "r0");
>   asm ("int   #10");
>
>   return;
> }

Note the lack of a value on the "return" statement.  The assumption is that the
interrupt handler implementing syscalls will put the return value into the
proper register, so falling off the end of the C function or returning with no
value works in the expected way.  It's not good code, but it probably works.

Working from that assumption I decided to just use a pragma to disable the
upgraded diagnostic from GCC -- essentially preserving existing behavior.

This is the only fr30 specific issue that needs to be resolved and the only
issue (so far) I've seen of this specific nature.
2023-12-14 10:30:13 -07:00
Hans-Peter Nilsson 3bafe2fae7 newlib cris: Fix compilation warnings that recent gcc treats as errors
For the newlib part, warnings are all from lack of sync between
libc/machine/cris/sys/signal.h and libc/include/sys/signal.h.  This
commit gets them sufficiently in sync again, functionality-wise and
declaration-wise.  Still, nothing is declared that isn't supported at
the system level (i.e. in libgloss system calls and handled by the
CRIS simulator in the gdb project).
2023-12-06 18:46:49 +01:00
Hans-Peter Nilsson 7cce4cdd6e libgloss/cris: Make C declarations present and match them
This is the libgloss part.
Recently, there was a change in gcc such that implicit function
declarations and type mismatches are now errors, no longer just
warnings.  Fix by adding and correcting declarations warned about;
including the right header or adding a declaration (for "main" in
lcrt0.c) and adjust to those types as necessary.
2023-12-06 18:45:57 +01:00
Corinna Vinschen 0737bda6ff Cygwin: fallocate(2): fix debug output
Fixes: e01c50c7b0 ("Cygwin: introduce fallocate(2)")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-05 22:20:48 +01:00
Corinna Vinschen 7f88c8e0b3 Cygwin: fallocate(2): fix offset and length sanity check
- len must not be <= 0
- offset + len must not exceed off_t (max. file size)

Fixes: e01c50c7b0 ("Cygwin: introduce fallocate(2)")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-05 22:20:42 +01:00
Corinna Vinschen 295bef07d6 Cygwin: posix_fallocate(3): fix offset and length sanity check
- len must not be <= 0
- offset + len must not exceed off_t (max. file size)

Fixes: 7636b58590 ("* autoload.cc (NtSetInformationFile): Define.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-05 22:19:05 +01:00
Dimitar Dimitrov 14d786873c pru: libm: Fix incorrect function name
Upstream GCC changed -Wimplicit-function-declaration warning into an
error. The build break about missing fpclassifyf function prototype
exposed a bug in the PRU port of libm.

The fix is to use the fpclassify macro for both double and float types.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2023-12-04 17:01:05 +01:00
Kito Cheng 04798b7bb6 RISC-V: Support long double math
Long double for RISC-V is using 128 bit IEEE 754 format like Aarch64,
so we reference AArch64 to support that.
2023-12-04 10:26:41 +01:00
Kito Cheng bcd1883560 RISC-V: Fix -Wint-conversion warning
Upstream GCC has change this warning into error by default, so...we need
to explicitly convert the type from pointer from/to integer, generally
it's unsafe, but we know what we are doing here.

However it's not safe for ilp32 on RV64, but we didn't support that yet, so I
think this fix is good enough now :)
2023-12-04 10:26:41 +01:00
Corinna Vinschen c0d2f38742 Cygwin: fallocate(2): drop useless zeroing pointer
The out pointer is only used if data_chunk_count is > 0,
so there's no reason to set it to NULL in the error case.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-04 10:20:55 +01:00
Jon Turney 97b1f4db06
Cygwin: CI: drop IRC notification from AppVeyor via notifico
Drop IRC status notification from AppVeyor via notifico, as we no longer
run tests there.
2023-12-03 13:05:18 +00:00
Kuan-Wei Chiu b64d0d53af newlib: libc: Fix indentation
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
2023-12-02 22:22:26 -05:00
Kuan-Wei Chiu 65f7ab0bb9 newlib: libc: Fix memory leak in computematchjumps()
In cases where malloc fails for the 'g->matchjump' allocation, the code
path does not handle the failure gracefully, potentially leading to a
memory leak. This fix ensures proper cleanup by freeing the allocated
memory for 'pmatches' before returning.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
2023-12-01 19:28:55 +01:00
Corinna Vinschen 10da646880 Cygwin: drop stray fs_info::check_ssd declaration
This is just a leftover from development

Fixes: 8b01c5d690 ("Cygwin: fs_info: check for SSD")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-01 09:56:05 +01:00
Corinna Vinschen cb21f8bc56 Cygwin: doc: add missing change to posix_spawnp
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:38:59 +01:00
Corinna Vinschen 832e91422c Cygwin: sparse support: enable automatic sparsifying of files on SSDs
Given that SSDs don't have a seek penalty, we can enable
automatic sparsifying of files on SSDs, even if the "sparse"
mount option is not set.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:37:35 +01:00
Corinna Vinschen 8b01c5d690 Cygwin: fs_info: check for SSD
During fs_info::update, check for the file being on an SSD.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:37:35 +01:00
Corinna Vinschen 61f49ada90 Cygwin: ntdll.h: add missing NtQueryVolumeInformationFile definitions
In preparation of using the FileFsSectorSizeInformation info class,
add a couple of missing definitions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:37:35 +01:00
Corinna Vinschen f816787c57 Cygwin: ntdll.h: add missing POBJECT_NAME_INFORMATION
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:37:35 +01:00
Corinna Vinschen 013de6b097 Cygwin: revert autoloading of DiscardVirtualMemory
Commit a3ae2a7348 ("Cygwin: don't autoload some kernel32 functions")
erroneously removed DiscardVirtualMemory from the list of autloaded
functions.  DiscardVirtualMemory is not available on Windows 8.1.

Fixes: a3ae2a7348 ("Cygwin: don't autoload some kernel32 functions")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30 22:37:35 +01:00
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