Inline::C uses its own Inline_Stack_(Vars|Reset|Done) macros in place of XS's dSP|EXTEND macros.
Inline_Stack_Push is used instead of mPUSHi, although you can still use the mXPUSHi form to simplify.
See "#The_Inline_Stack_Macros" in Inline::C.
The Inline docs say that you should be able to use the old macros, but I cannot see how to make that work.
Having made the changes mentioned above, this code now works for me:
#! perl -slw
use strict;
use Inline C => Config => BUILD_NOISY => 1;
use Inline C => <<'END_C', NAME => 'rand64fast', CLEAN_AFTER_BUILD =>
+ 0;
void rnd( int n ) {
// dSP;
// static __int64 y = 2463534242;
static int y = 2463534242; // My machine is 32-bit.
// EXTEND( SP, n );
Inline_Stack_Vars;
Inline_Stack_Reset;
while( --n ) {
y ^= y << 13;
y ^= y >> 17;
y ^= y << 5;
// mPUSHi( (IV)y );
Inline_Stack_Push( sv_2mortal( newSViv(y) ) );
// mXPUSHi(y); // Could have used this instead. Note the added
+ X
}
// return;
Inline_Stack_Done;
}
END_C
print for rnd( 100 );
Caveat: All my XS knowledge predates Inline::C, so any of the above could be flawed in minor ways.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|