-/* $NetBSD: primes.c,v 1.9 1999/09/08 21:17:55 jsm Exp $ */
+/* $NetBSD: primes.c,v 1.11 2003/08/07 09:37:33 agc Exp $ */
/*
* Copyright (c) 1989, 1993
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#if 0
static char sccsid[] = "@(#)primes.c 8.5 (Berkeley) 5/10/95";
#else
-__RCSID("$NetBSD: primes.c,v 1.9 1999/09/08 21:17:55 jsm Exp $");
+__RCSID("$NetBSD: primes.c,v 1.11 2003/08/07 09:37:33 agc Exp $");
#endif
#endif /* not lint */
char *tab_lim; /* the limit to sieve on the table */
const ubig *p; /* prime table pointer */
ubig fact_lim; /* highest prime for current block */
+ ubig mod; /* temp storage for mod */
/*
* A number of systems can not convert double values into unsigned
p = &prime[7]; /* 19 is next prime, pi(19)=7 */
do {
/* determine the factor's initial sieve point */
- q = (char *)(start%factor); /* temp storage for mod */
- if ((long)q & 0x1) {
- q = &table[(factor-(long)q)/2];
+ mod = start%factor;
+ if (mod & 0x1) {
+ q = &table[(factor-mod)/2];
} else {
- q = &table[q ? factor-((long)q/2) : 0];
+ q = &table[mod ? factor-(mod/2) : 0];
}
/* sive for our current factor */
for ( ; q < tab_lim; q += factor) {