This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
If long double math functions do not work, drop uselongdouble.
authorJarkko Hietaniemi <jhi@iki.fi>
Tue, 11 Nov 2014 23:14:40 +0000 (18:14 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Wed, 12 Nov 2014 11:49:07 +0000 (06:49 -0500)
This moves a earlier version of the test from the freebsd hints
to Configure, thus stopping also any other platforms that have
lacking longdouble implementations.

The test is not comprehensive (not all long double interfaces are tested),
but it covers some of the most common ones.

The earlier test was actually wrong, so no FreeBSD could ever pass.
Sorry, FreeBSD.

Configure
hints/freebsd.sh

index 2a9e25b..d092c74 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -7029,6 +7029,153 @@ case "$longdblkind" in
 esac
 $rm_try
 
+: Check print/scan long double stuff
+echo " "
+
+if $test X"$d_longdbl" = X"$define"; then
+
+echo "Checking how to print long doubles..." >&4
+
+if $test X"$sPRIfldbl" = X -a X"$doublesize" = X"$longdblsize"; then
+       $cat >try.c <<'EOCP'
+#include <sys/types.h>
+#include <stdio.h>
+int main() {
+  double d = 123.456;
+  printf("%.3f\n", d);
+}
+EOCP
+       set try
+       if eval $compile; then
+               yyy=`$run ./try`
+               case "$yyy" in
+               123.456)
+                       sPRIfldbl='"f"'; sPRIgldbl='"g"'; sPRIeldbl='"e"';
+                       sPRIFUldbl='"F"'; sPRIGUldbl='"G"'; sPRIEUldbl='"E"';
+                       echo "We will use %f."
+                       ;;
+               esac
+       fi
+fi
+
+if $test X"$sPRIfldbl" = X; then
+       $cat >try.c <<'EOCP'
+#include <sys/types.h>
+#include <stdio.h>
+int main() {
+  long double d = 123.456;
+  printf("%.3Lf\n", d);
+}
+EOCP
+       set try
+       if eval $compile; then
+               yyy=`$run ./try`
+               case "$yyy" in
+               123.456)
+                       sPRIfldbl='"Lf"'; sPRIgldbl='"Lg"'; sPRIeldbl='"Le"';
+                       sPRIFUldbl='"LF"'; sPRIGUldbl='"LG"'; sPRIEUldbl='"LE"';
+                       echo "We will use %Lf."
+                       ;;
+               esac
+       fi
+fi
+
+if $test X"$sPRIfldbl" = X; then
+       $cat >try.c <<'EOCP'
+#include <sys/types.h>
+#include <stdio.h>
+int main() {
+  long double d = 123.456;
+  printf("%.3llf\n", d);
+}
+EOCP
+       set try
+       if eval $compile; then
+               yyy=`$run ./try`
+               case "$yyy" in
+               123.456)
+                       sPRIfldbl='"llf"'; sPRIgldbl='"llg"'; sPRIeldbl='"lle"';
+                       sPRIFUldbl='"llF"'; sPRIGUldbl='"llG"'; sPRIEUldbl='"llE"';
+                       echo "We will use %llf."
+                       ;;
+               esac
+       fi
+fi
+
+if $test X"$sPRIfldbl" = X; then
+       $cat >try.c <<'EOCP'
+#include <sys/types.h>
+#include <stdio.h>
+int main() {
+  long double d = 123.456;
+  printf("%.3lf\n", d);
+}
+EOCP
+       set try
+       if eval $compile; then
+               yyy=`$run ./try`
+               case "$yyy" in
+               123.456)
+                       sPRIfldbl='"lf"'; sPRIgldbl='"lg"'; sPRIeldbl='"le"';
+                       sPRIFUldbl='"lF"'; sPRIGUldbl='"lG"'; sPRIEUldbl='"lE"';
+                       echo "We will use %lf."
+                       ;;
+               esac
+       fi
+fi
+
+if $test X"$sPRIfldbl" = X; then
+       echo "Cannot figure out how to print long doubles." >&4
+else
+       sSCNfldbl=$sPRIfldbl    # expect consistency
+fi
+
+$rm_try
+
+fi # d_longdbl
+
+case "$sPRIfldbl" in
+'')    d_PRIfldbl="$undef"; d_PRIgldbl="$undef"; d_PRIeldbl="$undef";
+       d_PRIFUldbl="$undef"; d_PRIGUldbl="$undef"; d_PRIEUldbl="$undef";
+       d_SCNfldbl="$undef";
+       ;;
+*)     d_PRIfldbl="$define"; d_PRIgldbl="$define"; d_PRIeldbl="$define";
+       d_PRIFUldbl="$define"; d_PRIGUldbl="$define"; d_PRIEUldbl="$define";
+       d_SCNfldbl="$define";
+       ;;
+esac
+
+: Before committing on uselongdouble, see whether that looks sane.
+if $test "$uselongdouble" = "$define"; then
+    message=""
+    echo " "
+    echo "Checking if your long double math functions work right..." >&4
+    $cat > try.c <<EOF
+#include <math.h>
+#include <stdio.h>
+int main() {
+  printf("%"$sPRIgldbl"\n", sqrtl(logl(expl(cosl(sinl(0.0L))))+powl(2.0L, 3.0L)));
+}
+EOF
+    case "$osname:$gccversion" in
+    aix:)      saveccflags="$ccflags"
+               ccflags="$ccflags -qlongdouble" ;; # to avoid core dump
+    esac
+    set try
+    if eval $compile_ok; then
+      yyy=`$run ./try`
+    fi
+    case "$yyy" in
+    3) echo "Your long double math functions are working correctly." >&4 ;;
+    *) echo "Your long double math functions are broken, not using long doubles." >&4
+       uselongdouble=$undef
+       ;;
+    esac
+    $rm_try
+    case "$osname:$gccversion" in
+    aix:)      ccflags="$saveccflags" ;; # restore
+    esac
+fi
 
 : determine the architecture name
 echo " "
@@ -10079,122 +10226,6 @@ esac
 set qgcvt d_qgcvt
 eval $inlibc
 
-: Check print/scan long double stuff
-echo " "
-
-if $test X"$d_longdbl" = X"$define"; then
-
-echo "Checking how to print long doubles..." >&4
-
-if $test X"$sPRIfldbl" = X -a X"$doublesize" = X"$longdblsize"; then
-       $cat >try.c <<'EOCP'
-#include <sys/types.h>
-#include <stdio.h>
-int main() {
-  double d = 123.456;
-  printf("%.3f\n", d);
-}
-EOCP
-       set try
-       if eval $compile; then
-               yyy=`$run ./try`
-               case "$yyy" in
-               123.456)
-                       sPRIfldbl='"f"'; sPRIgldbl='"g"'; sPRIeldbl='"e"';
-                       sPRIFUldbl='"F"'; sPRIGUldbl='"G"'; sPRIEUldbl='"E"';
-                       echo "We will use %f."
-                       ;;
-               esac
-       fi
-fi
-
-if $test X"$sPRIfldbl" = X; then
-       $cat >try.c <<'EOCP'
-#include <sys/types.h>
-#include <stdio.h>
-int main() {
-  long double d = 123.456;
-  printf("%.3Lf\n", d);
-}
-EOCP
-       set try
-       if eval $compile; then
-               yyy=`$run ./try`
-               case "$yyy" in
-               123.456)
-                       sPRIfldbl='"Lf"'; sPRIgldbl='"Lg"'; sPRIeldbl='"Le"';
-                       sPRIFUldbl='"LF"'; sPRIGUldbl='"LG"'; sPRIEUldbl='"LE"';
-                       echo "We will use %Lf."
-                       ;;
-               esac
-       fi
-fi
-
-if $test X"$sPRIfldbl" = X; then
-       $cat >try.c <<'EOCP'
-#include <sys/types.h>
-#include <stdio.h>
-int main() {
-  long double d = 123.456;
-  printf("%.3llf\n", d);
-}
-EOCP
-       set try
-       if eval $compile; then
-               yyy=`$run ./try`
-               case "$yyy" in
-               123.456)
-                       sPRIfldbl='"llf"'; sPRIgldbl='"llg"'; sPRIeldbl='"lle"';
-                       sPRIFUldbl='"llF"'; sPRIGUldbl='"llG"'; sPRIEUldbl='"llE"';
-                       echo "We will use %llf."
-                       ;;
-               esac
-       fi
-fi
-
-if $test X"$sPRIfldbl" = X; then
-       $cat >try.c <<'EOCP'
-#include <sys/types.h>
-#include <stdio.h>
-int main() {
-  long double d = 123.456;
-  printf("%.3lf\n", d);
-}
-EOCP
-       set try
-       if eval $compile; then
-               yyy=`$run ./try`
-               case "$yyy" in
-               123.456)
-                       sPRIfldbl='"lf"'; sPRIgldbl='"lg"'; sPRIeldbl='"le"';
-                       sPRIFUldbl='"lF"'; sPRIGUldbl='"lG"'; sPRIEUldbl='"lE"';
-                       echo "We will use %lf."
-                       ;;
-               esac
-       fi
-fi
-
-if $test X"$sPRIfldbl" = X; then
-       echo "Cannot figure out how to print long doubles." >&4
-else
-       sSCNfldbl=$sPRIfldbl    # expect consistency
-fi
-
-$rm_try
-
-fi # d_longdbl
-
-case "$sPRIfldbl" in
-'')    d_PRIfldbl="$undef"; d_PRIgldbl="$undef"; d_PRIeldbl="$undef";
-       d_PRIFUldbl="$undef"; d_PRIGUldbl="$undef"; d_PRIEUldbl="$undef";
-       d_SCNfldbl="$undef";
-       ;;
-*)     d_PRIfldbl="$define"; d_PRIgldbl="$define"; d_PRIeldbl="$define";
-       d_PRIFUldbl="$define"; d_PRIGUldbl="$define"; d_PRIEUldbl="$define";
-       d_SCNfldbl="$define";
-       ;;
-esac
-
 : Check how to convert floats to strings.
 
 if test "X$d_Gconvert" = X; then
index 673dc4b..8d436a1 100644 (file)
@@ -310,35 +310,3 @@ esac
 # of FreeBSD.
 d_printf_format_null='undef'
 
-$cat > UU/uselongdouble.cbu <<'EOCBU'
-# This script UU/uselongdouble.cbu will get 'called-back' by Configure
-# after it has prompted the user for whether to use long doubles.
-
-# Some FreeBSD releases apparently don't really have the C99 long double
-# versions of math functions.  If this seems to be the case, disable
-# uselongdouble.
-#
-# XXX This sanity check logic could be move to Configure.
-case "$uselongdouble" in
-define)
-  echo "Checking if your long double math functions work right..." >&4
-  cat > ldblm$$.c <<EOF
-#include <math.h>
-#include <stdio.h>
-int main() {
-  printf("%Lg\n", sqrtl(logl(expl(1.0L))+powl(2.0L, 3.0L))+cosl(sinl(1.0L)));
-}
-EOF
-  $cc -o ldblm$$ ldblm$$.c -lm
-  case `test -x ldblm$$ && ./ldblm$$` in
-  4) echo "Your long double math functions are working correctly." >&4 ;;
-  *)
-    echo "Your long double math functions are broken, disabling uselongdouble." >&4
-    uselongdouble=$undef
-    ;;
-  esac
-  rm -f ldblm$$.c ldblm$$
-  ;;
-esac
-
-EOCBU