public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] nvptx: In offloading execution, map '_exit' to 'abort' [GCC PR85463]
       [not found] <87in8nsgz9.fsf@euler.schwinge.homeip.net>
@ 2023-01-19 22:00 ` Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-01-19 22:00 UTC (permalink / raw)
  To: newlib; +Cc: tdevries, Thomas Schwinge

This is still not properly resolving <https://gcc.gnu.org/PR85463>
'[nvptx] "exit" in offloaded region doesn't terminate process', but is
one step into that direction, and allows for simplifying some GCC code.
---
 newlib/libc/machine/nvptx/_exit.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/newlib/libc/machine/nvptx/_exit.c b/newlib/libc/machine/nvptx/_exit.c
index ae434c930..f2253df66 100644
--- a/newlib/libc/machine/nvptx/_exit.c
+++ b/newlib/libc/machine/nvptx/_exit.c
@@ -14,6 +14,7 @@
  */

 #include <unistd.h>
+#include <stdlib.h>

 /* Sadly, PTX doesn't support weak declarations, only weak
    definitions.  Weakly define it here in case we're not using crt0
@@ -26,7 +27,15 @@ void __attribute__((noreturn))
 _exit (int status)
 {
   if (__exitval_ptr)
-    *__exitval_ptr = status;
-  for (;;)
-    asm ("exit;" ::: "memory");
+    {
+      *__exitval_ptr = status;
+      for (;;)
+       asm ("exit;" ::: "memory");
+    }
+  else /* offloading */
+    {
+      /* Map to 'abort'; see <https://gcc.gnu.org/PR85463>
+        '[nvptx] "exit" in offloaded region doesn't terminate process'.  */
+      abort ();
+    }
 }
--
2.25.1

-----------------
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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-19 22:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87in8nsgz9.fsf@euler.schwinge.homeip.net>
2023-01-19 22:00 ` [PATCH] nvptx: In offloading execution, map '_exit' to 'abort' [GCC PR85463] Thomas Schwinge

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).