Skip to content

Commit

Permalink
floatval=long double: fix fdiv_i_i neg, add fabsl
Browse files Browse the repository at this point in the history
also fix ceil_n, floor_n for long double.
use ceill and floorl only with long double.

fix most long double tests,
just the embed API is still broken for long double:
t/src/embed/pmc.t                         (Wstat: 256 Tests: 9 Failed: 1)
  Failed test:  2
t/src/extend_vtable.t                     (Wstat: 3840 Tests: 134 Failed: 15)
  Failed tests:  7, 22, 46-47, 59, 72, 80-81, 89-90, 96-97
                103-104, 128

Missing: long variants for more float methods, like sin, cos, ...
Closes GH #1111
  • Loading branch information
Reini Urban committed Nov 24, 2014
1 parent d9f1535 commit 77cb00e
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 81 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Expand Up @@ -16,12 +16,13 @@
+ Warn in Configure on experimental flags intval, floatval and gc #1148
+ Die in Configure on unsupported intval sizes #1148, #642, ...
+ Renamed auto::labs to auto::mathl, probe and use more long math
functions: ceill floorl powl fmodl expl logl #1111
functions: fabsl powl ceill floorl fmodl expl logl #1111
- Documentation
- Tests
+ Fix t/steps/auto/arch-01.t darwin regression #1142
+ Added bigger t/stress/gc.t test to catch most GC issues.
+ Add optional copyright year test on TEST_SLOW #719
+ Fix most --floatval='long double' tests, just embed API broken #1111
- Community

2014-11-18 release 6.10.0
Expand Down
10 changes: 7 additions & 3 deletions config/auto/mathl.pm
Expand Up @@ -6,8 +6,12 @@ config/auto/mathl.pm - Test for C90 and C99 long math extensions
=head1 DESCRIPTION
Test for the presence of labs(), powl(), ...
labs is needed on 64bit intval, powl on long double floatval.
Test for the presence of various long math variants.
powl and labs are used if available.
fabsl floorl ceill fmodl expl logl are used for NUMVAL_SIZE > 8 only.
no quad variants yet.
=cut

Expand All @@ -18,7 +22,7 @@ use warnings;

use base qw(Parrot::Configure::Step);

our @probes = qw(labs powl floorl ceill fmodl expl logl);
our @probes = qw(labs powl fabsl floorl ceill fmodl expl logl);

sub _init {
my $self = shift;
Expand Down
9 changes: 9 additions & 0 deletions config/auto/mathl/test_c.in
Expand Up @@ -31,6 +31,15 @@ main(int argc, char* argv[])
printf("broken p o w l: ld = %Lg\n", ld);
#endif

#ifdef FABSL
ld = -10.0;
ld = fabsl(ld);
if (ld == 10.0)
puts("fabsl");
else
printf("broken f a b s l: ld = %Lg\n", ld);
#endif

#ifdef FLOORL
ld = 10.0;
ld = floorl(ld);
Expand Down
92 changes: 44 additions & 48 deletions src/ops/core_ops.c
Expand Up @@ -17337,7 +17337,14 @@ Parrot_abs_i(opcode_t *cur_opcode, PARROT_INTERP) {

opcode_t *
Parrot_abs_n(opcode_t *cur_opcode, PARROT_INTERP) {
NREG(1) = fabs(NREG(1));
#if defined(PARROT_HAS_FABSL) && NUMVAL_SIZE > 8
NREG(1) = fabsl((HUGEFLOATVAL)NREG(1));

#else
NREG(1) = fabs(NREG(1));

#endif
;
return cur_opcode + 2;
}

Expand All @@ -17356,7 +17363,14 @@ Parrot_abs_i_i(opcode_t *cur_opcode, PARROT_INTERP) {

opcode_t *
Parrot_abs_n_n(opcode_t *cur_opcode, PARROT_INTERP) {
NREG(1) = fabs(NREG(2));
#if defined(PARROT_HAS_FABSL) && NUMVAL_SIZE > 8
NREG(1) = fabsl((HUGEFLOATVAL)NREG(2));

#else
NREG(1) = fabs(NREG(2));

#endif
;
return cur_opcode + 3;
}

Expand Down Expand Up @@ -17750,11 +17764,11 @@ Parrot_fdiv_i_i(opcode_t *cur_opcode, PARROT_INTERP) {
return (opcode_t *)handler;
}

#if defined(PARROT_HAS_FLOORL)
f = (FLOATVAL)floorl((IREG(1) / den));
#if defined(PARROT_HAS_FLOORL) && NUMVAL_SIZE > 8
f = (FLOATVAL)floorl(((HUGEFLOATVAL)IREG(1) / den));

#else
f = (FLOATVAL)floor((IREG(1) / den));
f = (FLOATVAL)floor(((FLOATVAL)IREG(1) / den));

#endif
;
Expand All @@ -17773,11 +17787,11 @@ Parrot_fdiv_i_ic(opcode_t *cur_opcode, PARROT_INTERP) {
return (opcode_t *)handler;
}

#if defined(PARROT_HAS_FLOORL)
f = (FLOATVAL)floorl((IREG(1) / den));
#if defined(PARROT_HAS_FLOORL) && NUMVAL_SIZE > 8
f = (FLOATVAL)floorl(((HUGEFLOATVAL)IREG(1) / den));

#else
f = (FLOATVAL)floor((IREG(1) / den));
f = (FLOATVAL)floor(((FLOATVAL)IREG(1) / den));

#endif
;
Expand All @@ -17795,7 +17809,7 @@ Parrot_fdiv_n_n(opcode_t *cur_opcode, PARROT_INTERP) {
return (opcode_t *)handler;
}

#if defined(PARROT_HAS_FLOORL)
#if defined(PARROT_HAS_FLOORL) && NUMVAL_SIZE > 8
NREG(1) = (FLOATVAL)floorl((NREG(1) / den));

#else
Expand All @@ -17816,7 +17830,7 @@ Parrot_fdiv_n_nc(opcode_t *cur_opcode, PARROT_INTERP) {
return (opcode_t *)handler;
}

#if defined(PARROT_HAS_FLOORL)
#if defined(PARROT_HAS_FLOORL) && NUMVAL_SIZE > 8
NREG(1) = (FLOATVAL)floorl((NREG(1) / den));

#else
Expand Down Expand Up @@ -17860,19 +17874,19 @@ Parrot_fdiv_p_nc(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_fdiv_i_i_i(opcode_t *cur_opcode, PARROT_INTERP) {
const INTVAL den = IREG(3);
FLOATVAL f;
FLOATVAL f = (FLOATVAL)IREG(2);

if (den == 0) {
opcode_t * const handler = Parrot_ex_throw_from_op_args(interp, cur_opcode + 4, EXCEPTION_DIV_BY_ZERO, "Divide by zero");

return (opcode_t *)handler;
}

#if defined(PARROT_HAS_FLOORL)
f = (FLOATVAL)floorl((IREG(2) / den));
#if defined(PARROT_HAS_FLOORL) && NUMVAL_SIZE > 8
f = (FLOATVAL)floorl((f / den));

#else
f = (FLOATVAL)floor((IREG(2) / den));
f = (FLOATVAL)floor((f / den));

#endif
;
Expand All @@ -17883,19 +17897,19 @@ Parrot_fdiv_i_i_i(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_fdiv_i_ic_i(opcode_t *cur_opcode, PARROT_INTERP) {
const INTVAL den = IREG(3);
FLOATVAL f;
FLOATVAL f = (FLOATVAL)ICONST(2);

if (den == 0) {
opcode_t * const handler = Parrot_ex_throw_from_op_args(interp, cur_opcode + 4, EXCEPTION_DIV_BY_ZERO, "Divide by zero");

return (opcode_t *)handler;
}

#if defined(PARROT_HAS_FLOORL)
f = (FLOATVAL)floorl((ICONST(2) / den));
#if defined(PARROT_HAS_FLOORL) && NUMVAL_SIZE > 8
f = (FLOATVAL)floorl((f / den));

#else
f = (FLOATVAL)floor((ICONST(2) / den));
f = (FLOATVAL)floor((f / den));

#endif
;
Expand All @@ -17906,19 +17920,19 @@ Parrot_fdiv_i_ic_i(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_fdiv_i_i_ic(opcode_t *cur_opcode, PARROT_INTERP) {
const INTVAL den = ICONST(3);
FLOATVAL f;
FLOATVAL f = (FLOATVAL)IREG(2);

if (den == 0) {
opcode_t * const handler = Parrot_ex_throw_from_op_args(interp, cur_opcode + 4, EXCEPTION_DIV_BY_ZERO, "Divide by zero");

return (opcode_t *)handler;
}

#if defined(PARROT_HAS_FLOORL)
f = (FLOATVAL)floorl((IREG(2) / den));
#if defined(PARROT_HAS_FLOORL) && NUMVAL_SIZE > 8
f = (FLOATVAL)floorl((f / den));

#else
f = (FLOATVAL)floor((IREG(2) / den));
f = (FLOATVAL)floor((f / den));

#endif
;
Expand All @@ -17936,7 +17950,7 @@ Parrot_fdiv_n_n_n(opcode_t *cur_opcode, PARROT_INTERP) {
return (opcode_t *)handler;
}

#if defined(PARROT_HAS_FLOORL)
#if defined(PARROT_HAS_FLOORL) && NUMVAL_SIZE > 8
NREG(1) = (FLOATVAL)floorl((NREG(2) / den));

#else
Expand All @@ -17957,7 +17971,7 @@ Parrot_fdiv_n_nc_n(opcode_t *cur_opcode, PARROT_INTERP) {
return (opcode_t *)handler;
}

#if defined(PARROT_HAS_FLOORL)
#if defined(PARROT_HAS_FLOORL) && NUMVAL_SIZE > 8
NREG(1) = (FLOATVAL)floorl((NCONST(2) / den));

#else
Expand All @@ -17978,7 +17992,7 @@ Parrot_fdiv_n_n_nc(opcode_t *cur_opcode, PARROT_INTERP) {
return (opcode_t *)handler;
}

#if defined(PARROT_HAS_FLOORL)
#if defined(PARROT_HAS_FLOORL) && NUMVAL_SIZE > 8
NREG(1) = (FLOATVAL)floorl((NREG(2) / den));

#else
Expand Down Expand Up @@ -18035,12 +18049,7 @@ Parrot_ceil_n(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_ceil_i_n(opcode_t *cur_opcode, PARROT_INTERP) {
#if defined(PARROT_HAS_CEILL) && (NUMVAL_SIZE > 8)
long;
double;
d = NREG(2);
const;
FLOATVAL;
f = (FLOATVAL)ceill(d);
const FLOATVAL f = (FLOATVAL)ceill(NREG(2));

#else
const FLOATVAL f = (FLOATVAL)ceil(NREG(2));
Expand All @@ -18062,10 +18071,7 @@ Parrot_ceil_i_n(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_ceil_n_n(opcode_t *cur_opcode, PARROT_INTERP) {
#if defined(PARROT_HAS_CEILL) && (NUMVAL_SIZE > 8)
long;
double;
d = NREG(2);
NREG(1) = (FLOATVAL)ceill(d);
NREG(1) = (FLOATVAL)ceill(NREG(2));

#else
NREG(1) = (FLOATVAL)ceil(NREG(2));
Expand All @@ -18078,10 +18084,7 @@ Parrot_ceil_n_n(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_floor_n(opcode_t *cur_opcode, PARROT_INTERP) {
#if defined(PARROT_HAS_FLOORL) && (NUMVAL_SIZE > 8)
long;
double;
d = NREG(1);
NREG(1) = (FLOATVAL)floorl(d);
NREG(1) = (FLOATVAL)floorl(NREG(1));

#else
NREG(1) = (FLOATVAL)floor(NREG(1));
Expand All @@ -18094,11 +18097,7 @@ Parrot_floor_n(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_floor_i_n(opcode_t *cur_opcode, PARROT_INTERP) {
#if defined(PARROT_HAS_FLOORL) && (NUMVAL_SIZE > 8)
long;
double;
d = NREG(2);
FLOATVAL;
f = (FLOATVAL)floorl(d);
FLOATVAL f = (FLOATVAL)floorl(NREG(2));

#else
FLOATVAL f = (FLOATVAL)floor(NREG(2));
Expand All @@ -18120,10 +18119,7 @@ Parrot_floor_i_n(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_floor_n_n(opcode_t *cur_opcode, PARROT_INTERP) {
#if defined(PARROT_HAS_FLOORL) && (NUMVAL_SIZE > 8)
long;
double;
d = NREG(2);
NREG(1) = (FLOATVAL)floorl(d);
NREG(1) = (FLOATVAL)floorl(NREG(2));

#else
NREG(1) = (FLOATVAL)floor(NREG(2));
Expand Down

0 comments on commit 77cb00e

Please sign in to comment.