public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: <newlib@sourceware.org>
Cc: Andrew Stubbs <ams@codesourcery.com>,
	Julian Brown <julian@codesourcery.com>
Subject: GCN: Implement '_exit' instead of 'exit' (was: nvptx: Implement '_exit' instead of 'exit')
Date: Sat, 23 Dec 2023 10:32:52 +0100	[thread overview]
Message-ID: <878r5ls1q3.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <878rjqaku5.fsf@dem-tschwing-1.ger.mentorg.com>

[-- Attachment #1: Type: text/plain, Size: 809 bytes --]

Hi!

On 2022-12-01T22:13:38+0100, I wrote:
> Subject: [PATCH] nvptx: Implement '_exit' instead of 'exit'
>
> ... so that all of 'exit', '_exit', '_Exit' work.  'exit' thus becomes the
> standard 'newlib/libc/stdlib/exit.c' -- and functions registered via 'atexit'
> are now called at return from 'main' or manual 'exit' invocation.

A year later, the same thing for GCN -- pushed to main branch
commit 1a177610d8e181d09206a5a8ce2d873822751657
"GCN: Implement '_exit' instead of 'exit'", see attached.


Grüße
 Thomas


-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-GCN-Implement-_exit-instead-of-exit.patch --]
[-- Type: text/x-diff, Size: 12249 bytes --]

From 1a177610d8e181d09206a5a8ce2d873822751657 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Mon, 6 Nov 2023 16:48:20 +0100
Subject: [PATCH] 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'".
---
 newlib/Makefile.in                            | 40 +++++++++----------
 newlib/libc/machine/amdgcn/Makefile.inc       |  2 +-
 .../libc/machine/amdgcn/{exit.c => _exit.c}   |  4 +-
 newlib/libc/machine/amdgcn/atexit.c           |  3 +-
 4 files changed, 24 insertions(+), 25 deletions(-)
 rename newlib/libc/machine/amdgcn/{exit.c => _exit.c} (95%)

diff --git a/newlib/Makefile.in b/newlib/Makefile.in
index 99a29465a..9a32646ab 100644
--- a/newlib/Makefile.in
+++ b/newlib/Makefile.in
@@ -630,8 +630,8 @@ check_PROGRAMS =
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/strrchr.S
 
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@am__append_67 = \
+@HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/_exit.c \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/abort.c \
-@HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/exit.c \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/atexit.c \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/mlock.c \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/getreent.c \
@@ -1892,8 +1892,8 @@ am__objects_51 = libc/ssp/libc_a-chk_fail.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/libc_a-strnlen.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/libc_a-strrchr-stub.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AARCH64_TRUE@	libc/machine/aarch64/libc_a-strrchr.$(OBJEXT)
-@HAVE_LIBC_MACHINE_AMDGCN_TRUE@am__objects_78 = libc/machine/amdgcn/libc_a-abort.$(OBJEXT) \
-@HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/libc_a-exit.$(OBJEXT) \
+@HAVE_LIBC_MACHINE_AMDGCN_TRUE@am__objects_78 = libc/machine/amdgcn/libc_a-_exit.$(OBJEXT) \
+@HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/libc_a-abort.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/libc_a-atexit.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/libc_a-mlock.$(OBJEXT) \
 @HAVE_LIBC_MACHINE_AMDGCN_TRUE@	libc/machine/amdgcn/libc_a-getreent.$(OBJEXT) \
@@ -8161,10 +8161,10 @@ libc/machine/amdgcn/$(am__dirstamp):
 libc/machine/amdgcn/$(DEPDIR)/$(am__dirstamp):
 	@$(MKDIR_P) libc/machine/amdgcn/$(DEPDIR)
 	@: > libc/machine/amdgcn/$(DEPDIR)/$(am__dirstamp)
-libc/machine/amdgcn/libc_a-abort.$(OBJEXT):  \
+libc/machine/amdgcn/libc_a-_exit.$(OBJEXT):  \
 	libc/machine/amdgcn/$(am__dirstamp) \
 	libc/machine/amdgcn/$(DEPDIR)/$(am__dirstamp)
-libc/machine/amdgcn/libc_a-exit.$(OBJEXT):  \
+libc/machine/amdgcn/libc_a-abort.$(OBJEXT):  \
 	libc/machine/amdgcn/$(am__dirstamp) \
 	libc/machine/amdgcn/$(DEPDIR)/$(am__dirstamp)
 libc/machine/amdgcn/libc_a-atexit.$(OBJEXT):  \
@@ -12816,9 +12816,9 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc_a-strnlen.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc_a-strrchr-stub.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/aarch64/$(DEPDIR)/libc_a-strrchr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-_exit.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-abort.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-atexit.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-exit.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-getreent.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-mlock.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libc/machine/amdgcn/$(DEPDIR)/libc_a-signal.Po@am__quote@
@@ -33347,6 +33347,20 @@ libc/machine/aarch64/libc_a-strrchr-stub.obj: libc/machine/aarch64/strrchr-stub.
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/aarch64/libc_a-strrchr-stub.obj `if test -f 'libc/machine/aarch64/strrchr-stub.c'; then $(CYGPATH_W) 'libc/machine/aarch64/strrchr-stub.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/aarch64/strrchr-stub.c'; fi`
 
+libc/machine/amdgcn/libc_a-_exit.o: libc/machine/amdgcn/_exit.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/amdgcn/libc_a-_exit.o -MD -MP -MF libc/machine/amdgcn/$(DEPDIR)/libc_a-_exit.Tpo -c -o libc/machine/amdgcn/libc_a-_exit.o `test -f 'libc/machine/amdgcn/_exit.c' || echo '$(srcdir)/'`libc/machine/amdgcn/_exit.c
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/amdgcn/$(DEPDIR)/libc_a-_exit.Tpo libc/machine/amdgcn/$(DEPDIR)/libc_a-_exit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/amdgcn/_exit.c' object='libc/machine/amdgcn/libc_a-_exit.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/amdgcn/libc_a-_exit.o `test -f 'libc/machine/amdgcn/_exit.c' || echo '$(srcdir)/'`libc/machine/amdgcn/_exit.c
+
+libc/machine/amdgcn/libc_a-_exit.obj: libc/machine/amdgcn/_exit.c
+@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/amdgcn/libc_a-_exit.obj -MD -MP -MF libc/machine/amdgcn/$(DEPDIR)/libc_a-_exit.Tpo -c -o libc/machine/amdgcn/libc_a-_exit.obj `if test -f 'libc/machine/amdgcn/_exit.c'; then $(CYGPATH_W) 'libc/machine/amdgcn/_exit.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/amdgcn/_exit.c'; fi`
+@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/amdgcn/$(DEPDIR)/libc_a-_exit.Tpo libc/machine/amdgcn/$(DEPDIR)/libc_a-_exit.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/amdgcn/_exit.c' object='libc/machine/amdgcn/libc_a-_exit.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/amdgcn/libc_a-_exit.obj `if test -f 'libc/machine/amdgcn/_exit.c'; then $(CYGPATH_W) 'libc/machine/amdgcn/_exit.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/amdgcn/_exit.c'; fi`
+
 libc/machine/amdgcn/libc_a-abort.o: libc/machine/amdgcn/abort.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/amdgcn/libc_a-abort.o -MD -MP -MF libc/machine/amdgcn/$(DEPDIR)/libc_a-abort.Tpo -c -o libc/machine/amdgcn/libc_a-abort.o `test -f 'libc/machine/amdgcn/abort.c' || echo '$(srcdir)/'`libc/machine/amdgcn/abort.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/amdgcn/$(DEPDIR)/libc_a-abort.Tpo libc/machine/amdgcn/$(DEPDIR)/libc_a-abort.Po
@@ -33361,20 +33375,6 @@ libc/machine/amdgcn/libc_a-abort.obj: libc/machine/amdgcn/abort.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/amdgcn/libc_a-abort.obj `if test -f 'libc/machine/amdgcn/abort.c'; then $(CYGPATH_W) 'libc/machine/amdgcn/abort.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/amdgcn/abort.c'; fi`
 
-libc/machine/amdgcn/libc_a-exit.o: libc/machine/amdgcn/exit.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/amdgcn/libc_a-exit.o -MD -MP -MF libc/machine/amdgcn/$(DEPDIR)/libc_a-exit.Tpo -c -o libc/machine/amdgcn/libc_a-exit.o `test -f 'libc/machine/amdgcn/exit.c' || echo '$(srcdir)/'`libc/machine/amdgcn/exit.c
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/amdgcn/$(DEPDIR)/libc_a-exit.Tpo libc/machine/amdgcn/$(DEPDIR)/libc_a-exit.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/amdgcn/exit.c' object='libc/machine/amdgcn/libc_a-exit.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/amdgcn/libc_a-exit.o `test -f 'libc/machine/amdgcn/exit.c' || echo '$(srcdir)/'`libc/machine/amdgcn/exit.c
-
-libc/machine/amdgcn/libc_a-exit.obj: libc/machine/amdgcn/exit.c
-@am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/amdgcn/libc_a-exit.obj -MD -MP -MF libc/machine/amdgcn/$(DEPDIR)/libc_a-exit.Tpo -c -o libc/machine/amdgcn/libc_a-exit.obj `if test -f 'libc/machine/amdgcn/exit.c'; then $(CYGPATH_W) 'libc/machine/amdgcn/exit.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/amdgcn/exit.c'; fi`
-@am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/amdgcn/$(DEPDIR)/libc_a-exit.Tpo libc/machine/amdgcn/$(DEPDIR)/libc_a-exit.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='libc/machine/amdgcn/exit.c' object='libc/machine/amdgcn/libc_a-exit.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@	$(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -c -o libc/machine/amdgcn/libc_a-exit.obj `if test -f 'libc/machine/amdgcn/exit.c'; then $(CYGPATH_W) 'libc/machine/amdgcn/exit.c'; else $(CYGPATH_W) '$(srcdir)/libc/machine/amdgcn/exit.c'; fi`
-
 libc/machine/amdgcn/libc_a-atexit.o: libc/machine/amdgcn/atexit.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libc_a_CPPFLAGS) $(CPPFLAGS) $(libc_a_CFLAGS) $(CFLAGS) -MT libc/machine/amdgcn/libc_a-atexit.o -MD -MP -MF libc/machine/amdgcn/$(DEPDIR)/libc_a-atexit.Tpo -c -o libc/machine/amdgcn/libc_a-atexit.o `test -f 'libc/machine/amdgcn/atexit.c' || echo '$(srcdir)/'`libc/machine/amdgcn/atexit.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) libc/machine/amdgcn/$(DEPDIR)/libc_a-atexit.Tpo libc/machine/amdgcn/$(DEPDIR)/libc_a-atexit.Po
diff --git a/newlib/libc/machine/amdgcn/Makefile.inc b/newlib/libc/machine/amdgcn/Makefile.inc
index d26603aa8..e1fc5ae4d 100644
--- a/newlib/libc/machine/amdgcn/Makefile.inc
+++ b/newlib/libc/machine/amdgcn/Makefile.inc
@@ -1,6 +1,6 @@
 libc_a_SOURCES += \
+	%D%/_exit.c \
 	%D%/abort.c \
-	%D%/exit.c \
 	%D%/atexit.c \
 	%D%/mlock.c \
 	%D%/getreent.c \
diff --git a/newlib/libc/machine/amdgcn/exit.c b/newlib/libc/machine/amdgcn/_exit.c
similarity index 95%
rename from newlib/libc/machine/amdgcn/exit.c
rename to newlib/libc/machine/amdgcn/_exit.c
index bdd532edd..82171aff9 100644
--- a/newlib/libc/machine/amdgcn/exit.c
+++ b/newlib/libc/machine/amdgcn/_exit.c
@@ -13,11 +13,11 @@
  * they apply.
  */
 
-#include <stdlib.h>
+#include <unistd.h>
 #include "exit-value.h"
 
 void __attribute__((noreturn))
-exit (int val)
+_exit (int val)
 {
   exit_with_status_and_signal (val, 0);
 }
diff --git a/newlib/libc/machine/amdgcn/atexit.c b/newlib/libc/machine/amdgcn/atexit.c
index 674571435..8ddd92cfa 100644
--- a/newlib/libc/machine/amdgcn/atexit.c
+++ b/newlib/libc/machine/amdgcn/atexit.c
@@ -18,8 +18,7 @@
 int
 atexit (void (*function)(void))
 {
-  /* Our current implementation of exit does not run functions registered with
-     atexit, so fail here.  */
+  /* Fail here.  */
   abort ();
   return 1;
 }
-- 
2.34.1


      parent reply	other threads:[~2023-12-23  9:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01 21:13 nvptx: Implement '_exit' instead of 'exit' Thomas Schwinge
2022-12-01 23:06 ` Jeff Johnston
2023-12-23  9:32 ` Thomas Schwinge [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878r5ls1q3.fsf@euler.schwinge.homeip.net \
    --to=thomas@codesourcery.com \
    --cc=ams@codesourcery.com \
    --cc=julian@codesourcery.com \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).