| 1 | /* pp.h
|
|---|
| 2 | *
|
|---|
| 3 | * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
|
|---|
| 4 | * 2000, 2001, 2002, 2003, 2004, 2005 by Larry Wall and others
|
|---|
| 5 | *
|
|---|
| 6 | * You may distribute under the terms of either the GNU General Public
|
|---|
| 7 | * License or the Artistic License, as specified in the README file.
|
|---|
| 8 | *
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | #ifdef USE_5005THREADS
|
|---|
| 12 | #define ARGS thr
|
|---|
| 13 | #define dARGS struct perl_thread *thr;
|
|---|
| 14 | #else
|
|---|
| 15 | #define ARGS
|
|---|
| 16 | #define dARGS
|
|---|
| 17 | #endif /* USE_5005THREADS */
|
|---|
| 18 |
|
|---|
| 19 | #define PP(s) OP * Perl_##s(pTHX)
|
|---|
| 20 |
|
|---|
| 21 | /*
|
|---|
| 22 | =head1 Stack Manipulation Macros
|
|---|
| 23 |
|
|---|
| 24 | =for apidoc AmU||SP
|
|---|
| 25 | Stack pointer. This is usually handled by C<xsubpp>. See C<dSP> and
|
|---|
| 26 | C<SPAGAIN>.
|
|---|
| 27 |
|
|---|
| 28 | =for apidoc AmU||MARK
|
|---|
| 29 | Stack marker variable for the XSUB. See C<dMARK>.
|
|---|
| 30 |
|
|---|
| 31 | =for apidoc Am|void|PUSHMARK|SP
|
|---|
| 32 | Opening bracket for arguments on a callback. See C<PUTBACK> and
|
|---|
| 33 | L<perlcall>.
|
|---|
| 34 |
|
|---|
| 35 | =for apidoc Ams||dSP
|
|---|
| 36 | Declares a local copy of perl's stack pointer for the XSUB, available via
|
|---|
| 37 | the C<SP> macro. See C<SP>.
|
|---|
| 38 |
|
|---|
| 39 | =for apidoc ms||djSP
|
|---|
| 40 |
|
|---|
| 41 | Declare Just C<SP>. This is actually identical to C<dSP>, and declares
|
|---|
| 42 | a local copy of perl's stack pointer, available via the C<SP> macro.
|
|---|
| 43 | See C<SP>. (Available for backward source code compatibility with the
|
|---|
| 44 | old (Perl 5.005) thread model.)
|
|---|
| 45 |
|
|---|
| 46 | =for apidoc Ams||dMARK
|
|---|
| 47 | Declare a stack marker variable, C<mark>, for the XSUB. See C<MARK> and
|
|---|
| 48 | C<dORIGMARK>.
|
|---|
| 49 |
|
|---|
| 50 | =for apidoc Ams||dORIGMARK
|
|---|
| 51 | Saves the original stack mark for the XSUB. See C<ORIGMARK>.
|
|---|
| 52 |
|
|---|
| 53 | =for apidoc AmU||ORIGMARK
|
|---|
| 54 | The original stack mark for the XSUB. See C<dORIGMARK>.
|
|---|
| 55 |
|
|---|
| 56 | =for apidoc Ams||SPAGAIN
|
|---|
| 57 | Refetch the stack pointer. Used after a callback. See L<perlcall>.
|
|---|
| 58 |
|
|---|
| 59 | =cut */
|
|---|
| 60 |
|
|---|
| 61 | #undef SP /* Solaris 2.7 i386 has this in /usr/include/sys/reg.h */
|
|---|
| 62 | #define SP sp
|
|---|
| 63 | #define MARK mark
|
|---|
| 64 | #define TARG targ
|
|---|
| 65 |
|
|---|
| 66 | #define PUSHMARK(p) \
|
|---|
| 67 | STMT_START { \
|
|---|
| 68 | if (++PL_markstack_ptr == PL_markstack_max) \
|
|---|
| 69 | markstack_grow(); \
|
|---|
| 70 | *PL_markstack_ptr = (p) - PL_stack_base; \
|
|---|
| 71 | } STMT_END
|
|---|
| 72 |
|
|---|
| 73 | #define TOPMARK (*PL_markstack_ptr)
|
|---|
| 74 | #define POPMARK (*PL_markstack_ptr--)
|
|---|
| 75 |
|
|---|
| 76 | #define dSP register SV **sp = PL_stack_sp
|
|---|
| 77 | #define djSP dSP
|
|---|
| 78 | #define dMARK register SV **mark = PL_stack_base + POPMARK
|
|---|
| 79 | #define dORIGMARK const I32 origmark = mark - PL_stack_base
|
|---|
| 80 | #define ORIGMARK (PL_stack_base + origmark)
|
|---|
| 81 |
|
|---|
| 82 | #define SPAGAIN sp = PL_stack_sp
|
|---|
| 83 | #define MSPAGAIN STMT_START { sp = PL_stack_sp; mark = ORIGMARK; } STMT_END
|
|---|
| 84 |
|
|---|
| 85 | #define GETTARGETSTACKED targ = (PL_op->op_flags & OPf_STACKED ? POPs : PAD_SV(PL_op->op_targ))
|
|---|
| 86 | #define dTARGETSTACKED SV * GETTARGETSTACKED
|
|---|
| 87 |
|
|---|
| 88 | #define GETTARGET targ = PAD_SV(PL_op->op_targ)
|
|---|
| 89 | #define dTARGET SV * GETTARGET
|
|---|
| 90 |
|
|---|
| 91 | #define GETATARGET targ = (PL_op->op_flags & OPf_STACKED ? sp[-1] : PAD_SV(PL_op->op_targ))
|
|---|
| 92 | #define dATARGET SV * GETATARGET
|
|---|
| 93 |
|
|---|
| 94 | #define dTARG SV *targ
|
|---|
| 95 |
|
|---|
| 96 | #define NORMAL PL_op->op_next
|
|---|
| 97 | #define DIE return Perl_die
|
|---|
| 98 | #ifndef PERL_CORE
|
|---|
| 99 | # define DIE_NULL return DieNull
|
|---|
| 100 | #endif
|
|---|
| 101 |
|
|---|
| 102 | /*
|
|---|
| 103 | =for apidoc Ams||PUTBACK
|
|---|
| 104 | Closing bracket for XSUB arguments. This is usually handled by C<xsubpp>.
|
|---|
| 105 | See C<PUSHMARK> and L<perlcall> for other uses.
|
|---|
| 106 |
|
|---|
| 107 | =for apidoc Amn|SV*|POPs
|
|---|
| 108 | Pops an SV off the stack.
|
|---|
| 109 |
|
|---|
| 110 | =for apidoc Amn|char*|POPp
|
|---|
| 111 | Pops a string off the stack. Deprecated. New code should use POPpx.
|
|---|
| 112 |
|
|---|
| 113 | =for apidoc Amn|char*|POPpx
|
|---|
| 114 | Pops a string off the stack.
|
|---|
| 115 |
|
|---|
| 116 | =for apidoc Amn|char*|POPpbytex
|
|---|
| 117 | Pops a string off the stack which must consist of bytes i.e. characters < 256.
|
|---|
| 118 |
|
|---|
| 119 | =for apidoc Amn|NV|POPn
|
|---|
| 120 | Pops a double off the stack.
|
|---|
| 121 |
|
|---|
| 122 | =for apidoc Amn|IV|POPi
|
|---|
| 123 | Pops an integer off the stack.
|
|---|
| 124 |
|
|---|
| 125 | =for apidoc Amn|long|POPl
|
|---|
| 126 | Pops a long off the stack.
|
|---|
| 127 |
|
|---|
| 128 | =cut
|
|---|
| 129 | */
|
|---|
| 130 |
|
|---|
| 131 | #define PUTBACK PL_stack_sp = sp
|
|---|
| 132 | #define RETURN return PUTBACK, NORMAL
|
|---|
| 133 | #define RETURNOP(o) return PUTBACK, o
|
|---|
| 134 | #define RETURNX(x) return x, PUTBACK, NORMAL
|
|---|
| 135 |
|
|---|
| 136 | #define POPs (*sp--)
|
|---|
| 137 | #define POPp (SvPVx(POPs, PL_na)) /* deprecated */
|
|---|
| 138 | #define POPpx (SvPVx_nolen(POPs))
|
|---|
| 139 | #define POPpconstx (SvPVx_nolen_const(POPs))
|
|---|
| 140 | #define POPpbytex (SvPVbytex_nolen(POPs))
|
|---|
| 141 | #define POPn (SvNVx(POPs))
|
|---|
| 142 | #define POPi ((IV)SvIVx(POPs))
|
|---|
| 143 | #define POPu ((UV)SvUVx(POPs))
|
|---|
| 144 | #define POPl ((long)SvIVx(POPs))
|
|---|
| 145 | #define POPul ((unsigned long)SvIVx(POPs))
|
|---|
| 146 | #ifdef HAS_QUAD
|
|---|
| 147 | #define POPq ((Quad_t)SvIVx(POPs))
|
|---|
|
|---|