From a5f8ce9f1eae29f87fe13adb61bd4e15faa628a2 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sun, 9 Mar 2025 23:02:21 +0800 Subject: Re-port to 32-bit systems without alignment primitives * configure.ac (ALIGNOF_INT, ALIGNOF_LONG, ALIGNOF_LONG_LONG): New variables. (emacs_cv_alignas_unavailable): Define if alignas and structure alignment primitives are unavailable. In such an environment, the MSB tagging scheme must be enabled, as must the GNU malloc. * msdos/sed2v2.inp: Adjust correspondingly. * src/alloc.c (union emacs_align_type): Remove types which contain flexible array members. The address of a field subsequent to an aggregate with flexible array members cannot validly be taken. (mark_memory) [!USE_LSB_TAG && !WIDE_EMACS_INT]: Strip type bits before scanning memory. * src/emacs.c (main): * src/eval.c (Fautoload_do_load): * src/fns.c (Frequire): Rename a number of illogically named fields. * src/lisp.h (ALIGNOF_EMACS_INT): Define to the natural alignment of EMACS_INT. (IDEAL_GCALIGNMENT): New macro. (USE_LSB_TAG): Disable if no alignment specifiers are available, WIDE_EMACS_INT is undefined, and the natural alignment of EMACS_INT falls short of LSB tagging's requirements. (gflags): Rename illogically named fields and don't define them as bitfields, which runs afoul of certain compiler issues. (will_dump_p, will_bootstrap_p, will_dump_with_pdumper_p) (dumped_with_pdumper_p): Adjust accordingly. * src/pdumper.c (VM_SUPPORTED): Define to 0 when !USE_LSB_TAG. It is better to read dump files into the heap by hand than to be supplied with an address that is not representable. (_dump_object_start_pseudovector): Rename to dump_object_start_pseudovector, to avoid encroaching on reserved names. (START_DUMP_PVEC): Adjust correspondingly. (dump_mmap_contiguous_vm): Preserve errno around failure cleanup. (dump_bitset_bit_set_p): Work around certain compiler issues. (pdumper_load) [!USE_LSB_TAG]: Reject dump file allocations that are not representable as Lisp_Objects. Tested on i386-unknown-solaris2.10, sparc-sun-solaris2.10. --- src/alloc.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/alloc.c') diff --git a/src/alloc.c b/src/alloc.c index 7fa05e54202..c0d68e6c964 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -150,8 +150,6 @@ union emacs_align_type { struct frame frame; struct Lisp_Bignum Lisp_Bignum; - struct Lisp_Bool_Vector Lisp_Bool_Vector; - struct Lisp_Char_Table Lisp_Char_Table; struct Lisp_CondVar Lisp_CondVar; struct Lisp_Finalizer Lisp_Finalizer; struct Lisp_Float Lisp_Float; @@ -160,21 +158,25 @@ union emacs_align_type struct Lisp_Misc_Ptr Lisp_Misc_Ptr; struct Lisp_Mutex Lisp_Mutex; struct Lisp_Overlay Lisp_Overlay; - struct Lisp_Sub_Char_Table Lisp_Sub_Char_Table; struct Lisp_Subr Lisp_Subr; struct Lisp_Sqlite Lisp_Sqlite; struct Lisp_User_Ptr Lisp_User_Ptr; - struct Lisp_Vector Lisp_Vector; struct terminal terminal; struct thread_state thread_state; struct window window; /* Omit the following since they would require including process.h - etc. In practice their alignments never exceed that of the - structs already listed. */ + etc, or because they are defined with flexible array members, which + are rejected by some C99 compilers when this union subsequently + appears in an `alignof' expression. In practice their alignments + never exceed that of the structs already listed. */ #if 0 + struct Lisp_Bool_Vector Lisp_Bool_Vector; + struct Lisp_Char_Table Lisp_Char_Table; + struct Lisp_Sub_Char_Table Lisp_Sub_Char_Table; struct Lisp_Module_Function Lisp_Module_Function; struct Lisp_Process Lisp_Process; + struct Lisp_Vector Lisp_Vector; struct save_window_data save_window_data; struct scroll_bar scroll_bar; struct xwidget_view xwidget_view; @@ -5167,14 +5169,20 @@ mark_memory (void const *start, void const *end) for (pp = start; (void const *) pp < end; pp += GC_POINTER_ALIGNMENT) { void *p = *(void *const *) pp; + intptr_t ip; + +#if !USE_LSB_TAG && !defined WIDE_EMACS_INT + ip = (intptr_t) p; + mark_maybe_pointer ((void *) (ip & VALMASK), false); +#else /* USE_LSB_TAG || WIDE_EMACS_INT */ mark_maybe_pointer (p, false); +#endif /* USE_LSB_TAG || WIDE_EMACS_INT */ /* Unmask any struct Lisp_Symbol pointer that make_lisp_symbol previously disguised by adding the address of 'lispsym'. On a host with 32-bit pointers and 64-bit Lisp_Objects, a Lisp_Object might be split into registers saved into non-adjacent words and P might be the low-order word's value. */ - intptr_t ip; ckd_add (&ip, (intptr_t) p, (intptr_t) lispsym); mark_maybe_pointer ((void *) ip, true); } -- cgit v1.2.1