line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
* |
3
|
|
|
|
|
|
|
* Copyright (c) 2018, Nicolas R. |
4
|
|
|
|
|
|
|
* |
5
|
|
|
|
|
|
|
* This is free software; you can redistribute it and/or modify it under the |
6
|
|
|
|
|
|
|
* same terms as Perl itself. |
7
|
|
|
|
|
|
|
* |
8
|
|
|
|
|
|
|
*/ |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include |
11
|
|
|
|
|
|
|
#include |
12
|
|
|
|
|
|
|
#include |
13
|
|
|
|
|
|
|
#include |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#if defined(SV_COW_REFCNT_MAX) |
16
|
|
|
|
|
|
|
# define B_CAN_COW 1 |
17
|
|
|
|
|
|
|
#else |
18
|
|
|
|
|
|
|
# define B_CAN_COW 0 |
19
|
|
|
|
|
|
|
#endif |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
/* CowREFCNT is incorrect on Perl < 5.32 */ |
22
|
|
|
|
|
|
|
#define myCowREFCNT(sv) ((SvLEN(sv)>0) ? CowREFCNT(sv) : 0) |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
MODULE = B__COW PACKAGE = B::COW |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
SV* |
27
|
|
|
|
|
|
|
can_cow() |
28
|
|
|
|
|
|
|
CODE: |
29
|
|
|
|
|
|
|
{ |
30
|
|
|
|
|
|
|
#if B_CAN_COW |
31
|
2
|
|
|
|
|
|
XSRETURN_YES; |
32
|
|
|
|
|
|
|
#else |
33
|
|
|
|
|
|
|
XSRETURN_NO; |
34
|
|
|
|
|
|
|
#endif |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
OUTPUT: |
37
|
|
|
|
|
|
|
RETVAL |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
SV* |
40
|
|
|
|
|
|
|
is_cow(sv) |
41
|
|
|
|
|
|
|
SV *sv; |
42
|
|
|
|
|
|
|
CODE: |
43
|
|
|
|
|
|
|
{ |
44
|
|
|
|
|
|
|
/* not exactly accurate but let's start there */ |
45
|
|
|
|
|
|
|
#if !B_CAN_COW |
46
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
47
|
|
|
|
|
|
|
#else |
48
|
9
|
100
|
|
|
|
|
if ( SvPOK(sv) && SvIsCOW(sv) ) XSRETURN_YES; |
|
|
100
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#endif |
50
|
2
|
|
|
|
|
|
XSRETURN_NO; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
OUTPUT: |
53
|
|
|
|
|
|
|
RETVAL |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
SV* |
56
|
|
|
|
|
|
|
cowrefcnt(sv) |
57
|
|
|
|
|
|
|
SV *sv; |
58
|
|
|
|
|
|
|
CODE: |
59
|
|
|
|
|
|
|
{ |
60
|
|
|
|
|
|
|
#if !B_CAN_COW |
61
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
62
|
|
|
|
|
|
|
#else |
63
|
10
|
100
|
|
|
|
|
if ( SvIsCOW(sv) ) XSRETURN_IV( myCowREFCNT(sv) ); |
|
|
100
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#endif |
65
|
1
|
|
|
|
|
|
XSRETURN_UNDEF; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
OUTPUT: |
68
|
|
|
|
|
|
|
RETVAL |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
SV* |
71
|
|
|
|
|
|
|
cowrefcnt_max() |
72
|
|
|
|
|
|
|
CODE: |
73
|
|
|
|
|
|
|
{ |
74
|
|
|
|
|
|
|
#if !B_CAN_COW |
75
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
76
|
|
|
|
|
|
|
#else |
77
|
1
|
|
|
|
|
|
XSRETURN_IV(SV_COW_REFCNT_MAX); |
78
|
|
|
|
|
|
|
#endif |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
OUTPUT: |
81
|
|
|
|
|
|
|
RETVAL |