[libmath-prime-util-perl] 46/181: Wrap isqrt in #define so only included when needed

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:51:05 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.36
in repository libmath-prime-util-perl.

commit 98d0e8e8b7e8fe3cf0fb4e80cf2aea40581da245
Author: Dana Jacobsen <dana at acm.org>
Date:   Thu Dec 26 00:06:44 2013 -0800

    Wrap isqrt in #define so only included when needed
---
 aks.c       | 2 ++
 factor.c    | 3 ++-
 lehmer.c    | 1 +
 lmo.c       | 1 +
 primality.c | 3 ++-
 sieve.c     | 2 ++
 util.c      | 3 ++-
 util.h      | 2 ++
 8 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/aks.c b/aks.c
index bc4a369..c600055 100644
--- a/aks.c
+++ b/aks.c
@@ -26,6 +26,7 @@
 
 #include "ptypes.h"
 #include "aks.h"
+#define FUNC_isqrt 1
 #include "util.h"
 #include "cache.h"
 #include "mulmod.h"
@@ -84,6 +85,7 @@ static int is_perfect_power(UV n) {
   return 0;
 }
 
+/* Naive znorder.  Works well here because limit will be very small. */
 static UV order(UV r, UV n, UV limit) {
   UV j;
   UV t = 1;
diff --git a/factor.c b/factor.c
index 78a4eba..6da205a 100644
--- a/factor.c
+++ b/factor.c
@@ -9,7 +9,8 @@
 #include "mulmod.h"
 #include "cache.h"
 #include "primality.h"
-#define FUNC_gcd_ui
+#define FUNC_isqrt  1
+#define FUNC_gcd_ui 1
 #include "util.h"
 
 /*
diff --git a/lehmer.c b/lehmer.c
index 725ed4a..ab4bec9 100644
--- a/lehmer.c
+++ b/lehmer.c
@@ -163,6 +163,7 @@ static uint32_t* generate_small_primes(UV n)
 /* We will use pre-sieving to speed up counting for small ranges */
 #define SIEVE_MULT   1
 
+#define FUNC_isqrt 1
 #define FUNC_icbrt 1
 #include "lehmer.h"
 #include "util.h"
diff --git a/lmo.c b/lmo.c
index 43993a6..a585290 100644
--- a/lmo.c
+++ b/lmo.c
@@ -62,6 +62,7 @@
 /* Phi sieve multiplier, adjust for best performance and memory use. */
 #define PHI_SIEVE_MULT 13
 
+#define FUNC_isqrt 1
 #define FUNC_icbrt 1
 #include "lmo.h"
 #include "util.h"
diff --git a/primality.c b/primality.c
index 9a5d624..efa6131 100644
--- a/primality.c
+++ b/primality.c
@@ -6,7 +6,8 @@
 #include "ptypes.h"
 #include "primality.h"
 #include "mulmod.h"
-#define FUNC_gcd_ui
+#define FUNC_isqrt  1
+#define FUNC_gcd_ui 1
 #include "util.h"
 
 /* Primality related functions, including Montgomery math */
diff --git a/sieve.c b/sieve.c
index 3f818ca..54a185f 100644
--- a/sieve.c
+++ b/sieve.c
@@ -7,7 +7,9 @@
 #include "sieve.h"
 #include "ptypes.h"
 #include "cache.h"
+#define FUNC_isqrt 1
 #include "util.h"
+#include "primality.h"
 
 /* If the base sieve is larger than this, presieve and test */
 #define BASE_SIEVE_LIMIT  4000000
diff --git a/util.c b/util.c
index ed85656..510426e 100644
--- a/util.c
+++ b/util.c
@@ -56,6 +56,7 @@
 
 
 #include "ptypes.h"
+#define FUNC_isqrt 1
 #include "util.h"
 #include "sieve.h"
 #include "primality.h"
@@ -342,7 +343,7 @@ static UV count_segment_maxcount(const unsigned char* sieve, UV base, UV nbytes,
              (top <    1000000) ? 4 :
              (top <   10000000) ? 3 : 2;
     UV minbytes = (maxcount-count)/div;
-    if (minbytes > (maxsieve-sieveptr)) minbytes = maxsieve-sieveptr;
+    if (minbytes > (UV)(maxsieve-sieveptr)) minbytes = maxsieve-sieveptr;
     count += count_zero_bits(sieveptr, minbytes);
     sieveptr += minbytes;
   }
diff --git a/util.h b/util.h
index 22f19b1..4dbcc6e 100644
--- a/util.h
+++ b/util.h
@@ -35,6 +35,7 @@ extern UV _XS_Inverse_Li(UV x);
   #define MPU_PROB_PRIME_BEST  UVCONST(100000000)
 #endif
 
+#ifdef FUNC_isqrt
 static UV isqrt(UV n) {
   UV root;
 #if BITS_PER_WORD == 32
@@ -47,6 +48,7 @@ static UV isqrt(UV n) {
   while ((root+1)*(root+1) <= n)  root++;
   return root;
 }
+#endif
 
 #ifdef FUNC_icbrt
 static UV icbrt(UV n) {

-- 
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