Subject: bug#12841: Make for AIX 8.20 fails with undefined symbol .rpl_malloc

From: Paul Eggert <[email-masked]>
Date: Mon, 12 Nov 2012 21:19:39 -0800

On 11/12/2012 08:12 PM, Jim Meyering wrote:
> Thanks for addressing those problems.
> Did you intend to commit the generated primes.h?

I did, but I see now that I was mistaken.  Thanks for
catching that.

I pushed the following further change, to fix it.  A downside
is that whoever generates primes.h for distribution should,
as a nicety, do so on a host that supports 128-bit int,
e.g., GCC 4.6 or later on x86-64 (but not x86).  If you forget
it's no big deal, as 64 bits is enough for now.

This patch should also fix the lines-too-long problem at
least until we have hosts with 1024-bit integers, at which
point we'll have to reformat primes.h again.

This email omits the part of the patch that deletes
primes.h, as that part's pretty boring.

>From e4a0c995070c92d678fdf766da4a0460990aebe4 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Mon, 12 Nov 2012 21:10:17 -0800
Subject: [PATCH] factor: improve primes.h change

This follows suggestions by Jim Meyering in
<http://bugs.gnu.org/12841#34>.
* src/make-prime-list.c (print_wide_uint): Change "nested" argument
to "nesting", and use it to avoid outputting lines that are too long.
* src/primes.h: Remove from git.  This can be generated by a
maintainer.  It's nicer to do so on a host with at least 128-bit
arithmetic.
---
 src/make-prime-list.c |   14 +-
 src/primes.h          | 2010 -------------------------------------------------
 2 files changed, 8 insertions(+), 2016 deletions(-)
 delete mode 100644 src/primes.h

diff --git a/src/make-prime-list.c b/src/make-prime-list.c
index ab0352e..5a222d9 100644
--- a/src/make-prime-list.c
+++ b/src/make-prime-list.c
@@ -76,7 +76,7 @@ process_prime (struct prime *info, unsigned p)
 }
 
 static void
-print_wide_uint (wide_uint n, int nested, unsigned wide_uint_bits)
+print_wide_uint (wide_uint n, int nesting, unsigned wide_uint_bits)
 {
   /* Number of bits per integer literal.  8 is too many, because
      uintmax_t is 32 bits on some machines so we cannot shift by 32 bits.
@@ -91,10 +91,12 @@ print_wide_uint (wide_uint n, int nested, unsigned wide_uint_bits)
       int needs_parentheses = n >> bits_per_literal >> bits_per_literal != 0;
       if (needs_parentheses)
         printf ("(");
-      print_wide_uint (n >> bits_per_literal, 1, wide_uint_bits);
-      printf (") << %d | " + !needs_parentheses, bits_per_literal);
+      print_wide_uint (n >> bits_per_literal, nesting + 1, wide_uint_bits);
+      if (needs_parentheses)
+        printf (")\n%*s", nesting + 3, "");
+      printf (" << %d | ", bits_per_literal);
     }
-  else if (nested)
+  else if (nesting)
     {
       printf ("(uintmax_t) ");
       hex_digits_per_literal
@@ -127,9 +129,9 @@ output_primes (const struct prime *primes, unsigned nprimes)
       unsigned int d8 = i + 8 < nprimes ? primes[i + 8].p - primes[i].p : 0xff;
       if (255 < d8) /* this happens at 668221 */
         abort ();
-      printf ("P (%u, %u,\n   ", primes[i].p - p, d8);
+      printf ("P (%u, %u,\n   (", primes[i].p - p, d8);
       print_wide_uint (primes[i].pinv, 0, wide_uint_bits);
-      printf (",\n   UINTMAX_MAX / %d)\n", primes[i].p);
+      printf ("),\n   UINTMAX_MAX / %d)\n", primes[i].p);
       p = primes[i].p;
     }
 
diff --git a/src/primes.h b/src/primes.h
deleted file mode 100644
index a47d5ce..0000000
--- a/src/primes.h
+++ /dev/null
@@ -1,2010 +0,0 @@
-/* Generated file -- DO NOT EDIT */
-
-#define WIDE_UINT_BITS 128
... rest of patch omitted as being too boring ...