]> www.ginac.de Git - cln.git/blobdiff - autoconf/floatparam.c
Revert "Convert complex numbers to real numbers if imaginary part is floating-point...
[cln.git] / autoconf / floatparam.c
index f62ae6aaa0e1194a7d23bf78abdce18c54e8f7bc..66b4d6122dac34628bfd23431d61ac5bfee985fd 100644 (file)
@@ -5,11 +5,6 @@
 
 #include <stdio.h>
 
-#if !(defined(__STDC__) || defined(__cplusplus))
-/* Only for use in function parameter lists and as function return type. */
-#define void
-#endif
-
 typedef int boolean;
 #define TRUE  1
 #define FALSE 0
@@ -29,7 +24,7 @@ static void header (void)
 }
 
 #define check(type,typeprefix,typestr,equalfn,mainfn)  \
-static boolean equalfn (type* x, type* y);                             \
+static boolean equalfn (volatile type* x, volatile type* y);           \
 static void mainfn (void)                                              \
 {                                                                      \
   int mant_bits;                                                       \
@@ -79,7 +74,10 @@ static void mainfn (void)                                            \
   }                                                                    \
   printf("\n");                                                                \
 }                                                                      \
-static boolean equalfn (type* x, type* y) { return *x == *y; }         \
+static boolean equalfn (volatile type* x, volatile type* y)            \
+{                                                                      \
+  return *x == *y;                                                     \
+}                                                                      \
 
 check(float,"float","float",equal_float,main_float)
 check(double,"double","double",equal_double,main_double)
@@ -92,8 +90,9 @@ check(ldouble,"long_double","long double",equal_ldouble,main_ldouble)
 static void flipped_double (void)
 {
   typedef struct { unsigned lo, hi; } dfloat;
-  double x = 2;
-  dfloat test = *(dfloat*)&x;
+  union { dfloat eksplicit; double machine_double; } x;
+  x.machine_double = 2;
+  dfloat test = x.eksplicit;
   if (test.lo==0 && test.hi!=0) {
     printf("#define double_wordorder_bigendian_p 0\n");
   } else if (test.lo!=0 && test.hi==0) {
@@ -115,11 +114,6 @@ int main()
 #endif
   flipped_double();
 
-#if defined(__cplusplus)
-  if (ferror(stdout)) return 1;
+  if (ferror(stdout) || fclose(stdout)) return 1;
   return 0;
-#else
-  if (ferror(stdout)) { exit(1); }
-  exit(0);
-#endif
 }