Skip to content

Commit 8444d54

Browse files
committed
Move prototype definition of SvPV_helper to embed.fnc
It's usually a bad idea to try to work around a limitation in common code by copy-pasting and then modifiying to taste. Fixes/improvements to the common code rarely get propagated to the outlier. I wrote code in 1ef9039 that did just this for the prototype definition of SvPV_helper, because the place where it really belongs, embed.fnc, couldn't (and still doesn't) handle function pointers as arguments (patches welcome). I should have at least added a comment to the common code noting the existence of this outlier. It turns out that that limitation can be worked around by declaring a typedef of the pointer, and then using that in embed.fnc. That's what this commit does. This commit removes the final instance of duplicating the work of embed.fnc in the core, except for some in the regex system whose comments say the reason is to avoid making a typedef public. I haven't investigated these further.
1 parent 4610cbf commit 8444d54

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

embed.fnc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3374,6 +3374,13 @@ CRdmp |char * |sv_2pvbyte_nolen \
33743374
Adp |char * |sv_2pv_flags |NN SV * const sv \
33753375
|NULLOK STRLEN * const lp \
33763376
|const U32 flags
3377+
Cip |char * |SvPV_helper |NN SV * const sv \
3378+
|NN STRLEN * const lp \
3379+
|const U32 flags \
3380+
|const PL_SvPVtype type \
3381+
|NN Perl_SvPV_helper_non_trivial_t non_trivial \
3382+
|const bool or_null \
3383+
|const U32 return_flags
33773384
Cdmp |char * |sv_pvn_force |NN SV *sv \
33783385
|NULLOK STRLEN *lp
33793386
Adp |char * |sv_pvn_force_flags \

embed.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
# define SvNV(a) Perl_SvNV(aTHX_ a)
110110
# define SvNV_nomg(a) Perl_SvNV_nomg(aTHX_ a)
111111
# define SvPVXtrue(a) Perl_SvPVXtrue(aTHX_ a)
112+
# define SvPV_helper(a,b,c,d,e,f,g) Perl_SvPV_helper(aTHX_ a,b,c,d,e,f,g)
112113
# define SvREFCNT_dec_ret_NULL(a) Perl_SvREFCNT_dec_ret_NULL(aTHX_ a)
113114
# define SvTRUE(a) Perl_SvTRUE(aTHX_ a)
114115
# define SvTRUE_NN(a) Perl_SvTRUE_NN(aTHX_ a)

proto.h

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sv.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,16 +1958,8 @@ typedef enum {
19581958
SvPVbyte_pure_type_
19591959
} PL_SvPVtype;
19601960

1961-
START_EXTERN_C
1962-
1963-
/* When this code was written, embed.fnc could not handle function pointer
1964-
* parameters; perhaps it still can't */
1965-
#ifndef PERL_NO_INLINE_FUNCTIONS
1966-
PERL_STATIC_INLINE char*
1967-
Perl_SvPV_helper(pTHX_ SV *const sv, STRLEN *const lp, const U32 flags, const PL_SvPVtype type, char * (*non_trivial)(pTHX_ SV *, STRLEN * const, const U32), const bool or_null, const U32 return_flags);
1968-
#endif
1969-
1970-
END_EXTERN_C
1961+
typedef char * (*Perl_SvPV_helper_non_trivial_t)(pTHX_ SV *, STRLEN * const,
1962+
const U32);
19711963

19721964
/* This test is "is there a cached PV that we can use directly?"
19731965
* We can if

0 commit comments

Comments
 (0)