Skip to content

Commit 72948ae

Browse files
Clean up medleyfp.h. (#127)
* Include <ieeefp.h> for Solaris. * Remove sections for sparc and Sun i386 for non-Solaris. * Have Linux use the same code as FreeBSD and macOS. * Make the FreeBSD / Linux / macOS code path the default, if nothing special is defined since it is the modern way. * Remove fpstatus_() usage from the ancient days.
1 parent 0c8ae86 commit 72948ae

File tree

1 file changed

+5
-36
lines changed

1 file changed

+5
-36
lines changed

inc/medleyfp.h

+5-36
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#ifdef FLTINT
2828
volatile extern int FP_error;
2929

30-
3130
/* Note that a compiler may very likely move code around the arithmetic
3231
operation, causing this test (set by an interrupt handler) to be
3332
incorrect. For example, the Sun SPARC compiler with -O2 makes
@@ -37,49 +36,19 @@ volatile extern int FP_error;
3736
#define FPCLEAR FP_error = 0;
3837
#define FPTEST(result) FP_error
3938

40-
#else
41-
42-
/* fpstatus_ is a FORTRAN library routine (in libc) which
43-
can be called to determine floating point status results.
44-
Documented in the Sun manual, "Floating Point Programmer's Guide",
45-
(Rev. A 19-Sep-86), pg. 34, it does *not* exist in libc for the
46-
SPARC.
47-
48-
For sparc, should also check for isnan? Don't know what isnormal
49-
& issubnormal do (these are sunos4.0 only)
50-
*/
51-
#if defined(OS5)
39+
#elif defined(OS5)
40+
#include <ieeefp.h>
5241
#define FPCLEAR
5342
#define FPTEST(result) (!finite(result))
5443

55-
#elif defined(sparc) || defined(I386)
56-
#define FPCLEAR
57-
#define FPTEST(result) (isinf(result) || isnan(result))
58-
59-
#elif defined(LINUX)
60-
#include <math.h>
61-
#define FPCLEAR
62-
#define FPTEST(result) ((!finite(result)) || isnan(result))
63-
64-
#elif defined(MACOSX) || defined(FREEBSD)
65-
#include <math.h>
66-
#define FPCLEAR
67-
#define FPTEST(result) (!isfinite(result))
68-
6944
#elif defined(DOS)
7045
#include <i32.h>
7146
#define FPCLEAR
7247
#define FPTEST(result) (_getrealerror() & ( I87_ZERO_DIVIDE | I87_OVERFLOW | I87_UNDERFLOW))
7348

7449
#else
75-
static int constant0 = 0;
76-
unsigned int fpstatus_();
77-
78-
#define FPCLEAR fpstatus_(&constant0);
79-
#define FPTEST(result) (fpstatus_(&constant0) & 0xF0)
50+
#include <math.h>
51+
#define FPCLEAR
52+
#define FPTEST(result) (!isfinite(result))
8053

81-
#endif
8254
#endif /* FLTINT */
83-
84-
85-

0 commit comments

Comments
 (0)