This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
_exit in libgloss\libnosys\_exit.c
- From: Dominic Plunkett <dominic dot plunkett at cambrionix dot com>
- To: "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Mon, 20 Apr 2015 15:06:32 +0000
- Subject: _exit in libgloss\libnosys\_exit.c
- Authentication-results: sourceware.org; auth=none
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