summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-28 14:57:13 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-29 14:42:41 +0100
commitc0fdee650ccddaa4a1d2adf7745aed02dbb0a602 (patch)
tree9f2466bb61f2772af3cd62672da6692d3213df4d
parentf800d0e18f11d3c11bd1daa3a3643fef23b55dd1 (diff)
downloadperl-c0fdee650ccddaa4a1d2adf7745aed02dbb0a602.tar.gz
Refactor FastCalc to initialise BASE and BASE_LEN as part of bootstrap.
This avoids the need for a separate, special, one-shot _set_XS_BASE routine. We take advantage of the fact that all arguments to XSLoader::load() are passed on to the module's bootstrap routine.
-rw-r--r--dist/Math-BigInt-FastCalc/FastCalc.pm11
-rw-r--r--dist/Math-BigInt-FastCalc/FastCalc.xs15
2 files changed, 9 insertions, 17 deletions
diff --git a/dist/Math-BigInt-FastCalc/FastCalc.pm b/dist/Math-BigInt-FastCalc/FastCalc.pm
index e574655e3e..bc7ab94f41 100644
--- a/dist/Math-BigInt-FastCalc/FastCalc.pm
+++ b/dist/Math-BigInt-FastCalc/FastCalc.pm
@@ -10,9 +10,6 @@ use vars qw/$VERSION $BASE $BASE_LEN/;
$VERSION = '0.24';
-require XSLoader;
-XSLoader::load(__PACKAGE__);
-
##############################################################################
# global constants, flags and accessory
@@ -41,15 +38,11 @@ BEGIN
*{'Math::BigInt::FastCalc::_' . $method} = \&{'Math::BigInt::Calc::_' . $method};
}
- # store BASE_LEN and BASE to later pass it to XS code
($BASE_LEN, $BASE) = Math::BigInt::Calc::_base_len();
-
}
-sub import
- {
- _set_XS_BASE($BASE, $BASE_LEN);
- }
+require XSLoader;
+XSLoader::load(__PACKAGE__, $VERSION, $BASE_LEN, $BASE);
##############################################################################
##############################################################################
diff --git a/dist/Math-BigInt-FastCalc/FastCalc.xs b/dist/Math-BigInt-FastCalc/FastCalc.xs
index 33f4b130e0..dfff9f4382 100644
--- a/dist/Math-BigInt-FastCalc/FastCalc.xs
+++ b/dist/Math-BigInt-FastCalc/FastCalc.xs
@@ -34,14 +34,13 @@ PROTOTYPES: DISABLE
ST(0) = sv_2mortal(newSViv(value)); \
XSRETURN(1);
-void
-_set_XS_BASE(BASE, BASE_LEN)
- SV* BASE
- SV* BASE_LEN
-
- CODE:
- XS_BASE = SvNV(BASE);
- XS_BASE_LEN = SvIV(BASE_LEN);
+BOOT:
+{
+ if (items < 4)
+ S_croak_xs_usage(aTHX_ cv, "package, version, base_len, base");
+ XS_BASE_LEN = SvIV(ST(2));
+ XS_BASE = SvNV(ST(3));
+}
##############################################################################
# _new