[ARM] Add endless loop to avoid a compiler warning on noreturn functions.

Christophe Lyon <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CAKdteOakzKmCEnCA5EZbd8Mc3HCy39nRR6=DDx2poWz6G1tvxQ@mail.gmail.com>
Hi,

While building newlib for ARM, I noticed GCC warnings for _exit() that
the compiler thinks they return a value despite being noreturn.

Like other targets, this small adds an endless loop to avoid the warning.

OK?

Christophe
newlib-1.txt (text/plain, 1.2 KB)
commit 72ab15cd60be82262be4b0bdb79aa78376724c8c
Author: Christophe Lyon <[email protected]>
Date:   Mon Oct 1 15:52:42 2018 +0000

    [ARM] Add endless loop to avoid a compiler warning on noreturn functions.
    
    2018-10-01  Christophe Lyon  <[email protected]>
    
    	* libgloss/arm/_exit.c (_exit): Add endless loop.
    	* newlib/libc/sys/arm/syscalls.c (_exit): Likewise.

diff --git a/libgloss/arm/_exit.c b/libgloss/arm/_exit.c
index ca2d21c..90220d2 100644
--- a/libgloss/arm/_exit.c
+++ b/libgloss/arm/_exit.c
@@ -12,4 +12,8 @@ _exit (int status)
      Note: The RDI implementation of _kill throws away both its
      arguments.  */
   _kill (status, -1);
+
+  /* Convince GCC that this function never returns.  */
+  for (;;)
+    ;
 }
diff --git a/newlib/libc/sys/arm/syscalls.c b/newlib/libc/sys/arm/syscalls.c
index 6e70467..311b28d 100644
--- a/newlib/libc/sys/arm/syscalls.c
+++ b/newlib/libc/sys/arm/syscalls.c
@@ -452,6 +452,10 @@ _exit (int status)
      Note: The RDI implementation of _kill throws away both its
      arguments.  */
   _kill(status, -1);
+
+  /* Convince GCC that this function never returns.  */
+  for (;;)
+    ;
 }
 
 pid_t
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.