Subject: Re: bug#75318: Lisp_Subr header and layout

From: Pip Cet <[email-masked]>
Date: Tue, 21 Jan 2025 13:04:48 +0000

"Pip Cet via \"Bug reports for GNU Emacs, the Swiss army knife of text editors\"" <[email-masked]> writes:

> I'll prepare patches for those two changes (remove command_modes;
> correct pvec headers for subrs); not the third (reorder Lisp_Subr
> fields) because it's a nativecomp change, and there may be a small
> performance impact.

The first patch is a simple bug fix. Is this okay?

PVECHEADERSIZE uses "lispsize" and "restsize", but allocate_pseudovector
uses "memlen" and "lisplen".  That's confusing.  Someone was confused,
the header value was wrong but it never caused any trouble.  Still, it's
good to fix this, and it caused trouble for feature/igc.

Ideally, we would fix the confusing situation.  My suggestion is to
always pass all three sizes.  Please let me know if that's desirable.

>From 08fd00deb5d4d7ea73d2959577d2b4ab9855f1c2 Mon Sep 17 00:00:00 2001
From: Pip Cet <[email-masked]>
Subject: [PATCH 1/2] Correct PVEC header for main_thread (bug#75318)

* src/thread.c (main_thread): Pass correct restsize to PVECHEADERSIZE.
---
 src/thread.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/thread.c b/src/thread.c
index 5610f8be0dd..5539fae15ab 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -50,7 +50,9 @@ static_assert (GCALIGNED (union aligned_thread_state));
       .header.size = PVECHEADERSIZE (PVEC_THREAD,
 				     PSEUDOVECSIZE (struct thread_state,
 						    event_object),
-				     VECSIZE (struct thread_state)),
+				     VECSIZE (struct thread_state) -
+				     PSEUDOVECSIZE (struct thread_state,
+						    event_object)),
       .m_last_thing_searched = LISPSYM_INITIALLY (Qnil),
       .m_saved_last_thing_searched = LISPSYM_INITIALLY (Qnil),
       .name = LISPSYM_INITIALLY (Qnil),
-- 
2.47.1