Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / gnulib-lib / libxml / trionan.c
1 /* Replacement 'trionan.c', using Gnulib functions.  */
2
3 #include "config.h"
4 #include <math.h>
5
6 /* Copied from gnulib/tests/infinity.h.  */
7
8 /* Infinityd () returns a 'double' +Infinity.  */
9
10 /* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0.  */
11 #if defined _MSC_VER
12 static double
13 Infinityd ()
14 {
15   static double zero = 0.0;
16   return 1.0 / zero;
17 }
18 #else
19 # define Infinityd() (1.0 / 0.0)
20 #endif
21
22 /* Copied from gnulib/tests/nan.h.  */
23
24 /* NaNd () returns a 'double' not-a-number.  */
25
26 /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler choke
27    on the expression 0.0 / 0.0.  */
28 #if defined __DECC || defined _MSC_VER
29 static double
30 NaNd ()
31 {
32   static double zero = 0.0;
33   return zero / zero;
34 }
35 #else
36 # define NaNd() (0.0 / 0.0)
37 #endif
38
39 /* Copied from gnulib/tests/minus-zero.h.  */
40
41 /* minus_zerod represents the value -0.0.  */
42
43 /* HP cc on HP-UX 10.20 has a bug with the constant expression -0.0.
44    ICC 10.0 has a bug when optimizing the expression -zero.
45    The expression -DBL_MIN * DBL_MIN does not work when cross-compiling
46    to PowerPC on Mac OS X 10.5.  */
47 #if defined __hpux || defined __sgi || defined __ICC
48 static double
49 compute_minus_zerod (void)
50 {
51   return -DBL_MIN * DBL_MIN;
52 }
53 # define minus_zerod compute_minus_zerod ()
54 #else
55 static double minus_zerod = -0.0;
56 #endif
57
58 #undef INFINITY
59 #undef NAN
60
61 #define INFINITY Infinityd()
62 #define NAN NaNd()
63
64 #define trio_pinf() INFINITY
65 #define trio_ninf() -INFINITY
66 #define trio_nan() NAN
67 #define trio_nzero() minus_zerod
68
69 #define trio_isnan(x) isnan(x)
70 #define trio_isinf(x) isinf(x)
71 #define trio_signbit(x) signbit(x)