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
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.
11 #define PP(s) OP * Perl_##s(pTHX)
14 =head1 Stack Manipulation Macros
17 Stack pointer. This is usually handled by C<xsubpp>. See C<L</dSP>> and
21 Stack marker variable for the XSUB. See C<L</dMARK>>.
23 =for apidoc Am|void|PUSHMARK|SP
24 Opening bracket for arguments on a callback. See C<L</PUTBACK>> and
28 Declares a local copy of perl's stack pointer for the XSUB, available via
29 the C<SP> macro. See C<L</SP>>.
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<L<perlapi/SP>>. (Available for backward source code compatibility with
36 the old (Perl 5.005) thread model.)
38 =for apidoc Ams||dMARK
39 Declare a stack marker variable, C<mark>, for the XSUB. See C<L</MARK>> and
42 =for apidoc Ams||dORIGMARK
43 Saves the original stack mark for the XSUB. See C<L</ORIGMARK>>.
45 =for apidoc AmU||ORIGMARK
46 The original stack mark for the XSUB. See C<L</dORIGMARK>>.
48 =for apidoc Ams||SPAGAIN
49 Refetch the stack pointer. Used after a callback. See L<perlcall>.
53 #undef SP /* Solaris 2.7 i386 has this in /usr/include/sys/reg.h */
58 #if defined(DEBUGGING) && defined(PERL_USE_GCC_BRACE_GROUPS)
59 # define PUSHMARK(p) \
61 I32 * mark_stack_entry; \
62 if (UNLIKELY((mark_stack_entry = ++PL_markstack_ptr) == PL_markstack_max)) \
63 mark_stack_entry = markstack_grow(); \
64 *mark_stack_entry = (I32)((p) - PL_stack_base); \
65 DEBUG_s(PerlIO_printf(Perl_debug_log, "MARK push %p %d\n", \
66 PL_markstack_ptr, *mark_stack_entry)); \
70 DEBUG_s(PerlIO_printf(Perl_debug_log, "MARK top %p %d\n", \
71 PL_markstack_ptr, *PL_markstack_ptr)); \
76 DEBUG_s(PerlIO_printf(Perl_debug_log, "MARK pop %p %d\n", \
77 (PL_markstack_ptr-1), *(PL_markstack_ptr-1))); \
78 assert((PL_markstack_ptr > PL_markstack) || !"MARK underflow");\
79 *PL_markstack_ptr--; \
83 DEBUG_s(PerlIO_printf(Perl_debug_log, "MARK inc %p %d\n", \
84 (PL_markstack_ptr+1), *(PL_markstack_ptr+1))); \
85 *PL_markstack_ptr++; \
88 # define PUSHMARK(p) \
90 I32 * mark_stack_entry; \
91 if (UNLIKELY((mark_stack_entry = ++PL_markstack_ptr) == PL_markstack_max)) \
92 mark_stack_entry = markstack_grow(); \
93 *mark_stack_entry = (I32)((p) - PL_stack_base); \
95 # define TOPMARK (*PL_markstack_ptr)
96 # define POPMARK (*PL_markstack_ptr--)
97 # define INCMARK (*PL_markstack_ptr++)
100 #define dSP SV **sp = PL_stack_sp
102 #define dMARK SV **mark = PL_stack_base + POPMARK
103 #define dORIGMARK const I32 origmark = (I32)(mark - PL_stack_base)
104 #define ORIGMARK (PL_stack_base + origmark)
106 #define SPAGAIN sp = PL_stack_sp
107 #define MSPAGAIN STMT_START { sp = PL_stack_sp; mark = ORIGMARK; } STMT_END
109 #define GETTARGETSTACKED targ = (PL_op->op_flags & OPf_STACKED ? POPs : PAD_SV(PL_op->op_targ))
110 #define dTARGETSTACKED SV * GETTARGETSTACKED
112 #define GETTARGET targ = PAD_SV(PL_op->op_targ)
113 #define dTARGET SV * GETTARGET
115 #define GETATARGET targ = (PL_op->op_flags & OPf_STACKED ? sp[-1] : PAD_SV(PL_op->op_targ))
116 #define dATARGET SV * GETATARGET
118 #define dTARG SV *targ
120 #define NORMAL PL_op->op_next
121 #define DIE return Perl_die
124 =for apidoc Ams||PUTBACK
125 Closing bracket for XSUB arguments. This is usually handled by C<xsubpp>.
126 See C<L</PUSHMARK>> and L<perlcall> for other uses.
128 =for apidoc Amn|SV*|POPs
129 Pops an SV off the stack.
131 =for apidoc Amn|char*|POPp
132 Pops a string off the stack.
134 =for apidoc Amn|char*|POPpx
135 Pops a string off the stack. Identical to POPp. There are two names for
138 =for apidoc Amn|char*|POPpbytex
139 Pops a string off the stack which must consist of bytes i.e. characters < 256.
141 =for apidoc Amn|NV|POPn
142 Pops a double off the stack.
144 =for apidoc Amn|IV|POPi
145 Pops an integer off the stack.
147 =for apidoc Amn|UV|POPu
148 Pops an unsigned integer off the stack.
150 =for apidoc Amn|long|POPl
151 Pops a long off the stack.
153 =for apidoc Amn|long|POPul
154 Pops an unsigned long off the stack.
159 #define PUTBACK PL_stack_sp = sp
160 #define RETURN return (PUTBACK, NORMAL)
161 #define RETURNOP(o) return (PUTBACK, o)
162 #define RETURNX(x) return (x, PUTBACK, NORMAL)
166 #define POPpx (SvPVx_nolen(POPs))
167 #define POPpconstx (SvPVx_nolen_const(POPs))
168 #define POPpbytex (SvPVbytex_nolen(POPs))
169 #define POPn (SvNVx(POPs))
170 #define POPi ((IV)SvIVx(POPs))
171 #define POPu ((UV)SvUVx(POPs))
172 #define POPl ((long)SvIVx(POPs))
173 #define POPul ((unsigned long)SvIVx(POPs))
176 #define TOPm1s (*(sp-1))
177 #define TOPp1s (*(sp+1))
179 #define TOPpx (SvPV_nolen(TOPs))
180 #define TOPn (SvNV(TOPs))
181 #define TOPi ((IV)SvIV(TOPs))
182 #define TOPu ((UV)SvUV(TOPs))
183 #define TOPl ((long)SvIV(TOPs))
184 #define TOPul ((unsigned long)SvUV(TOPs))
186 /* Go to some pains in the rare event that we must extend the stack. */
189 =for apidoc Am|void|EXTEND|SP|SSize_t nitems
190 Used to extend the argument stack for an XSUB's return values. Once
191 used, guarantees that there is room for at least C<nitems> to be pushed
194 =for apidoc Am|void|PUSHs|SV* sv
195 Push an SV onto the stack. The stack must have room for this element.
196 Does not handle 'set' magic. Does not use C<TARG>. See also
197 C<L</PUSHmortal>>, C<L</XPUSHs>>, and C<L</XPUSHmortal>>.
199 =for apidoc Am|void|PUSHp|char* str|STRLEN len
200 Push a string onto the stack. The stack must have room for this element.
201 The C<len> indicates the length of the string. Handles 'set' magic. Uses
202 C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to declare it. Do not
203 call multiple C<TARG>-oriented macros to return lists from XSUB's - see
204 C<L</mPUSHp>> instead. See also C<L</XPUSHp>> and C<L</mXPUSHp>>.
206 =for apidoc Am|void|PUSHn|NV nv
207 Push a double onto the stack. The stack must have room for this element.
208 Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
209 called to declare it. Do not call multiple C<TARG>-oriented macros to
210 return lists from XSUB's - see C<L</mPUSHn>> instead. See also C<L</XPUSHn>>
213 =for apidoc Am|void|PUSHi|IV iv
214 Push an integer onto the stack. The stack must have room for this element.
215 Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
216 called to declare it. Do not call multiple C<TARG>-oriented macros to
217 return lists from XSUB's - see C<L</mPUSHi>> instead. See also C<L</XPUSHi>>
220 =for apidoc Am|void|PUSHu|UV uv
221 Push an unsigned integer onto the stack. The stack must have room for this
222 element. Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG>
223 should be called to declare it. Do not call multiple C<TARG>-oriented
224 macros to return lists from XSUB's - see C<L</mPUSHu>> instead. See also
225 C<L</XPUSHu>> and C<L</mXPUSHu>>.
227 =for apidoc Am|void|XPUSHs|SV* sv
228 Push an SV onto the stack, extending the stack if necessary. Does not
229 handle 'set' magic. Does not use C<TARG>. See also C<L</XPUSHmortal>>,
230 C<PUSHs> and C<PUSHmortal>.
232 =for apidoc Am|void|XPUSHp|char* str|STRLEN len
233 Push a string onto the stack, extending the stack if necessary. The C<len>
234 indicates the length of the string. Handles 'set' magic. Uses C<TARG>, so
235 C<dTARGET> or C<dXSTARG> should be called to declare it. Do not call
236 multiple C<TARG>-oriented macros to return lists from XSUB's - see
237 C<L</mXPUSHp>> instead. See also C<L</PUSHp>> and C<L</mPUSHp>>.
239 =for apidoc Am|void|XPUSHn|NV nv
240 Push a double onto the stack, extending the stack if necessary. Handles
241 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
242 declare it. Do not call multiple C<TARG>-oriented macros to return lists
243 from XSUB's - see C<L</mXPUSHn>> instead. See also C<L</PUSHn>> and
246 =for apidoc Am|void|XPUSHi|IV iv
247 Push an integer onto the stack, extending the stack if necessary. Handles
248 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
249 declare it. Do not call multiple C<TARG>-oriented macros to return lists
250 from XSUB's - see C<L</mXPUSHi>> instead. See also C<L</PUSHi>> and
253 =for apidoc Am|void|XPUSHu|UV uv
254 Push an unsigned integer onto the stack, extending the stack if necessary.
255 Handles 'set' magic. Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
256 called to declare it. Do not call multiple C<TARG>-oriented macros to
257 return lists from XSUB's - see C<L</mXPUSHu>> instead. See also C<L</PUSHu>> and
260 =for apidoc Am|void|mPUSHs|SV* sv
261 Push an SV onto the stack and mortalizes the SV. The stack must have room
262 for this element. Does not use C<TARG>. See also C<L</PUSHs>> and
265 =for apidoc Am|void|PUSHmortal
266 Push a new mortal SV onto the stack. The stack must have room for this
267 element. Does not use C<TARG>. See also C<L</PUSHs>>, C<L</XPUSHmortal>> and
270 =for apidoc Am|void|mPUSHp|char* str|STRLEN len
271 Push a string onto the stack. The stack must have room for this element.
272 The C<len> indicates the length of the string. Does not use C<TARG>.
273 See also C<L</PUSHp>>, C<L</mXPUSHp>> and C<L</XPUSHp>>.
275 =for apidoc Am|void|mPUSHn|NV nv
276 Push a double onto the stack. The stack must have room for this element.
277 Does not use C<TARG>. See also C<L</PUSHn>>, C<L</mXPUSHn>> and C<L</XPUSHn>>.
279 =for apidoc Am|void|mPUSHi|IV iv
280 Push an integer onto the stack. The stack must have room for this element.
281 Does not use C<TARG>. See also C<L</PUSHi>>, C<L</mXPUSHi>> and C<L</XPUSHi>>.
283 =for apidoc Am|void|mPUSHu|UV uv
284 Push an unsigned integer onto the stack. The stack must have room for this
285 element. Does not use C<TARG>. See also C<L</PUSHu>>, C<L</mXPUSHu>> and
288 =for apidoc Am|void|mXPUSHs|SV* sv
289 Push an SV onto the stack, extending the stack if necessary and mortalizes
290 the SV. Does not use C<TARG>. See also C<L</XPUSHs>> and C<L</mPUSHs>>.
292 =for apidoc Am|void|XPUSHmortal
293 Push a new mortal SV onto the stack, extending the stack if necessary.
294 Does not use C<TARG>. See also C<L</XPUSHs>>, C<L</PUSHmortal>> and
297 =for apidoc Am|void|mXPUSHp|char* str|STRLEN len
298 Push a string onto the stack, extending the stack if necessary. The C<len>
299 indicates the length of the string. Does not use C<TARG>. See also
300 C<L</XPUSHp>>, C<mPUSHp> and C<PUSHp>.
302 =for apidoc Am|void|mXPUSHn|NV nv
303 Push a double onto the stack, extending the stack if necessary.
304 Does not use C<TARG>. See also C<L</XPUSHn>>, C<L</mPUSHn>> and C<L</PUSHn>>.
306 =for apidoc Am|void|mXPUSHi|IV iv
307 Push an integer onto the stack, extending the stack if necessary.
308 Does not use C<TARG>. See also C<L</XPUSHi>>, C<L</mPUSHi>> and C<L</PUSHi>>.
310 =for apidoc Am|void|mXPUSHu|UV uv
311 Push an unsigned integer onto the stack, extending the stack if necessary.
312 Does not use C<TARG>. See also C<L</XPUSHu>>, C<L</mPUSHu>> and C<L</PUSHu>>.
317 /* _EXTEND_SAFE_N(n): private helper macro for EXTEND().
318 * Tests whether the value of n would be truncated when implicitly cast to
319 * SSize_t as an arg to stack_grow(). If so, sets it to -1 instead to
320 * trigger a panic. It will be constant folded on platforms where this
324 #define _EXTEND_SAFE_N(n) \
325 (sizeof(n) > sizeof(SSize_t) && ((SSize_t)(n) != (n)) ? -1 : (n))
327 #ifdef STRESS_REALLOC
328 # define EXTEND(p,n) STMT_START { \
329 sp = stack_grow(sp,p,_EXTEND_SAFE_N(n)); \
330 PERL_UNUSED_VAR(sp); \
332 /* Same thing, but update mark register too. */
333 # define MEXTEND(p,n) STMT_START { \
334 const SSize_t markoff = mark - PL_stack_base; \
335 sp = stack_grow(sp,p,_EXTEND_SAFE_N(n)); \
336 mark = PL_stack_base + markoff; \
337 PERL_UNUSED_VAR(sp); \
341 /* _EXTEND_NEEDS_GROW(p,n): private helper macro for EXTEND().
342 * Tests to see whether n is too big and we need to grow the stack. Be
343 * very careful if modifying this. There are many ways to get things wrong
344 * (wrapping, truncating etc) that could cause a false negative and cause
345 * the call to stack_grow() to be skipped. On the other hand, false
346 * positives are safe.
347 * Bear in mind that sizeof(p) may be less than, equal to, or greater
348 * than sizeof(n), and while n is documented to be signed, someone might
349 * pass an unsigned value or expression. In general don't use casts to
350 * avoid warnings; instead expect the caller to fix their code.
351 * It is legal for p to be greater than PL_stack_max.
352 * If the allocated stack is already very large but current usage is
353 * small, then PL_stack_max - p might wrap round to a negative value, but
354 * this just gives a safe false positive
357 # define _EXTEND_NEEDS_GROW(p,n) ( (n) < 0 || PL_stack_max - p < (n))
359 # define EXTEND(p,n) STMT_START { \
360 if (UNLIKELY(_EXTEND_NEEDS_GROW(p,n))) { \
361 sp = stack_grow(sp,p,_EXTEND_SAFE_N(n)); \
362 PERL_UNUSED_VAR(sp); \
364 /* Same thing, but update mark register too. */
365 # define MEXTEND(p,n) STMT_START { \
366 if (UNLIKELY(_EXTEND_NEEDS_GROW(p,n))) { \
367 const SSize_t markoff = mark - PL_stack_base;\
368 sp = stack_grow(sp,p,_EXTEND_SAFE_N(n)); \
369 mark = PL_stack_base + markoff; \
370 PERL_UNUSED_VAR(sp); \
374 /* set TARG to the IV value i. If do_taint is false,
375 * assume that PL_tainted can never be true */
376 #define TARGi(i, do_taint) \
380 ((SvFLAGS(TARG) & (SVTYPEMASK|SVf_THINKFIRST)) == SVt_IV) \
381 & (do_taint ? !TAINT_get : 1))) \
383 /* Cheap SvIOK_only(). \
384 * Assert that flags which SvIOK_only() would test or \
385 * clear can't be set, because we're SVt_IV */ \
386 assert(!(SvFLAGS(TARG) & \
387 (SVf_OOK|SVf_UTF8|(SVf_OK & ~(SVf_IOK|SVp_IOK))))); \
388 SvFLAGS(TARG) |= (SVf_IOK|SVp_IOK); \
389 /* SvIV_set() where sv_any points to head */ \
390 TARG->sv_u.svu_iv = TARGi_iv; \
393 sv_setiv_mg(targ, TARGi_iv); \
396 /* set TARG to the UV value u. If do_taint is false,
397 * assume that PL_tainted can never be true */
398 #define TARGu(u, do_taint) \
402 ((SvFLAGS(TARG) & (SVTYPEMASK|SVf_THINKFIRST)) == SVt_IV) \
403 & (do_taint ? !TAINT_get : 1) \
404 & (TARGu_uv <= (UV)IV_MAX))) \
406 /* Cheap SvIOK_only(). \
407 * Assert that flags which SvIOK_only() would test or \
408 * clear can't be set, because we're SVt_IV */ \
409 assert(!(SvFLAGS(TARG) & \
410 (SVf_OOK|SVf_UTF8|(SVf_OK & ~(SVf_IOK|SVp_IOK))))); \
411 SvFLAGS(TARG) |= (SVf_IOK|SVp_IOK); \
412 /* SvIV_set() where sv_any points to head */ \
413 TARG->sv_u.svu_iv = TARGu_uv; \
416 sv_setuv_mg(targ, TARGu_uv); \
419 /* set TARG to the NV value n. If do_taint is false,
420 * assume that PL_tainted can never be true */
421 #define TARGn(n, do_taint) \
425 ((SvFLAGS(TARG) & (SVTYPEMASK|SVf_THINKFIRST)) == SVt_NV) \
426 & (do_taint ? !TAINT_get : 1))) \
428 /* Cheap SvNOK_only(). \
429 * Assert that flags which SvNOK_only() would test or \
430 * clear can't be set, because we're SVt_NV */ \
431 assert(!(SvFLAGS(TARG) & \
432 (SVf_OOK|SVf_UTF8|(SVf_OK & ~(SVf_NOK|SVp_NOK))))); \
433 SvFLAGS(TARG) |= (SVf_NOK|SVp_NOK); \
434 SvNV_set(TARG, TARGn_nv); \
437 sv_setnv_mg(targ, TARGn_nv); \
440 #define PUSHs(s) (*++sp = (s))
441 #define PUSHTARG STMT_START { SvSETMAGIC(TARG); PUSHs(TARG); } STMT_END
442 #define PUSHp(p,l) STMT_START { sv_setpvn(TARG, (p), (l)); PUSHTARG; } STMT_END
443 #define PUSHn(n) STMT_START { TARGn(n,1); PUSHs(TARG); } STMT_END
444 #define PUSHi(i) STMT_START { TARGi(i,1); PUSHs(TARG); } STMT_END
445 #define PUSHu(u) STMT_START { TARGu(u,1); PUSHs(TARG); } STMT_END
447 #define XPUSHs(s) STMT_START { EXTEND(sp,1); *++sp = (s); } STMT_END
448 #define XPUSHTARG STMT_START { SvSETMAGIC(TARG); XPUSHs(TARG); } STMT_END
449 #define XPUSHp(p,l) STMT_START { sv_setpvn(TARG, (p), (l)); XPUSHTARG; } STMT_END
450 #define XPUSHn(n) STMT_START { TARGn(n,1); XPUSHs(TARG); } STMT_END
451 #define XPUSHi(i) STMT_START { TARGi(i,1); XPUSHs(TARG); } STMT_END
452 #define XPUSHu(u) STMT_START { TARGu(u,1); XPUSHs(TARG); } STMT_END
453 #define XPUSHundef STMT_START { SvOK_off(TARG); XPUSHs(TARG); } STMT_END
455 #define mPUSHs(s) PUSHs(sv_2mortal(s))
456 #define PUSHmortal PUSHs(sv_newmortal())
457 #define mPUSHp(p,l) PUSHs(newSVpvn_flags((p), (l), SVs_TEMP))
458 #define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n))
459 #define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i))
460 #define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u))
462 #define mXPUSHs(s) XPUSHs(sv_2mortal(s))
463 #define XPUSHmortal XPUSHs(sv_newmortal())
464 #define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); mPUSHp((p), (l)); } STMT_END
465 #define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END
466 #define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END
467 #define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END
469 #define SETs(s) (*sp = s)
470 #define SETTARG STMT_START { SvSETMAGIC(TARG); SETs(TARG); } STMT_END
471 #define SETp(p,l) STMT_START { sv_setpvn(TARG, (p), (l)); SETTARG; } STMT_END
472 #define SETn(n) STMT_START { TARGn(n,1); SETs(TARG); } STMT_END
473 #define SETi(i) STMT_START { TARGi(i,1); SETs(TARG); } STMT_END
474 #define SETu(u) STMT_START { TARGu(u,1); SETs(TARG); } STMT_END
476 #define dTOPss SV *sv = TOPs
477 #define dPOPss SV *sv = POPs
478 #define dTOPnv NV value = TOPn
479 #define dPOPnv NV value = POPn
480 #define dPOPnv_nomg NV value = (sp--, SvNV_nomg(TOPp1s))
481 #define dTOPiv IV value = TOPi
482 #define dPOPiv IV value = POPi
483 #define dTOPuv UV value = TOPu
484 #define dPOPuv UV value = POPu
486 #define dPOPXssrl(X) SV *right = POPs; SV *left = CAT2(X,s)
487 #define dPOPXnnrl(X) NV right = POPn; NV left = CAT2(X,n)
488 #define dPOPXiirl(X) IV right = POPi; IV left = CAT2(X,i)
490 #define USE_LEFT(sv) \
491 (SvOK(sv) || !(PL_op->op_flags & OPf_STACKED))
492 #define dPOPXiirl_ul_nomg(X) \
493 IV right = (sp--, SvIV_nomg(TOPp1s)); \
494 SV *leftsv = CAT2(X,s); \
495 IV left = USE_LEFT(leftsv) ? SvIV_nomg(leftsv) : 0
497 #define dPOPPOPssrl dPOPXssrl(POP)
498 #define dPOPPOPnnrl dPOPXnnrl(POP)
499 #define dPOPPOPiirl dPOPXiirl(POP)
501 #define dPOPTOPssrl dPOPXssrl(TOP)
502 #define dPOPTOPnnrl dPOPXnnrl(TOP)
503 #define dPOPTOPnnrl_nomg \
504 NV right = SvNV_nomg(TOPs); NV left = (sp--, SvNV_nomg(TOPs))
505 #define dPOPTOPiirl dPOPXiirl(TOP)
506 #define dPOPTOPiirl_ul_nomg dPOPXiirl_ul_nomg(TOP)
507 #define dPOPTOPiirl_nomg \
508 IV right = SvIV_nomg(TOPs); IV left = (sp--, SvIV_nomg(TOPs))
510 #define RETPUSHYES RETURNX(PUSHs(&PL_sv_yes))
511 #define RETPUSHNO RETURNX(PUSHs(&PL_sv_no))
512 #define RETPUSHUNDEF RETURNX(PUSHs(&PL_sv_undef))
514 #define RETSETYES RETURNX(SETs(&PL_sv_yes))
515 #define RETSETNO RETURNX(SETs(&PL_sv_no))
516 #define RETSETUNDEF RETURNX(SETs(&PL_sv_undef))
517 #define RETSETTARG STMT_START { SETTARG; RETURN; } STMT_END
519 #define ARGTARG PL_op->op_targ
521 #define MAXARG (PL_op->op_private & OPpARG4_MASK)
523 #define SWITCHSTACK(f,t) \
525 AvFILLp(f) = sp - PL_stack_base; \
526 PL_stack_base = AvARRAY(t); \
527 PL_stack_max = PL_stack_base + AvMAX(t); \
528 sp = PL_stack_sp = PL_stack_base + AvFILLp(t); \
532 #define EXTEND_MORTAL(n) \
534 SSize_t eMiX = PL_tmps_ix + (n); \
535 if (UNLIKELY(eMiX >= PL_tmps_max)) \
536 (void)Perl_tmps_grow_p(aTHX_ eMiX); \
539 #define AMGf_noright 1
540 #define AMGf_noleft 2
541 #define AMGf_assign 4
543 #define AMGf_numeric 0x10 /* for Perl_try_amagic_bin */
544 #define AMGf_set 0x20 /* for Perl_try_amagic_bin */
545 #define AMGf_want_list 0x40
546 #define AMGf_numarg 0x80
549 /* do SvGETMAGIC on the stack args before checking for overload */
551 #define tryAMAGICun_MG(method, flags) STMT_START { \
552 if ( UNLIKELY((SvFLAGS(TOPs) & (SVf_ROK|SVs_GMG))) \
553 && Perl_try_amagic_un(aTHX_ method, flags)) \
556 #define tryAMAGICbin_MG(method, flags) STMT_START { \
557 if ( UNLIKELY(((SvFLAGS(TOPm1s)|SvFLAGS(TOPs)) & (SVf_ROK|SVs_GMG))) \
558 && Perl_try_amagic_bin(aTHX_ method, flags)) \
562 #define AMG_CALLunary(sv,meth) \
563 amagic_call(sv,&PL_sv_undef, meth, AMGf_noright | AMGf_unary)
565 /* No longer used in core. Use AMG_CALLunary instead */
566 #define AMG_CALLun(sv,meth) AMG_CALLunary(sv, CAT2(meth,_amg))
568 #define tryAMAGICunTARGETlist(meth, jump) \
573 int gimme = GIMME_V; \
574 if (UNLIKELY(SvAMAGIC(arg) && \
575 (tmpsv = amagic_call(arg, &PL_sv_undef, meth, \
576 AMGf_want_list | AMGf_noright \
580 if (gimme == G_VOID) { \
583 else if (gimme == G_ARRAY) { \
586 assert(SvTYPE(tmpsv) == SVt_PVAV); \
587 len = av_tindex((AV *)tmpsv) + 1; \
588 (void)POPs; /* get rid of the arg */ \
590 for (i = 0; i < len; ++i) \
591 PUSHs(av_shift((AV *)tmpsv)); \
593 else { /* AMGf_want_scalar */ \
594 dATARGET; /* just use the arg's location */ \
595 sv_setsv(TARG, tmpsv); \
602 OP *jump_o = NORMAL->op_next; \
603 while (jump_o->op_type == OP_NULL) \
604 jump_o = jump_o->op_next; \
605 assert(jump_o->op_type == OP_ENTERSUB); \
607 return jump_o->op_next; \
613 /* This is no longer used anywhere in the core. You might wish to consider
614 calling amagic_deref_call() directly, as it has a cleaner interface. */
615 #define tryAMAGICunDEREF(meth) \
617 sv = amagic_deref_call(*sp, CAT2(meth,_amg)); \
622 #define opASSIGN (PL_op->op_flags & OPf_STACKED)
625 =for apidoc mU||LVRET
626 True if this op will be the return value of an lvalue subroutine
629 #define LVRET ((PL_op->op_private & OPpMAYBE_LVSUB) && is_lvalue_sub())
631 #define SvCANEXISTDELETE(sv) \
633 || !(mg = mg_find((const SV *) sv, PERL_MAGIC_tied)) \
634 || ( (stash = SvSTASH(SvRV(SvTIED_obj(MUTABLE_SV(sv), mg)))) \
635 && gv_fetchmethod_autoload(stash, "EXISTS", TRUE) \
636 && gv_fetchmethod_autoload(stash, "DELETE", TRUE) \
642 /* These are just for Perl_tied_method(), which is not part of the public API.
643 Use 0x04 rather than the next available bit, to help the compiler if the
644 architecture can generate more efficient instructions. */
645 # define TIED_METHOD_MORTALIZE_NOT_NEEDED 0x04
646 # define TIED_METHOD_ARGUMENTS_ON_STACK 0x08
647 # define TIED_METHOD_SAY 0x10
649 /* Used in various places that need to dereference a glob or globref */
650 # define MAYBE_DEREF_GV_flags(sv,phlags) \
652 (void)(phlags & SV_GMAGIC && (SvGETMAGIC(sv),0)), \
655 : SvROK(sv) && SvTYPE(SvRV(sv)) <= SVt_PVLV && \
656 (SvGETMAGIC(SvRV(sv)), isGV_with_GP(SvRV(sv))) \
660 # define MAYBE_DEREF_GV(sv) MAYBE_DEREF_GV_flags(sv,SV_GMAGIC)
661 # define MAYBE_DEREF_GV_nomg(sv) MAYBE_DEREF_GV_flags(sv,0)
663 # define FIND_RUNCV_padid_eq 1
664 # define FIND_RUNCV_level_eq 2
669 * ex: set ts=8 sts=4 sw=4 et: