diff options
author | TAKAI Kousuke <62541129+t-a-k@users.noreply.github.com> | 2021-01-20 20:58:22 +0900 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2021-12-24 08:22:09 -0700 |
commit | ee444c8d1a7d537784075be303d6fef32ab72a50 (patch) | |
tree | 3126b57cf3d6eb5c75260c13e23d7c76a44bbce6 /ext | |
parent | 69101e619b5e99e3c5fe2c937b4f7a7722fde56b (diff) | |
download | perl-ee444c8d1a7d537784075be303d6fef32ab72a50.tar.gz |
POSIX: FLT_ROUNDS is now an XS function rather than a constant
POSIX::FLT_ROUNDS used to be an NV constant, but C FLT_ROUNDS is
actually an integer and not a constant (C99 seems to say that
it reflects the current rounding mode set by fesetround()).
Diffstat (limited to 'ext')
-rw-r--r-- | ext/POSIX/Makefile.PL | 1 | ||||
-rw-r--r-- | ext/POSIX/POSIX.xs | 22 | ||||
-rw-r--r-- | ext/POSIX/t/iv_const.t | 6 |
3 files changed, 25 insertions, 4 deletions
diff --git a/ext/POSIX/Makefile.PL b/ext/POSIX/Makefile.PL index f673b985b3..462b8ede01 100644 --- a/ext/POSIX/Makefile.PL +++ b/ext/POSIX/Makefile.PL @@ -82,7 +82,6 @@ my @names = {name=>"NULL", value=>"0"}, {name=>"_POSIX_JOB_CONTROL", type=>"YES", default=>["IV", "0"]}, {name=>"_POSIX_SAVED_IDS", type=>"YES", default=>["IV", "0"]}, - {name=>'FLT_ROUNDS', type=>"NV", not_constant=>1}, {name=>"HUGE_VAL", type=>"NV", not_constant=>1, macro=>[<<'END', "#endif\n"], #if (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)) || defined(HUGE_VAL) diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 355c8b6462..bd6d12e512 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -2501,13 +2501,29 @@ acos(x) IV fegetround() + PROTOTYPE: + ALIAS: + FLT_ROUNDS = 1 CODE: + switch (ix) { + case 0: + default: #ifdef HAS_FEGETROUND - RETVAL = my_fegetround(); + RETVAL = my_fegetround(); #else - RETVAL = -1; - not_here("fegetround"); + RETVAL = -1; + not_here("fegetround"); #endif + break; + case 1: +#ifdef FLT_ROUNDS + RETVAL = FLT_ROUNDS; +#else + RETVAL = -1; + not_here("FLT_ROUNDS"); +#endif + break; + } OUTPUT: RETVAL diff --git a/ext/POSIX/t/iv_const.t b/ext/POSIX/t/iv_const.t index 38d1b366fb..c443b5c9d0 100644 --- a/ext/POSIX/t/iv_const.t +++ b/ext/POSIX/t/iv_const.t @@ -66,4 +66,10 @@ push @tests, qw(FE_TONEAREST FE_TOWARDZERO FE_UPWARD FE_DOWNWARD) is_iv(eval "POSIX::$_", "$_ is an integer") foreach @tests; +SKIP: { + my $x; + skip $@, 1 unless eval '$x = FLT_ROUNDS; 1'; + is_iv($x, 'FLT_ROUNDS is an integer'); +} + done_testing(); |