Subject: bug#53136: 28.0.90; segfault in lock_file

From: Paul Eggert <[email-masked]>
Date: Mon, 10 Jan 2022 15:30:10 -0800

One little thing I noticed in the Haiku port. I assume the lisp.h 
complication for pD was needed on 32-bit Haiku to avoid compiler 
warnings when passing long vs int (same size, either would work, but 
compiler warning). I installed the attached to simplify the ifdefs here. 
If my diagnosis of the issue is wrong and this patch doesn't work for 
Haiku, please let me know or feel free to revert and we can find a 
better way.

At some point we can get rid of pD by replacing pD with "t" everywhere 
in Emacs, but one step at a time.

From c4cadadea6f03308eb2c25c757431c19b9108e58 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Mon, 10 Jan 2022 15:21:08 -0800
Subject: [PATCH] Assume C99 when defining pD

* src/lisp.h (pD): Assume C99 or later, to simplify the ifdefs.
---
 src/lisp.h | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/src/lisp.h b/src/lisp.h
index f8fe2a6906..c5e63110c7 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -137,25 +137,9 @@ verify (BITS_WORD_MAX >> (BITS_PER_BITS_WORD - 1) == 1);
 /* Use pD to format ptrdiff_t values, which suffice for indexes into
    buffers and strings.  Emacs never allocates objects larger than
    PTRDIFF_MAX bytes, as they cause problems with pointer subtraction.
-   In C99, pD can always be "t"; configure it here for the sake of
-   pre-C99 libraries such as glibc 2.0 and Solaris 8.
-
-   On Haiku, the size of ptrdiff_t is inconsistent with the value of
-   PTRDIFF_MAX.  In that case, "t" should be sufficient. */
-
-#ifndef HAIKU
-#if PTRDIFF_MAX == INT_MAX
-# define pD ""
-#elif PTRDIFF_MAX == LONG_MAX
-# define pD "l"
-#elif PTRDIFF_MAX == LLONG_MAX
-# define pD "ll"
-#else
-# define pD "t"
-#endif
-#else
-# define pD "t"
-#endif
+   In C99, pD can always be "t", as we no longer need to worry about
+   pre-C99 libraries such as glibc 2.0 (1997) and Solaris 8 (2000).  */
+#define pD "t"
 
 /* Convenience macro for rarely-used functions that do not return.  */
 #define AVOID _Noreturn ATTRIBUTE_COLD void
-- 
2.32.0