From 9c222b9c1a7f91497a37567b4d7de3a511fff069 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 2 Dec 2021 19:01:33 -0800 Subject: 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. --- src/alloc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/alloc.c') 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) module_finalize_function (function); } #endif - else if (NATIVE_COMP_FLAG - && PSEUDOVECTOR_TYPEP (&vector->header, PVEC_NATIVE_COMP_UNIT)) +#ifdef HAVE_NATIVE_COMP + else if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_NATIVE_COMP_UNIT)) { struct Lisp_Native_Comp_Unit *cu = PSEUDOVEC_STRUCT (vector, Lisp_Native_Comp_Unit); unload_comp_unit (cu); } - else if (NATIVE_COMP_FLAG - && PSEUDOVECTOR_TYPEP (&vector->header, PVEC_SUBR)) + else if (PSEUDOVECTOR_TYPEP (&vector->header, PVEC_SUBR)) { struct Lisp_Subr *subr = PSEUDOVEC_STRUCT (vector, Lisp_Subr); - if (!NILP (subr->native_comp_u[0])) + if (!NILP (subr->native_comp_u)) { /* FIXME Alternative and non invasive solution to this cast? */ xfree ((char *)subr->symbol_name); - xfree (subr->native_c_name[0]); + xfree (subr->native_c_name); } } +#endif } /* Reclaim space used by unmarked vectors. */ @@ -6773,15 +6773,17 @@ mark_object (Lisp_Object arg) break; case PVEC_SUBR: +#ifdef HAVE_NATIVE_COMP if (SUBR_NATIVE_COMPILEDP (obj)) { set_vector_marked (ptr); struct Lisp_Subr *subr = XSUBR (obj); mark_object (subr->native_intspec); - mark_object (subr->native_comp_u[0]); - mark_object (subr->lambda_list[0]); - mark_object (subr->type[0]); + mark_object (subr->native_comp_u); + mark_object (subr->lambda_list); + mark_object (subr->type); } +#endif break; case PVEC_FREE: -- cgit v1.2.1