[libmath-prime-util-perl] 09/33: Fix 32-bit unsigned long issues
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:51:41 UTC 2015
This is an automated email from the git hooks/post-receive script.
ppm-guest pushed a commit to annotated tag v0.37
in repository libmath-prime-util-perl.
commit 9728b3943adb551f3a4a97728f8e17f8f0e31182
Author: Dana Jacobsen <dana at acm.org>
Date: Sat Jan 18 12:36:40 2014 -0800
Fix 32-bit unsigned long issues
---
TODO | 7 -------
factor.c | 12 ++++++------
util.c | 2 +-
3 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/TODO b/TODO
index 1881492..71523b8 100644
--- a/TODO
+++ b/TODO
@@ -6,8 +6,6 @@
* Test on 32-bit Perl. Test on Win32.
-- Add test to check maxbits in compiled library vs. Perl
-
- Figure out documentation solution for PP.pm
- Is the current PP.pm setup the way we want to do it?
@@ -36,11 +34,6 @@
- Use Montgomery routines in more places: Factoring.
-- Put euler_phi and moebius directly in XS.
- (1) optional second argument. Easily handled, and not hard to do in
- generic sub call.
- (2) generic sub returns an array. This is the sticking point.
-
- Factoring in PP code is really wasteful -- we're calling _isprime7 before
we've done enough trial division, and later we're calling it on known
composites. Note how the XS code splits the factor code into the public
diff --git a/factor.c b/factor.c
index 32ac323..1a22ee8 100644
--- a/factor.c
+++ b/factor.c
@@ -658,12 +658,12 @@ int pminus1_factor(UV n, UV *factors, UV B1, UV B2)
}
/* Simple Williams p+1 */
-static void pp1_pow(UV *cX, unsigned long exp, UV n)
+static void pp1_pow(UV *cX, UV exp, UV n)
{
UV X0 = *cX;
UV X = *cX;
UV Y = mulsubmod(X, X, 2, n);
- unsigned long bit = 1UL << (clz(exp)-1);
+ UV bit = UVCONST(1) << (clz(exp)-1);
while (bit) {
UV T = mulsubmod(X, Y, X0, n);
if ( exp & bit ) {
@@ -937,7 +937,7 @@ UV dlp_prho(UV a, UV g, UV p, UV maxrounds) {
pollard_rho_cycle(u,v,w,p,n,a,g); /* xi, ai, bi */
pollard_rho_cycle(U,V,W,p,n,a,g);
pollard_rho_cycle(U,V,W,p,n,a,g); /* x2i, a2i, b2i */
- if (verbose > 3) printf( "%3lu %4lu %3lu %3lu %4lu %3lu %3lu\n", i, u, v, w, U, V, W );
+ if (verbose > 3) printf( "%3"UVuf" %4"UVuf" %3"UVuf" %3"UVuf" %4"UVuf" %3"UVuf" %3"UVuf"\n", i, u, v, w, U, V, W );
if (u == U) {
UV r1, r2, k;
r1 = submod(v, V, n);
@@ -948,11 +948,11 @@ UV dlp_prho(UV a, UV g, UV p, UV maxrounds) {
r2 = submod(W, w, n);
k = divmod(r2, r1, n);
if (powmod(g,k,p) != a) {
- if (verbose > 2) printf("r1 = %lu r2 = %lu k = %lu\n", r1, r2, k);
- if (verbose) printf("Incorrect DLP Rho solution: %lu\n", k);
+ if (verbose > 2) printf("r1 = %"UVuf" r2 = %"UVuf" k = %"UVuf"\n", r1, r2, k);
+ if (verbose) printf("Incorrect DLP Rho solution: %"UVuf"\n", k);
return 0;
}
- if (verbose) printf("DLP Rho solution found after %lu steps\n", i);
+ if (verbose) printf("DLP Rho solution found after %"UVuf" steps\n", i);
return k;
}
}
diff --git a/util.c b/util.c
index dd8d5b2..3a6dca8 100644
--- a/util.c
+++ b/util.c
@@ -763,7 +763,7 @@ UV* _totient_range(UV lo, UV hi) {
unsigned char* segment;
void* ctx;
- if (hi < lo) croak("_totient_range error hi %lu < lo %lu\n", hi, lo);
+ if (hi < lo) croak("_totient_range error hi %"UVuf" < lo %"UVuf"\n", hi, lo);
New(0, totients, hi-lo+1, UV);
/* Do via factoring if very small or if we have a small range */
--
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