diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2012-11-12 08:32:04 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-11-12 08:32:31 -0800 |
commit | f16e251dae43117c2cd19359c26ce7b5e05165b6 (patch) | |
tree | 7232d39cb3dba3f89480d3aac383b73779826aba /src/factor.c | |
parent | 0d664d227cadb8cf4892e70954cd6c616192c0f8 (diff) | |
download | coreutils-f16e251dae43117c2cd19359c26ce7b5e05165b6.tar.xz |
factor: maintainer builds primes.h, not builder
With this change, the maintainer builds primes.h and it is part of
the tarball. primes.h's contents are not architecture-specific.
* .gitignore: Remove /src/primes.h.
* src/factor.c: Include verify.h.
(W): New constant. Verify that uintmax_t lacks holes
and that W is no wider than the integers used to generate primes.h.
* src/local.mk (EXTRA_DIST): Add src/primes.h.
(BUILT_SOURCES, CLEANFILES): Remove src/primes.h.
($(top_srcdir)/src/primes.h): Rename from src/primes.h.
Do not depend on src/make-prime-list. Instead, use sub-make to
build, so that we build primes.h only if it does not exist.
* src/make-prime-list.c: Include <limits.h>, for ULONG_MAX.
(wide_uint): Define to uintmax_t or unsigned __int128 if not #defined.
(struct prime, binvert, process_prime): Use it instead of uintmax_t.
(print_wide_uint): New function. This generates the proper pinv
value regardless of the width of uintmax_t on the target, so long
as the width doesn't exceed that of the width of wide_uint on the
maintainer host that generated src/primes.h.
(output_primes): Use it. Output WIDE_UINT_BITS, too. Let the
target compute its own lim, since its uintmax_t may be narrower
than ours.
(SZ): Remove.
* src/primes.h: New file, generated with 128-bit integers and usable
on any host where uintmax_t's width is no greater than 128 bits.
Diffstat (limited to 'src/factor.c')
-rw-r--r-- | src/factor.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/factor.c b/src/factor.c index 1d667175a..45f00bb05 100644 --- a/src/factor.c +++ b/src/factor.c @@ -101,6 +101,7 @@ #include "quote.h" #include "readtokens.h" #include "xstrtol.h" +#include "verify.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "factor" @@ -639,6 +640,12 @@ mp_factor_insert_ui (struct mp_factors *factors, unsigned long int prime) #endif /* HAVE_GMP */ +/* Number of bits in an uintmax_t. */ +enum { W = sizeof (uintmax_t) * CHAR_BIT }; + +/* Verify that uintmax_t does not have holes in its representation. */ +verify (UINTMAX_MAX >> (W - 1) == 1); + #define P(a,b,c,d) a, static const unsigned char primes_diff[] = { #include "primes.h" @@ -668,6 +675,10 @@ static const struct primes_dtab primes_dtab[] = { }; #undef P +/* Verify that uintmax_t is not wider than + the integers used to generate primes.h. */ +verify (W <= WIDE_UINT_BITS); + /* This flag is honored only in the GMP code. */ static int verbose = 0; |