summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-08 16:13:38 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-08 16:58:10 +0100
commit379a89070cf5bdcfa33b12551d2c9ef0a3e11418 (patch)
treecb9b0b65bb4e6d39f6ab346c09997551637e148f
parent88c4b02d8afbe13e65dd6f677f5056354ec301cb (diff)
downloadperl-379a89070cf5bdcfa33b12551d2c9ef0a3e11418.tar.gz
Convert the implementation of XS_APIVERSION_BOOTCHECK to a function.
The previous macro generated over .5K of object code. This is in every shared object, and is only called once. Hence this change increases the perl binary by about .5K (once), to save .5K for every XS module loaded.
-rw-r--r--XSUB.h19
-rw-r--r--embed.fnc4
-rw-r--r--global.sym1
-rw-r--r--proto.h6
-rw-r--r--util.c25
5 files changed, 37 insertions, 18 deletions
diff --git a/XSUB.h b/XSUB.h
index 174ce886d6..6906ded1f9 100644
--- a/XSUB.h
+++ b/XSUB.h
@@ -304,24 +304,7 @@ Rethrows a previously caught exception. See L<perlguts/"Exception Handling">.
#endif
#define XS_APIVERSION_BOOTCHECK \
- STMT_START { \
- SV *_xpt = NULL; \
- SV *_compver = Perl_newSVpv(aTHX_ "v" PERL_API_VERSION_STRING, 0); \
- SV *_runver = new_version(PL_apiversion); \
- _compver = upg_version(_compver, 0); \
- if (vcmp(_compver, _runver)) { \
- _xpt = Perl_newSVpvf(aTHX_ "Perl API version %"SVf \
- " of %s does not match %"SVf, \
- SVfARG(Perl_sv_2mortal(aTHX_ vstringify(_compver))), \
- SvPV_nolen_const(ST(0)), \
- SVfARG(Perl_sv_2mortal(aTHX_ vstringify(_runver)))); \
- Perl_sv_2mortal(aTHX_ _xpt); \
- } \
- SvREFCNT_dec(_compver); \
- SvREFCNT_dec(_runver); \
- if (_xpt) \
- Perl_croak_sv(aTHX_ _xpt); \
- } STMT_END
+ Perl_xs_apiversion_bootcheck(aTHX_ ST(0), STR_WITH_LEN("v" PERL_API_VERSION_STRING))
#ifdef NO_XSLOCKS
# define dXCPT dJMPENV; int rEtV = 0
diff --git a/embed.fnc b/embed.fnc
index bae3e4ab6e..3ddf03dd31 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -2259,6 +2259,10 @@ Apo |void* |my_cxt_init |NN int *index|size_t size
: XS_VERSION_BOOTCHECK
Xpo |void |xs_version_bootcheck|U32 items|U32 ax|NN const char *xs_p \
|STRLEN xs_len
+: This function is an implementation detail. The public API for this is
+: XS_APIVERSION_BOOTCHECK
+Xpo |void |xs_apiversion_bootcheck|NN SV *module|NN const char *api_p \
+ |STRLEN api_len
#ifndef HAS_STRLCAT
Apno |Size_t |my_strlcat |NULLOK char *dst|NULLOK const char *src|Size_t size
diff --git a/global.sym b/global.sym
index a429d93529..203affb52c 100644
--- a/global.sym
+++ b/global.sym
@@ -742,6 +742,7 @@ Perl_warn
Perl_warn_sv
Perl_warner
Perl_whichsig
+Perl_xs_apiversion_bootcheck
Perl_xs_version_bootcheck
Perl_yylex
Perl_utf8n_to_uvchr
diff --git a/proto.h b/proto.h
index fffbdca52f..8a020f5d44 100644
--- a/proto.h
+++ b/proto.h
@@ -4687,6 +4687,12 @@ PERL_CALLCONV void Perl_write_to_stderr(pTHX_ SV* msv)
#define PERL_ARGS_ASSERT_WRITE_TO_STDERR \
assert(msv)
+PERL_CALLCONV void Perl_xs_apiversion_bootcheck(pTHX_ SV *module, const char *api_p, STRLEN api_len)
+ __attribute__nonnull__(pTHX_1)
+ __attribute__nonnull__(pTHX_2);
+#define PERL_ARGS_ASSERT_XS_APIVERSION_BOOTCHECK \
+ assert(module); assert(api_p)
+
PERL_CALLCONV void Perl_xs_version_bootcheck(pTHX_ U32 items, U32 ax, const char *xs_p, STRLEN xs_len)
__attribute__nonnull__(pTHX_3);
#define PERL_ARGS_ASSERT_XS_VERSION_BOOTCHECK \
diff --git a/util.c b/util.c
index 427f053a79..9375bd2789 100644
--- a/util.c
+++ b/util.c
@@ -6514,6 +6514,31 @@ Perl_xs_version_bootcheck(pTHX_ U32 items, U32 ax, const char *xs_p,
}
}
+void
+Perl_xs_apiversion_bootcheck(pTHX_ SV *module, const char *api_p,
+ STRLEN api_len)
+{
+ SV *xpt = NULL;
+ SV *compver = Perl_newSVpvn(aTHX_ api_p, api_len);
+ SV *runver = new_version(PL_apiversion);
+
+ PERL_ARGS_ASSERT_XS_APIVERSION_BOOTCHECK;
+
+ compver = upg_version(compver, 0);
+ if (vcmp(compver, runver)) {
+ xpt = Perl_newSVpvf(aTHX_ "Perl API version %"SVf
+ " of %s does not match %"SVf,
+ SVfARG(Perl_sv_2mortal(aTHX_ vstringify(compver))),
+ SvPV_nolen_const(module),
+ SVfARG(Perl_sv_2mortal(aTHX_ vstringify(runver))));
+ Perl_sv_2mortal(aTHX_ xpt);
+ }
+ SvREFCNT_dec(compver);
+ SvREFCNT_dec(runver);
+ if (xpt)
+ Perl_croak_sv(aTHX_ xpt);
+}
+
#ifndef HAS_STRLCAT
Size_t
Perl_my_strlcat(char *dst, const char *src, Size_t size)