This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

_exit in libgloss\libnosys\_exit.c


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>

_VOID
_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 ? 

Thanks


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]