diff options
| author | Paul Eggert | 2021-12-02 19:01:33 -0800 |
|---|---|---|
| committer | Paul Eggert | 2021-12-02 19:03:14 -0800 |
| commit | 9c222b9c1a7f91497a37567b4d7de3a511fff069 (patch) | |
| tree | a0e9016aac8318734b5e9d744f9cc1502bef72f3 /src/alloc.c | |
| parent | fed35a89517aa4e282273f7e3c75bafd4e698ce4 (diff) | |
| download | emacs-9c222b9c1a7f91497a37567b4d7de3a511fff069.tar.gz emacs-9c222b9c1a7f91497a37567b4d7de3a511fff069.zip | |
Port to C compilers that lack size-0 arrays
The C standard does not allow size-zero arrays, so redo struct
Lisp_Subr to not use size-zero arrays when native compilation is
not being used. Formerly, the code was using size-zero arrays (a
GNU C extension) to avoid using memory unnecessarily when
HAVE_NATIVE_COMP is not defined. Replace this hack with the
more-traditional hack of putting the relevant members inside
‘#ifdef HAVE_NATIVE_COMP’.
* src/alloc.c (cleanup_vector, mark_object):
* src/comp.c (make_subr):
* src/data.c (Fsubr_native_lambda_list, Fsubr_native_comp_unit):
* src/eval.c (init_eval_once, funcall_lambda):
* src/lisp.h (SUBR_NATIVE_COMPILEDP, SUBR_NATIVE_COMPILED_DYNP)
(SUBR_TYPE):
* src/lread.c (Fload):
Conditionally compile with ‘#ifdef HAVE_NATIVE_COMP’ instead of
with ‘if (NATIVE_COMP_FLAG)’. Redo members like native_comp_u[0]
to be plain native_comp_u. Put all uses of these members inside
‘#ifdef HAVE_NATIVE_COMP’.
* src/lisp.h (struct Lisp_Subr): Members native_comp_u,
native_c_name, lambda_list, type are now all ifdeffed out if
HAVE_NATIVE_COMP is not defined, instead of being size-zero
arrays. All uses changed.
* src/pdumper.c (dump_subr, dump_cold_native_subr)
(dump_do_dump_relocation):
* src/comp.h (NATIVE_COMP_FLAG): Remove; no longer needed.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/alloc.c b/src/alloc.c index 0c04d5cde05..e2184d7ba86 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3152,26 +3152,26 @@ cleanup_vector (struct Lisp_Vector *vector) | |||
| 3152 | module_finalize_function (function); | 3152 | module_finalize_function (function); |
| 3153 | } | 3153 | } |
| 3154 | #endif | 3154 | #endif |
| 3155 | else if (NATIVE_COMP_FLAG | 3155 | #ifdef HAVE_NATIVE_COMP |
| 3156 | && PSEUDOVECTOR_TYPEP (&vector->header, PVEC_NATIVE_COMP_UNIT)) | 3156 | else if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_NATIVE_COMP_UNIT)) |
| 3157 | { | 3157 | { |
| 3158 | struct Lisp_Native_Comp_Unit *cu = | 3158 | struct Lisp_Native_Comp_Unit *cu = |
| 3159 | PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit); | 3159 | PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit); |
| 3160 | unload_comp_unit (cu); | 3160 | unload_comp_unit (cu); |
| 3161 | } | 3161 | } |
| 3162 | else if (NATIVE_COMP_FLAG | 3162 | else if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_SUBR)) |
| 3163 | && PSEUDOVECTOR_TYPEP (&vector->header, PVEC_SUBR)) | ||
| 3164 | { | 3163 | { |
| 3165 | struct Lisp_Subr *subr = | 3164 | struct Lisp_Subr *subr = |
| 3166 | PSEUDOVEC_STRUCT (vector, Lisp_Subr); | 3165 | PSEUDOVEC_STRUCT (vector, Lisp_Subr); |
| 3167 | if (!NILP (subr->native_comp_u[0])) | 3166 | if (!NILP (subr->native_comp_u)) |
| 3168 | { | 3167 | { |
| 3169 | /* FIXME Alternative and non invasive solution to this | 3168 | /* FIXME Alternative and non invasive solution to this |
| 3170 | cast? */ | 3169 | cast? */ |
| 3171 | xfree ((char *)subr->symbol_name); | 3170 | xfree ((char *)subr->symbol_name); |
| 3172 | xfree (subr->native_c_name[0]); | 3171 | xfree (subr->native_c_name); |
| 3173 | } | 3172 | } |
| 3174 | } | 3173 | } |
| 3174 | #endif | ||
| 3175 | } | 3175 | } |
| 3176 | 3176 | ||
| 3177 | /* Reclaim space used by unmarked vectors. */ | 3177 | /* Reclaim space used by unmarked vectors. */ |
| @@ -6773,15 +6773,17 @@ mark_object (Lisp_Object arg) | |||
| 6773 | break; | 6773 | break; |
| 6774 | 6774 | ||
| 6775 | case PVEC_SUBR: | 6775 | case PVEC_SUBR: |
| 6776 | #ifdef HAVE_NATIVE_COMP | ||
| 6776 | if (SUBR_NATIVE_COMPILEDP (obj)) | 6777 | if (SUBR_NATIVE_COMPILEDP (obj)) |
| 6777 | { | 6778 | { |
| 6778 | set_vector_marked (ptr); | 6779 | set_vector_marked (ptr); |
| 6779 | struct Lisp_Subr *subr = XSUBR (obj); | 6780 | struct Lisp_Subr *subr = XSUBR (obj); |
| 6780 | mark_object (subr->native_intspec); | 6781 | mark_object (subr->native_intspec); |
| 6781 | mark_object (subr->native_comp_u[0]); | 6782 | mark_object (subr->native_comp_u); |
| 6782 | mark_object (subr->lambda_list[0]); | 6783 | mark_object (subr->lambda_list); |
| 6783 | mark_object (subr->type[0]); | 6784 | mark_object (subr->type); |
| 6784 | } | 6785 | } |
| 6786 | #endif | ||
| 6785 | break; | 6787 | break; |
| 6786 | 6788 | ||
| 6787 | case PVEC_FREE: | 6789 | case PVEC_FREE: |