This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #125669] op/pack.t failures with PPC long double (double double) builds
authorSisyphus <sisyphus1@optusnet.com.au>
Thu, 20 Aug 2015 11:28:33 +0000 (07:28 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Thu, 20 Aug 2015 12:22:01 +0000 (08:22 -0400)
unpack '%65...' failures, to be more exact.

pp_pack.c

index b1a0d85..8d7f1e2 100644 (file)
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -1767,7 +1767,18 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c
                }
                while (cdouble < 0.0)
                    cdouble += anv;
-               cdouble = Perl_modf(cdouble / anv, &trouble) * anv;
+               cdouble = Perl_modf(cdouble / anv, &trouble);
+#ifdef LONGDOUBLE_DOUBLEDOUBLE
+                /* Workaround for powerpc doubledouble modfl bug:
+                 * close to 1.0L and -1.0L cdouble is 0, and trouble
+                 * is cdouble / anv. */
+                if (trouble != Perl_ceil(trouble)) {
+                  cdouble = trouble;
+                  if (cdouble >  1.0L) cdouble -= 1.0L;
+                  if (cdouble < -1.0L) cdouble += 1.0L;
+                }
+#endif
+                cdouble *= anv;
                sv = newSVnv(cdouble);
            }
            else {