Subject: bug#36597: 27.0.50; rehash hash tables eagerly in pdumper

From: Paul Eggert <[email-masked]>
Date: Tue, 11 Aug 2020 16:43:16 -0700

On 8/11/20 11:35 AM, Eli Zaretskii wrote:
> It doesn't, because we avoid the Gnulib inttypes module on MinGW.

In that case perhaps I should revert the change that added the Gnulib inttypes 
module, as MS-Windows is the only currently-active platform with PRIdPTR etc. 
problems that I've heard of.

> I don't understand why it's needed; there's nothing wrong with MinGW's
> inttypes.h header.

I don't know what the problems with MS-Windows are or were. Perhaps they're 
fixed on all development environments we know about. That would suggest 
reverting the inttypes change too.

Does the attached simplification pacify GCC on MinGW? If so, that could be 
combined with reverting the inttypes change.

Does the following standalone program compile OK with 'gcc -Wall' on MinGW? If 
so, why does the same thing not work when compiling Emacs? The error message you 
quoted in Bug#36597#67 suggests that PRIdPTR is "d" whereas intptr_t is 'long' 
which means the following program should run afoul of MinGW.

#include <inttypes.h>
#include <stdio.h>
char buf[1000];
intptr_t ip;
int main (void) {
   return sprintf (buf, "%"PRIdPTR, ip);
}
diff --git a/src/pdumper.c b/src/pdumper.c
index 7708bc892f..0bc48aedbe 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -143,8 +143,6 @@ #define DUMP_OFF_MIN INT_LEAST32_MIN
 #define DUMP_OFF_MAX INT_LEAST32_MAX
 #define PRIdDUMP_OFF PRIdLEAST32
 
-enum { EMACS_INT_XDIGITS = (EMACS_INT_WIDTH + 3) / 4 };
-
 static void ATTRIBUTE_FORMAT_PRINTF (1, 2)
 dump_trace (const char *fmt, ...)
 {
@@ -1008,9 +1006,7 @@ dump_queue_enqueue (struct dump_queue *dump_queue,
   if (NILP (weights))
     {
       /* Object is new.  */
-      EMACS_UINT uobj = XLI (object);
-      dump_trace ("new object %0*"pI"x weight=%d\n", EMACS_INT_XDIGITS, uobj,
-		  weight.value);
+      dump_trace ("new object %p weight=%d\n", XLP (object), weight.value);
 
       if (weight.value == WEIGHT_NONE.value)
         {
@@ -1306,10 +1302,9 @@ dump_queue_dequeue (struct dump_queue *dump_queue, dump_off basis)
   else
     emacs_abort ();
 
-  EMACS_UINT uresult = XLI (result);
-  dump_trace ("  result score=%f src=%s object=%0*"pI"x\n",
+  dump_trace ("  result score=%f src=%s object=%p\n",
               best < 0 ? -1.0 : (double) candidates[best].score,
-	      src, EMACS_INT_XDIGITS, uresult);
+	      src, XLP (result));
 
   {
     Lisp_Object weights = Fgethash (result, dump_queue->link_weights, Qnil);