hax/cv_set_anysv_refcounted.c.inc

filter: Statementstmt 0.0% 0 / 4 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 4 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« hax/croak_from_caller.c.inc ↑ Summary lib/Future/XS.xs »
1 /* vi: set ft=c : */
2  
3 #if HAVE_PERL_VERSION(5, 26, 0)
4 # define XSANY_sv XSANY.any_sv
5 # define CvXSUBANY_sv(cv) CvXSUBANY(cv).any_sv
6 # define CvXSUBANY_sv_set(cv, sv) (CvXSUBANY(cv).any_sv = (sv))
7 #else
8 /* Older perls did not have a .any_sv; we'll just cast the .any_ptr pointer */
9 # define XSANY_sv ((SV *)XSANY.any_ptr)
10 # define CvXSUBANY_sv(cv) ((SV *)CvXSUBANY(cv).any_ptr)
11 # define CvXSUBANY_sv_set(cv, sv) (CvXSUBANY(cv).any_ptr = (sv))
12 #endif
13  
14 #ifdef CvREFCOUNTED_ANYSV
15 # define HAVE_CVREFCOUNTED_ANYSV
16 #endif
17  
18 #ifndef HAVE_CVREFCOUNTED_ANYSV
19 static int free_anysv_refcounted(pTHX_ SV *sv, MAGIC *mg)
20 {
21 SvREFCNT_dec(CvXSUBANY_sv((CV *)sv));
22 return 0;
23 }
24  
25 static MGVTBL vtbl_anysv_refcounted = {
26 .svt_free = &free_anysv_refcounted,
27 };
28 #endif
29  
30 #define cv_set_anysv_refcounted(cv, sv) S_cv_set_anysv_refcounted(aTHX_ cv, sv)
31 0 static void S_cv_set_anysv_refcounted(pTHX_ CV *cv, SV *sv)
32 {
33 0 CvXSUBANY_sv_set(cv, sv);
34  
35 #ifdef HAVE_CVREFCOUNTED_ANYSV
36 0 CvREFCOUNTED_ANYSV_on(cv);
37 #else
38 sv_magicext((SV *)cv, NULL, PERL_MAGIC_ext, &vtbl_anysv_refcounted, NULL, 0);
39 #endif
40 0 }
« hax/croak_from_caller.c.inc ↑ Summary lib/Future/XS.xs »