From 2f2b8926845e758620c91adffe34e706ccc8d03d Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Wed, 9 Oct 2024 20:30:09 +0100 Subject: [PATCH] Declare the XSUB function for builtin::indexed via embed.fnc so that op.c can take its address --- builtin.c | 7 +++++-- embed.fnc | 2 ++ embed.h | 1 + op.c | 5 +---- proto.h | 6 ++++++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/builtin.c b/builtin.c index 34865ec9a4bb..acd5635e2cae 100644 --- a/builtin.c +++ b/builtin.c @@ -490,9 +490,12 @@ static OP *ck_builtin_func1(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) } } -XS(XS_builtin_indexed) +/* This does not use the XS() macro so that op.c can see its prototype */ +void +Perl_XS_builtin_indexed(pTHX_ CV *cv) { dXSARGS; + PERL_ARGS_ASSERT_XS_BUILTIN_INDEXED; switch(GIMME_V) { case G_VOID: @@ -638,7 +641,7 @@ static const struct BuiltinFuncDescriptor builtins[] = { { "load_module", NO_BUNDLE, &XS_builtin_load_module, &ck_builtin_func1, 0, true }, /* list functions */ - { "indexed", SHORTVER(5,39), &XS_builtin_indexed, &ck_builtin_funcN, 0, false }, + { "indexed", SHORTVER(5,39), &Perl_XS_builtin_indexed, &ck_builtin_funcN, 0, false }, { "export_lexically", NO_BUNDLE, &XS_builtin_export_lexically, NULL, 0, true }, { NULL, 0, NULL, NULL, 0, false } diff --git a/embed.fnc b/embed.fnc index f490397f7de6..9825bb84f11d 100644 --- a/embed.fnc +++ b/embed.fnc @@ -4087,6 +4087,8 @@ p |void |finish_export_lexical p |void |import_builtin_bundle \ |U16 ver p |void |prepare_export_lexical +p |void |XS_builtin_indexed \ + |NN CV *cv #endif #if defined(PERL_IN_CLASS_C) || defined(PERL_IN_OP_C) || \ defined(PERL_IN_PAD_C) || defined(PERL_IN_PERLY_C) || \ diff --git a/embed.h b/embed.h index 74aaea51bcd5..b14bf0a70bdd 100644 --- a/embed.h +++ b/embed.h @@ -1202,6 +1202,7 @@ # define get_aux_mg(a) S_get_aux_mg(aTHX_ a) # endif # if defined(PERL_IN_BUILTIN_C) || defined(PERL_IN_OP_C) +# define XS_builtin_indexed(a) Perl_XS_builtin_indexed(aTHX_ a) # define finish_export_lexical() Perl_finish_export_lexical(aTHX) # define import_builtin_bundle(a) Perl_import_builtin_bundle(aTHX_ a) # define prepare_export_lexical() Perl_prepare_export_lexical(aTHX) diff --git a/op.c b/op.c index bc8df993cfaa..9dc1c79dc1cc 100644 --- a/op.c +++ b/op.c @@ -171,9 +171,6 @@ recursive, but it's recursive on basic blocks, not on tree nodes. static const char array_passed_to_stat[] = "Array passed to stat will be coerced to a scalar"; -/* UGH!! */ -EXTERN_C void XS_builtin_indexed(pTHX_ CV *); - /* remove any leading "empty" ops from the op_next chain whose first * node's address is stored in op_p. Store the updated address of the * first node in op_p. @@ -9825,7 +9822,7 @@ Perl_newFOROP(pTHX_ I32 flags, OP *sv, OP *expr, OP *block, OP *cont) if(firstarg == lastarg) firstarg = NULL; - if (op_is_cv_xsub(lastarg, &XS_builtin_indexed) && /* a call to builtin::indexed */ + if (op_is_cv_xsub(lastarg, &Perl_XS_builtin_indexed) && /* a call to builtin::indexed */ firstarg && OpSIBLING(firstarg) == lastarg && /* with one arg */ (firstarg->op_type == OP_RV2AV || firstarg->op_type == OP_PADAV) /* ... which is an array */ ) { diff --git a/proto.h b/proto.h index cb2fa83c0dfd..a5f5fd2e1271 100644 --- a/proto.h +++ b/proto.h @@ -6202,6 +6202,12 @@ S_get_aux_mg(pTHX_ AV *av); #endif #if defined(PERL_IN_BUILTIN_C) || defined(PERL_IN_OP_C) +PERL_CALLCONV void +Perl_XS_builtin_indexed(pTHX_ CV *cv) + __attribute__visibility__("hidden"); +# define PERL_ARGS_ASSERT_XS_BUILTIN_INDEXED \ + assert(cv); assert(SvTYPE(cv) == SVt_PVCV || SvTYPE(cv) == SVt_PVFM) + PERL_CALLCONV void Perl_finish_export_lexical(pTHX) __attribute__visibility__("hidden");