Commit Graph

3268 Commits

Author SHA1 Message Date
Aaron Nyholm b8d3dec491 newlib/libc/include/time.h: Removed clock_id casts
The POSIX specification defines these as constants. The cast is
unnecessary. This brings newlib inline with the equivalent FreeBSD
defines.
2024-11-20 12:04:43 +01:00
Lenard Mollenkopf 5e0fb305a8 sys/features.h: Use _ISOC23_SOURCE instead of _ISOC23_SOURCE and remap _ISOC2x_SOURCE to _ISOC23_SOURCE
Signed-off-by: Lenard Mollenkopf <newlib@lenardmollenkopf.de>
2024-11-04 11:44:55 +01:00
Lenard Mollenkopf 5e6eb2f200 sys/features.h: Spelling _ISOC2x_SOURCE is not C11 2024-10-28 13:49:28 +01:00
Jeff Johnston 5a9fe58014 Make sure mallinfo structure matches newlib's malloc.h 2024-09-16 19:21:46 -04:00
yang.zhang 1b3dcfdc6f Replace __restrict with __restrict_arr in regex.h
when a C++ source file include this header file, it would build fail.

Signed-off-by: yang.zhang <zhangyang01@kylinos.cn>
2024-09-02 22:23:50 +02:00
Alexey Lapshin cc0d1bf2f1 newlib: esp: add dirent.h header file
Support dirent in *-esp-* toolchains
2024-09-02 22:16:59 +02:00
Alexey Lapshin 48f1655c95 newlib: xtensa: remove sys/xtensa. use machine/xtensa
Remove sys/xtensa that is actually duplicate newlib's code.
Move used code to machine/xtensa or to libgloss
2024-09-02 22:16:59 +02:00
Corinna Vinschen d78ca12ab4 locales: Fix definition of lc_messages_T::codeset
nl_langinfo_l accesses lc_messages_T::codeset as soon as
__HAVE_LOCALE_INFO__ is defined, but codeset only exists
if __HAVE_LOCALE_INFO_EXTENDED__ is defined.

Fix this by defining lc_messages_T::codeset depending on
__HAVE_LOCALE_INFO__.

Fixes: ac7f1d5e93 ("Get rid of LCID, reformat type definitions in setlocale.h")
Reported-by: Inglis <Brian.Inglis@SystematicSW.ab.ca>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-22 21:21:51 +02:00
Corinna Vinschen ea1a458d20 nl_langinfo_l: drop erroneus messages::codeset entry
The nl_ext array contains offsets into the extended info of
locale structures, the index being equivalent to the nl_item
values in langinfo.h.

For the lc_messages_T struct, nl_ext erroneusly contains an
entry for the codeset member, which is in fact not part of the
extended info in nl_item.  However, due to that, the offsets for
subsequent entries are off by one.

Fix this by dropping the messages::codeset entry from nl_ext.

Fixes: d47d5b850b ("Extend locale support to maintain wide char values of native strings")
Reported-by: Brian Inglis <Brian.Inglis@systematicsw.ab.ca>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-22 21:15:44 +02:00
Yuriy Kolerov 820dd5009b arc64: Add port for Synopsys DesignWare ARCv3 ISA
Synopsys ARCv3 ISA includes 32-bit ARC HS5x targets and
64-bit ARC HS6x targets. Both CPU families are placed
in "arc64" subdirectories as it done for GCC port.
Target name arc64 is used for historical reasons and
Synopsys ARCv3 baremetal toolchains contain multilib
configurations both for 32-bit and 64-bit families.
arc32 target name is reserved for 32-bit ARC HS5x
targets in case of non-multilib 32-bit builds.

Note that libgloss libraries for ARCv3 are compatible with
libgloss for ARCv1/2. Thus, Makefile.inc for libgloss uses
sources from libgloss/arc directory except crtX.S files.

Co-authored-by: Shahab Vahedi <list@vahedi.org>
Co-authored-by: Claudiu Zissulescu <claziss@gmail.com>
Co-authored-by: Bruno Mauricio <brunoasmauricio@gmail.com>
Co-authored-by: Luis Silva <luis.m.silva99@hotmail.com>
Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
2024-08-21 15:32:22 -04:00
Alexey Brodkin 16accfa08d arc: Remove @ from symbol references in assembly
There's no semantic change, it's only to make the same code
compilable with MetaWare toolchian, which actually assumes
@x as a full name, not omitting @.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
2024-08-20 18:23:20 -04:00
Claudiu Zissulescu 3e9f6a005c arc: Use __ARC_UNALIGNED__ compiler macro
Replace __ARC_ALIGNED_ACCESS__ macro with the compiler defined
macro __ARC_UNALIGNED__ and improve file comments.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2024-08-20 18:23:06 -04:00
Jordi Sanfeliu e5689df37d Fix glob() function
Fixed glob() function to return GLOB_NOMATCH if pattern does
not match any existing pathname (and GLOB_NOCHECK was not set in flags).
2024-08-20 14:42:03 +02:00
Joel Sherrill a86f468f96 newlib/libc/include/sys/tree.h: Add deprecation warning 2024-08-19 12:04:17 +02:00
Joel Sherrill f6eb96418a libc/include/sys/tree.h: Re-add sys/tree.h
Reverts 1339af4467
2024-08-19 12:04:17 +02:00
Corinna Vinschen b2e05e03df stdlib.h: define __itoa/__utoa while building newlib
This avoids a `__utoa undefined' warning when building newlib
for Cygwin.  We still need to export the symbols for backward
compatibility.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-15 20:54:57 +02:00
Corinna Vinschen ca31784fef Fix POSIX guards for POSIX.1-2024 extensions
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-15 20:42:04 +02:00
Corinna Vinschen 13c89a620b features.h: support POSIX.1-2024
TBD: Align _GNU_SOURCE, too?

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-15 17:40:06 +02:00
Corinna Vinschen c6f14f261a features.h: fix whitespace
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-15 17:36:54 +02:00
Alexey Lapshin d001c01a7c stdatomic: make atomics compatible with GCC-14
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631525.html
brings c_atomic and cxx_atomic definitions into GCC.
This patch makes atomics type detection correct for GCC.

680f40f383
2024-07-30 14:45:27 +02:00
Joel Sherrill 1339af4467 sys/tree.h: Removed
This file was from a specific older FreeBSD version. There have been
multiple changes to this file with FreeBSD 14 including breaking
changes to the file. Including this file as part of newlib results
in not always having the correct version of sys/tree.h for any
specific software. RTEMS will manage its use of this file outside
of newlib.
2024-07-09 17:53:08 -05:00
Clément Chigot a7b62e886e libc/arm: add missing .cfi_sections
The modifications added by the series "M-profile PACBTI-enablement"
(see 9d6b00511e) have introduced a couple
of .cfi_* instructions.

Like for e6459123e4, these instructions
create object files which contain .eh_frame sections.  However, ARM uses
its own unwind info format, not .eh_frame, which is generated by
ARM-specific directives, not .cfi_*. The .eh_frame sections are useless,
but also not removed by strip and may be harmful with some linker
scripts.

Adding ".cfi_sections .debug_frame" (as in glibc) moves the generated
directives towards .debug_frame instead of .eh_frame. Making them easier
to handle.

            * libc/machine/arm/aeabi_memmove-thumb2.S: Use .cfi_sections
            .debug_frame.
            * libc/machine/arm/aeabi_memset-thumb2.S: Likewise.
            * libc/machine/arm/memchr.S: Likewise.
            * libc/machine/arm/memcpy-armv7m.S: Likewise.
            * libc/machine/arm/setjmp.S: Likewise.
            * libc/machine/arm/strlen-armv7.S: Likewise.
            * libc/machine/arm/strlen-thumb2-Os.S: Likewise.
2024-07-09 15:25:49 +01:00
Joel Sherrill 80550ffc2e libc/include/sys/resource.h: Add RUSAGE_THREAD 2024-07-09 08:46:22 -05:00
Warner Losh 5876c8cab4 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2024-07-09 08:20:50 +02:00
Warner Losh 69913208c1 spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2024-07-09 08:20:50 +02:00
Konstantin Belousov 9f86886873 sys/stdatomic.h: be nicer to c++
Use of stdatomic.h is undefined in C++, even the C++ 2020 standard does not
list stdatomic.h as a C library header supported by the language.  More,
there are some subtle differences between the <atomic> C++ header, and
C11+ stdatomic.h provided features.

Nonetheless, it is a quality of the implementation aspect, so let mis-users
mis-use stdatomic.h as they want, by making a compat shim for _Bool.

PR:	262683
Reported by:	yuri
Reviewed by:	dim, emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D34686
2024-07-09 08:20:50 +02:00
Pedro F. Giffuni 27ddfd9f8e sys/sys: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2024-07-09 08:20:40 +02:00
Joel Sherrill a5ffae1455 libc/include/complex.h: Add CMPLX, CMPLXF, and CMPLXL 2024-07-03 08:52:33 -05:00
Joel Sherrill a0637f8033 libc/include/sys/_default_fcntl.h: O_RSYNC and O_DSYNC are POSIX
These should not be in a Cygewin conditional.
2024-07-03 08:51:40 -05:00
Pietro Monteiro 36e398b04e libc: sh: add missing prototypes and change functions from K&R to ANSI
The SuperH target doesn't build on GCC 14.1 because of missing
function prototypes or because some function declarations use the
deprecated K&R style.  This patch adds missing prototypes on the files
the functions are used and convert K&R declarations to ANSI-style.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2024-06-28 11:25:51 +02:00
Christophe Lyon c2091f706c arm: emit .type %function directive in FUNC_START macro
The linker needs to know whether a symbol is STT_FUNCTION when
deciding which farcall stub to emit (if needed), this patch adds this
to the FUNC_START macro which is used in crt0.
2024-06-26 09:02:32 +00:00
Shahab Vahedi 3f7e8eef09 arc: libc: Record r58/r59 in long-jump's buffer
The "longjmp" expects the "setjmp" to save the r58/r59 registers,
if there is any. With this change they are saved accordingly.

Checked for regression with running GCC's DejaGnu tests:

    $ runtest execute.exp=pr56982.c dg-torture.exp=pr48542.c

Signed-off-by: Shahab Vahedi <shahab@synopsys.com>
2024-05-22 14:25:29 -04:00
Yuriy Kolerov 880d537347 arc: libc, libgloss: Remove .file directive from .S files
Assembler for ARCv2 always extends the name provided by
.file directive to an absolute form.

On ARCv3 targets .file directive forces assembler to put
a provided string to DW_AT_name field as is without
extending to an absolute path. Then GDB cannot find
source files because of it.

The best way to fix this issue is just delete lines
with .file directive in .S files and let the compiler
to decide what DW_AT_name must contain. Particularly,
the compiler fills this filed by an absolute path to
a .S file because only absolute paths are used in
toolchain's build process.

Signed-off-by: Yuriy Kolerov <kolerov93@gmail.com>
2024-05-22 14:25:21 -04:00
Claudiu Zissulescu d85bb55f45 arc: libc: Add support of 16-entry register file
ARC supports a restricted register file with 16 registers.
However, optimized routines support only a full register
file. Thus, fallback on default implementation in case
of 16-entry register file.

Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2024-05-22 14:22:26 -04:00
Thomas Schwinge ed50a50b9b amdgcn: Implement proper locks: Fix 'newlib/libc/sys/amdgcn/include/sys/lock.h' for C++
As of commit 7dd4eb1db9
"amdgcn: Implement proper locks", we get, by the thousands, for C++ code:

    In file included from [...]/newlib/libc/include/stdio.h:60,
                     from [...]:
    [...]/newlib/libc/include/sys/reent.h:911:1: error: expected declaration before '}' token
2024-04-04 16:01:35 +02:00
Andrew Stubbs 7dd4eb1db9 amdgcn: Implement proper locks
This should prevent printf output from multiple threads getting garbled.

I don't know why IO ever worked properly -- probably it was always a bit
broken -- but the GFX11 devices have a different cache architecture and
trying to print from many threads at once corrupted the FILE buffers.
2024-03-25 11:32:52 +01:00
Joel Sherrill 176b19fbe5 libc/include/sys/select.h: Use elif not elifdef
The cpp directive "elifdef" is only available in very recent GCC versions.
This should be able to compile on older toolchains in C99 mode.`
2024-03-13 09:29:36 -05:00
Chris Johns 8d38c37ed9 RTEMS: Increase FS_SETSIZE to 256 bits 2024-03-13 08:59:24 -05:00
Torbjörn SVENSSON 3b97a5ec67 libc/stdio: Remove wchar_t functions from NEWLIB_NANO_FORMATTED_IO
Regression tested in basepoints/gcc-14-9032-g945cb8490cb with arm-none-eabi.

Example failure without this change:
$ arm-none-eabi-g++ .../pr100611.C -std=c++20 --specs=nosys.specs -o /dev/null --specs=nano.specs
.../ld: .../libc_nano.a(libc_a-svfwprintf.o): in function `_svfwprintf_r':
(.text._svfwprintf_r+0xd8): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x834): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x85c): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x8a8): undefined reference to `__ssputws_r'
.../ld: (.text._svfwprintf_r+0x8dc): undefined reference to `__ssputws_r'
.../ld: .../libc_nano.a(libc_a-svfwprintf.o):(.text._svfwprintf_r+0x900): more undefined references to `__ssputws_r' follow
collect2: error: ld returned 1 exit status

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Yvan ROUX <yvan.roux@foss.st.com>
2024-03-11 11:29:55 +01:00
Christian Franke 6f996d7751 Cygwin: add compile warning if ENOSHARE or ECASECLASH is used
These errno values are no longer used by Cygwin.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-28 09:59:07 +01:00
Sebastian Huber 3e16e86a56 RTEMS: Define ssize_t for <dirent.h>
This fixes the following build issue:

newlib/libc/include/dirent.h:84:1: error: unknown type name 'ssize_t'; did you mean '_ssize_t'?
   84 | ssize_t posix_getdents(int, void *, size_t, int);
      | ^~~~~~~
      | _ssize_t
2024-02-24 11:31:43 +01:00
Alexey Lapshin acf176104f strptime: fix am/pm converting to 24-hour system
Fix the issue of parsing 08:00AM, which currently gives a 20:00 representation.
2024-02-21 15:52:14 +01:00
Corinna Vinschen bfb68a9e6e getlocalename_l: fix _reent for _REENT_SMALL targets
The new _MB_CAPABALE-only _misc_reent member getlocalename_l_buf was
incorrectly initialized in the _REENT_INIT_MISC macro, so the build
failed for _REENT_SMALL targets, independet of the _MB_CAPABALE setting.

Fixes: 71511d4ac8 ("getlocalename_l: implement per SUS Base Specifications Issue 8 draft")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-05 10:38:28 +01:00
Corinna Vinschen 2e7f7b96e5 Cygwin: implement setproctitle
Make sure to create commandline according to setting of setproctitle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31 20:11:58 +01:00
Corinna Vinschen 3600654b78 sys/stat.h: drop __INSIDE_CYGWIN__ guards
These were only necessary until we dropped 32 bit Cygwin.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31 20:11:58 +01:00
Corinna Vinschen 62ca95721a Cygwin: posix_getdents: implement per SUS Base Specifications Issue 8 draft
- Basically maintain a hidden DIR* inside fhandlers.

- lseek has to be tweaked to allow basic seeking on the directory
  descriptor.

- the current implementation does not keep the dir positions
  between duplicated descriptor in sync.  In fact, every descriptor
  keeps its own copy of the DIR* and after dup/fork/exec, the
  directory position is reset to 0, i. e., to the start of the
  directory, as if rewinddir() has been called on the new descriptors.

  While this behaviour isn't yet covered by the Issue 8 draft,
  a bug report along these lines exists and will probably be
  picked up for TC1.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31 20:11:58 +01:00
Corinna Vinschen 71511d4ac8 getlocalename_l: implement per SUS Base Specifications Issue 8 draft
#include <locale.h>
  const char *getlocalename_l(int category, locale_t locobj);

Most notably, we need a per-thread space to store the string
returned if locobj is LC_GLOBAL_LOCALE.  No errors are defined
for getlocalename_l.  So we can't use buffer allocation which
might lead to an ENOMEM error.  We have to use a "static" buffer
in the per-thread state.

Note that the feature test macro in locale.h is not quite correct.
This needs to be fixed as soon as the

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31 20:11:57 +01:00
Christian Franke 31f7cd1e43 Hide itoa, utoa, __itoa and __utoa in stdlib.h on Cygwin only
These functions are non-standard and not exported by Cygwin.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-01-31 20:06:38 +01:00
Christian Franke 497e6eb2c0 ssp: add support for _FORTIFY_SOURCE=3
If specified, use __builtin_dynamic_object_size() instead of
__builtin_object_size() if supported (GCC 12.0 or later).
This enables buffer overflow checks if the buffer size is non-const
but known during runtime.
Use new macro __ssp_bos_known() instead of the (bos(p) != (size_t)-1)
checks.  The latter is no longer a compile time constant in all cases.
This avoids the generation of unused code.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-01-29 14:03:37 +01:00
Mike Frysinger 72b6105518 newlib: docs: add "Function " to every function node
When creating a split manual with one-node-per-page, the main index.html
ends up getting clobbered by the page for the index() function because
it uses "@node index" which, for html, also creates an index.html page.
To remedy this, add "Function " to every function node so now we output
"Function-index.html" and avoid clobbering.  It also namespaces every
other function and helps make sure we don't clobber anything else.

Otherwise, there isn't really much rendering difference as @node text
is mostly internal.  Node title text comes from @section instead.
2024-01-22 21:58:58 -05:00