summaryrefslogtreecommitdiff
path: root/src/factor.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2012-10-30 02:15:36 +0000
committerPádraig Brady <P@draigBrady.com>2012-11-04 00:49:04 +0000
commit6108baa47e90aaefb83eb230e2e063906ca14e87 (patch)
treec05898f88e424ba2d4c2fd01ec0584255ea205c0 /src/factor.c
parent1411022cf23d81bac8176b06008898439a2c1a59 (diff)
downloadcoreutils-6108baa47e90aaefb83eb230e2e063906ca14e87.tar.xz
build: don't assume uintmax_t is 64 bits
This was not seen to be an issue in practise, but to make the code more robust, don't assume uintmax_t is 64 bits. * src/factor.c (W_TYPE_SIZE): Define based on integer limits. * src/make-prime-list.c (output_primes): Define format width based on integer limits.
Diffstat (limited to 'src/factor.c')
-rw-r--r--src/factor.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/factor.c b/src/factor.c
index be5a36cd5..1d667175a 100644
--- a/src/factor.c
+++ b/src/factor.c
@@ -124,7 +124,16 @@
#if USE_LONGLONG_H
/* Make definitions for longlong.h to make it do what it can do for us */
-# define W_TYPE_SIZE 64 /* bitcount for uintmax_t */
+
+/* bitcount for uintmax_t */
+#if UINTMAX_MAX == UINT32_MAX
+# define W_TYPE_SIZE 32
+#elif UINTMAX_MAX == UINT64_MAX
+# define W_TYPE_SIZE 64
+#elif UINTMAX_MAX == UINT128_MAX
+# define W_TYPE_SIZE 128
+#endif
+
# define UWtype uintmax_t
# define UHWtype unsigned long int
# undef UDWtype