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
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
SV* |
29
|
|
|
|
|
|
|
can_cow() |
30
|
|
|
|
|
|
|
CODE: |
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
#if B_CAN_COW |
33
|
2
|
|
|
|
|
|
XSRETURN_YES; |
34
|
|
|
|
|
|
|
#else |
35
|
|
|
|
|
|
|
XSRETURN_NO; |
36
|
|
|
|
|
|
|
#endif |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
OUTPUT: |
39
|
|
|
|
|
|
|
RETVAL |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
SV* |
42
|
|
|
|
|
|
|
is_cow(sv) |
43
|
|
|
|
|
|
|
SV *sv; |
44
|
|
|
|
|
|
|
CODE: |
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
/* not exactly accurate but let's start there */ |
47
|
|
|
|
|
|
|
#if !B_CAN_COW |
48
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
49
|
|
|
|
|
|
|
#else |
50
|
9
|
100
|
|
|
|
|
if ( SvPOK(sv) && SvIsCOW(sv) ) XSRETURN_YES; |
|
|
100
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#endif |
52
|
2
|
|
|
|
|
|
XSRETURN_NO; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
OUTPUT: |
55
|
|
|
|
|
|
|
RETVAL |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
SV* |
58
|
|
|
|
|
|
|
cowrefcnt(sv) |
59
|
|
|
|
|
|
|
SV *sv; |
60
|
|
|
|
|
|
|
CODE: |
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
#if !B_CAN_COW |
63
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
64
|
|
|
|
|
|
|
#else |
65
|
10
|
100
|
|
|
|
|
if ( SvIsCOW(sv) ) XSRETURN_IV( myCowREFCNT(sv) ); |
|
|
100
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#endif |
67
|
1
|
|
|
|
|
|
XSRETURN_UNDEF; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
OUTPUT: |
70
|
|
|
|
|
|
|
RETVAL |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
SV* |
73
|
|
|
|
|
|
|
cowrefcnt_max() |
74
|
|
|
|
|
|
|
CODE: |
75
|
|
|
|
|
|
|
{ |
76
|
|
|
|
|
|
|
#if !B_CAN_COW |
77
|
|
|
|
|
|
|
XSRETURN_UNDEF; |
78
|
|
|
|
|
|
|
#else |
79
|
1
|
|
|
|
|
|
XSRETURN_IV(SV_COW_REFCNT_MAX); |
80
|
|
|
|
|
|
|
#endif |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
OUTPUT: |
83
|
|
|
|
|
|
|
RETVAL |