diff options
author | Aaron Crane <arc@cpan.org> | 2016-04-01 18:53:35 +0100 |
---|---|---|
committer | Aaron Crane <arc@cpan.org> | 2016-04-02 12:00:58 +0100 |
commit | 25a9f0e724ff0f469866f8713f0e79f3159bf870 (patch) | |
tree | 7161e8496718ce71cedb738456ec943c281e530d /ext/POSIX | |
parent | 61b2a465d0f2b304d68e610aa08fe0a01ba2d3d8 (diff) | |
download | perl-25a9f0e724ff0f469866f8713f0e79f3159bf870.tar.gz |
Export lround() from POSIX
This function was implemented as of 5.21.4, but not exported (even by
request). It's too late in the 5.24 freeze for it to be exported by default,
or as part of a tag, but we can at least make it available to those who want
to import it by name.
Diffstat (limited to 'ext/POSIX')
-rw-r--r-- | ext/POSIX/lib/POSIX.pm | 8 | ||||
-rw-r--r-- | ext/POSIX/lib/POSIX.pod | 4 | ||||
-rw-r--r-- | ext/POSIX/t/export.t | 4 | ||||
-rw-r--r-- | ext/POSIX/t/math.t | 3 |
4 files changed, 17 insertions, 2 deletions
diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm index 2b339b7c8a..8461943a2f 100644 --- a/ext/POSIX/lib/POSIX.pm +++ b/ext/POSIX/lib/POSIX.pm @@ -4,7 +4,7 @@ use warnings; our ($AUTOLOAD, %SIGRT); -our $VERSION = '1.64'; +our $VERSION = '1.65'; require XSLoader; @@ -445,7 +445,11 @@ my %other_export_tags = ( our @EXPORT = keys %export; our @EXPORT_OK = (qw(close lchown nice open pipe read sleep times write - printf sprintf), + printf sprintf lround), + # lround() should really be in @EXPORT and in the + # :math_h_c99 tag, but we're too far into the 5.24 code + # freeze for that to be done now. This can be revisited in + # the 5.25.x cycle. grep {!exists $export{$_}} keys %reimpl, keys %replacement, keys %export_ok); our %EXPORT_TAGS = ( %default_export_tags, %other_export_tags ); diff --git a/ext/POSIX/lib/POSIX.pod b/ext/POSIX/lib/POSIX.pod index 904f3e9717..a31518fa50 100644 --- a/ext/POSIX/lib/POSIX.pod +++ b/ext/POSIX/lib/POSIX.pod @@ -1011,6 +1011,10 @@ Like L</round>, but as integer, as opposed to floating point [C99]. See also L</ceil>, L</floor>, L</trunc>. +Owing to an oversight, this is not currently exported by default, or as part of +the C<:math_h_c99> export tag; importing it must therefore be done by explicit +name. This will be changed in Perl 5.26. + =item C<malloc> Not implemented. C<malloc()> is C-specific. Perl does memory management transparently. diff --git a/ext/POSIX/t/export.t b/ext/POSIX/t/export.t index aa7d78ccf7..5c37f83a07 100644 --- a/ext/POSIX/t/export.t +++ b/ext/POSIX/t/export.t @@ -166,6 +166,10 @@ my %expect = ( POLL_IN POLL_OUT POLL_MSG POLL_ERR POLL_PRI POLL_HUP SI_USER SI_QUEUE SI_TIMER SI_ASYNCIO SI_MESGQ ), + # this was implemented in 5.21, but not exported; it was added to + # @EXPORT_OK late in 5.23, and will be added to :math_h_c99 tag early + # in 5.25 + qw( lround ), ], ); diff --git a/ext/POSIX/t/math.t b/ext/POSIX/t/math.t index 869d1b710f..54067d1f02 100644 --- a/ext/POSIX/t/math.t +++ b/ext/POSIX/t/math.t @@ -4,6 +4,7 @@ use strict; use POSIX ':math_h_c99'; use POSIX ':nan_payload'; +use POSIX 'lround'; use Test::More; use Config; @@ -118,6 +119,8 @@ SKIP: { is(round(-2.5), -3, "round -2.5"); is(round(2.75), 3, "round 2.75"); is(round(-2.75), -3, "round 2.75"); + is(lround(-2.75), -3, "lround -0.25"); + is(signbit(lround(-0.25)), 0, "lround -0.25 -> +0"); # unlike round() is(trunc(2.25), 2, "trunc 2.25"); is(trunc(-2.25), -2, "trunc -2.25"); is(trunc(2.5), 2, "trunc 2.5"); |