-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathfpehandler.c
More file actions
63 lines (40 loc) · 1.38 KB
/
Copy pathfpehandler.c
File metadata and controls
63 lines (40 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* ------- file: -------------------------- fpehandler.c ------------
Version: rh2.0
Author: Han Uitenbroek (huitenbroek@nso.edu)
Last modified: Thu May 20 11:29:23 2021 --
-------------------------- ----------RH-- */
/* --- Trap floating point exceptions on various machines:
-- -------------- */
#include <math.h>
#include <stdio.h>
#include "rh.h"
#include "error.h"
extern char messageStr[];
#if defined(Darwin)
void SetFPEtraps(void)
{
/* --- Explicitly do not set traps -- -------------- */
Error(MESSAGE, "SetFPEtraps",
"\n Darwin: FPE traps have not been set explicitly\n");
}
/* --- end SETNOTRAPS -- -------------- */
#elif defined(Linux)
#define _GNU_SOURCE 1
#include <fenv.h>
int feenableexcept(int excepts);
void SetFPEtraps(void)
{
int result;
/* --- Enable some exceptions.
At startup all exceptions are masked. -- -------------- */
result = feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
}
#else
/* --- unknown -- -------------- */
void SetFPEtraps(void)
{
Error(MESSAGE, "SetFPEtraps",
"\nUnsupported CPU and/or OS: cannot set FPE traps explicitly\n");
}
#endif
/* ------- end ------------------------------------------------------ */