is there an ieee handler in Linux?
Andrew Haley
aph at redhat.com
Sat Apr 24 09:30:26 UTC 2010
On 04/23/2010 08:49 PM, reg at dwf.com wrote:
> There must be a handler for ieee arithmetic errors under Linux for C and for
> Fortran,
> but my search with man and google don't turn up anything.
> Can someone point me at the correct subroutine names.
See fgetenv(3).
Here's an example for C.
Andrew.
#define _GNU_SOURCE
#include <signal.h>
#include <stdio.h>
#include <math.h>
#include <fenv.h>
#include <stdlib.h>
static void
sigfpe_handler(int signo)
{
fprintf (stderr, "%s\n", __FUNCTION__);
exit (1);
}
void
main()
{
signal (SIGFPE, sigfpe_handler);
feenableexcept (FE_NOMASK_ENV);
fprintf (stderr, "%g\n", 0.0e0/0.0e0);
}
More information about the users
mailing list