_exit in libgloss\libnosys\_exit.c

Dominic Plunkett dominic.plunkett@cambrionix.com
Tue Apr 21 06:14:00 GMT 2015

Newbie here so please be gentle.

In libgloss\libnosys\_exit.c has the following code :

/* Stub version of _exit.  */

#include <limits.h>
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>

_DEFUN (_exit, (rc),
                int rc)
  /* Default stub just causes a divide by 0 exception.  */
  int x = rc / INT_MAX;
  x = 4 / x;

  /* Convince GCC that this function never returns.  */
  for (;;)

I think this following may exist :

1)	If rc = INT_MAX then exception isn't raised, unlikely to be a real problem
2)	If the compiler is any good then x will be optimised out.

Is there some better code to use here ? 


More information about the Newlib mailing list