File Coverage

hax/perl-backcompat.c.inc
Criterion Covered Total %
statement 0 15 0.0
branch 0 46 0.0
condition n/a
subroutine n/a
pod n/a
total 0 61 0.0


line stmt bran cond sub pod time code
1             /* vi: set ft=c : */
2              
3             #define HAVE_PERL_VERSION(R, V, S) \
4             (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S))))))
5              
6             #ifndef NOT_REACHED
7             # define NOT_REACHED assert(0)
8             #endif
9              
10             #ifndef SvTRUE_NN
11             # define SvTRUE_NN(sv) SvTRUE(sv)
12             #endif
13              
14             #ifndef G_LIST
15             # define G_LIST G_ARRAY
16             #endif
17              
18             #if !HAVE_PERL_VERSION(5, 18, 0)
19             typedef AV PADNAMELIST;
20             # define PadlistARRAY(pl) ((PAD **)AvARRAY(pl))
21             # define PadlistNAMES(pl) (*PadlistARRAY(pl))
22              
23             typedef SV PADNAME;
24             # define PadnamePV(pn) (SvPOKp(pn) ? SvPVX(pn) : NULL)
25             # define PadnameLEN(pn) SvCUR(pn)
26             # define PadnameIsSTATE(pn) (!!SvPAD_STATE(pn))
27             # define PadnameOUTER(pn) (SvFAKE(pn) && !SvPAD_STATE(pn))
28             # define PadnamelistARRAY(pnl) AvARRAY(pnl)
29             # define PadnamelistMAX(pnl) AvFILLp(pnl)
30              
31             # define PadARRAY(p) AvARRAY(p)
32             # define PadMAX(pad) AvFILLp(pad)
33             #endif
34              
35             #if !HAVE_PERL_VERSION(5, 22, 0)
36             # define CvPADLIST_set(cv, padlist) (CvPADLIST(cv) = padlist)
37             # define newPADNAMEpvn(p,n) S_newPADNAMEpvn(aTHX_ p,n)
38             static PADNAME *S_newPADNAMEpvn(pTHX_ const char *pv, STRLEN n)
39             {
40             PADNAME *pn = newSVpvn(pv, n);
41             /* PADNAMEs need to be at least SVt_PVNV in order to store the COP_SEQ_*
42             * fields */
43             sv_upgrade(pn, SVt_PVNV);
44             return pn;
45             }
46             # define PadnameREFCNT_dec(pn) SvREFCNT_dec(pn)
47             #endif
48              
49             #ifndef av_count
50             # define av_count(av) (AvFILL(av) + 1)
51             #endif
52              
53             #ifndef av_fetch_simple
54             # define av_fetch_simple(av, idx, lval) av_fetch(av, idx, lval)
55             #endif
56              
57             #ifndef av_push_simple
58             # define av_push_simple(av, sv) av_push(av, sv)
59             #endif
60              
61             #ifndef av_top_index
62             # define av_top_index(av) AvFILL(av)
63             #endif
64              
65             #ifndef block_end
66             # define block_end(a,b) Perl_block_end(aTHX_ a,b)
67             #endif
68              
69             #ifndef block_start
70             # define block_start(a) Perl_block_start(aTHX_ a)
71             #endif
72              
73             #ifndef cophh_exists_pvs
74             # define cophh_exists_pvs(a,b,c) cBOOL(cophh_fetch_pvs(a,b,c))
75             #endif
76              
77             #ifndef cv_clone
78             # define cv_clone(a) Perl_cv_clone(aTHX_ a)
79             #endif
80              
81             #ifndef intro_my
82             # define intro_my() Perl_intro_my(aTHX)
83             #endif
84              
85             #ifndef pad_alloc
86             # define pad_alloc(a,b) Perl_pad_alloc(aTHX_ a,b)
87             #endif
88              
89             #ifndef CX_CUR
90             # define CX_CUR() (&cxstack[cxstack_ix])
91             #endif
92              
93             #if HAVE_PERL_VERSION(5, 24, 0)
94             # define OLDSAVEIX(cx) (cx->blk_oldsaveix)
95             #else
96             # define OLDSAVEIX(cx) (PL_scopestack[cx->blk_oldscopesp-1])
97             #endif
98              
99             #ifndef OpSIBLING
100             # define OpSIBLING(op) ((op)->op_sibling)
101             #endif
102              
103             #ifndef OpHAS_SIBLING
104             # define OpHAS_SIBLING(op) (cBOOL(OpSIBLING(op)))
105             #endif
106              
107             #ifndef OpMORESIB_set
108             # define OpMORESIB_set(op,sib) ((op)->op_sibling = (sib))
109             #endif
110              
111             #ifndef OpLASTSIB_set
112             /* older perls don't need to store this at all */
113             # define OpLASTSIB_set(op,parent)
114             #endif
115              
116             #ifndef op_convert_list
117             # define op_convert_list(type, flags, o) S_op_convert_list(aTHX_ type, flags, o)
118             static OP *S_op_convert_list(pTHX_ I32 type, I32 flags, OP *o)
119             {
120             /* A minimal recreation just for our purposes */
121             assert(
122             /* A hardcoded list of the optypes we know this will work for */
123             type == OP_ENTERSUB ||
124             type == OP_JOIN ||
125             type == OP_PUSH ||
126             0);
127              
128             o->op_type = type;
129             o->op_flags |= flags;
130             o->op_ppaddr = PL_ppaddr[type];
131              
132             o = PL_check[type](aTHX_ o);
133              
134             /* op_std_init() */
135             if(PL_opargs[type] & OA_RETSCALAR)
136             o = op_contextualize(o, G_SCALAR);
137             if(PL_opargs[type] & OA_TARGET && !o->op_targ)
138             o->op_targ = pad_alloc(type, SVs_PADTMP);
139              
140             return o;
141             }
142             #endif
143              
144             #ifndef newMETHOP_named
145             # define newMETHOP_named(type, flags, name) newSVOP(type, flags, name)
146             #endif
147              
148             #ifndef PARENT_PAD_INDEX_set
149             # if HAVE_PERL_VERSION(5, 22, 0)
150             # define PARENT_PAD_INDEX_set(pn,val) (PARENT_PAD_INDEX(pn) = val)
151             # else
152             /* stolen from perl-5.20.0's pad.c */
153             # define PARENT_PAD_INDEX_set(sv,val) \
154             STMT_START { ((XPVNV*)SvANY(sv))->xnv_u.xpad_cop_seq.xlow = (val); } STMT_END
155             # endif
156             #endif
157              
158             /* On Perl 5.14 this had a different name */
159             #ifndef pad_add_name_pvn
160             #define pad_add_name_pvn(name, len, flags, typestash, ourstash) MY_pad_add_name(aTHX_ name, len, flags, typestash, ourstash)
161             static PADOFFSET MY_pad_add_name(pTHX_ const char *name, STRLEN len, U32 flags, HV *typestash, HV *ourstash)
162             {
163             /* perl 5.14's Perl_pad_add_name requires a NUL-terminated name */
164             SV *namesv = sv_2mortal(newSVpvn(name, len));
165              
166             return Perl_pad_add_name(aTHX_ SvPV_nolen(namesv), SvCUR(namesv), flags, typestash, ourstash);
167             }
168             #endif
169              
170             #if !HAVE_PERL_VERSION(5, 26, 0)
171             # define isIDFIRST_utf8_safe(s, e) (PERL_UNUSED_ARG(e), isIDFIRST_utf8(s))
172             # define isIDCONT_utf8_safe(s, e) (PERL_UNUSED_ARG(e), isIDCONT_utf8(s))
173             #endif
174              
175             #ifndef CXp_EVALBLOCK
176             /* before perl 5.34 this was called CXp_TRYBLOCK */
177             # define CXp_EVALBLOCK CXp_TRYBLOCK
178             #endif
179              
180             #if !HAVE_PERL_VERSION(5, 26, 0)
181             # define sv_set_undef(sv) sv_setsv(sv, &PL_sv_undef)
182             #endif
183              
184             #ifndef newAVav
185             # define newAVav(av) S_newAVav(aTHX_ av)
186 0           static AV *S_newAVav(pTHX_ AV *av)
187             {
188 0           AV *ret = newAV();
189 0 0         U32 count = av_count(av);
190             U32 i;
191 0 0         for(i = 0; i < count; i++)
192 0           av_push(ret, newSVsv(AvARRAY(av)[i]));
193 0           return ret;
194             }
195             #endif
196              
197             #if !defined(sv_derived_from_hv) && HAVE_PERL_VERSION(5, 16, 0)
198             # define sv_derived_from_hv(sv, hv) MY_sv_derived_from_hv(aTHX_ sv, hv)
199 0           static bool MY_sv_derived_from_hv(pTHX_ SV *sv, HV *hv)
200             {
201 0 0         char *hvname = HvNAME(hv);
    0          
    0          
    0          
    0          
    0          
202 0 0         if(!hvname)
203 0           return FALSE;
204              
205 0 0         return sv_derived_from_pvn(sv, hvname, HvNAMELEN(hv), HvNAMEUTF8(hv) ? SVf_UTF8 : 0);
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
    0          
206             }
207             #endif
208              
209             #ifndef xV_FROM_REF
210             # ifdef PERL_USE_GCC_BRACE_GROUPS
211             # define xV_FROM_REF(XV, ref) \
212             ({ SV *_ref = ref; assert(SvROK(_ref)); assert(SvTYPE(SvRV(_ref)) == SVt_PV ## XV); (XV *)(SvRV(_ref)); })
213             # else
214             # define xV_FROM_REF(XV, ref) ((XV *)SvRV(ref))
215             # endif
216              
217             # define AV_FROM_REF(ref) xV_FROM_REF(AV, ref)
218             # define CV_FROM_REF(ref) xV_FROM_REF(CV, ref)
219             # define HV_FROM_REF(ref) xV_FROM_REF(HV, ref)
220             #endif
221              
222             #ifndef newPADxVOP
223             # define newPADxVOP(type, flags, padix) S_newPADxVOP(aTHX_ type, flags, padix)
224 0           static OP *S_newPADxVOP(pTHX_ I32 type, I32 flags, PADOFFSET padix)
225             {
226 0           OP *op = newOP(type, flags);
227 0           op->op_targ = padix;
228 0           return op;
229             }
230             #endif