diff options
author | Paul Janzen <pjanzen@cvs.openbsd.org> | 2001-08-19 17:12:44 +0000 |
---|---|---|
committer | Paul Janzen <pjanzen@cvs.openbsd.org> | 2001-08-19 17:12:44 +0000 |
commit | 39265ff3fd8cc671e910126e6378f443f2c99a70 (patch) | |
tree | 37a9760bd588a704d35a869e9f282542ddc9da8d | |
parent | ca597fff3d881e3a9b40b28415b35aceb766e1bb (diff) |
Use u_int32_t rather than unsigned long, both for platform invariance and
because the primes generation table really depends on there not being more
than 32 bits.
-rw-r--r-- | games/factor/factor.c | 10 | ||||
-rw-r--r-- | games/primes/pr_tbl.c | 7 | ||||
-rw-r--r-- | games/primes/primes.h | 6 |
3 files changed, 12 insertions, 11 deletions
diff --git a/games/factor/factor.c b/games/factor/factor.c index 65d1d64b5aa..2f33b48bbe3 100644 --- a/games/factor/factor.c +++ b/games/factor/factor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: factor.c,v 1.8 2001/08/19 15:22:43 pjanzen Exp $ */ +/* $OpenBSD: factor.c,v 1.9 2001/08/19 17:12:40 pjanzen Exp $ */ /* $NetBSD: factor.c,v 1.5 1995/03/23 08:28:07 cgd Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)factor.c 8.4 (Berkeley) 5/4/95"; #else -static char rcsid[] = "$OpenBSD: factor.c,v 1.8 2001/08/19 15:22:43 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: factor.c,v 1.9 2001/08/19 17:12:40 pjanzen Exp $"; #endif #endif /* not lint */ @@ -183,7 +183,7 @@ pr_fact(val) } /* Factor value. */ - (void)printf("%lu:", val); + (void)printf("%lu:", (unsigned long) val); for (fact = &prime[0]; val > 1; ++fact) { /* Look for the smallest factor. */ do { @@ -193,13 +193,13 @@ pr_fact(val) /* Watch for primes larger than the table. */ if (fact > pr_limit) { - (void)printf(" %lu", val); + (void)printf(" %lu", (unsigned long) val); break; } /* Divide factor out until none are left. */ do { - (void)printf(" %lu", *fact); + (void)printf(" %lu", (unsigned long) *fact); val /= (long)*fact; } while ((val % (long)*fact) == 0); diff --git a/games/primes/pr_tbl.c b/games/primes/pr_tbl.c index 51ee1033a9d..cac95e399c8 100644 --- a/games/primes/pr_tbl.c +++ b/games/primes/pr_tbl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pr_tbl.c,v 1.2 1999/09/25 15:52:20 pjanzen Exp $ */ +/* $OpenBSD: pr_tbl.c,v 1.3 2001/08/19 17:12:43 pjanzen Exp $ */ /* $NetBSD: pr_tbl.c,v 1.3 1995/03/23 08:35:52 cgd Exp $ */ /* @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)pr_tbl.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: pr_tbl.c,v 1.2 1999/09/25 15:52:20 pjanzen Exp $"; +static char rcsid[] = "$OpenBSD: pr_tbl.c,v 1.3 2001/08/19 17:12:43 pjanzen Exp $"; #endif #endif /* not lint */ @@ -56,6 +56,7 @@ static char rcsid[] = "$OpenBSD: pr_tbl.c,v 1.2 1999/09/25 15:52:20 pjanzen Exp * and 65537^2 > 2^32-1. */ +#include <sys/types.h> #include "primes.h" const ubig prime[] = { @@ -550,4 +551,4 @@ const ubig prime[] = { }; /* pr_limit - largest prime in the prime table */ -const unsigned long *pr_limit = &prime[(sizeof(prime)/sizeof(prime[0]))-1]; +const ubig *pr_limit = &prime[(sizeof(prime)/sizeof(prime[0]))-1]; diff --git a/games/primes/primes.h b/games/primes/primes.h index ae993d6240d..42b321ba089 100644 --- a/games/primes/primes.h +++ b/games/primes/primes.h @@ -1,4 +1,4 @@ -/* $OpenBSD: primes.h,v 1.2 1999/09/25 15:52:20 pjanzen Exp $ */ +/* $OpenBSD: primes.h,v 1.3 2001/08/19 17:12:43 pjanzen Exp $ */ /* $NetBSD: primes.h,v 1.4 1995/03/23 08:35:58 cgd Exp $ */ /* @@ -48,8 +48,8 @@ */ /* ubig is the type that holds a large unsigned value */ -typedef unsigned long ubig; /* must be >=32 bit unsigned value */ -#define BIG ULONG_MAX /* largest value will sieve */ +typedef u_int32_t ubig; /* must be 32 bit unsigned value */ +#define BIG 0xffffffffU /* largest value will sieve */ /* bytes in sieve table (must be > 3*5*7*11) */ #define TABSIZE 256*1024 |