Thanks! I've found statement in intrpvar.h:
PERLVAR(I, stack_sp, SV **) /* top of the stack */
and in perl.h:
# define PERLVAR(prefix,var,type) type prefix##var;
/* 'var' is an array of length 'n' */
# define PERLVARA(prefix,var,n,type) type prefix##var[n];
/* initialize 'var' to init' */
# define PERLVARI(prefix,var,type,init) type prefix##var;
/* like PERLVARI, but make 'var' a const */
# define PERLVARIC(prefix,var,type,init) type prefix##var;
struct interpreter {
# include "intrpvar.h"
};
So perl use PERLVAR to define perlinterpreter struct, it's strange to me, why is it not define perlinterpreter structure directly in perl.h?
Please enlighten me.
I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction
| [reply] [d/l] |
The perl binary has multiple ways in which it can be built. The simplest (and original) model just defines PL_stack_sp directly as a global variable. But when built with MULTIPLICITY (when for example building a threaded perl), then multiple interpreters are allowed, and (within the core), PL_stack_sp is defined as my_perl->Ispack_sp.
However in XS code (rather than in the core), it's more complex. At one point PL_stack_sp was defined as a function call, which would shield the XS code from changes in the interpreter struct layout across differing perl versions - so XS modules wouldn't have be to recompiled for each new perl release. However, this slowed XS code down a lot, and there were other things which also broke binary compatibility, so that was ditched and we just changed the binary guarantee to apply only across minor releases.
Dave.
| [reply] |