Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 512 lines (417 sloc) 18.279 kB
a0d0e21 perl 5.000
Larry Wall authored
1 /* pp.h
7907280 perl 5.0 alpha 2
Larry Wall authored
2 *
1129b88 Update copyright years.
Nicholas Clark authored
3 * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
4 * 2002, 2003, 2004, 2005, 2006, 2007, 2008 by Larry Wall and others
7907280 perl 5.0 alpha 2
Larry Wall authored
5 *
a0d0e21 perl 5.000
Larry Wall authored
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.
7907280 perl 5.0 alpha 2
Larry Wall authored
8 *
a0d0e21 perl 5.000
Larry Wall authored
9 */
7907280 perl 5.0 alpha 2
Larry Wall authored
10
cea2e8a more complete support for implicit thread/interpreter pointer,
Gurusamy Sarathy authored
11 #define PP(s) OP * Perl_##s(pTHX)
7907280 perl 5.0 alpha 2
Larry Wall authored
12
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
13 /*
ccfc67b @jhi Missed the =head1 additions.
jhi authored
14 =head1 Stack Manipulation Macros
15
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
16 =for apidoc AmU||SP
17 Stack pointer. This is usually handled by C<xsubpp>. See C<dSP> and
18 C<SPAGAIN>.
19
20 =for apidoc AmU||MARK
21 Stack marker variable for the XSUB. See C<dMARK>.
22
c578083 Fix apidoc entries for PUSHMARK and newXSproto.
Marcus Holland-Moritz authored
23 =for apidoc Am|void|PUSHMARK|SP
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
24 Opening bracket for arguments on a callback. See C<PUTBACK> and
25 L<perlcall>.
26
27 =for apidoc Ams||dSP
28 Declares a local copy of perl's stack pointer for the XSUB, available via
29 the C<SP> macro. See C<SP>.
30
fac3506 @mstevens djSP
mstevens authored
31 =for apidoc ms||djSP
32
33 Declare Just C<SP>. This is actually identical to C<dSP>, and declares
34 a local copy of perl's stack pointer, available via the C<SP> macro.
35 See C<SP>. (Available for backward source code compatibility with the
36 old (Perl 5.005) thread model.)
37
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
38 =for apidoc Ams||dMARK
39 Declare a stack marker variable, C<mark>, for the XSUB. See C<MARK> and
40 C<dORIGMARK>.
41
42 =for apidoc Ams||dORIGMARK
43 Saves the original stack mark for the XSUB. See C<ORIGMARK>.
44
45 =for apidoc AmU||ORIGMARK
46 The original stack mark for the XSUB. See C<dORIGMARK>.
47
48 =for apidoc Ams||SPAGAIN
49 Refetch the stack pointer. Used after a callback. See L<perlcall>.
50
fac3506 @mstevens djSP
mstevens authored
51 =cut */
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
52
ac634a9 @jhi Integrate changes #8641,8644,8649,8654,8662,8663,8664,8665,8667,8669
jhi authored
53 #undef SP /* Solaris 2.7 i386 has this in /usr/include/sys/reg.h */
7907280 perl 5.0 alpha 2
Larry Wall authored
54 #define SP sp
55 #define MARK mark
56 #define TARG targ
57
16e7e11 Missign STATEMENT brackets in PUSHMARK
Ton Hospel authored
58 #define PUSHMARK(p) \
59 STMT_START { \
60 if (++PL_markstack_ptr == PL_markstack_max) \
61 markstack_grow(); \
514696a @jandubois Cast markstack values to I32
jandubois authored
62 *PL_markstack_ptr = (I32)((p) - PL_stack_base);\
16e7e11 Missign STATEMENT brackets in PUSHMARK
Ton Hospel authored
63 } STMT_END
a0d0e21 perl 5.000
Larry Wall authored
64
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
65 #define TOPMARK (*PL_markstack_ptr)
66 #define POPMARK (*PL_markstack_ptr--)
a0d0e21 perl 5.000
Larry Wall authored
67
bc0d193 Remove register keyword from dSP; (at least for now)
Nicholas Clark authored
68 #define dSP SV **sp = PL_stack_sp
39644a2 @timj Re: sync sync sync: have I missed any patches?
timj authored
69 #define djSP dSP
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
70 #define dMARK register SV **mark = PL_stack_base + POPMARK
514696a @jandubois Cast markstack values to I32
jandubois authored
71 #define dORIGMARK const I32 origmark = (I32)(mark - PL_stack_base)
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
72 #define ORIGMARK (PL_stack_base + origmark)
7907280 perl 5.0 alpha 2
Larry Wall authored
73
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
74 #define SPAGAIN sp = PL_stack_sp
16e7e11 Missign STATEMENT brackets in PUSHMARK
Ton Hospel authored
75 #define MSPAGAIN STMT_START { sp = PL_stack_sp; mark = ORIGMARK; } STMT_END
7907280 perl 5.0 alpha 2
Larry Wall authored
76
533c011 PL_ stuff for threads
Nick Ing-Simmons authored
77 #define GETTARGETSTACKED targ = (PL_op->op_flags & OPf_STACKED ? POPs : PAD_SV(PL_op->op_targ))
7907280 perl 5.0 alpha 2
Larry Wall authored
78 #define dTARGETSTACKED SV * GETTARGETSTACKED
79
533c011 PL_ stuff for threads
Nick Ing-Simmons authored
80 #define GETTARGET targ = PAD_SV(PL_op->op_targ)
7907280 perl 5.0 alpha 2
Larry Wall authored
81 #define dTARGET SV * GETTARGET
82
533c011 PL_ stuff for threads
Nick Ing-Simmons authored
83 #define GETATARGET targ = (PL_op->op_flags & OPf_STACKED ? sp[-1] : PAD_SV(PL_op->op_targ))
7907280 perl 5.0 alpha 2
Larry Wall authored
84 #define dATARGET SV * GETATARGET
85
86 #define dTARG SV *targ
87
533c011 PL_ stuff for threads
Nick Ing-Simmons authored
88 #define NORMAL PL_op->op_next
9fed993 Return DIE(...) to *return*ing Perl_die(...).
Nicholas Clark authored
89 #define DIE return Perl_die
7907280 perl 5.0 alpha 2
Larry Wall authored
90
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
91 /*
92 =for apidoc Ams||PUTBACK
93 Closing bracket for XSUB arguments. This is usually handled by C<xsubpp>.
94 See C<PUSHMARK> and L<perlcall> for other uses.
95
96 =for apidoc Amn|SV*|POPs
97 Pops an SV off the stack.
98
99 =for apidoc Amn|char*|POPp
8c074e2 Convert POPpx POPpconstx and POPpbytex to use nolen macros.
Nicholas Clark authored
100 Pops a string off the stack. Deprecated. New code should use POPpx.
595ae48 Some tests for Camel 3rd edition features.
Nick Ing-Simmons authored
101
102 =for apidoc Amn|char*|POPpx
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
103 Pops a string off the stack.
595ae48 Some tests for Camel 3rd edition features.
Nick Ing-Simmons authored
104
105 =for apidoc Amn|char*|POPpbytex
106 Pops a string off the stack which must consist of bytes i.e. characters < 256.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
107
108 =for apidoc Amn|NV|POPn
109 Pops a double off the stack.
110
111 =for apidoc Amn|IV|POPi
112 Pops an integer off the stack.
113
114 =for apidoc Amn|long|POPl
115 Pops a long off the stack.
116
117 =cut
118 */
119
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
120 #define PUTBACK PL_stack_sp = sp
8a67133 Create new macros AMG_CALLun_var, AMG_CALLun_var and tryAMAGICun_var
Nicholas Clark authored
121 #define RETURN return (PUTBACK, NORMAL)
122 #define RETURNOP(o) return (PUTBACK, o)
123 #define RETURNX(x) return (x, PUTBACK, NORMAL)
7907280 perl 5.0 alpha 2
Larry Wall authored
124
125 #define POPs (*sp--)
2d8e6c8 another threads reliability fix: serialize writes to thr->threadsv
Gurusamy Sarathy authored
126 #define POPp (SvPVx(POPs, PL_na)) /* deprecated */
8c074e2 Convert POPpx POPpconstx and POPpbytex to use nolen macros.
Nicholas Clark authored
127 #define POPpx (SvPVx_nolen(POPs))
128 #define POPpconstx (SvPVx_nolen_const(POPs))
129 #define POPpbytex (SvPVbytex_nolen(POPs))
463ee0b perl 5.0 alpha 4
Larry Wall authored
130 #define POPn (SvNVx(POPs))
a0d0e21 perl 5.000
Larry Wall authored
131 #define POPi ((IV)SvIVx(POPs))
ff68c71 [inseparable changes from patch from perl5.003_09 to perl5.003_10]
Perl 5 Porters authored
132 #define POPu ((UV)SvUVx(POPs))
463ee0b perl 5.0 alpha 4
Larry Wall authored
133 #define POPl ((long)SvIVx(POPs))
d9b3e12 @jhi Jumbo Configure and large file support update.
jhi authored
134 #define POPul ((unsigned long)SvIVx(POPs))
1b8cd67 @jhi Regen Configure.
jhi authored
135 #ifdef HAS_QUAD
d9b3e12 @jhi Jumbo Configure and large file support update.
jhi authored
136 #define POPq ((Quad_t)SvIVx(POPs))
c5a0f51 @jhi Implement 64-bit vec().
jhi authored
137 #define POPuq ((Uquad_t)SvUVx(POPs))
d9b3e12 @jhi Jumbo Configure and large file support update.
jhi authored
138 #endif
7907280 perl 5.0 alpha 2
Larry Wall authored
139
140 #define TOPs (*sp)
56370e9 @jhi Add TOPm1s to peek at the second topmost stack item.
jhi authored
141 #define TOPm1s (*(sp-1))
7dca457 Re: [PATCH] Re: [ID 20010105.023] numeric problems in IRIX
Nicholas Clark authored
142 #define TOPp1s (*(sp+1))
2d8e6c8 another threads reliability fix: serialize writes to thr->threadsv
Gurusamy Sarathy authored
143 #define TOPp (SvPV(TOPs, PL_na)) /* deprecated */
95fad91 Eliminate more C<n_a>s
Nicholas Clark authored
144 #define TOPpx (SvPV_nolen(TOPs))
463ee0b perl 5.0 alpha 4
Larry Wall authored
145 #define TOPn (SvNV(TOPs))
a0d0e21 perl 5.000
Larry Wall authored
146 #define TOPi ((IV)SvIV(TOPs))
ff68c71 [inseparable changes from patch from perl5.003_09 to perl5.003_10]
Perl 5 Porters authored
147 #define TOPu ((UV)SvUV(TOPs))
463ee0b perl 5.0 alpha 4
Larry Wall authored
148 #define TOPl ((long)SvIV(TOPs))
c5a0f51 @jhi Implement 64-bit vec().
jhi authored
149 #define TOPul ((unsigned long)SvUV(TOPs))
1b8cd67 @jhi Regen Configure.
jhi authored
150 #ifdef HAS_QUAD
d9b3e12 @jhi Jumbo Configure and large file support update.
jhi authored
151 #define TOPq ((Quad_t)SvIV(TOPs))
c5a0f51 @jhi Implement 64-bit vec().
jhi authored
152 #define TOPuq ((Uquad_t)SvUV(TOPs))
d9b3e12 @jhi Jumbo Configure and large file support update.
jhi authored
153 #endif
7907280 perl 5.0 alpha 2
Larry Wall authored
154
155 /* Go to some pains in the rare event that we must extend the stack. */
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
156
157 /*
158 =for apidoc Am|void|EXTEND|SP|int nitems
159 Used to extend the argument stack for an XSUB's return values. Once
4375e83 various pod nits (from Larry Virden and others)
Gurusamy Sarathy authored
160 used, guarantees that there is room for at least C<nitems> to be pushed
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
161 onto the stack.
162
163 =for apidoc Am|void|PUSHs|SV* sv
aacdac4 If overloaded %{} etc. return the object do not loop.
Nick Ing-Simmons authored
164 Push an SV onto the stack. The stack must have room for this element.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
165 Does not handle 'set' magic. Does not use C<TARG>. See also C<PUSHmortal>,
166 C<XPUSHs> and C<XPUSHmortal>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
167
168 =for apidoc Am|void|PUSHp|char* str|STRLEN len
169 Push a string onto the stack. The stack must have room for this element.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
170 The C<len> indicates the length of the string. Handles 'set' magic. Uses
171 C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to declare it. Do not
172 call multiple C<TARG>-oriented macros to return lists from XSUB's - see
173 C<mPUSHp> instead. See also C<XPUSHp> and C<mXPUSHp>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
174
175 =for apidoc Am|void|PUSHn|NV nv
176 Push a double onto the stack. The stack must have room for this element.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
177 Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
178 called to declare it. Do not call multiple C<TARG>-oriented macros to
179 return lists from XSUB's - see C<mPUSHn> instead. See also C<XPUSHn> and
180 C<mXPUSHn>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
181
182 =for apidoc Am|void|PUSHi|IV iv
183 Push an integer onto the stack. The stack must have room for this element.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
184 Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
185 called to declare it. Do not call multiple C<TARG>-oriented macros to
186 return lists from XSUB's - see C<mPUSHi> instead. See also C<XPUSHi> and
187 C<mXPUSHi>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
188
189 =for apidoc Am|void|PUSHu|UV uv
190 Push an unsigned integer onto the stack. The stack must have room for this
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
191 element. Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG>
192 should be called to declare it. Do not call multiple C<TARG>-oriented
193 macros to return lists from XSUB's - see C<mPUSHu> instead. See also
194 C<XPUSHu> and C<mXPUSHu>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
195
196 =for apidoc Am|void|XPUSHs|SV* sv
197 Push an SV onto the stack, extending the stack if necessary. Does not
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
198 handle 'set' magic. Does not use C<TARG>. See also C<XPUSHmortal>,
199 C<PUSHs> and C<PUSHmortal>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
200
201 =for apidoc Am|void|XPUSHp|char* str|STRLEN len
202 Push a string onto the stack, extending the stack if necessary. The C<len>
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
203 indicates the length of the string. Handles 'set' magic. Uses C<TARG>, so
204 C<dTARGET> or C<dXSTARG> should be called to declare it. Do not call
205 multiple C<TARG>-oriented macros to return lists from XSUB's - see
206 C<mXPUSHp> instead. See also C<PUSHp> and C<mPUSHp>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
207
208 =for apidoc Am|void|XPUSHn|NV nv
209 Push a double onto the stack, extending the stack if necessary. Handles
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
210 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
211 declare it. Do not call multiple C<TARG>-oriented macros to return lists
212 from XSUB's - see C<mXPUSHn> instead. See also C<PUSHn> and C<mPUSHn>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
213
214 =for apidoc Am|void|XPUSHi|IV iv
215 Push an integer onto the stack, extending the stack if necessary. Handles
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
216 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
217 declare it. Do not call multiple C<TARG>-oriented macros to return lists
218 from XSUB's - see C<mXPUSHi> instead. See also C<PUSHi> and C<mPUSHi>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
219
220 =for apidoc Am|void|XPUSHu|UV uv
aacdac4 If overloaded %{} etc. return the object do not loop.
Nick Ing-Simmons authored
221 Push an unsigned integer onto the stack, extending the stack if necessary.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
222 Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
223 called to declare it. Do not call multiple C<TARG>-oriented macros to
224 return lists from XSUB's - see C<mXPUSHu> instead. See also C<PUSHu> and
225 C<mPUSHu>.
226
6e449a3 Add macros mPUSHs() and mXPUSHs() for pushing SVs on the stack
Marcus Holland-Moritz authored
227 =for apidoc Am|void|mPUSHs|SV* sv
228 Push an SV onto the stack and mortalizes the SV. The stack must have room
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
229 for this element. Does not use C<TARG>. See also C<PUSHs> and C<mXPUSHs>.
6e449a3 Add macros mPUSHs() and mXPUSHs() for pushing SVs on the stack
Marcus Holland-Moritz authored
230
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
231 =for apidoc Am|void|PUSHmortal
232 Push a new mortal SV onto the stack. The stack must have room for this
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
233 element. Does not use C<TARG>. See also C<PUSHs>, C<XPUSHmortal> and C<XPUSHs>.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
234
235 =for apidoc Am|void|mPUSHp|char* str|STRLEN len
236 Push a string onto the stack. The stack must have room for this element.
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
237 The C<len> indicates the length of the string. Does not use C<TARG>.
238 See also C<PUSHp>, C<mXPUSHp> and C<XPUSHp>.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
239
240 =for apidoc Am|void|mPUSHn|NV nv
241 Push a double onto the stack. The stack must have room for this element.
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
242 Does not use C<TARG>. See also C<PUSHn>, C<mXPUSHn> and C<XPUSHn>.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
243
244 =for apidoc Am|void|mPUSHi|IV iv
245 Push an integer onto the stack. The stack must have room for this element.
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
246 Does not use C<TARG>. See also C<PUSHi>, C<mXPUSHi> and C<XPUSHi>.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
247
248 =for apidoc Am|void|mPUSHu|UV uv
249 Push an unsigned integer onto the stack. The stack must have room for this
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
250 element. Does not use C<TARG>. See also C<PUSHu>, C<mXPUSHu> and C<XPUSHu>.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
251
6e449a3 Add macros mPUSHs() and mXPUSHs() for pushing SVs on the stack
Marcus Holland-Moritz authored
252 =for apidoc Am|void|mXPUSHs|SV* sv
253 Push an SV onto the stack, extending the stack if necessary and mortalizes
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
254 the SV. Does not use C<TARG>. See also C<XPUSHs> and C<mPUSHs>.
6e449a3 Add macros mPUSHs() and mXPUSHs() for pushing SVs on the stack
Marcus Holland-Moritz authored
255
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
256 =for apidoc Am|void|XPUSHmortal
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
257 Push a new mortal SV onto the stack, extending the stack if necessary.
258 Does not use C<TARG>. See also C<XPUSHs>, C<PUSHmortal> and C<PUSHs>.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
259
260 =for apidoc Am|void|mXPUSHp|char* str|STRLEN len
261 Push a string onto the stack, extending the stack if necessary. The C<len>
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
262 indicates the length of the string. Does not use C<TARG>. See also C<XPUSHp>,
263 C<mPUSHp> and C<PUSHp>.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
264
265 =for apidoc Am|void|mXPUSHn|NV nv
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
266 Push a double onto the stack, extending the stack if necessary.
267 Does not use C<TARG>. See also C<XPUSHn>, C<mPUSHn> and C<PUSHn>.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
268
269 =for apidoc Am|void|mXPUSHi|IV iv
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
270 Push an integer onto the stack, extending the stack if necessary.
271 Does not use C<TARG>. See also C<XPUSHi>, C<mPUSHi> and C<PUSHi>.
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
272
273 =for apidoc Am|void|mXPUSHu|UV uv
274 Push an unsigned integer onto the stack, extending the stack if necessary.
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
275 Does not use C<TARG>. See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
276
277 =cut
278 */
279
c5661c8 Integrate from maint:
Marcus Holland-Moritz authored
280 #define EXTEND(p,n) STMT_START { if (PL_stack_max - p < (int)(n)) { \
bbce6d6 [inseparable changes from patch from perl5.003_08 to perl5.003_09]
Perl 5 Porters authored
281 sp = stack_grow(sp,p, (int) (n)); \
8654792 Incorporate new single-statement macros
Perl 5 Porters authored
282 } } STMT_END
a0d0e21 perl 5.000
Larry Wall authored
283
7907280 perl 5.0 alpha 2
Larry Wall authored
284 /* Same thing, but update mark register too. */
1b6737c @petdance Const Boy II: The Localizing
petdance authored
285 #define MEXTEND(p,n) STMT_START {if (PL_stack_max - p < (int)(n)) { \
286 const int markoff = mark - PL_stack_base; \
bbce6d6 [inseparable changes from patch from perl5.003_08 to perl5.003_09]
Perl 5 Porters authored
287 sp = stack_grow(sp,p,(int) (n)); \
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
288 mark = PL_stack_base + markoff; \
8654792 Incorporate new single-statement macros
Perl 5 Porters authored
289 } } STMT_END
7907280 perl 5.0 alpha 2
Larry Wall authored
290
291 #define PUSHs(s) (*++sp = (s))
8654792 Incorporate new single-statement macros
Perl 5 Porters authored
292 #define PUSHTARG STMT_START { SvSETMAGIC(TARG); PUSHs(TARG); } STMT_END
293 #define PUSHp(p,l) STMT_START { sv_setpvn(TARG, (p), (l)); PUSHTARG; } STMT_END
6520202 slightly tweaked version of suggested patch
Dan Sugalski authored
294 #define PUSHn(n) STMT_START { sv_setnv(TARG, (NV)(n)); PUSHTARG; } STMT_END
8654792 Incorporate new single-statement macros
Perl 5 Porters authored
295 #define PUSHi(i) STMT_START { sv_setiv(TARG, (IV)(i)); PUSHTARG; } STMT_END
55497cf [inseparable changes from patch from perl5.003_07 to perl5.003_08]
Perl 5 Porters authored
296 #define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END
7907280 perl 5.0 alpha 2
Larry Wall authored
297
8654792 Incorporate new single-statement macros
Perl 5 Porters authored
298 #define XPUSHs(s) STMT_START { EXTEND(sp,1); (*++sp = (s)); } STMT_END
299 #define XPUSHTARG STMT_START { SvSETMAGIC(TARG); XPUSHs(TARG); } STMT_END
300 #define XPUSHp(p,l) STMT_START { sv_setpvn(TARG, (p), (l)); XPUSHTARG; } STMT_END
6520202 slightly tweaked version of suggested patch
Dan Sugalski authored
301 #define XPUSHn(n) STMT_START { sv_setnv(TARG, (NV)(n)); XPUSHTARG; } STMT_END
8654792 Incorporate new single-statement macros
Perl 5 Porters authored
302 #define XPUSHi(i) STMT_START { sv_setiv(TARG, (IV)(i)); XPUSHTARG; } STMT_END
55497cf [inseparable changes from patch from perl5.003_07 to perl5.003_08]
Perl 5 Porters authored
303 #define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END
b162f9e Optimize away OP_SASSIGN
Ilya Zakharevich authored
304 #define XPUSHundef STMT_START { SvOK_off(TARG); XPUSHs(TARG); } STMT_END
7907280 perl 5.0 alpha 2
Larry Wall authored
305
6e449a3 Add macros mPUSHs() and mXPUSHs() for pushing SVs on the stack
Marcus Holland-Moritz authored
306 #define mPUSHs(s) PUSHs(sv_2mortal(s))
2cc7004 Fix mX?PUSH[inup] macros. (Follow-up to #22756 and #22757)
Marcus Holland-Moritz authored
307 #define PUSHmortal PUSHs(sv_newmortal())
8f14ea0 Re-implement mPUSHp() and mXPUSHp() using Perl_newSVpvn_flags(), which
Nicholas Clark authored
308 #define mPUSHp(p,l) PUSHs(newSVpvn_flags((p), (l), SVs_TEMP))
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
309 #define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n))
310 #define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i))
311 #define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u))
2cc7004 Fix mX?PUSH[inup] macros. (Follow-up to #22756 and #22757)
Marcus Holland-Moritz authored
312
6e449a3 Add macros mPUSHs() and mXPUSHs() for pushing SVs on the stack
Marcus Holland-Moritz authored
313 #define mXPUSHs(s) XPUSHs(sv_2mortal(s))
2cc7004 Fix mX?PUSH[inup] macros. (Follow-up to #22756 and #22757)
Marcus Holland-Moritz authored
314 #define XPUSHmortal XPUSHs(sv_newmortal())
8f14ea0 Re-implement mPUSHp() and mXPUSHp() using Perl_newSVpvn_flags(), which
Nicholas Clark authored
315 #define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); mPUSHp((p), (l)); } STMT_END
121b771 There's no need to handle 'set' magic in the mX?PUSH macros.
Marcus Holland-Moritz authored
316 #define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END
317 #define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END
318 #define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END
d82b684 Document limitations in PUSHi et al macros and add new mPUSHi et al m…
Steve Hay authored
319
7907280 perl 5.0 alpha 2
Larry Wall authored
320 #define SETs(s) (*sp = s)
8654792 Incorporate new single-statement macros
Perl 5 Porters authored
321 #define SETTARG STMT_START { SvSETMAGIC(TARG); SETs(TARG); } STMT_END
322 #define SETp(p,l) STMT_START { sv_setpvn(TARG, (p), (l)); SETTARG; } STMT_END
6520202 slightly tweaked version of suggested patch
Dan Sugalski authored
323 #define SETn(n) STMT_START { sv_setnv(TARG, (NV)(n)); SETTARG; } STMT_END
8654792 Incorporate new single-statement macros
Perl 5 Porters authored
324 #define SETi(i) STMT_START { sv_setiv(TARG, (IV)(i)); SETTARG; } STMT_END
55497cf [inseparable changes from patch from perl5.003_07 to perl5.003_08]
Perl 5 Porters authored
325 #define SETu(u) STMT_START { sv_setuv(TARG, (UV)(u)); SETTARG; } STMT_END
a0d0e21 perl 5.000
Larry Wall authored
326
7907280 perl 5.0 alpha 2
Larry Wall authored
327 #define dTOPss SV *sv = TOPs
328 #define dPOPss SV *sv = POPs
6520202 slightly tweaked version of suggested patch
Dan Sugalski authored
329 #define dTOPnv NV value = TOPn
330 #define dPOPnv NV value = POPn
6f1401d @iabyn make overload respect get magic
iabyn authored
331 #define dPOPnv_nomg NV value = (sp--, SvNV_nomg(TOPp1s))
a0d0e21 perl 5.000
Larry Wall authored
332 #define dTOPiv IV value = TOPi
333 #define dPOPiv IV value = POPi
55497cf [inseparable changes from patch from perl5.003_07 to perl5.003_08]
Perl 5 Porters authored
334 #define dTOPuv UV value = TOPu
335 #define dPOPuv UV value = POPu
1b8cd67 @jhi Regen Configure.
jhi authored
336 #ifdef HAS_QUAD
2d4389e @jhi Batch of small 64-bit/long double/large file support tweaks:
jhi authored
337 #define dTOPqv Quad_t value = TOPu
338 #define dPOPqv Quad_t value = POPu
339 #define dTOPuqv Uquad_t value = TOPuq
340 #define dPOPuqv Uquad_t value = POPuq
341 #endif
7907280 perl 5.0 alpha 2
Larry Wall authored
342
7a4c00b [inseparable changes from patch from perl5.003_15 to perl5.003_16]
Perl 5 Porters authored
343 #define dPOPXssrl(X) SV *right = POPs; SV *left = CAT2(X,s)
6520202 slightly tweaked version of suggested patch
Dan Sugalski authored
344 #define dPOPXnnrl(X) NV right = POPn; NV left = CAT2(X,n)
7a4c00b [inseparable changes from patch from perl5.003_15 to perl5.003_16]
Perl 5 Porters authored
345 #define dPOPXiirl(X) IV right = POPi; IV left = CAT2(X,i)
346
347 #define USE_LEFT(sv) \
533c011 PL_ stuff for threads
Nick Ing-Simmons authored
348 (SvOK(sv) || SvGMAGICAL(sv) || !(PL_op->op_flags & OPf_STACKED))
7a4c00b [inseparable changes from patch from perl5.003_15 to perl5.003_16]
Perl 5 Porters authored
349 #define dPOPXnnrl_ul(X) \
6520202 slightly tweaked version of suggested patch
Dan Sugalski authored
350 NV right = POPn; \
7a4c00b [inseparable changes from patch from perl5.003_15 to perl5.003_16]
Perl 5 Porters authored
351 SV *leftsv = CAT2(X,s); \
6520202 slightly tweaked version of suggested patch
Dan Sugalski authored
352 NV left = USE_LEFT(leftsv) ? SvNV(leftsv) : 0.0
7a4c00b [inseparable changes from patch from perl5.003_15 to perl5.003_16]
Perl 5 Porters authored
353 #define dPOPXiirl_ul(X) \
354 IV right = POPi; \
355 SV *leftsv = CAT2(X,s); \
356 IV left = USE_LEFT(leftsv) ? SvIV(leftsv) : 0
6f1401d @iabyn make overload respect get magic
iabyn authored
357 #define dPOPXiirl_ul_nomg(X) \
096c060 Revert parts of c31c291..96b6b87
Father Chrysostomos authored
358 IV right = (sp--, SvIV_nomg(TOPp1s)); \
6f1401d @iabyn make overload respect get magic
iabyn authored
359 SV *leftsv = CAT2(X,s); \
096c060 Revert parts of c31c291..96b6b87
Father Chrysostomos authored
360 IV left = USE_LEFT(leftsv) ? SvIV_nomg(leftsv) : 0
7a4c00b [inseparable changes from patch from perl5.003_15 to perl5.003_16]
Perl 5 Porters authored
361
362 #define dPOPPOPssrl dPOPXssrl(POP)
363 #define dPOPPOPnnrl dPOPXnnrl(POP)
364 #define dPOPPOPnnrl_ul dPOPXnnrl_ul(POP)
365 #define dPOPPOPiirl dPOPXiirl(POP)
366 #define dPOPPOPiirl_ul dPOPXiirl_ul(POP)
367
368 #define dPOPTOPssrl dPOPXssrl(TOP)
369 #define dPOPTOPnnrl dPOPXnnrl(TOP)
370 #define dPOPTOPnnrl_ul dPOPXnnrl_ul(TOP)
6f1401d @iabyn make overload respect get magic
iabyn authored
371 #define dPOPTOPnnrl_nomg \
372 NV right = SvNV_nomg(TOPs); NV left = (sp--, SvNV_nomg(TOPs))
7a4c00b [inseparable changes from patch from perl5.003_15 to perl5.003_16]
Perl 5 Porters authored
373 #define dPOPTOPiirl dPOPXiirl(TOP)
374 #define dPOPTOPiirl_ul dPOPXiirl_ul(TOP)
6f1401d @iabyn make overload respect get magic
iabyn authored
375 #define dPOPTOPiirl_ul_nomg dPOPXiirl_ul_nomg(TOP)
376 #define dPOPTOPiirl_nomg \
096c060 Revert parts of c31c291..96b6b87
Father Chrysostomos authored
377 IV right = SvIV_nomg(TOPs); IV left = (sp--, SvIV_nomg(TOPs))
7907280 perl 5.0 alpha 2
Larry Wall authored
378
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
379 #define RETPUSHYES RETURNX(PUSHs(&PL_sv_yes))
380 #define RETPUSHNO RETURNX(PUSHs(&PL_sv_no))
381 #define RETPUSHUNDEF RETURNX(PUSHs(&PL_sv_undef))
7907280 perl 5.0 alpha 2
Larry Wall authored
382
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
383 #define RETSETYES RETURNX(SETs(&PL_sv_yes))
384 #define RETSETNO RETURNX(SETs(&PL_sv_no))
385 #define RETSETUNDEF RETURNX(SETs(&PL_sv_undef))
7907280 perl 5.0 alpha 2
Larry Wall authored
386
533c011 PL_ stuff for threads
Nick Ing-Simmons authored
387 #define ARGTARG PL_op->op_targ
b162f9e Optimize away OP_SASSIGN
Ilya Zakharevich authored
388
389 /* See OPpTARGET_MY: */
390 #define MAXARG (PL_op->op_private & 15)
7907280 perl 5.0 alpha 2
Larry Wall authored
391
e336de0 [win32] implement stack-of-stacks so that magic invocations don't
Gurusamy Sarathy authored
392 #define SWITCHSTACK(f,t) \
393 STMT_START { \
677b06e grow PL_tmps_stack more efficiently; make it more amenable to
Gurusamy Sarathy authored
394 AvFILLp(f) = sp - PL_stack_base; \
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
395 PL_stack_base = AvARRAY(t); \
677b06e grow PL_tmps_stack more efficiently; make it more amenable to
Gurusamy Sarathy authored
396 PL_stack_max = PL_stack_base + AvMAX(t); \
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
397 sp = PL_stack_sp = PL_stack_base + AvFILLp(t); \
677b06e grow PL_tmps_stack more efficiently; make it more amenable to
Gurusamy Sarathy authored
398 PL_curstack = t; \
e336de0 [win32] implement stack-of-stacks so that magic invocations don't
Gurusamy Sarathy authored
399 } STMT_END
7907280 perl 5.0 alpha 2
Larry Wall authored
400
bbce6d6 [inseparable changes from patch from perl5.003_08 to perl5.003_09]
Perl 5 Porters authored
401 #define EXTEND_MORTAL(n) \
677b06e grow PL_tmps_stack more efficiently; make it more amenable to
Gurusamy Sarathy authored
402 STMT_START { \
403 if (PL_tmps_ix + (n) >= PL_tmps_max) \
404 tmps_grow(n); \
405 } STMT_END
bbce6d6 [inseparable changes from patch from perl5.003_08 to perl5.003_09]
Perl 5 Porters authored
406
a0d0e21 perl 5.000
Larry Wall authored
407 #define AMGf_noright 1
408 #define AMGf_noleft 2
409 #define AMGf_assign 4
410 #define AMGf_unary 8
6f1401d @iabyn make overload respect get magic
iabyn authored
411 #define AMGf_numeric 0x10 /* for Perl_try_amagic_bin */
412 #define AMGf_set 0x20 /* for Perl_try_amagic_bin */
413
414
415 /* do SvGETMAGIC on the stack args before checking for overload */
416
417 #define tryAMAGICun_MG(method, flags) STMT_START { \
418 if ( (SvFLAGS(TOPs) & (SVf_ROK|SVs_GMG)) \
419 && Perl_try_amagic_un(aTHX_ method, flags)) \
420 return NORMAL; \
421 } STMT_END
422 #define tryAMAGICbin_MG(method, flags) STMT_START { \
423 if ( ((SvFLAGS(TOPm1s)|SvFLAGS(TOPs)) & (SVf_ROK|SVs_GMG)) \
424 && Perl_try_amagic_bin(aTHX_ method, flags)) \
425 return NORMAL; \
426 } STMT_END
427
31d632c @iabyn standardise amagic method naming
iabyn authored
428 #define AMG_CALLunary(sv,meth) \
429 amagic_call(sv,&PL_sv_undef, meth, AMGf_noright | AMGf_unary)
430
431 /* No longer used in core. Use AMG_CALLunary instead */
432 #define AMG_CALLun(sv,meth) AMG_CALLunary(sv, CAT2(meth,_amg))
a0d0e21 perl 5.000
Larry Wall authored
433
b5c0882 @iabyn reindent tryAMAGICunTARGET after previous change
iabyn authored
434 #define tryAMAGICunTARGET(meth, shift, jump) \
9f39b4f Inline tryAMAGICunW_var() into macros tryAMAGICun{DEREF_var,TARGET}
Nicholas Clark authored
435 STMT_START { \
b5c0882 @iabyn reindent tryAMAGICunTARGET after previous change
iabyn authored
436 dATARGET; \
437 dSP; \
438 SV *tmpsv; \
439 SV *arg= sp[shift]; \
440 if (SvAMAGIC(arg) && \
441 (tmpsv = amagic_call(arg, &PL_sv_undef, meth, \
442 AMGf_noright | AMGf_unary))) { \
443 SPAGAIN; \
444 sp += shift; \
445 sv_setsv(TARG, tmpsv); \
446 if (opASSIGN) \
447 sp--; \
448 SETTARG; \
449 PUTBACK; \
450 if (jump) { \
451 PL_markstack_ptr--; \
452 return NORMAL->op_next->op_next; \
9f39b4f Inline tryAMAGICunW_var() into macros tryAMAGICun{DEREF_var,TARGET}
Nicholas Clark authored
453 } \
b5c0882 @iabyn reindent tryAMAGICunTARGET after previous change
iabyn authored
454 return NORMAL; \
455 } \
9f39b4f Inline tryAMAGICunW_var() into macros tryAMAGICun{DEREF_var,TARGET}
Nicholas Clark authored
456 } STMT_END
457
8897dca Inline tryAMAGICunDEREF_var() into its callers and eliminate it.
Nicholas Clark authored
458 /* This is no longer used anywhere in the core. You might wish to consider
459 calling amagic_deref_call() directly, as it has a cleaner interface. */
460 #define tryAMAGICunDEREF(meth) \
9f39b4f Inline tryAMAGICunW_var() into macros tryAMAGICun{DEREF_var,TARGET}
Nicholas Clark authored
461 STMT_START { \
e89bfaa Fix error in tryAMAGICunDEREF() introduced in 25a9ffce153b0e67.
Nicholas Clark authored
462 sv = amagic_deref_call(*sp, CAT2(meth,_amg)); \
25a9ffc Add Perl_amagic_deref_call() to implement the bulk of tryAMAGICunDERE…
Nicholas Clark authored
463 SPAGAIN; \
16e7e11 Missign STATEMENT brackets in PUSHMARK
Ton Hospel authored
464 } STMT_END
e8c2096 Re: [PATCH 5.00552] Overloaded <> and deref again
Ilya Zakharevich authored
465
180b7b9 @mauzo Move magic logic into tryAMAGICftest macro.
mauzo authored
466
533c011 PL_ stuff for threads
Nick Ing-Simmons authored
467 #define opASSIGN (PL_op->op_flags & OPf_STACKED)
e990555 perl 5.003_01: pp.h
Perl 5 Porters authored
468 #define SETsv(sv) STMT_START { \
b162f9e Optimize away OP_SASSIGN
Ilya Zakharevich authored
469 if (opASSIGN || (SvFLAGS(TARG) & SVs_PADMY)) \
470 { sv_setsv(TARG, (sv)); SETTARG; } \
471 else SETs(sv); } STMT_END
472
473 #define SETsvUN(sv) STMT_START { \
474 if (SvFLAGS(TARG) & SVs_PADMY) \
475 { sv_setsv(TARG, (sv)); SETTARG; } \
e990555 perl 5.003_01: pp.h
Perl 5 Porters authored
476 else SETs(sv); } STMT_END
a0d0e21 perl 5.000
Larry Wall authored
477
78f9721 Consolidated lvalue sub changes
Stephen McCamant authored
478 /*
479 =for apidoc mU||LVRET
480 True if this op will be the return value of an lvalue subroutine
481
482 =cut */
9d96b2e @jhi Use the /^Perl_/-less form of is_lvalue_sub().
jhi authored
483 #define LVRET ((PL_op->op_private & OPpMAYBE_LVSUB) && is_lvalue_sub())
1b6737c @petdance Const Boy II: The Localizing
petdance authored
484
d30e492 @vpit Introduce SvCANEXISTDELETE in pp.h, which simplify the logic in pp_he…
vpit authored
485 #define SvCANEXISTDELETE(sv) \
486 (!SvRMAGICAL(sv) \
487 || ((mg = mg_find((const SV *) sv, PERL_MAGIC_tied)) \
488 && (stash = SvSTASH(SvRV(SvTIED_obj(MUTABLE_SV(sv), mg)))) \
489 && gv_fetchmethod_autoload(stash, "EXISTS", TRUE) \
490 && gv_fetchmethod_autoload(stash, "DELETE", TRUE) \
491 ) \
492 )
493
d682515 Rename tied_handle_method() to tied_method(), and make it non-static.
Nicholas Clark authored
494 #ifdef PERL_CORE
495 /* These are just for Perl_tied_method(), which is not part of the public API.
496 Use 0x04 rather than the next available bit, to help the compiler if the
497 architecture can generate more efficient instructions. */
498 # define TIED_METHOD_MORTALIZE_NOT_NEEDED 0x04
499 # define TIED_METHOD_ARGUMENTS_ON_STACK 0x08
94bc412 Convert tied PRINT to using Perl_tied_method()
Nicholas Clark authored
500 # define TIED_METHOD_SAY 0x10
d682515 Rename tied_handle_method() to tied_method(), and make it non-static.
Nicholas Clark authored
501 #endif
502
1b6737c @petdance Const Boy II: The Localizing
petdance authored
503 /*
504 * Local variables:
505 * c-indentation-style: bsd
506 * c-basic-offset: 4
507 * indent-tabs-mode: t
508 * End:
509 *
510 * ex: set ts=8 sts=4 sw=4 noet:
511 */
Something went wrong with that request. Please try again.