This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Decouple quadmath from longdouble.
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 30 Oct 2014 01:30:18 +0000 (21:30 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Thu, 30 Oct 2014 11:21:28 +0000 (07:21 -0400)
Configure
INSTALL
perl.h
sv.c
t/porting/libperl.t

index caa93a0..03c9a99 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -4451,8 +4451,6 @@ eval $setvar
 case "$usequadmath" in
 "$define"|true|[yY]*)
        usequadmath="$define"
-        # if usequadmath enabled also enable uselongdouble
-       uselongdouble="$define"
        ;;
 *)     usequadmath="$undef" ;;
 esac
@@ -7065,6 +7063,18 @@ $define)
        esac
        ;;
 esac
+case "$usequadmath" in
+$define)
+       echo "quadmath selected." >&4
+       case "$archname" in
+        *-ld*) echo "...and architecture name already has -quadmath." >&4
+                ;;
+        *)      archname="$archname-quadmath"
+                echo "...setting architecture name to $archname." >&4
+               ;;
+        esac
+       ;;
+esac
 if $test -f archname.cbu; then
        echo "Your platform has some specific hints for architecture name, using them..."
        . ./archname.cbu
diff --git a/INSTALL b/INSTALL
index d53933a..9a63a5b 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -351,8 +351,8 @@ installation, or you may need to install it separately.
 
 With "Configure -Dusequadmath" you can try enabling its use, but note
 the compiler dependency, you may need to also add "-Dcc=...".
-This option also turns on -Duselongdouble.  At C level the type is called
-C<__float128> (note, not "long double"), but Perl source knows it as NV.
+At C level the type is called C<__float128> (note, not "long double"),
+but Perl source knows it as NV.
 
 =head3 Algorithmic Complexity Attacks on Hashes
 
diff --git a/perl.h b/perl.h
index 27aa70b..da1f94f 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -1872,22 +1872,7 @@ typedef NVTYPE NV;
 #   ifdef I_SUNMATH
 #       include <sunmath.h>
 #   endif
-#   if defined(USE_QUADMATH) && defined(I_QUADMATH)
-#       include <quadmath.h>
-#   endif
-#   ifdef FLT128_DIG
-#       define NV_DIG FLT128_DIG
-#       define NV_MANT_DIG FLT128_MANT_DIG
-#       define NV_MIN FLT128_MIN
-#       define NV_MAX FLT128_MAX
-#       define NV_MIN_EXP FLT128_MIN_EXP
-#       define NV_MAX_EXP FLT128_MAX_EXP
-#       define NV_EPSILON FLT128_EPSILON
-#       define NV_MIN_10_EXP FLT128_MIN_10_EXP
-#       define NV_MAX_10_EXP FLT128_MAX_10_EXP
-#       define NV_INF HUGE_VALQ
-#       define NV_NAN nanq("0")
-#   elif defined(LDBL_DIG)
+#   if defined(LDBL_DIG)
 #       define NV_DIG LDBL_DIG
 #       ifdef LDBL_MANT_DIG
 #           define NV_MANT_DIG LDBL_MANT_DIG
@@ -1922,33 +1907,7 @@ typedef NVTYPE NV;
 #           endif
 #       endif
 #   endif
-#   if defined(USE_QUADMATH) && defined(I_QUADMATH)
-#       define Perl_acos acosq
-#       define Perl_asin asinq
-#       define Perl_atan atanq
-#       define Perl_atan2 atan2q
-#       define Perl_ceil ceilq
-#       define Perl_cos cosq
-#       define Perl_cosh coshq
-#       define Perl_exp expq
-/* no Perl_fabs, but there's PERL_ABS */
-#       define Perl_floor floorq
-#       define Perl_fmod fmodq
-#       define Perl_log logq
-#       define Perl_log10 log10q
-#       define Perl_pow powq
-#       define Perl_sin sinq
-#       define Perl_sinh sinhq
-#       define Perl_sqrt sqrtq
-#       define Perl_tan tanq
-#       define Perl_tanh tanhq
-#       define Perl_modf(x,y) modfq(x,y)
-#       define Perl_frexp(x,y) frexpq(x,y)
-#       define Perl_ldexp(x, y) ldexpq(x,y)
-#       define Perl_isinf(x) isinfq(x)
-#       define Perl_isnan(x) isnanq(x)
-#       define Perl_isfinite(x) !(isnanq(x) || isinfq(x))
-#   elif defined(HAS_SQRTL)
+#   if defined(HAS_SQRTL)
 #       define Perl_acos acosl
 #       define Perl_asin asinl
 #       define Perl_atan atanl
@@ -2017,6 +1976,44 @@ extern long double Perl_my_frexpl(long double x, int *e);
 #   ifndef Perl_isfinite
 #       define Perl_isfinite(x) Perl_isfinitel(x)
 #   endif
+#elif defined(USE_QUADMATH) && defined(I_QUADMATH)
+#   include <quadmath.h>
+#   define NV_DIG FLT128_DIG
+#   define NV_MANT_DIG FLT128_MANT_DIG
+#   define NV_MIN FLT128_MIN
+#   define NV_MAX FLT128_MAX
+#   define NV_MIN_EXP FLT128_MIN_EXP
+#   define NV_MAX_EXP FLT128_MAX_EXP
+#   define NV_EPSILON FLT128_EPSILON
+#   define NV_MIN_10_EXP FLT128_MIN_10_EXP
+#   define NV_MAX_10_EXP FLT128_MAX_10_EXP
+#   define NV_INF HUGE_VALQ
+#   define NV_NAN nanq("0")
+#   define Perl_acos acosq
+#   define Perl_asin asinq
+#   define Perl_atan atanq
+#   define Perl_atan2 atan2q
+#   define Perl_ceil ceilq
+#   define Perl_cos cosq
+#   define Perl_cosh coshq
+#   define Perl_exp expq
+/* no Perl_fabs, but there's PERL_ABS */
+#   define Perl_floor floorq
+#   define Perl_fmod fmodq
+#   define Perl_log logq
+#   define Perl_log10 log10q
+#   define Perl_pow powq
+#   define Perl_sin sinq
+#   define Perl_sinh sinhq
+#   define Perl_sqrt sqrtq
+#   define Perl_tan tanq
+#   define Perl_tanh tanhq
+#   define Perl_modf(x,y) modfq(x,y)
+#   define Perl_frexp(x,y) frexpq(x,y)
+#   define Perl_ldexp(x, y) ldexpq(x,y)
+#   define Perl_isinf(x) isinfq(x)
+#   define Perl_isnan(x) isnanq(x)
+#   define Perl_isfinite(x) !(isnanq(x) || isinfq(x))
 #else
 #   define NV_DIG DBL_DIG
 #   ifdef DBL_MANT_DIG
diff --git a/sv.c b/sv.c
index 47b6e93..6aa29e1 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -11081,7 +11081,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
        return;
     }
 
-#ifndef USE_LONG_DOUBLE
+#if !defined(USE_LONG_DOUBLE) && !defined(USE_QUADMATH)
     /* special-case "%.<number>[gf]" */
     if ( !args && patlen <= 5 && pat[0] == '%' && pat[1] == '.'
         && (pat[patlen-1] == 'g' || pat[patlen-1] == 'f') ) {
@@ -11889,7 +11889,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
            */
            switch (intsize) {
            case 'V':
-#if defined(USE_LONG_DOUBLE)
+#if defined(USE_LONG_DOUBLE) || defined(USE_QUADMATH)
                intsize = 'q';
 #endif
                break;
@@ -11897,7 +11897,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
            case 'l':
                /* FALLTHROUGH */
            default:
-#if defined(USE_LONG_DOUBLE)
+#if defined(USE_LONG_DOUBLE) || defined(USE_QUADMATH)
                intsize = args ? 0 : 'q';
 #endif
                break;
@@ -12277,8 +12277,13 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                 char *ptr = ebuf + sizeof ebuf;
                 *--ptr = '\0';
                 *--ptr = c;
+#if defined(USE_QUADMATH)
+               if (intsize == 'q') {
+                    /* "g" -> "Qg" */
+                    *--ptr = 'Q';
+                }
                 /* FIXME: what to do if HAS_LONG_DOUBLE but not PERL_PRIfldbl? */
-#if defined(HAS_LONG_DOUBLE) && defined(PERL_PRIfldbl)
+#elif defined(HAS_LONG_DOUBLE) && defined(PERL_PRIfldbl)
                /* Note that this is HAS_LONG_DOUBLE and PERL_PRIfldbl,
                 * not USE_LONG_DOUBLE and NVff.  In other words,
                 * this needs to work without USE_LONG_DOUBLE. */
@@ -12286,13 +12291,9 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                    /* Copy the one or more characters in a long double
                     * format before the 'base' ([efgEFG]) character to
                     * the format string. */
-#ifdef USE_QUADMATH
-                    *--ptr = 'Q';
-#else
                    static char const ldblf[] = PERL_PRIfldbl;
                    char const *p = ldblf + sizeof(ldblf) - 3;
                    while (p >= ldblf) { *--ptr = *p--; }
-#endif
                }
 #endif
                if (has_precis) {
index 0e0296e..d97b332 100644 (file)
@@ -441,11 +441,9 @@ my %expected = (
     );
 
 if ($Config{uselongdouble} && $Config{longdblsize} > $Config{doublesize}) {
-    if ($Config{usequadmath}) {
-        $expected{expq} = undef; # There is no Configure symbol for expq.
-    } else {
-        $expected{expl} = undef; # There is no Configure symbol for expl.
-    }
+    $expected{expl} = undef; # There is no Configure symbol for expl.
+} elsif ($Config{usequadmath}) {
+    $expected{expq} = undef; # There is no Configure symbol for expq.
 } else {
     $expected{exp} = undef; # There is no Configure symbol for exp.
 }