[libmath-prime-util-perl] 33/43: Make sure nth_twin_prime goes to PP when the argument will overflow the C code
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:53:08 UTC 2015
This is an automated email from the git hooks/post-receive script.
ppm-guest pushed a commit to annotated tag v0.40
in repository libmath-prime-util-perl.
commit 6b0ad3d17dadffb8a988164edb5d794246199e94
Author: Dana Jacobsen <dana at acm.org>
Date: Mon Apr 14 18:28:01 2014 -0700
Make sure nth_twin_prime goes to PP when the argument will overflow the C code
---
XS.xs | 3 ++-
constants.h | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/XS.xs b/XS.xs
index 6795342..8515dce 100644
--- a/XS.xs
+++ b/XS.xs
@@ -613,7 +613,8 @@ next_prime(IN SV* svn)
if (_validate_int(aTHX_ svn, 0)) {
UV n = my_svuv(svn);
if ( (n >= MPU_MAX_PRIME && ix == 0) ||
- (n >= MPU_MAX_PRIME_IDX && (ix==2 || ix==3 || ix==4 || ix==5)) ) {
+ (n >= MPU_MAX_PRIME_IDX && (ix==2 || ix==3 || ix==4 || ix==5)) ||
+ (n >= MPU_MAX_TWIN_PRIME_IDX && (ix==6 || ix==7)) ) {
/* Out of range. Fall through to Perl. */
} else {
UV ret;
diff --git a/constants.h b/constants.h
index 0fc1e5a..65f3986 100644
--- a/constants.h
+++ b/constants.h
@@ -7,9 +7,13 @@
#if BITS_PER_WORD == 32
#define MPU_MAX_PRIME UVCONST(4294967291)
#define MPU_MAX_PRIME_IDX UVCONST(203280221)
+ #define MPU_MAX_TWIN_PRIME UVCONST(4294965839)
+ #define MPU_MAX_TWIN_PRIME_IDX UVCONST(12739574)
#else
#define MPU_MAX_PRIME UVCONST(18446744073709551557)
#define MPU_MAX_PRIME_IDX UVCONST(425656284035217743)
+ #define MPU_MAX_TWIN_PRIME UVCONST(18446744073709550771)
+ #define MPU_MAX_TWIN_PRIME_IDX UVCONST(12975810317986308) /* Approx */
#endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git
More information about the Pkg-perl-cvs-commits
mailing list