Missign STATEMENT brackets in PUSHMARK
[p5sagit/p5-mst-13.2.git] / pp.h
1 /*    pp.h
2  *
3  *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999,
4  *    2000, 2001, 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 #define PP(s) OP * Perl_##s(pTHX)
12
13 /*
14 =head1 Stack Manipulation Macros
15
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
23 =for apidoc Am|void|PUSHMARK|SP
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
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
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
51 =cut */
52
53 #undef SP /* Solaris 2.7 i386 has this in /usr/include/sys/reg.h */
54 #define SP sp
55 #define MARK mark
56 #define TARG targ
57
58 #define PUSHMARK(p)     \
59         STMT_START {                                    \
60             if (++PL_markstack_ptr == PL_markstack_max) \
61             markstack_grow();                           \
62             *PL_markstack_ptr = (p) - PL_stack_base;    \
63         } STMT_END
64
65 #define TOPMARK         (*PL_markstack_ptr)
66 #define POPMARK         (*PL_markstack_ptr--)
67
68 #define dSP             register SV **sp = PL_stack_sp
69 #define djSP            dSP
70 #define dMARK           register SV **mark = PL_stack_base + POPMARK
71 #define dORIGMARK       I32 origmark = mark - PL_stack_base
72 #define SETORIGMARK     origmark = mark - PL_stack_base
73 #define ORIGMARK        (PL_stack_base + origmark)
74
75 #define SPAGAIN         sp = PL_stack_sp
76 #define MSPAGAIN        STMT_START { sp = PL_stack_sp; mark = ORIGMARK; } STMT_END
77
78 #define GETTARGETSTACKED targ = (PL_op->op_flags & OPf_STACKED ? POPs : PAD_SV(PL_op->op_targ))
79 #define dTARGETSTACKED SV * GETTARGETSTACKED
80
81 #define GETTARGET targ = PAD_SV(PL_op->op_targ)
82 #define dTARGET SV * GETTARGET
83
84 #define GETATARGET targ = (PL_op->op_flags & OPf_STACKED ? sp[-1] : PAD_SV(PL_op->op_targ))
85 #define dATARGET SV * GETATARGET
86
87 #define dTARG SV *targ
88
89 #define NORMAL PL_op->op_next
90 #define DIE return Perl_die
91
92 /*
93 =for apidoc Ams||PUTBACK
94 Closing bracket for XSUB arguments.  This is usually handled by C<xsubpp>.
95 See C<PUSHMARK> and L<perlcall> for other uses.
96
97 =for apidoc Amn|SV*|POPs
98 Pops an SV off the stack.
99
100 =for apidoc Amn|char*|POPp
101 Pops a string off the stack. Deprecated. New code should provide
102 a STRLEN n_a and use POPpx.
103
104 =for apidoc Amn|char*|POPpx
105 Pops a string off the stack.
106 Requires a variable STRLEN n_a in scope.
107
108 =for apidoc Amn|char*|POPpbytex
109 Pops a string off the stack which must consist of bytes i.e. characters < 256.
110 Requires a variable STRLEN n_a in scope.
111
112 =for apidoc Amn|NV|POPn
113 Pops a double off the stack.
114
115 =for apidoc Amn|IV|POPi
116 Pops an integer off the stack.
117
118 =for apidoc Amn|long|POPl
119 Pops a long off the stack.
120
121 =cut
122 */
123
124 #define PUTBACK         PL_stack_sp = sp
125 #define RETURN          return PUTBACK, NORMAL
126 #define RETURNOP(o)     return PUTBACK, o
127 #define RETURNX(x)      return x, PUTBACK, NORMAL
128
129 #define POPs            (*sp--)
130 #define POPp            (SvPVx(POPs, PL_na))            /* deprecated */
131 #define POPpx           (SvPVx(POPs, n_a))
132 #define POPpbytex       (SvPVbytex(POPs, n_a))
133 #define POPn            (SvNVx(POPs))
134 #define POPi            ((IV)SvIVx(POPs))
135 #define POPu            ((UV)SvUVx(POPs))
136 #define POPl            ((long)SvIVx(POPs))
137 #define POPul           ((unsigned long)SvIVx(POPs))
138 #ifdef HAS_QUAD
139 #define POPq            ((Quad_t)SvIVx(POPs))
140 #define POPuq           ((Uquad_t)SvUVx(POPs))
141 #endif
142
143 #define TOPs            (*sp)
144 #define TOPm1s          (*(sp-1))
145 #define TOPp1s          (*(sp+1))
146 #define TOPp            (SvPV(TOPs, PL_na))             /* deprecated */
147 #define TOPpx           (SvPV(TOPs, n_a))
148 #define TOPn            (SvNV(TOPs))
149 #define TOPi            ((IV)SvIV(TOPs))
150 #define TOPu            ((UV)SvUV(TOPs))
151 #define TOPl            ((long)SvIV(TOPs))
152 #define TOPul           ((unsigned long)SvUV(TOPs))
153 #ifdef HAS_QUAD
154 #define TOPq            ((Quad_t)SvIV(TOPs))
155 #define TOPuq           ((Uquad_t)SvUV(TOPs))
156 #endif
157
158 /* Go to some pains in the rare event that we must extend the stack. */
159
160 /*
161 =for apidoc Am|void|EXTEND|SP|int nitems
162 Used to extend the argument stack for an XSUB's return values. Once
163 used, guarantees that there is room for at least C<nitems> to be pushed
164 onto the stack.
165
166 =for apidoc Am|void|PUSHs|SV* sv
167 Push an SV onto the stack.  The stack must have room for this element.
168 Does not handle 'set' magic.  Does not use C<TARG>.  See also C<PUSHmortal>,
169 C<XPUSHs> and C<XPUSHmortal>.
170
171 =for apidoc Am|void|PUSHp|char* str|STRLEN len
172 Push a string onto the stack.  The stack must have room for this element.
173 The C<len> indicates the length of the string.  Handles 'set' magic.  Uses
174 C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to declare it.  Do not
175 call multiple C<TARG>-oriented macros to return lists from XSUB's - see
176 C<mPUSHp> instead.  See also C<XPUSHp> and C<mXPUSHp>.
177
178 =for apidoc Am|void|PUSHn|NV nv
179 Push a double onto the stack.  The stack must have room for this element.
180 Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
181 called to declare it.  Do not call multiple C<TARG>-oriented macros to
182 return lists from XSUB's - see C<mPUSHn> instead.  See also C<XPUSHn> and
183 C<mXPUSHn>.
184
185 =for apidoc Am|void|PUSHi|IV iv
186 Push an integer onto the stack.  The stack must have room for this element.
187 Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
188 called to declare it.  Do not call multiple C<TARG>-oriented macros to 
189 return lists from XSUB's - see C<mPUSHi> instead.  See also C<XPUSHi> and
190 C<mXPUSHi>.
191
192 =for apidoc Am|void|PUSHu|UV uv
193 Push an unsigned integer onto the stack.  The stack must have room for this
194 element.  Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG>
195 should be called to declare it.  Do not call multiple C<TARG>-oriented
196 macros to return lists from XSUB's - see C<mPUSHu> instead.  See also
197 C<XPUSHu> and C<mXPUSHu>.
198
199 =for apidoc Am|void|XPUSHs|SV* sv
200 Push an SV onto the stack, extending the stack if necessary.  Does not
201 handle 'set' magic.  Does not use C<TARG>.  See also C<XPUSHmortal>,
202 C<PUSHs> and C<PUSHmortal>.
203
204 =for apidoc Am|void|XPUSHp|char* str|STRLEN len
205 Push a string onto the stack, extending the stack if necessary.  The C<len>
206 indicates the length of the string.  Handles 'set' magic.  Uses C<TARG>, so
207 C<dTARGET> or C<dXSTARG> should be called to declare it.  Do not call
208 multiple C<TARG>-oriented macros to return lists from XSUB's - see
209 C<mXPUSHp> instead.  See also C<PUSHp> and C<mPUSHp>.
210
211 =for apidoc Am|void|XPUSHn|NV nv
212 Push a double onto the stack, extending the stack if necessary.  Handles
213 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
214 declare it.  Do not call multiple C<TARG>-oriented macros to return lists
215 from XSUB's - see C<mXPUSHn> instead.  See also C<PUSHn> and C<mPUSHn>.
216
217 =for apidoc Am|void|XPUSHi|IV iv
218 Push an integer onto the stack, extending the stack if necessary.  Handles
219 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be called to
220 declare it.  Do not call multiple C<TARG>-oriented macros to return lists
221 from XSUB's - see C<mXPUSHi> instead.  See also C<PUSHi> and C<mPUSHi>.
222
223 =for apidoc Am|void|XPUSHu|UV uv
224 Push an unsigned integer onto the stack, extending the stack if necessary.
225 Handles 'set' magic.  Uses C<TARG>, so C<dTARGET> or C<dXSTARG> should be
226 called to declare it.  Do not call multiple C<TARG>-oriented macros to
227 return lists from XSUB's - see C<mXPUSHu> instead.  See also C<PUSHu> and
228 C<mPUSHu>.
229
230 =for apidoc Am|void|PUSHmortal
231 Push a new mortal SV onto the stack.  The stack must have room for this
232 element.  Does not handle 'set' magic.  Does not use C<TARG>.  See also
233 C<PUSHs>, C<XPUSHmortal> and C<XPUSHs>.
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.
237 The C<len> indicates the length of the string.  Handles 'set' magic.  Does
238 not use C<TARG>.  See also C<PUSHp>, C<mXPUSHp> and C<XPUSHp>.
239
240 =for apidoc Am|void|mPUSHn|NV nv
241 Push a double onto the stack.  The stack must have room for this element.
242 Handles 'set' magic.  Does not use C<TARG>.  See also C<PUSHn>, C<mXPUSHn>
243 and C<XPUSHn>.
244
245 =for apidoc Am|void|mPUSHi|IV iv
246 Push an integer onto the stack.  The stack must have room for this element.
247 Handles 'set' magic.  Does not use C<TARG>.  See also C<PUSHi>, C<mXPUSHi>
248 and C<XPUSHi>.
249
250 =for apidoc Am|void|mPUSHu|UV uv
251 Push an unsigned integer onto the stack.  The stack must have room for this
252 element.  Handles 'set' magic.  Does not use C<TARG>.  See also C<PUSHu>,
253 C<mXPUSHu> and C<XPUSHu>.
254
255 =for apidoc Am|void|XPUSHmortal
256 Push a new mortal SV onto the stack, extending the stack if necessary.  Does
257 not handle 'set' magic.  Does not use C<TARG>.  See also C<XPUSHs>,
258 C<PUSHmortal> and C<PUSHs>.
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>
262 indicates the length of the string.  Handles 'set' magic.  Does not use
263 C<TARG>.  See also C<XPUSHp>, C<mPUSHp> and C<PUSHp>.
264
265 =for apidoc Am|void|mXPUSHn|NV nv
266 Push a double onto the stack, extending the stack if necessary.  Handles
267 'set' magic.  Does not use C<TARG>.  See also C<XPUSHn>, C<mPUSHn> and
268 C<PUSHn>.
269
270 =for apidoc Am|void|mXPUSHi|IV iv
271 Push an integer onto the stack, extending the stack if necessary.  Handles
272 'set' magic.  Does not use C<TARG>.  See also C<XPUSHi>, C<mPUSHi> and
273 C<PUSHi>.
274
275 =for apidoc Am|void|mXPUSHu|UV uv
276 Push an unsigned integer onto the stack, extending the stack if necessary.
277 Handles 'set' magic.  Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu>
278 and C<PUSHu>.
279
280 =cut
281 */
282
283 #define EXTEND(p,n)     STMT_START { if (PL_stack_max - p < (int)(n)) {         \
284                             sp = stack_grow(sp,p, (int) (n));           \
285                         } } STMT_END
286
287 /* Same thing, but update mark register too. */
288 #define MEXTEND(p,n)    STMT_START {if (PL_stack_max - p < (int)(n)) {          \
289                             int markoff = mark - PL_stack_base;         \
290                             sp = stack_grow(sp,p,(int) (n));            \
291                             mark = PL_stack_base + markoff;             \
292                         } } STMT_END
293
294 #define PUSHs(s)        (*++sp = (s))
295 #define PUSHTARG        STMT_START { SvSETMAGIC(TARG); PUSHs(TARG); } STMT_END
296 #define PUSHp(p,l)      STMT_START { sv_setpvn(TARG, (p), (l)); PUSHTARG; } STMT_END
297 #define PUSHn(n)        STMT_START { sv_setnv(TARG, (NV)(n)); PUSHTARG; } STMT_END
298 #define PUSHi(i)        STMT_START { sv_setiv(TARG, (IV)(i)); PUSHTARG; } STMT_END
299 #define PUSHu(u)        STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END
300
301 #define XPUSHs(s)       STMT_START { EXTEND(sp,1); (*++sp = (s)); } STMT_END
302 #define XPUSHTARG       STMT_START { SvSETMAGIC(TARG); XPUSHs(TARG); } STMT_END
303 #define XPUSHp(p,l)     STMT_START { sv_setpvn(TARG, (p), (l)); XPUSHTARG; } STMT_END
304 #define XPUSHn(n)       STMT_START { sv_setnv(TARG, (NV)(n)); XPUSHTARG; } STMT_END
305 #define XPUSHi(i)       STMT_START { sv_setiv(TARG, (IV)(i)); XPUSHTARG; } STMT_END
306 #define XPUSHu(u)       STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END
307 #define XPUSHundef      STMT_START { SvOK_off(TARG); XPUSHs(TARG); } STMT_END
308
309 #define PUSHmortal      PUSHs(sv_newmortal())
310 #define mPUSHp(p,l)     sv_setpvn_mg(PUSHmortal, (p), (l))
311 #define mPUSHn(n)       sv_setnv_mg(PUSHmortal, (NV)(n))
312 #define mPUSHi(i)       sv_setiv_mg(PUSHmortal, (IV)(i))
313 #define mPUSHu(u)       sv_setuv_mg(PUSHmortal, (UV)(u))
314
315 #define XPUSHmortal     XPUSHs(sv_newmortal())
316 #define mXPUSHp(p,l)    STMT_START { EXTEND(sp,1); sv_setpvn_mg(PUSHmortal, (p), (l)); } STMT_END
317 #define mXPUSHn(n)      STMT_START { EXTEND(sp,1); sv_setnv_mg(PUSHmortal, (NV)(n)); } STMT_END
318 #define mXPUSHi(i)      STMT_START { EXTEND(sp,1); sv_setiv_mg(PUSHmortal, (IV)(i)); } STMT_END
319 #define mXPUSHu(u)      STMT_START { EXTEND(sp,1); sv_setuv_mg(PUSHmortal, (UV)(u)); } STMT_END
320
321 #define SETs(s)         (*sp = s)
322 #define SETTARG         STMT_START { SvSETMAGIC(TARG); SETs(TARG); } STMT_END
323 #define SETp(p,l)       STMT_START { sv_setpvn(TARG, (p), (l)); SETTARG; } STMT_END
324 #define SETn(n)         STMT_START { sv_setnv(TARG, (NV)(n)); SETTARG; } STMT_END
325 #define SETi(i)         STMT_START { sv_setiv(TARG, (IV)(i)); SETTARG; } STMT_END
326 #define SETu(u)         STMT_START { sv_setuv(TARG, (UV)(u)); SETTARG; } STMT_END
327
328 #define dTOPss          SV *sv = TOPs
329 #define dPOPss          SV *sv = POPs
330 #define dTOPnv          NV value = TOPn
331 #define dPOPnv          NV value = POPn
332 #define dTOPiv          IV value = TOPi
333 #define dPOPiv          IV value = POPi
334 #define dTOPuv          UV value = TOPu
335 #define dPOPuv          UV value = POPu
336 #ifdef HAS_QUAD
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
342
343 #define dPOPXssrl(X)    SV *right = POPs; SV *left = CAT2(X,s)
344 #define dPOPXnnrl(X)    NV right = POPn; NV left = CAT2(X,n)
345 #define dPOPXiirl(X)    IV right = POPi; IV left = CAT2(X,i)
346
347 #define USE_LEFT(sv) \
348         (SvOK(sv) || SvGMAGICAL(sv) || !(PL_op->op_flags & OPf_STACKED))
349 #define dPOPXnnrl_ul(X) \
350     NV right = POPn;                            \
351     SV *leftsv = CAT2(X,s);                             \
352     NV left = USE_LEFT(leftsv) ? SvNV(leftsv) : 0.0
353 #define dPOPXiirl_ul(X) \
354     IV right = POPi;                                    \
355     SV *leftsv = CAT2(X,s);                             \
356     IV left = USE_LEFT(leftsv) ? SvIV(leftsv) : 0
357
358 #define dPOPPOPssrl     dPOPXssrl(POP)
359 #define dPOPPOPnnrl     dPOPXnnrl(POP)
360 #define dPOPPOPnnrl_ul  dPOPXnnrl_ul(POP)
361 #define dPOPPOPiirl     dPOPXiirl(POP)
362 #define dPOPPOPiirl_ul  dPOPXiirl_ul(POP)
363
364 #define dPOPTOPssrl     dPOPXssrl(TOP)
365 #define dPOPTOPnnrl     dPOPXnnrl(TOP)
366 #define dPOPTOPnnrl_ul  dPOPXnnrl_ul(TOP)
367 #define dPOPTOPiirl     dPOPXiirl(TOP)
368 #define dPOPTOPiirl_ul  dPOPXiirl_ul(TOP)
369
370 #define RETPUSHYES      RETURNX(PUSHs(&PL_sv_yes))
371 #define RETPUSHNO       RETURNX(PUSHs(&PL_sv_no))
372 #define RETPUSHUNDEF    RETURNX(PUSHs(&PL_sv_undef))
373
374 #define RETSETYES       RETURNX(SETs(&PL_sv_yes))
375 #define RETSETNO        RETURNX(SETs(&PL_sv_no))
376 #define RETSETUNDEF     RETURNX(SETs(&PL_sv_undef))
377
378 #define ARGTARG         PL_op->op_targ
379
380     /* See OPpTARGET_MY: */
381 #define MAXARG          (PL_op->op_private & 15)
382
383 #define SWITCHSTACK(f,t) \
384     STMT_START {                                                        \
385         AvFILLp(f) = sp - PL_stack_base;                                \
386         PL_stack_base = AvARRAY(t);                                     \
387         PL_stack_max = PL_stack_base + AvMAX(t);                        \
388         sp = PL_stack_sp = PL_stack_base + AvFILLp(t);                  \
389         PL_curstack = t;                                                \
390     } STMT_END
391
392 #define EXTEND_MORTAL(n) \
393     STMT_START {                                                        \
394         if (PL_tmps_ix + (n) >= PL_tmps_max)                            \
395             tmps_grow(n);                                               \
396     } STMT_END
397
398 #define AMGf_noright    1
399 #define AMGf_noleft     2
400 #define AMGf_assign     4
401 #define AMGf_unary      8
402
403 #define tryAMAGICbinW(meth,assign,set) STMT_START { \
404           if (PL_amagic_generation) { \
405             SV* tmpsv; \
406             SV* right= *(sp); SV* left= *(sp-1);\
407             if ((SvAMAGIC(left)||SvAMAGIC(right))&&\
408                 (tmpsv=amagic_call(left, \
409                                    right, \
410                                    CAT2(meth,_amg), \
411                                    (assign)? AMGf_assign: 0))) {\
412                SPAGAIN; \
413                (void)POPs; set(tmpsv); RETURN; } \
414           } \
415         } STMT_END
416
417 #define tryAMAGICbin(meth,assign) tryAMAGICbinW(meth,assign,SETsv)
418 #define tryAMAGICbinSET(meth,assign) tryAMAGICbinW(meth,assign,SETs)
419
420 #define AMG_CALLun(sv,meth) amagic_call(sv,&PL_sv_undef,  \
421                                         CAT2(meth,_amg),AMGf_noright | AMGf_unary)
422 #define AMG_CALLbinL(left,right,meth) \
423             amagic_call(left,right,CAT2(meth,_amg),AMGf_noright)
424
425 #define tryAMAGICunW(meth,set,shift,ret) STMT_START { \
426           if (PL_amagic_generation) { \
427             SV* tmpsv; \
428             SV* arg= sp[shift]; \
429           if(0) goto am_again;  /* shut up unused warning */ \
430           am_again: \
431             if ((SvAMAGIC(arg))&&\
432                 (tmpsv=AMG_CALLun(arg,meth))) {\
433                SPAGAIN; if (shift) sp += shift; \
434                set(tmpsv); ret; } \
435           } \
436         } STMT_END
437
438 #define FORCE_SETs(sv) STMT_START { sv_setsv(TARG, (sv)); SETTARG; } STMT_END
439
440 #define tryAMAGICun(meth)       tryAMAGICunW(meth,SETsvUN,0,RETURN)
441 #define tryAMAGICunSET(meth)    tryAMAGICunW(meth,SETs,0,RETURN)
442 #define tryAMAGICunTARGET(meth, shift)                                  \
443         STMT_START { dSP; sp--;         /* get TARGET from below PL_stack_sp */         \
444             { dTARGETSTACKED;                                           \
445                 { dSP; tryAMAGICunW(meth,FORCE_SETs,shift,RETURN);}}} STMT_END
446
447 #define setAGAIN(ref)   \
448     STMT_START {                                        \
449         sv = ref;                                       \
450         if (!SvROK(ref))                                \
451             Perl_croak(aTHX_ "Overloaded dereference did not return a reference");      \
452         if (ref != arg && SvRV(ref) != SvRV(arg)) {     \
453             arg = ref;                                  \
454             goto am_again;                              \
455         }                                               \
456     } STMT_END
457
458 #define tryAMAGICunDEREF(meth) tryAMAGICunW(meth,setAGAIN,0,(void)0)
459
460 #define opASSIGN (PL_op->op_flags & OPf_STACKED)
461 #define SETsv(sv)       STMT_START {                                    \
462                 if (opASSIGN || (SvFLAGS(TARG) & SVs_PADMY))            \
463                    { sv_setsv(TARG, (sv)); SETTARG; }                   \
464                 else SETs(sv); } STMT_END
465
466 #define SETsvUN(sv)     STMT_START {                                    \
467                 if (SvFLAGS(TARG) & SVs_PADMY)          \
468                    { sv_setsv(TARG, (sv)); SETTARG; }                   \
469                 else SETs(sv); } STMT_END
470
471 /* newSVsv does not behave as advertised, so we copy missing
472  * information by hand */
473
474 /* SV* ref causes confusion with the member variable
475    changed SV* ref to SV* tmpRef */
476 #define RvDEEPCP(rv) STMT_START { SV* tmpRef=SvRV(rv);      \
477   if (SvREFCNT(tmpRef)>1) {                 \
478     SvRV(rv)=AMG_CALLun(rv,copy);       \
479     SvREFCNT_dec(tmpRef);                   \
480   } } STMT_END
481
482 /*
483 =for apidoc mU||LVRET
484 True if this op will be the return value of an lvalue subroutine
485
486 =cut */
487 #define LVRET ((PL_op->op_private & OPpMAYBE_LVSUB) && is_lvalue_sub())