is there an ieee handler in Linux?
Andrew Haley
aph at redhat.com
Sat Apr 24 10:32:36 UTC 2010
On 04/24/2010 10:30 AM, Andrew Haley wrote:
> 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);
Sorry,
feenableexcept (FE_ALL_EXCEPT);
>
> fprintf (stderr, "%g\n", 0.0e0/0.0e0);
>
> }
More information about the users
mailing list