From 6f324ad9fffabd8f516a475f168e954d9be9c9df Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Fri, 25 Jul 2025 13:16:37 -0600 Subject: [PATCH] Revert "Attempt to remove deprecated sv_locking/unlocking" This reverts commit 3afafdb6cda45b8879aa284d5fb90c3446584bfc. It turns out that Perl_sv_nounlocking() is the mechanism that is used to make sure mathoms.c gets loaded, as the comments in the reverted commit say, but which I had not noticed. Without this function being in mathoms.c, some build configurations will not load mathoms, leaving other functions in mathoms.c undefined, as happened with the two issues this fixes. This commit could be reinstated if another method is created to force mathoms to be loaded; This fixes #23473 This fixes #23474 --- embed.fnc | 3 +++ embed.h | 2 ++ intrpvar.h | 8 +++++++- mathoms.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ pod/perldelta.pod | 3 +-- proto.h | 10 ++++++++++ 6 files changed, 68 insertions(+), 3 deletions(-) diff --git a/embed.fnc b/embed.fnc index 0c19d7288004..57abee4e02da 100644 --- a/embed.fnc +++ b/embed.fnc @@ -3274,7 +3274,10 @@ ARdp |SV * |sv_mortalcopy_flags \ |U32 flags ARdp |SV * |sv_newmortal Cdp |SV * |sv_newref |NULLOK SV * const sv +ADbdp |void |sv_nolocking |NULLOK SV *sv + Adp |void |sv_nosharing |NULLOK SV *sv +ADbdp |void |sv_nounlocking |NULLOK SV *sv : Used in pp.c, pp_hot.c, sv.c dpx |SV * |sv_2num |NN SV * const sv Adm |bool |sv_numeq |NULLOK SV *sv1 \ diff --git a/embed.h b/embed.h index 505fcb3a8933..ca7a782babe1 100644 --- a/embed.h +++ b/embed.h @@ -923,6 +923,8 @@ # endif # endif # if !defined(NO_MATHOMS) +# define sv_nolocking(a) Perl_sv_nolocking(aTHX_ a) +# define sv_nounlocking(a) Perl_sv_nounlocking(aTHX_ a) # define utf8_to_uvchr(a,b) Perl_utf8_to_uvchr(aTHX_ a,b) # define utf8_to_uvuni(a,b) Perl_utf8_to_uvuni(aTHX_ a,b) # define utf8n_to_uvuni(a,b,c,d) Perl_utf8n_to_uvuni(aTHX_ a,b,c,d) diff --git a/intrpvar.h b/intrpvar.h index 4d109bac0a4d..cc5c41f951fc 100644 --- a/intrpvar.h +++ b/intrpvar.h @@ -936,7 +936,13 @@ PERLVARI(I, lockhook, share_proc_t, Perl_sv_nosharing) GCC_DIAG_IGNORE(-Wdeprecated-declarations) MSVC_DIAG_IGNORE(4996) -PERLVARI(I, unlockhook, share_proc_t, Perl_sv_nosharing) +#ifdef NO_MATHOMS +# define PERL_UNLOCK_HOOK Perl_sv_nosharing +#else +/* This reference ensures that the mathoms are linked with perl */ +# define PERL_UNLOCK_HOOK Perl_sv_nounlocking +#endif +PERLVARI(I, unlockhook, share_proc_t, PERL_UNLOCK_HOOK) MSVC_DIAG_RESTORE GCC_DIAG_RESTORE diff --git a/mathoms.c b/mathoms.c index 56c898ac62dc..7af34aa9f778 100644 --- a/mathoms.c +++ b/mathoms.c @@ -437,6 +437,51 @@ Perl_do_aexec(pTHX_ SV *really, SV **mark, SV **sp) } #endif +/* +=for apidoc_section $SV +=for apidoc sv_nolocking + +Dummy routine which "locks" an SV when there is no locking module present. +Exists to avoid test for a C function pointer and because it could +potentially warn under some level of strict-ness. + +"Superseded" by C. + +=cut +*/ + +void +Perl_sv_nolocking(pTHX_ SV *sv) +{ + PERL_UNUSED_CONTEXT; + PERL_UNUSED_ARG(sv); +} + + +/* +=for apidoc_section $SV +=for apidoc sv_nounlocking + +Dummy routine which "unlocks" an SV when there is no locking module present. +Exists to avoid test for a C function pointer and because it could +potentially warn under some level of strict-ness. + +"Superseded" by C. + +=cut + +PERL_UNLOCK_HOOK in intrpvar.h is the macro that refers to this, and guarantees +that mathoms gets loaded. + +*/ + +void +Perl_sv_nounlocking(pTHX_ SV *sv) +{ + PERL_UNUSED_CONTEXT; + PERL_UNUSED_ARG(sv); +} + void Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len) { diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 3111cf685fbe..2193bff2f318 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -349,8 +349,7 @@ well. =item * -Removed the deprecated (since 5.32) functions C and -C. +XXX =back diff --git a/proto.h b/proto.h index 9553b735a6e1..55c18d2c4aa1 100644 --- a/proto.h +++ b/proto.h @@ -6052,6 +6052,16 @@ Perl_sv_mortalcopy(pTHX_ SV * const oldsv) __attribute__warn_unused_result__; # define PERL_ARGS_ASSERT_SV_MORTALCOPY +PERL_CALLCONV void +Perl_sv_nolocking(pTHX_ SV *sv) + __attribute__deprecated__; +# define PERL_ARGS_ASSERT_SV_NOLOCKING + +PERL_CALLCONV void +Perl_sv_nounlocking(pTHX_ SV *sv) + __attribute__deprecated__; +# define PERL_ARGS_ASSERT_SV_NOUNLOCKING + PERL_CALLCONV char * Perl_sv_pv(pTHX_ SV *sv) __attribute__warn_unused_result__;