From: Paul Eggert Date: Fri, 27 Sep 2024 03:20:05 +0000 (-0700) Subject: factor: macro refactoring X-Git-Tag: v9.6~150 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74d791c4b0dd57170485a1145e3e82481686aa7a;p=thirdparty%2Fcoreutils.git factor: macro refactoring * src/factor.c (W_TYPE_SIZE): Simplify by always defining to UINTMAX_WIDTH. (W): Remove. All uses replaced by W_TYPE_SIZE. We no longer need one of its static_asserts. --- diff --git a/src/factor.c b/src/factor.c index e463186ded..9b90dbab0d 100644 --- a/src/factor.c +++ b/src/factor.c @@ -136,19 +136,12 @@ # endif #endif +#define W_TYPE_SIZE UINTMAX_WIDTH + #if USE_LONGLONG_H /* Make definitions for longlong.h to make it do what it can do for us */ -/* 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 @@ -189,7 +182,6 @@ typedef unsigned long int UDItype; #else /* not USE_LONGLONG_H */ -# define W_TYPE_SIZE (8 * sizeof (uintmax_t)) # define __ll_B ((uintmax_t) 1 << (W_TYPE_SIZE / 2)) # define __ll_lowpart(t) ((uintmax_t) (t) & (__ll_B - 1)) # define __ll_highpart(t) ((uintmax_t) (t) >> (W_TYPE_SIZE / 2)) @@ -638,12 +630,6 @@ mp_factor_insert_ui (struct mp_factors *factors, unsigned long int prime) } -/* 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. */ -static_assert (UINTMAX_MAX >> (W - 1) == 1); - #define P(a,b,c,d) a, static const unsigned char primes_diff[] = { #include "primes.h" @@ -675,7 +661,7 @@ static const struct primes_dtab primes_dtab[] = { /* Verify that uintmax_t is not wider than the integers used to generate primes.h. */ -static_assert (W <= WIDE_UINT_BITS); +static_assert (UINTMAX_WIDTH <= WIDE_UINT_BITS); /* debugging for developers. Enables devmsg(). This flag is used only in the GMP code. */