lib: IEC559 tests are fragile, reduce to warning rather than error.
* {network,stream}.c: Weaken the compile time tests for IEEE754 / IEC-559
binary floating point format from an error to a warning when not detected.
I can't think of any platforms that are not IEEE-754 format, and as the
testing for the defines appears to be fragile (often not set) the error
just gives false positives.
Even the warnings may be too much. Those should probably be moved
to some configure test. Will do for now though, to fix compilation
on CentOS and some BSDs.
diff --git a/lib/stream.c b/lib/stream.c
index 4d4f867..43575e1 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -498,33 +498,31 @@
float
stream_getf (struct stream *s)
{
-#if defined(__STDC_IEC_559__) || __GCC_IEC_559 >= 1
-/* we can safely assume 'float' is in the single precision
- IEC 60559 binary format in host order */
+#if !defined(__STDC_IEC_559__) && __GCC_IEC_559 < 1
+#warning "Unknown floating-point format, __func__ may be wrong"
+#endif
+/* we assume 'float' is in the single precision IEC 60559 binary
+ format, in host byte order */
union {
float r;
uint32_t d;
} u;
u.d = stream_getl (s);
return u.r;
-#else
-#error "Please supply stream_getf implementation for this platform"
-#endif
}
double
stream_getd (struct stream *s)
{
-#if defined(__STDC_IEC_559__) || __GCC_IEC_559 >= 1
+#if !defined(__STDC_IEC_559__) && __GCC_IEC_559 < 1
+#warning "Unknown floating-point format, __func__ may be wrong"
+#endif
union {
double r;
uint64_t d;
} u;
u.d = stream_getq (s);
return u.r;
-#else
-#error "Please supply stream_getd implementation for this platform"
-#endif
}
/* Copy to source to stream.
@@ -638,7 +636,10 @@
int
stream_putf (struct stream *s, float f)
{
-#if defined(__STDC_IEC_559__) || __GCC_IEC_559 >= 1
+#if !defined(__STDC_IEC_559__) && __GCC_IEC_559 < 1
+#warning "Unknown floating-point format, __func__ may be wrong"
+#endif
+
/* we can safely assume 'float' is in the single precision
IEC 60559 binary format in host order */
union {
@@ -647,24 +648,20 @@
} u;
u.i = f;
return stream_putl (s, u.o);
-#else
-#error "Please supply stream_putf implementation for this platform"
-#endif
}
int
stream_putd (struct stream *s, double d)
{
-#if defined(__STDC_IEC_559__) || __GCC_IEC_559 >= 1
+#if !defined(__STDC_IEC_559__) && __GCC_IEC_559 < 1
+#warning "Unknown floating-point format, __func__ may be wrong"
+#endif
union {
double i;
uint64_t o;
} u;
u.i = d;
return stream_putq (s, u.o);
-#else
-#error "Please supply stream_putd implementation for this platform"
-#endif
}
int