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.
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.
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.
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).
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.
- 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>
- 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>
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>
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 :)
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>
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>
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>
In preparation of using the FileFsSectorSizeInformation info class,
add a couple of missing definitions.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
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>
Replace multiplication with division for microseconds calculation from
nanoseconds in _gettimeofday function.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
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>
__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>
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>
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>
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>
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>