]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
5 months agoCygwin: implement fdclosedir
Corinna Vinschen [Tue, 23 Jan 2024 12:41:14 +0000 (13:41 +0100)]
Cygwin: implement fdclosedir

fdclosedir is BSD-only but already present in dirent.h for a couple
of years.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 months agoCygwin: implement dirent.d_reclen
Corinna Vinschen [Sun, 21 Jan 2024 18:51:54 +0000 (19:51 +0100)]
Cygwin: implement dirent.d_reclen

This change is in preparation of adding posix_getdents() from
the upcoming POSIX Base Specification Issue 8.

- Add d_reclen
- Add GLibC compatible test macros for dirent members
- Bump dirent version
- Set d_reclen to the fixed size of the dirent struct
  We can do that because the size is a multiple of 8, so it fits
  snugly in the buffer filled by posix_getdents and keep the
  alignement.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 months agoCygwin: export getlocalename_l
Corinna Vinschen [Sun, 21 Jan 2024 12:24:52 +0000 (13:24 +0100)]
Cygwin: export getlocalename_l

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 months agogetlocalename_l: implement per SUS Base Specifications Issue 8 draft
Corinna Vinschen [Sun, 21 Jan 2024 12:23:09 +0000 (13:23 +0100)]
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>
5 months agoCygwin: path: convert symlink_info to class
Corinna Vinschen [Wed, 17 Jan 2024 11:19:33 +0000 (12:19 +0100)]
Cygwin: path: convert symlink_info to class

encapsulate everything

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 months agoCygwin: files: slightly simplify suffix handling
Corinna Vinschen [Tue, 16 Jan 2024 14:23:06 +0000 (15:23 +0100)]
Cygwin: files: slightly simplify suffix handling

- drop appending .exe.lnk to files
- drop exe_suffixes, it's the same as stat_suffixes for a long time

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 months agoCygwin: bump DLL version to 3.6.0 cygwin-3.6.0-dev
Corinna Vinschen [Tue, 23 Jan 2024 12:42:44 +0000 (13:42 +0100)]
Cygwin: bump DLL version to 3.6.0

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 months agoHide itoa, utoa, __itoa and __utoa in stdlib.h on Cygwin only cygwin-3.5.0
Christian Franke [Mon, 22 Jan 2024 18:11:20 +0000 (19:11 +0100)]
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>
5 months agoCygwin: machine/_arc4random.h: Fix copy/paste bug
Corinna Vinschen [Mon, 29 Jan 2024 15:42:50 +0000 (16:42 +0100)]
Cygwin: machine/_arc4random.h: Fix copy/paste bug

Remove a stray  __END_DECLS.  It didn't hurt in the only
(plain C) file including this header, but still...

Fixes: 030a762535c1 ("Cygwin: fix arc4random after fork(2)")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 months agossp: add support for _FORTIFY_SOURCE=3
Christian Franke [Fri, 26 Jan 2024 16:20:37 +0000 (17:20 +0100)]
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>
5 months agoCygwin: fix arc4random after fork(2)
Corinna Vinschen [Mon, 29 Jan 2024 12:38:14 +0000 (13:38 +0100)]
Cygwin: fix arc4random after fork(2)

After using fork(), arc4random does not reseed itself, which
causes the results to become predictable.  Activate droppingfork-recognition

Fixes: e0fc33322d50 ("Delete Cygwin's arc4random in favor of new Newlib implementation")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 months agoCygwin: redefine how to recognize forkee state
Corinna Vinschen [Mon, 29 Jan 2024 12:33:05 +0000 (13:33 +0100)]
Cygwin: redefine how to recognize forkee state

So far the global variable in_forkee only indicated if the
process is the child process during fork(2) itself.

However, we need an indicator accessible from plain C code
in newlib, allowing to check for a process being a forked
process all the time, after fork(2) succeeded.

Redefine bool in_forkee to int __in_forkee to allow exposing
it to newlib.  Redefine how it indicates fork state (not
forked, forking, forked).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 months agoCygwin: Add a timeout to ensure we don't wait forever for dumper
Jon Turney [Tue, 23 Jan 2024 16:07:34 +0000 (16:07 +0000)]
Cygwin: Add a timeout to ensure we don't wait forever for dumper

5 months agolibgloss: start a MAINTAINERS file
Mike Frysinger [Wed, 24 Jan 2024 04:32:32 +0000 (23:32 -0500)]
libgloss: start a MAINTAINERS file

5 months agoCygwin: pthread: Fix handle leak in pthread_once.
Takashi Yano [Wed, 24 Jan 2024 13:33:12 +0000 (22:33 +0900)]
Cygwin: pthread: Fix handle leak in pthread_once.

If pthread_once() is called with pthread_once_t initialized using
PTREAD_ONCE_INIT, pthread_once does not release pthread_mutex used
internally. This patch fixes that by calling pthread_mutex_destroy()
in the thread which has called init_routine.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
5 months agoCygwin: Don't terminate via dumper
Jon Turney [Tue, 16 Jan 2024 16:12:51 +0000 (16:12 +0000)]
Cygwin: Don't terminate via dumper

A process which is exiting due to a core dumping signal doesn't
propagate the correct exist status after dumping core, because 'dumper'
itself forcibly terminates the process.

Use 'dumper -n' to avoid killing the dumped process, so we continue to
the end of signal_exit(), to exit with the 128+signal exit status.

Busy-wait in exec_prepared_command() in an attempt to reliably notice
the dumper attaching, so we don't get stuck there.

Also: document these important facts for custom uses of error_start.

5 months agolibgloss: merge cr16 into top-level Makefile
Mike Frysinger [Sun, 21 Jan 2024 04:47:12 +0000 (23:47 -0500)]
libgloss: merge cr16 into top-level Makefile

Avoid a recursive make to speed things up a bit.
A cr16-elf build shows installed objects & libs produce same code.

The test targets were dropped as they didn't actually work -- there
is no test.o rule in here.

5 months agoconfigure.ac: configurable tooldir install path
Neal Frager [Thu, 11 Jan 2024 18:30:19 +0000 (18:30 +0000)]
configure.ac: configurable tooldir install path

This patch is required to fix how the newlib headers are installed
when using a sysroot install directory.

The cross compiler expects headers to be in
.../host/usr/arm-none-eabi/sysroot/usr/include/newlib.h
by default newlib installed the headers into
.../host/usr/arm-none-eabi/sysroot/usr/arm-none-eabi/include/newlib.h

${exec_prefix} provides the .../host/usr/arm-none-eabi/sysroot path
${target_noncanonical} provides an extra arm-none-eabi/ that must be removed.

With this patch, users can specify the tooldir path that is needed.

Signed-off-by: Neal Frager <neal.frager@amd.com>
Co-developed-by: Chris Wardman <cjwfirmware@vxmdesign.com>
5 months agolibgloss: pru: Trim crt0-minrt.o
Dimitar Dimitrov [Mon, 22 Jan 2024 16:11:36 +0000 (18:11 +0200)]
libgloss: pru: Trim crt0-minrt.o

Strip a few more instructions from crt0-minrt.S:
  - Remove "halt" and rely on the infinite loop after main()'s return.
  - Remove main()'s argc and argv argument initialization.  Host loader
    does not set them, and typical firmware does not use them, either.
  - Remove the __dso_handle symbol.

This should be safe because the default crt0.S is fully standards
compliant.  Whereas crt0-minrt.S has been documented from the beginning
to intentionally miss features in order to reduce firmware size, while
still enabling typical PRU firmware to operate.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
5 months agolibgloss: merge pru into top-level Makefile
Dimitar Dimitrov [Mon, 22 Jan 2024 16:11:35 +0000 (18:11 +0200)]
libgloss: merge pru into top-level Makefile

Avoid a recursive make to speed things up a bit.  This change was
inspired by the recent similar patch for c6x:
https://sourceware.org/pipermail/newlib/2023/020869.html

While at it, fork crt0-minrt.S into a separate source file instead of
relying on a predefined macro to generate two different object files.
This improves clarity, simplifies the build rules, and would allow
further optimization in crt0-minrt.S to be implemented more cleanly.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
5 months agoCygwin: seekdir: don't set errno
Corinna Vinschen [Mon, 22 Jan 2024 18:59:09 +0000 (19:59 +0100)]
Cygwin: seekdir: don't set errno

Commit 3f3bd1010455 ("* Throughout, use __try/__except/__endtry blocks [...]")
introduced setting EINVAL, marked as "Diagnosis".  The reason
for this is lost in time and space, but looks very much like
a debug helper which was supposed to be removed before release.
It's rather pointless, so remove it.

Fixes: 3f3bd1010455 ("* Throughout, use __try/__except/__endtry blocks [...]")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 months agonewlib: docs: add "Function " to every function node
Mike Frysinger [Fri, 5 Jan 2024 05:01:23 +0000 (00:01 -0500)]
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.

5 months agonewlib: docs: print the function index
Mike Frysinger [Fri, 5 Jan 2024 05:00:22 +0000 (00:00 -0500)]
newlib: docs: print the function index

The generated function documentation makes sure to include entries for
every function in the function index via @findex, but then the manuals
forget to actually print the index.

5 months agolibgloss: doc: unify duplicate copyright/license content
Mike Frysinger [Wed, 27 Dec 2023 00:53:51 +0000 (19:53 -0500)]
libgloss: doc: unify duplicate copyright/license content

Use @copying & @insertcopying directives to define the copyright &
license block only once, and then inserted at the same places as it
was before.

5 months agolibgloss: doc: fix dir info entry usage
Mike Frysinger [Wed, 27 Dec 2023 00:09:29 +0000 (19:09 -0500)]
libgloss: doc: fix dir info entry usage

Wrapping the dir info with @ifnottex means it's included in all other
outputs like html which makes no sense.  Switch to @direntry which is
specific for this content and is automatically written to the output
that makes sense, and omitted from the rest.

5 months agoAdd Dimitar Dimitrov as maintainer for pru
Jeff Johnston [Mon, 22 Jan 2024 18:57:50 +0000 (13:57 -0500)]
Add Dimitar Dimitrov as maintainer for pru

6 months agolibgloss: xc16x: drop old stub port
Mike Frysinger [Sat, 30 Dec 2023 02:29:44 +0000 (21:29 -0500)]
libgloss: xc16x: drop old stub port

First off, afaict, xc16x support has never been merged into gcc.
Upstream merge isn't strictly required for new ports, but it seems
like people should merge eventually in some shape, and considering
the libgloss port was merged in 2009, ~14 years seems like plenty
of leeway.  Which is to say, no one else can seem to build this
which makes updating & testing things very difficult.

Ignoring that, from what I can tell, this port has only ever built
and installed a crt0.o file.  It defines libeval.a & libcygmon.a
targets, but nothing depends on them.  The SCRIPTS & BSP variables
are always empty.  The original port merge define these in the
configure script as substitutes, but never set the vars, so they
were always replaced with nothing.

I actually broke this build 2 years ago when merging the configure
up a level in commit 30f244155b8e82aa948ddcb8f2350654fc1adb92
("libgloss: merge subdirs that have unique makefile_frags up a
level").  I saw that it was exporting a bunch of vars in the
configure script, but never set them, so I incorrectly assumed
they weren't used.  Which means the Makefile has been setting them
to invalid values like literal @bsp_list@ and @script_list@.

Considering no one has complained, I have to assume no one cares
about this port, and we can all stop wasting time on it.

6 months agolibgloss: merge microblaze into top-level Makefile
Mike Frysinger [Sun, 31 Dec 2023 06:51:47 +0000 (01:51 -0500)]
libgloss: merge microblaze into top-level Makefile

Avoid a recursive make to speed things up a bit.
A microblaze-elf build shows installed objects & libs produce same code.

6 months agolibgloss: microblaze: use port-specific sbrk
Mike Frysinger [Sun, 31 Dec 2023 07:07:04 +0000 (02:07 -0500)]
libgloss: microblaze: use port-specific sbrk

The default search path uses the common sbrk.c over the microblaze
one, so add a rule to force the microblaze variant instead.

6 months agolibgloss: merge tic6x into top-level Makefile
Mike Frysinger [Sun, 31 Dec 2023 06:41:30 +0000 (01:41 -0500)]
libgloss: merge tic6x into top-level Makefile

Avoid a recursive make to speed things up a bit.
A tic6x-elf build shows installed objects & libs produce same code.

6 months agolibgloss: merge sparc_leon into top-level Makefile
Mike Frysinger [Fri, 29 Dec 2023 07:10:36 +0000 (02:10 -0500)]
libgloss: merge sparc_leon into top-level Makefile

Avoid a recursive make to speed things up a bit.
A sparc-elf build shows installed objects & libs produce same code.

6 months agolibgloss: sparc_leon: workaround newer newlib pthread APIs
Mike Frysinger [Fri, 29 Dec 2023 22:52:31 +0000 (17:52 -0500)]
libgloss: sparc_leon: workaround newer newlib pthread APIs

Fix a compile error due to duplicate pthreads types:
.../libgloss/sparc_leon/mutex.c:50:8: error: conflicting types for ‘pthread_mutex_t’; have ‘struct pthread_mutex’
   50 |      } pthread_mutex_t;
In file included from .../newlib/libc/include/sys/types.h:221,
                 from .../libgloss/sparc_leon/mutex.c:26:
.../newlib/libc/include/sys/_pthreadtypes.h:154:20: note: previous declaration of ‘pthread_mutex_t’ with type ‘pthread_mutex_t’ {aka ‘long unsigned int’}
  154 | typedef __uint32_t pthread_mutex_t;      /* identify a mutex */

.../libgloss/sparc_leon/mutex.c:57:8: error: conflicting types for ‘pthread_mutexattr_t’; have ‘struct <anonymous>’
   57 |      } pthread_mutexattr_t;
../newlib/libc/include/sys/_pthreadtypes.h:169:3: note: previous declaration of ‘pthread_mutexattr_t’ with type ‘pthread_mutexattr_t’
  169 | } pthread_mutexattr_t;

6 months agolibgloss: merge sparc into top-level Makefile
Mike Frysinger [Fri, 29 Dec 2023 05:42:13 +0000 (00:42 -0500)]
libgloss: merge sparc into top-level Makefile

Avoid a recursive make to speed things up a bit.
A sparc-elf build shows installed objects & libs produce same code.

6 months agolibgloss: sparc: always install erc32 sim files
Mike Frysinger [Fri, 29 Dec 2023 06:31:10 +0000 (01:31 -0500)]
libgloss: sparc: always install erc32 sim files

These are already compiled for all sparc targets, so we might as well
install them all the time so they can be used with the erc32 sim.

6 months agolibgloss: merge ft32 into top-level Makefile
Mike Frysinger [Fri, 29 Dec 2023 05:16:46 +0000 (00:16 -0500)]
libgloss: merge ft32 into top-level Makefile

Avoid a recursive make to speed things up a bit.
A ft32-elf build shows installed objects & libs produce same code.

Mention of ft32-elf-common.ld is dropped as it has never existed
in the tree, and has been an (ignored) error in the past.

6 months agolibgloss: ft32: delete unused/invalid assembly file
Mike Frysinger [Fri, 29 Dec 2023 05:20:10 +0000 (00:20 -0500)]
libgloss: ft32: delete unused/invalid assembly file

This is a .c file, not assembly, and it's a duplicate (same content)
as the existing sim-lseek.c.  Delete it since it's unused and doesn't
actually compile.

6 months agolibgloss: merge fr30 into top-level Makefile
Mike Frysinger [Fri, 29 Dec 2023 05:11:38 +0000 (00:11 -0500)]
libgloss: merge fr30 into top-level Makefile

Avoid a recursive make to speed things up a bit.
A fr30-elf build shows installed objects & libs produce same code.

A lot of code seems like it hasn't been migrated, but that's because
it's all disabled/unused (i.e. all the test & mon code).  It looks
like a lot of copy & paste holdovers from the original port.

6 months agolibgloss: merge or1k into top-level Makefile
Mike Frysinger [Fri, 29 Dec 2023 05:00:11 +0000 (00:00 -0500)]
libgloss: merge or1k into top-level Makefile

Avoid a recursive make to speed things up a bit.
A or1k-elf build shows installed objects & libs produce same code.

6 months agolibgloss: merge epiphany into top-level Makefile
Mike Frysinger [Thu, 28 Dec 2023 01:45:25 +0000 (20:45 -0500)]
libgloss: merge epiphany into top-level Makefile

Avoid a recursive make to speed things up a bit.
A epiphany-elf build shows installed objects & libs produce same code.

6 months agolibgloss: xtensa: fix CPPFLAGS clobbering
Mike Frysinger [Wed, 27 Dec 2023 07:42:30 +0000 (02:42 -0500)]
libgloss: xtensa: fix CPPFLAGS clobbering

No sub-Makefile.inc file should ever set CPPFLAGS directly.  That is
a global/common variable.  Instead, ports should set the per-target
CPPFLAGS to include what they need.

Further, per-target CPPFLAGS should respect $(AM_CPPFLAGS).

6 months agolibgloss: merge visium into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 06:05:23 +0000 (01:05 -0500)]
libgloss: merge visium into top-level Makefile

Avoid a recursive make to speed things up a bit.
A visium-elf build shows installed objects & libs produce same code.

6 months agolibgloss: visium: fix sbrk search path
Mike Frysinger [Wed, 27 Dec 2023 06:20:50 +0000 (01:20 -0500)]
libgloss: visium: fix sbrk search path

The code was loading the common ../sbrk.c file rather than the visium
specific sbrk.c due to VPATH setup.  Add an explicit rule for this one
file so we make sure the correct one is used.

6 months agolibgloss: merge m32r into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 05:54:13 +0000 (00:54 -0500)]
libgloss: merge m32r into top-level Makefile

Avoid a recursive make to speed things up a bit.
A m32r-elf build shows installed objects & libs produce same code.

6 months agolibgloss: merge rl78 into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 05:43:25 +0000 (00:43 -0500)]
libgloss: merge rl78 into top-level Makefile

Avoid a recursive make to speed things up a bit.
A rl78-elf build shows installed objects & libs produce same code.

6 months agolibgloss: merge rx into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 05:38:25 +0000 (00:38 -0500)]
libgloss: merge rx into top-level Makefile

Avoid a recursive make to speed things up a bit.
A rx-elf build shows installed objects & libs produce same code.

6 months agolibgloss: merge xstormy16 into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 05:18:12 +0000 (00:18 -0500)]
libgloss: merge xstormy16 into top-level Makefile

Avoid a recursive make to speed things up a bit.
A xstormy16-elf build shows installed objects & libs produce same code.

6 months agolibgloss: merge nds32 into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 04:59:00 +0000 (23:59 -0500)]
libgloss: merge nds32 into top-level Makefile

Avoid a recursive make to speed things up a bit.
A nds32le-elf build shows installed objects & libs produce same code.

6 months agolibgloss: merge mcore into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 04:44:44 +0000 (23:44 -0500)]
libgloss: merge mcore into top-level Makefile

Avoid a recursive make to speed things up a bit.
A mcore-elf build shows installed objects & libs produce same code.

6 months agolibgloss: merge mn10200 into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 04:26:40 +0000 (23:26 -0500)]
libgloss: merge mn10200 into top-level Makefile

Avoid a recursive make to speed things up a bit.
Untested, but follows the same pattern as mn10300, but simpler.

6 months agolibgloss: merge mn10300 into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 04:13:37 +0000 (23:13 -0500)]
libgloss: merge mn10300 into top-level Makefile

Avoid a recursive make to speed things up a bit.
A mn10300-elf build shows installed objects & libs produce same code.

6 months agolibgloss: merge i386 into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 03:39:05 +0000 (22:39 -0500)]
libgloss: merge i386 into top-level Makefile

Avoid a recursive make to speed things up a bit.
A i386-elf build shows installed objects & libs produce same code other
than a rename from cygmon-gmon.o & cygmon-salib.o to i386_libcygmon_a-*.o
due to the use of custom CPPFLAGS in here.

6 months agolibgloss: merge frv into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 03:29:20 +0000 (22:29 -0500)]
libgloss: merge frv into top-level Makefile

Avoid a recursive make to speed things up a bit.
A frv-elf build shows installed objects & libs produce same code.

6 months agolibgloss: merge msp430 into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 02:11:58 +0000 (21:11 -0500)]
libgloss: merge msp430 into top-level Makefile

Avoid a recursive make to speed things up a bit.
A msp430-elf build shows installed objects & libs produce same code.

6 months agolibgloss: msp430: delete custom .S.o rule
Mike Frysinger [Wed, 27 Dec 2023 03:17:22 +0000 (22:17 -0500)]
libgloss: msp430: delete custom .S.o rule

This was added to specify -Wa,-gdwarf2 when compiling the assembly
files.  Considering the size of these .S files, it seems unnecessary
overkill and complicates the build system.  All but one of these
compile down to 6 or fewer lines, and those hardly need extra debug
for anyone who is poking msp430 assembly.  The 1 file that is larger
than that (crt_move_highdata.S) is still <15 insns.

This will also simplify merging it into the top-level Makefile.

6 months agolibgloss: msp430: split up crt0.S source
Mike Frysinger [Wed, 27 Dec 2023 03:01:30 +0000 (22:01 -0500)]
libgloss: msp430: split up crt0.S source

The build system compiles crt0.S many times to produce independent
object files by defining different -DLxxx symbols for each.  This
complicates the build, and has led to some bugs in the source and
build (see the previous cleanup commits in here).  The crt_bss.S
file has also been duplicated with crt0.S leading to confusion as
to which one is the "real" one.  The only reason to keep them in
one file is to make management of the section numbers when calling
START_CRT_FUNC a little easier, but that seems trivial to check
with a quick grep across all the files.

Considering how complicated the build is now, and the bugs we've
had as a result, split the crt0.S file up into multiple source
files so we don't have to compile it multiple times.  This will
also simplify merging it into the top-level Makefile.

6 months agolibgloss: msp430: delete stub crt_init.o
Mike Frysinger [Wed, 27 Dec 2023 02:56:00 +0000 (21:56 -0500)]
libgloss: msp430: delete stub crt_init.o

This object is created by compiling crt0.S with -DLinit, but there
has never been an "#if Linit" check in crt0.S, so this has always
produced a stub object file.  Drop compiling it entirely.

6 months agolibgloss: msp430: delete outdated/wrong code
Mike Frysinger [Wed, 27 Dec 2023 02:46:59 +0000 (21:46 -0500)]
libgloss: msp430: delete outdated/wrong code

The #if 0 & comment imply this code doesn't exist and is never used,
except there's another #if Lrun_fini_array section below which *does*
define this function, which makes this code comment confusing.  This
seems to be a hold over of the cleanup of the minrt code in the old
commit 884b05b54e4595433c85f8ca9820e88b4c723e38 ("MSP430: Remove
.init/.fini sections").

6 months agolibgloss: add per-file & per-dir flag support
Mike Frysinger [Sat, 30 Dec 2023 01:34:38 +0000 (20:34 -0500)]
libgloss: add per-file & per-dir flag support

This logic is copied from what's used in newlib today.  This allows
subdirs to easily define per-directory flags & per-file flags without
having to setup unique automake rules for each one.

6 months agolibgloss: add some objcopy/objdump build rules
Mike Frysinger [Fri, 29 Dec 2023 06:51:27 +0000 (01:51 -0500)]
libgloss: add some objcopy/objdump build rules

A bunch of ports have manual rules to generate disassembly, srec, and
binary files from test programs.  Add top-level pattern rules so every
test program gets this for free, and we don't have to duplicate it in
every subdir.

6 months agolibgloss: check for objcopy & objdump properly
Mike Frysinger [Wed, 27 Dec 2023 05:26:14 +0000 (00:26 -0500)]
libgloss: check for objcopy & objdump properly

A bunch of ports hack together these values rather than setting them
up in the configure script for everyone.

6 months agoCygwin: remove warnings from testsuite build
Corinna Vinschen [Fri, 19 Jan 2024 14:11:32 +0000 (15:11 +0100)]
Cygwin: remove warnings from testsuite build

- drop unused variable
- remove deprectated usage of std::pointer_to_unary_function.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 months agofputwc: call __fputwc directly
Corinna Vinschen [Fri, 19 Jan 2024 10:14:33 +0000 (11:14 +0100)]
fputwc: call __fputwc directly

Avoid another hop in the call stack.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 months agomemccpy: fix pointer assignment
Corinna Vinschen [Fri, 19 Jan 2024 10:28:11 +0000 (11:28 +0100)]
memccpy: fix pointer assignment

The local vars dst and src are unsigned pointers, but two assignments
cast their value to signed explicitely.  This results in the warning
"pointer targets in assignment from ‘char *’ to ‘unsigned char *’
differ in signedness [-Wpointer-sign]" in case of -Wall.

Fix the cast.

Fixes: d254189b38bb ("2002-07-23 Jeff Johnston <jjohnstn@redhat.com>")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 months agoORIENT: avoid "expression has no effect" warning
Corinna Vinschen [Fri, 19 Jan 2024 10:20:17 +0000 (11:20 +0100)]
ORIENT: avoid "expression has no effect" warning

The warning "right-hand operand of comma expression has no effect
[-Wunused-value]" crops up with -Wall in cases where ORIENT is called
without checking or assigning its value.

Explicitely void the expression in these cases to avoid the warning.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 months ago_fputwc_r: actually return result of __fputwc
Corinna Vinschen [Fri, 19 Jan 2024 10:13:39 +0000 (11:13 +0100)]
_fputwc_r: actually return result of __fputwc

Compiling with -Wall uncovered a bug in _fputwc_r introduced in
commit 09119463a1445 ("stdio: split byte- and wide-char-oriented
low-level output functions").  The underlying function __fputwc
has been accidentally called without fetching its return value.
So the return value of _fputwc_r (and thus fputwc) was undefined.

Fixes: 09119463a1445 ("stdio: split byte- and wide-char-oriented low-level output functions"
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 months agoCygwin: replace all `fgrep' with `grep -F'
Corinna Vinschen [Thu, 18 Jan 2024 09:53:25 +0000 (10:53 +0100)]
Cygwin: replace all `fgrep' with `grep -F'

Unfortunately fgrep is now deprecated in a very pushy way.
Make sure to use grep -F instead all around, even in docs
and comments/

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 months agoCygwin: copy doc changes from commit 241b50a7abe2 to release notes
Corinna Vinschen [Wed, 17 Jan 2024 11:39:50 +0000 (12:39 +0100)]
Cygwin: copy doc changes from commit 241b50a7abe2 to release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 months agoCygwin: Update documentation for cygwin_stackdump
Jon Turney [Thu, 11 Jan 2024 17:37:03 +0000 (17:37 +0000)]
Cygwin: Update documentation for cygwin_stackdump

6 months agoCygwin: Treat api_fatal() similarly to a core-dumping signal
Jon Turney [Thu, 11 Jan 2024 21:34:27 +0000 (21:34 +0000)]
Cygwin: Treat api_fatal() similarly to a core-dumping signal

Provide the same debugging opportunities for api_fatal() as we do for a
core-dumping signal:

1) Break into any attached debugger
2) Start JIT debugger (if configured) (keeping these under DEBUGGING doesn't seem helpful)
3) Write a coredump (if rlim_core > 1MB)
4) Write a stackdump (if that failed, or 0 < rlim_core <= 1MB)

6 months agoCygwin: Define and use __WCOREFLAG
Jon Turney [Wed, 10 Jan 2024 20:35:49 +0000 (20:35 +0000)]
Cygwin: Define and use __WCOREFLAG

Also fix a typo in description of exit status

6 months agoCygwin: Disable writing core dumps by default.
Jon Turney [Tue, 9 Jan 2024 14:12:31 +0000 (14:12 +0000)]
Cygwin: Disable writing core dumps by default.

Change the default core limit from unlimited to 0 (disabled)

6 months agoCygwin: Make 'ulimit -c' control writing a coredump
Jon Turney [Thu, 11 Jan 2024 20:00:14 +0000 (20:00 +0000)]
Cygwin: Make 'ulimit -c' control writing a coredump

Pre-format a command to be executed on a fatal error to run 'dumper'
(using an absolute path).

Factor out executing a pre-formatted command, so we can use that for
invoking the JIT debugger in try_to_debug() (if error_start is present
in the CYGWIN env var) and to invoke dumper when a fatal error occurs.

On a fatal error, if the core file size limit is greater than 1MB,
invoke dumper to write a core dump. Otherwise, if that limit is greater
than 0, write a .stackdump file, as previously.

Adjust and clarify the associated documentation.

Also: Fix so that the error_start JIT debugger is now invoked, even when
ulimit -c is zero.

Also: Fix uses of console_printf() inside exec_prepared_command(). It's
output is written via the Windows console device, so needs to use
Windows-style line endings.

Also: consistently return non-zero from try_to_debug() if we debugged.

Future work: Truncate or remove the file written, if it exceeds the
maximum size set by the ulimit.

Future work: Using the words "fatal error" could probably be improved
on. This means exiting on one of the "certain signals whose default
action is to cause the process to terminate and produce a core dump
file".

6 months agoCygwin: introduce close_range(2)
Christian Franke [Mon, 15 Jan 2024 11:13:30 +0000 (12:13 +0100)]
Cygwin: introduce close_range(2)

This function closes or sets the close-on-exec flag for a specified
range of file descriptors.  It is available on FreeBSD and Linux.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
6 months agoCygwin: api docs: add missing fallocate
Corinna Vinschen [Mon, 15 Jan 2024 10:03:48 +0000 (11:03 +0100)]
Cygwin: api docs: add missing fallocate

Also add notes in terms of fallocate quirks.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 months agoCygwin: Clarifications in 3.5 changes doc
Jon Turney [Wed, 10 Jan 2024 17:38:54 +0000 (17:38 +0000)]
Cygwin: Clarifications in 3.5 changes doc

6 months agoCygwin: path.cc: fix comment starting with // but ending in */
Corinna Vinschen [Thu, 11 Jan 2024 12:21:54 +0000 (13:21 +0100)]
Cygwin: path.cc: fix comment starting with // but ending in */

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 months agoCygwin: Fix a stray '\n' in cygcheck manpage
Jon Turney [Wed, 10 Jan 2024 12:39:47 +0000 (12:39 +0000)]
Cygwin: Fix a stray '\n' in cygcheck manpage

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
6 months agoRISC-V: fix setting up std streams in init_semihosting()
Venkata Ramanaiah Nalamothu [Wed, 3 Jan 2024 06:52:16 +0000 (12:22 +0530)]
RISC-V: fix setting up std streams in init_semihosting()

Currently init_semihosting() assumes the return value from _open()
call as the file descriptor handle and that is incorrect.

The semihost _open() call returns the fdtable index returned by the
__add_fdentry() for the file opened.

6 months agofix strverscmp comparison of digit sequence with non-digits
Brian Inglis [Mon, 8 Jan 2024 13:56:21 +0000 (06:56 -0700)]
fix strverscmp comparison of digit sequence with non-digits

From: Rich Felker <dalias@aerifal.cx>
Date: Mon, 7 Nov 2022 22:17:55 -0500

the rule that longest digit sequence not beginning with a zero is
greater only applies when both sequences being compared are
non-degenerate. this is spelled out explicitly in the man page, which
may be deemed authoritative for this nonstandard function: "If one or
both of these is empty, then return what strcmp(3) would have
returned..."

we were wrongly treating any sequence of digits not beginning with a
zero as greater than a non-digit in the other string.

Signed-off-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca>
6 months agoRISC-V: Initialize the jvt CSR
Hau Hsu [Fri, 5 Jan 2024 07:06:39 +0000 (15:06 +0800)]
RISC-V: Initialize the jvt CSR

Set symbol '__jvt_base$' as weak. So if the symbol is not set in the
linker script, the address would be 0. We initialize jvt CSR only if
the address is not 0.

Also use csr number directly instead of using symbolic name to prevent the
backward incompatible issue.

psabi reference:
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/2d770815dc9a8b11e61ea1abd487cb25ee56ad5e/riscv-elf.adoc#table-jump-relaxation

6 months agoCygwin: check remote drives for being SSDs as well
Corinna Vinschen [Thu, 7 Dec 2023 19:35:44 +0000 (20:35 +0100)]
Cygwin: check remote drives for being SSDs as well

This enables automatic sparse file support for remote SSDs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 months agolibgloss: merge i960 into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 01:59:58 +0000 (20:59 -0500)]
libgloss: merge i960 into top-level Makefile

Avoid a recursive make to speed things up a bit.
I can't test this as current versions of binutils doesn't support i960.

6 months agolibgloss: i960: delete dead/broken code
Mike Frysinger [Wed, 27 Dec 2023 01:53:43 +0000 (20:53 -0500)]
libgloss: i960: delete dead/broken code

The i960 port has a lot of references to sim files that have never been
included in the tree afaict, and thus has never worked.  Delete all the
code to simplify.

6 months agolibgloss: merge v850 into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 01:47:38 +0000 (20:47 -0500)]
libgloss: merge v850 into top-level Makefile

Avoid a recursive make to speed things up a bit.
A v850e-elf build shows installed objects & libs produce same code.

6 months agolibgloss: merge moxie into top-level Makefile
Mike Frysinger [Wed, 27 Dec 2023 01:21:28 +0000 (20:21 -0500)]
libgloss: merge moxie into top-level Makefile

Avoid a recursive make to speed things up a bit.
A moxie-elf build shows installed objects & libs produce same code.

6 months agolibgloss: moxie: delete unused/invalid assembly file
Mike Frysinger [Wed, 27 Dec 2023 01:25:18 +0000 (20:25 -0500)]
libgloss: moxie: delete unused/invalid assembly file

This is a .c file, not assembly, and it's a duplicate (same content)
as the existing sim-lseek.c.  Delete it since it's unused and doesn't
actually compile.

6 months agolibgloss: fix up incorrect "it's"
Mike Frysinger [Mon, 25 Dec 2023 23:17:38 +0000 (18:17 -0500)]
libgloss: fix up incorrect "it's"

6 months agonewlib: libc: Improved the readability of strspn with minor optimization
Xiao Zeng [Tue, 2 Jan 2024 05:56:15 +0000 (13:56 +0800)]
newlib: libc: Improved the readability of strspn with minor optimization

Signed-off-by: Xiao Zeng <zengxiao@eswincomputing.com>
6 months agoChanges for newlib 4.4.0 snapshot newlib-4.4.0
Jeff Johnston [Sun, 31 Dec 2023 17:00:18 +0000 (12:00 -0500)]
Changes for newlib 4.4.0 snapshot

- bump up version to 4.4.0

6 months agoMinor improvement to H8 startup code
Jeff Law [Sun, 31 Dec 2023 16:08:21 +0000 (09:08 -0700)]
Minor improvement to H8 startup code

Basically the startup code needs to clear memory from _edata to _end. In the
past it's been done with a fairly naive copy loop.  This changes the code to
just call memset and let memset figure out a sensible way to handle the
operation given the size and alignment requirements.

I don't have performance data on this.  I cobbled it together some time ago in
response to seeing some of the GCC tests with larger .bss sections taking an
insane amount of time to just get from _start to main.  With the fixes to the
H8 decoder in the simulator it may not matter nearly as much anymore.

This has been in my tester for months.  Naturally it does not cause any
regressions in the H8 port.

6 months agoFix various c99/gcc-14 issues in generic libgloss code
Jeff Law [Sat, 30 Dec 2023 04:31:27 +0000 (21:31 -0700)]
Fix various c99/gcc-14 issues in generic libgloss code

Similar to what's been done in the ports, but this time in generic code.

Add missing #includes to pick up prototypes.  Add prototypes for various
internal functions where needed.  Fix signatures of various functions to match
what's provided by the headers (read, sbrk, write, unlink).

Nearly done with this effort ;-)

Pushed to the trunk,

6 months agoFix another missing header file for mcore libgloss
Jeff Law [Sat, 30 Dec 2023 04:23:26 +0000 (21:23 -0700)]
Fix another missing header file for mcore libgloss

I guess I must have missed this when working through the trivial port specific
changes.

This adds an include of stdlib.h to get a prototype for exit().

Pushed to the trunk.

6 months agolibgloss: sparc: add missing m4 include
Mike Frysinger [Fri, 29 Dec 2023 05:33:05 +0000 (00:33 -0500)]
libgloss: sparc: add missing m4 include

Commit 8d758283785042589e95c93d7899cecf28ef00ea ("libgloss: merge
sparc configure script up a level") missed including the sparc
acinclude.m4 file which meant none of the sparc-specific vars were
propagating to the sub-makefile.

6 months agolibgloss: xtensa: fix crt0.o rule
Mike Frysinger [Wed, 27 Dec 2023 07:37:30 +0000 (02:37 -0500)]
libgloss: xtensa: fix crt0.o rule

Don't hardcode a custom rule for this -- reuse libobjs_a_SOURCES
which was designed for this exact scenario.

6 months agonewlib MMIX: Fix compilation warnings that recent gcc treats as errors
Hans-Peter Nilsson [Thu, 28 Dec 2023 03:31:19 +0000 (04:31 +0100)]
newlib MMIX: Fix compilation warnings that recent gcc treats as errors

Without this, when building with recent gcc, we'll see errors when
compiling for --target mmix the first being:
  CC       libc/sys/mmixware/libc_a-chmod.o
In file included from /x/newlib/libc/sys/mmixware/chmod.c:17:
/x/newlib/libc/sys/mmixware/chmod.c: In function 'chmod':
/x/newlib/libc/sys/mmixware/sys/syscall.h:139:6: error: implicit declaration \
of function 'sprintf' [-Wimplicit-function-declaration]
  139 |      sprintf (buf, "UNIMPLEMENTED %s in %s\n", __FUNCTION__,
 __FILE__); \

Other warnings also quelled.

* libc/sys/mmixware/sys/syscall.h: Include stdio.h, string.h
and unistd.h.
* libc/sys/mmixware/_exit.c: Call __unreachable after simulator exit.
* libc/sys/mmixware/chown.c (chown): Match declaration in unistd.h.
* libc/sys/mmixware/getpid.c (_getpid): Ditto.
* libc/sys/mmixware/kill.c (_kill): Ditto.
* libc/sys/mmixware/link.c (_link): Ditto.
* libc/sys/mmixware/read.c (_read): Ditto.
* libc/sys/mmixware/sbrk.c (_sbrk): Ditto.
* libc/sys/mmixware/unlink.c (_unlink): Ditto.
* libc/sys/mmixware/write.c (_write): Ditto.

6 months agoGCN: Implement '_exit' instead of 'exit'
Thomas Schwinge [Mon, 6 Nov 2023 15:48:20 +0000 (16:48 +0100)]
GCN: Implement '_exit' instead of 'exit'

... so that all of 'exit', '_exit', '_Exit' work.  'exit' thus becomes the
standard 'newlib/libc/stdlib/exit.c'.  (Getting 'atexit' functional needs
further work elsewhere.)

See also commit 5841b2f6a4208682264d03e3edfa0a09881932a6
"nvptx: Implement '_exit' instead of 'exit'".

6 months agoFix epiphany libgloss for c99/gcc-14
Jeff Law [Sat, 23 Dec 2023 04:29:56 +0000 (21:29 -0700)]
Fix epiphany libgloss for c99/gcc-14

So in this case we mostly need to include an internal header
(epiphany-syscalls.h).  In a few cases an explicit prototype is added.  We've
also got a return with no value in a function with a non-void return type.
Finally the asm_syscall interface expects a pointer as its first argument.  In
a few cases we've actually got an int (file descriptor) which we just cast to a
void *.

It's slightly more than Jeff J's pre-approval, but I think still reasonable.

6 months agoFix most of m32r libgloss for c99/gcc-14
Jeff Law [Sat, 23 Dec 2023 04:21:52 +0000 (21:21 -0700)]
Fix most of m32r libgloss for c99/gcc-14

Make implicit its explicit, add missing prototypes and header includes.  This
does not fix m32r-stub.c which needs more than the trivial work that Jeff J has
pre-approved.

6 months agoFix mcore libgloss port for c99/gcc-14
Jeff Law [Sat, 23 Dec 2023 04:17:36 +0000 (21:17 -0700)]
Fix mcore libgloss port for c99/gcc-14

Missing headers and prototypes, much like other ports.

6 months agoFix rl78 libgloss port for c99/gcc-14
Jeff Law [Sat, 23 Dec 2023 04:00:35 +0000 (21:00 -0700)]
Fix rl78 libgloss port for c99/gcc-14

Needed a prototype for SYS_write and the prototype for write was incorrect
(returns an int, not a char *).

This page took 0.072022 seconds and 5 git commands to generate.