diff options
| author | Po Lu | 2025-03-09 23:02:21 +0800 |
|---|---|---|
| committer | Po Lu | 2025-03-09 23:07:33 +0800 |
| commit | a5f8ce9f1eae29f87fe13adb61bd4e15faa628a2 (patch) | |
| tree | 602dba32bf3efcd7743f0d2df5e73339d98a5b2e /src/alloc.c | |
| parent | 57cef07710d91988b6332ad3ed2f5c4b4b371585 (diff) | |
| download | emacs-a5f8ce9f1eae29f87fe13adb61bd4e15faa628a2.tar.gz emacs-a5f8ce9f1eae29f87fe13adb61bd4e15faa628a2.zip | |
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.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 22 |
1 files changed, 15 insertions, 7 deletions
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 | |||
| 150 | { | 150 | { |
| 151 | struct frame frame; | 151 | struct frame frame; |
| 152 | struct Lisp_Bignum Lisp_Bignum; | 152 | struct Lisp_Bignum Lisp_Bignum; |
| 153 | struct Lisp_Bool_Vector Lisp_Bool_Vector; | ||
| 154 | struct Lisp_Char_Table Lisp_Char_Table; | ||
| 155 | struct Lisp_CondVar Lisp_CondVar; | 153 | struct Lisp_CondVar Lisp_CondVar; |
| 156 | struct Lisp_Finalizer Lisp_Finalizer; | 154 | struct Lisp_Finalizer Lisp_Finalizer; |
| 157 | struct Lisp_Float Lisp_Float; | 155 | struct Lisp_Float Lisp_Float; |
| @@ -160,21 +158,25 @@ union emacs_align_type | |||
| 160 | struct Lisp_Misc_Ptr Lisp_Misc_Ptr; | 158 | struct Lisp_Misc_Ptr Lisp_Misc_Ptr; |
| 161 | struct Lisp_Mutex Lisp_Mutex; | 159 | struct Lisp_Mutex Lisp_Mutex; |
| 162 | struct Lisp_Overlay Lisp_Overlay; | 160 | struct Lisp_Overlay Lisp_Overlay; |
| 163 | struct Lisp_Sub_Char_Table Lisp_Sub_Char_Table; | ||
| 164 | struct Lisp_Subr Lisp_Subr; | 161 | struct Lisp_Subr Lisp_Subr; |
| 165 | struct Lisp_Sqlite Lisp_Sqlite; | 162 | struct Lisp_Sqlite Lisp_Sqlite; |
| 166 | struct Lisp_User_Ptr Lisp_User_Ptr; | 163 | struct Lisp_User_Ptr Lisp_User_Ptr; |
| 167 | struct Lisp_Vector Lisp_Vector; | ||
| 168 | struct terminal terminal; | 164 | struct terminal terminal; |
| 169 | struct thread_state thread_state; | 165 | struct thread_state thread_state; |
| 170 | struct window window; | 166 | struct window window; |
| 171 | 167 | ||
| 172 | /* Omit the following since they would require including process.h | 168 | /* Omit the following since they would require including process.h |
| 173 | etc. In practice their alignments never exceed that of the | 169 | etc, or because they are defined with flexible array members, which |
| 174 | structs already listed. */ | 170 | are rejected by some C99 compilers when this union subsequently |
| 171 | appears in an `alignof' expression. In practice their alignments | ||
| 172 | never exceed that of the structs already listed. */ | ||
| 175 | #if 0 | 173 | #if 0 |
| 174 | struct Lisp_Bool_Vector Lisp_Bool_Vector; | ||
| 175 | struct Lisp_Char_Table Lisp_Char_Table; | ||
| 176 | struct Lisp_Sub_Char_Table Lisp_Sub_Char_Table; | ||
| 176 | struct Lisp_Module_Function Lisp_Module_Function; | 177 | struct Lisp_Module_Function Lisp_Module_Function; |
| 177 | struct Lisp_Process Lisp_Process; | 178 | struct Lisp_Process Lisp_Process; |
| 179 | struct Lisp_Vector Lisp_Vector; | ||
| 178 | struct save_window_data save_window_data; | 180 | struct save_window_data save_window_data; |
| 179 | struct scroll_bar scroll_bar; | 181 | struct scroll_bar scroll_bar; |
| 180 | struct xwidget_view xwidget_view; | 182 | struct xwidget_view xwidget_view; |
| @@ -5167,14 +5169,20 @@ mark_memory (void const *start, void const *end) | |||
| 5167 | for (pp = start; (void const *) pp < end; pp += GC_POINTER_ALIGNMENT) | 5169 | for (pp = start; (void const *) pp < end; pp += GC_POINTER_ALIGNMENT) |
| 5168 | { | 5170 | { |
| 5169 | void *p = *(void *const *) pp; | 5171 | void *p = *(void *const *) pp; |
| 5172 | intptr_t ip; | ||
| 5173 | |||
| 5174 | #if !USE_LSB_TAG && !defined WIDE_EMACS_INT | ||
| 5175 | ip = (intptr_t) p; | ||
| 5176 | mark_maybe_pointer ((void *) (ip & VALMASK), false); | ||
| 5177 | #else /* USE_LSB_TAG || WIDE_EMACS_INT */ | ||
| 5170 | mark_maybe_pointer (p, false); | 5178 | mark_maybe_pointer (p, false); |
| 5179 | #endif /* USE_LSB_TAG || WIDE_EMACS_INT */ | ||
| 5171 | 5180 | ||
| 5172 | /* Unmask any struct Lisp_Symbol pointer that make_lisp_symbol | 5181 | /* Unmask any struct Lisp_Symbol pointer that make_lisp_symbol |
| 5173 | previously disguised by adding the address of 'lispsym'. | 5182 | previously disguised by adding the address of 'lispsym'. |
| 5174 | On a host with 32-bit pointers and 64-bit Lisp_Objects, | 5183 | On a host with 32-bit pointers and 64-bit Lisp_Objects, |
| 5175 | a Lisp_Object might be split into registers saved into | 5184 | a Lisp_Object might be split into registers saved into |
| 5176 | non-adjacent words and P might be the low-order word's value. */ | 5185 | non-adjacent words and P might be the low-order word's value. */ |
| 5177 | intptr_t ip; | ||
| 5178 | ckd_add (&ip, (intptr_t) p, (intptr_t) lispsym); | 5186 | ckd_add (&ip, (intptr_t) p, (intptr_t) lispsym); |
| 5179 | mark_maybe_pointer ((void *) ip, true); | 5187 | mark_maybe_pointer ((void *) ip, true); |
| 5180 | } | 5188 | } |