source: trunk/essentials/dev-lang/perl/pp.h@ 3296

Last change on this file since 3296 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 17.3 KB
Line 
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
25Stack pointer. This is usually handled by C<xsubpp>. See C<dSP> and
26C<SPAGAIN>.
27
28=for apidoc AmU||MARK
29Stack marker variable for the XSUB. See C<dMARK>.
30
31=for apidoc Am|void|PUSHMARK|SP
32Opening bracket for arguments on a callback. See C<PUTBACK> and
33L<perlcall>.
34
35=for apidoc Ams||dSP
36Declares a local copy of perl's stack pointer for the XSUB, available via
37the C<SP> macro. See C<SP>.
38
39=for apidoc ms||djSP
40
41Declare Just C<SP>. This is actually identical to C<dSP>, and declares
42a local copy of perl's stack pointer, available via the C<SP> macro.
43See C<SP>. (Available for backward source code compatibility with the
44old (Perl 5.005) thread model.)
45
46=for apidoc Ams||dMARK
47Declare a stack marker variable, C<mark>, for the XSUB. See C<MARK> and
48C<dORIGMARK>.
49
50=for apidoc Ams||dORIGMARK
51Saves the original stack mark for the XSUB. See C<ORIGMARK>.
52
53=for apidoc AmU||ORIGMARK
54The original stack mark for the XSUB. See C<dORIGMARK>.
55
56=for apidoc Ams||SPAGAIN
57Refetch 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
104Closing bracket for XSUB arguments. This is usually handled by C<xsubpp>.
105See C<PUSHMARK> and L<perlcall> for other uses.
106
107=for apidoc Amn|SV*|POPs
108Pops an SV off the stack.
109
110=for apidoc Amn|char*|POPp
111Pops a string off the stack. Deprecated. New code should use POPpx.
112
113=for apidoc Amn|char*|POPpx
114Pops a string off the stack.
115
116=for apidoc Amn|char*|POPpbytex
117Pops a string off the stack which must consist of bytes i.e. characters < 256.
118
119=for apidoc Amn|NV|POPn
120Pops a double off the stack.
121
122=for apidoc Amn|IV|POPi
123Pops an integer off the stack.
124
125=for apidoc Amn|long|POPl
126Pops 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))