Subject: bug#12754: factor.c selects 64 bit code from longlong.h on 32-bit hppa systems

From: Pádraig Brady <[email-masked]>
Date: Mon, 29 Oct 2012 02:26:58 +0000

On 10/28/2012 07:46 PM, John David Anglin wrote:
> When USE_LONGLONG_H is defined, factor.c unilaterally defines W_TYPE_SIZE
> to 64.  This selects the wrong code from longlong.h on 32-bit hppa systems
> causing an assembly failure.
>
> Attached is a hack which should work on most but probably not all systems.

This is closely related to the general solution I proposed
for http://bugs.gnu.org/12753#8
I.E. making the size of uintmax_t available to the preprocessor.
A particular size doesn't matter according to:
http://lists.gnu.org/archive/html/bug-coreutils/2012-09/msg00111.html

So I'll do something like the following.

thanks,
Pádraig.

diff --git a/src/factor.c b/src/factor.c
index 4c2af98..1b1b37f 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