aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/ChangeLog7
-rw-r--r--src/lib/sockio-c.c22
2 files changed, 23 insertions, 6 deletions
diff --git a/src/lib/ChangeLog b/src/lib/ChangeLog
index a77f2c17..3d78f5f1 100644
--- a/src/lib/ChangeLog
+++ b/src/lib/ChangeLog
@@ -1,3 +1,10 @@
+2007-12-08 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * sockio-c.c: Include <math.h>
+ (plus_infinity): Use INFINITY if available.
+ (minus_infinity): Use plus_infinity().
+ (NANQ): Use NAN if available.
+
2007-12-04 Gabriel Dos Reis <gdr@cs.tamu.edu>
* sockio-c.c (plus_infinity): Use GCC builtin.
diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c
index 718276b1..31c849bb 100644
--- a/src/lib/sockio-c.c
+++ b/src/lib/sockio-c.c
@@ -48,6 +48,9 @@
#include <string.h>
#include <signal.h>
+#define _ISOC99_SOURCE
+#include <math.h>
+
#include "com.h"
#include "bsdsignal.h"
@@ -1149,23 +1152,30 @@ print_line(char *s)
}
-/* The next three functions use GCC extensions. At the moment, that
- is not a problem because GCC is a requirement. */
-
double
plus_infinity(void )
{
- return __builtin_huge_val();
+#ifdef INFINITY
+ return INFINITY;
+#else
+ /* This must be a curious platform. */
+ volatile double zero = 0.0;
+ return 1.0 / zero; /* If it traps, well, it traps. */
+#endif
}
double
minus_infinity(void)
{
- return -__builtin_huge_val();
+ return -plus_infinity();
}
double
NANQ(void)
{
- return __builtin_nan("");
+#ifdef NAN
+ return NAN;
+#else
+ return sqrt(-1.0); /* Juts pick one. */
+#endif
}