summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-07 16:30:32 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-07 16:30:32 +0100
commite9b067d91703bf151aa6769b5c49fb95a91f6fa5 (patch)
treeaf044dc7ae0745b91d42609bb05337360bc0f757 /util.c
parent7b20c7cd49d506897c54f5ed022a5e5b5f8c594a (diff)
downloadperl-e9b067d91703bf151aa6769b5c49fb95a91f6fa5.tar.gz
Convert the implementation of XS_VERSION_BOOTCHECK to a function from a macro.
The macro expansion generates over 1K of object code. This is in every shared object, and is only called once. Hence this change increases the perl binary by about 1K (once), to save 1K for every XS module loaded.
Diffstat (limited to 'util.c')
-rw-r--r--util.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/util.c b/util.c
index 75dbc1bf65..b1b2af5d3b 100644
--- a/util.c
+++ b/util.c
@@ -6471,6 +6471,49 @@ Perl_my_cxt_init(pTHX_ const char *my_cxt_key, size_t size)
#endif /* #ifndef PERL_GLOBAL_STRUCT_PRIVATE */
#endif /* PERL_IMPLICIT_CONTEXT */
+void
+Perl_xs_version_bootcheck(pTHX_ U32 items, U32 ax, const char *xs_p,
+ STRLEN xs_len)
+{
+ SV *sv;
+ const char *vn = NULL;
+ const char *module = SvPV_nolen_const(PL_stack_base[ax]);
+
+ PERL_ARGS_ASSERT_XS_VERSION_BOOTCHECK;
+
+ if (items >= 2) /* version supplied as bootstrap arg */
+ sv = PL_stack_base[ax + 1];
+ else {
+ /* XXX GV_ADDWARN */
+ sv = get_sv(Perl_form(aTHX_ "%s::%s", module, vn = "XS_VERSION"), 0);
+ if (!sv || !SvOK(sv))
+ sv = get_sv(Perl_form(aTHX_ "%s::%s", module, vn = "VERSION"), 0);
+ }
+ if (sv) {
+ SV *xpt = NULL;
+ SV *xssv = Perl_newSVpvn(aTHX_ xs_p, xs_len);
+ SV *pmsv = sv_derived_from(sv, "version")
+ ? SvREFCNT_inc_simple_NN(sv)
+ : new_version(sv);
+ xssv = upg_version(xssv, 0);
+ if ( vcmp(pmsv,xssv) ) {
+ xpt = Perl_newSVpvf(aTHX_ "%s object version %"SVf
+ " does not match %s%s%s%s %"SVf,
+ module,
+ SVfARG(Perl_sv_2mortal(aTHX_ vstringify(xssv))),
+ vn ? "$" : "", vn ? module : "",
+ vn ? "::" : "",
+ vn ? vn : "bootstrap parameter",
+ SVfARG(Perl_sv_2mortal(aTHX_ vstringify(pmsv))));
+ Perl_sv_2mortal(aTHX_ xpt);
+ }
+ SvREFCNT_dec(xssv);
+ SvREFCNT_dec(pmsv);
+ if (xpt)
+ Perl_croak_sv(aTHX_ xpt);
+ }
+}
+
#ifndef HAS_STRLCAT
Size_t
Perl_my_strlcat(char *dst, const char *src, Size_t size)