Shared.xs

filter: Statementstmt 97.8% 225 / 230 Branchbran 60.9% 240 / 394 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 74.5% 465 / 624 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« hist.h ↑ Summary
1 #define PERL_NO_GET_CONTEXT
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5 #include "ppport.h"
6 #include "hist.h"
7  
8 #define EXTRACT(sv) \
9 if (!sv_isobject(sv) || !sv_derived_from(sv, "Data::Histogram::Shared")) \
10 croak("Expected a Data::Histogram::Shared object"); \
11 HistHandle *h = INT2PTR(HistHandle*, SvIV(SvRV(sv))); \
12 if (!h) croak("Attempted to use a destroyed Data::Histogram::Shared object"); \
13 HistHandle *h0 = h; PERL_UNUSED_VAR(h0); \
14 sv_2mortal(SvREFCNT_inc(SvRV(sv)))
15  
16 /* Re-read the handle after a call that can run Perl code (tied/overloaded
17 * argument magic, tied-array fetches). That code may call $obj->DESTROY
18 * explicitly, which frees the handle and zeroes the IV; EXTRACT's mortal
19 * pins the referent only against refcount-driven destruction, not an
20 * explicit DESTROY, so the local `h` would dangle. Used only where magic
21 * can actually intervene between EXTRACT and the first use of h. */
22 /* The same Perl that can destroy the handle can also REPLACE the invocant
23 * ($obj = 42 from an overload handler mutates ST(0), because Perl passes
24 * aliases), so SvROK must be re-checked before SvRV -- otherwise SvRV would
25 * run on a non-reference. */
26 #define REEXTRACT(sv) \
27 if (!SvROK(sv)) \
28 croak("Data::Histogram::Shared object was replaced during the call"); \
29 h = INT2PTR(HistHandle*, SvIV(SvRV(sv))); \
30 if (h != h0) croak("Data::Histogram::Shared object replaced or destroyed during the call")
31  
32 #define MAKE_OBJ(class, handle) \
33 SV *obj = newSViv(PTR2IV(handle)); \
34 SV *ref = newRV_noinc(obj); \
35 sv_bless(ref, gv_stashpv(class, GV_ADD)); \
36 RETVAL = ref
37  
38 MODULE = Data::Histogram::Shared PACKAGE = Data::Histogram::Shared
39  
40 PROTOTYPES: DISABLE
41  
42 SV *
43 new(class, path = &PL_sv_undef, lowest = 1, highest = 3600000000LL, sig_figs = 3, ...)
44 const char *class
45 SV *path
46 IV lowest
47 IV highest
48 int sig_figs
49 PREINIT:
50 char errbuf[HIST_ERR_BUFLEN];
51 CODE:
52 /* Optional trailing mode arg (ST(5)) sets the create permissions; default
53 * 0600 (owner-only). Pass e.g. 0660 to opt in to group sharing. */
54 73 ▶ mode_t mode = (items > 5 && (SvGETMAGIC(ST(5)), SvOK(ST(5)))) ? (mode_t)SvUV(ST(5)) : 0600;
Branch: 4 branches
BranchTrueFalseTotal
mode_t mode = (items > 5 && (SvGETMAGIC(ST(5)), SvOK(ST(5)))) ? (mode_t)SvUV(ST(5)) : 0600; 0 73 73
mode_t mode = (items > 5 && (SvGETMAGIC(ST(5)), SvOK(ST(5)))) ? (mode_t)SvUV(ST(5)) : 0600; 0 0 0
mode_t mode = (items > 5 && (SvGETMAGIC(ST(5)), SvOK(ST(5)))) ? (mode_t)SvUV(ST(5)) : 0600; 0 0 0
mode_t mode = (items > 5 && (SvGETMAGIC(ST(5)), SvOK(ST(5)))) ? (mode_t)SvUV(ST(5)) : 0600; 0 0 0
55 91 ▶ const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL;
Branch: 3 branches
BranchTrueFalseTotal
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 0 73 73
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 0 0 0
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 18 55 73
56 73 HistHandle *h = hist_create(p, (int64_t)lowest, (int64_t)highest,
57 (int32_t)sig_figs, mode, errbuf); /* validates args into errbuf */
58 73 ▶ if (!h) croak("Data::Histogram::Shared->new: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Histogram::Shared->new: %s", errbuf[0] ? errbuf : "out of memory"); 10 63 73
if (!h) croak("Data::Histogram::Shared->new: %s", errbuf[0] ? errbuf : "out of memory"); 10 0 10
59 63 MAKE_OBJ(class, h);
60 OUTPUT:
61 RETVAL
62  
63 SV *
64 new_memfd(class, name = &PL_sv_undef, lowest = 1, highest = 3600000000LL, sig_figs = 3)
65 const char *class
66 SV *name
67 IV lowest
68 IV highest
69 int sig_figs
70 PREINIT:
71 char errbuf[HIST_ERR_BUFLEN];
72 CODE:
73 7 ▶ const char *nm = (SvGETMAGIC(name), SvOK(name)) ? SvPV_nolen(name) : NULL; /* undef -> default label */
Branch: 3 branches
BranchTrueFalseTotal
const char *nm = (SvGETMAGIC(name), SvOK(name)) ? SvPV_nolen(name) : NULL; /* undef -> default label */ 0 4 4
const char *nm = (SvGETMAGIC(name), SvOK(name)) ? SvPV_nolen(name) : NULL; /* undef -> default label */ 0 0 0
const char *nm = (SvGETMAGIC(name), SvOK(name)) ? SvPV_nolen(name) : NULL; /* undef -> default label */ 3 1 4
74 4 HistHandle *h = hist_create_memfd(nm, (int64_t)lowest, (int64_t)highest,
75 (int32_t)sig_figs, errbuf); /* validates args into errbuf */
76 4 ▶ if (!h) croak("Data::Histogram::Shared->new_memfd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Histogram::Shared->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 2 2 4
if (!h) croak("Data::Histogram::Shared->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 2 0 2
77 2 MAKE_OBJ(class, h);
78 OUTPUT:
79 RETVAL
80  
81 SV *
82 new_from_fd(class, fd)
83 const char *class
84 int fd
85 PREINIT:
86 char errbuf[HIST_ERR_BUFLEN];
87 CODE:
88 2 HistHandle *h = hist_open_fd(fd, errbuf);
89 2 ▶ if (!h) croak("Data::Histogram::Shared->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Histogram::Shared->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 1 1 2
if (!h) croak("Data::Histogram::Shared->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 1 0 1
90 1 MAKE_OBJ(class, h);
91 OUTPUT:
92 RETVAL
93  
94 SV *
95 new_readonly(class, path)
96 const char *class
97 SV *path
98 PREINIT:
99 char errbuf[HIST_ERR_BUFLEN];
100 CODE:
101 /* Open a FROZEN (sealed) file read-only: O_RDONLY + PROT_READ, no lock
102 ever. A sealed file is immutable and no read path writes the mapping,
103 so queries take no reader-slot / rwlock traffic and any number of
104 processes can share one PROT_READ mapping (same architecture; the
105 magic rejects a wrong-endian file). */
106 13 ▶ const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL;
Branch: 3 branches
BranchTrueFalseTotal
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 0 7 7
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 0 0 0
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 6 1 7
107 7 ▶ if (!p) croak("Data::Histogram::Shared->new_readonly: path is required");
Branch: 1 branch
BranchTrueFalseTotal
if (!p) croak("Data::Histogram::Shared->new_readonly: path is required"); 1 6 7
108 6 HistHandle *h = hist_open_readonly(p, errbuf);
109 6 ▶ if (!h) croak("Data::Histogram::Shared->new_readonly: %s", errbuf);
Branch: 1 branch
BranchTrueFalseTotal
if (!h) croak("Data::Histogram::Shared->new_readonly: %s", errbuf); 2 4 6
110 /* Re-read the class-name PV immediately before blessing: SvGETMAGIC(path)
111 * above can run arbitrary Perl (tied/overloaded path) that reallocs or
112 * frees ST(0)'s PV, dangling the `class` pointer captured by the typemap. */
113 4 class = SvPV_nolen(ST(0));
114 4 MAKE_OBJ(class, h);
115 OUTPUT:
116 RETVAL
117  
118 void
119 DESTROY(self)
120 SV *self
121 CODE:
122 72 ▶ if (sv_isobject(self) && sv_derived_from(self, "Data::Histogram::Shared")) {
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(self) && sv_derived_from(self, "Data::Histogram::Shared")) { 72 0 72
if (sv_isobject(self) && sv_derived_from(self, "Data::Histogram::Shared")) { 72 0 72
123 72 HistHandle *h = INT2PTR(HistHandle*, SvIV(SvRV(self)));
124 72 ▶ if (h) { sv_setiv(SvRV(self), 0); hist_destroy(h); } /* null first: activates EXTRACT's use-after-destroy croak + makes a double DESTROY a no-op */
Branch: 1 branch
BranchTrueFalseTotal
if (h) { sv_setiv(SvRV(self), 0); hist_destroy(h); } /* null first: activates EXTRACT's use-after-destroy croak + makes a double DESTROY a no-op */ 70 2 72
125 }
126  
127 IV
128 record(self, value, ...)
129 SV *self
130 IV value
131 PREINIT:
132 321129 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 321129 0 321129
EXTRACT(self); 0 321129 321129
EXTRACT(self); 1 321128 321129
133 int64_t idx;
134 IV total;
135 CODE:
136 321128 ▶ if (h->readonly) croak("Data::Histogram::Shared->record: histogram is frozen (read-only)");
Branch: 1 branch
BranchTrueFalseTotal
if (h->readonly) croak("Data::Histogram::Shared->record: histogram is frozen (read-only)"); 2 321126 321128
137 /* optional count (default 1); read here so an explicit undef falls through to
138 * the default instead of warning "uninitialized value". */
139 321126 ▶ int has_count = (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2))));
Branch: 4 branches
BranchTrueFalseTotal
int has_count = (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))); 2 321124 321126
int has_count = (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))); 0 2 2
int has_count = (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))); 0 0 0
int has_count = (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))); 2 0 2
140 321126 ▶ UV count = has_count ? SvUV(ST(2)) : 1;
Branch: 1 branch
BranchTrueFalseTotal
UV count = has_count ? SvUV(ST(2)) : 1; 2 321124 321126
141 /* Range-check + index-compute BEFORE locking so a croak holds no lock. */
142 321126 ▶ if (value < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (value < 0) 1 321125 321126
143 1 croak("Data::Histogram::Shared->record: negative value (%lld)", (long long)value);
144 /* count is a UV: a negative arg wraps to a huge unsigned and would silently
145 * inflate the bucket. Reject it via a signed check on the raw SV. */
146 321125 ▶ if (has_count && SvNV(ST(2)) < 0)
Branch: 2 branches
BranchTrueFalseTotal
if (has_count && SvNV(ST(2)) < 0) 2 321123 321125
if (has_count && SvNV(ST(2)) < 0) 0 2 2
147 0 croak("Data::Histogram::Shared->record: negative count (%lld)", (long long)SvIV(ST(2)));
148 /* A huge positive count (>= 2^63) passes the signed check above but wraps to a
149 * negative int64_t below, corrupting the bucket/total. Reject it too. */
150 321125 ▶ if (count > (UV)INT64_MAX)
Branch: 1 branch
BranchTrueFalseTotal
if (count > (UV)INT64_MAX) 0 321125 321125
151 0 croak("Data::Histogram::Shared->record: count too large (%llu)", (unsigned long long)count);
152 321125 ▶ REEXTRACT(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT(self); 0 321125 321125
REEXTRACT(self); 0 321125 321125
153 321125 idx = hist_index_for(h, (int64_t)value);
154 321125 ▶ if (idx < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (idx < 0) 1 321124 321125
155 1 croak("Data::Histogram::Shared->record: value %lld exceeds highest_trackable_value (%lld)",
156 (long long)value, (long long)h->hdr->highest);
157 321124 hist_rwlock_wrlock(h);
158 321124 ▶ if (h->hdr->sealed) { hist_rwlock_wrunlock(h); croak("Data::Histogram::Shared->record: histogram is frozen (read-only)"); }
Branch: 1 branch
BranchTrueFalseTotal
if (h->hdr->sealed) { hist_rwlock_wrunlock(h); croak("Data::Histogram::Shared->record: histogram is frozen (read-only)"); } 1 321123 321124
159 321123 hist_record_locked(h, (int64_t)value, (int64_t)count);
160 321123 total = (IV)h->hdr->total_count;
161 321123 __atomic_fetch_add(&h->hdr->stat_ops, 1, __ATOMIC_RELAXED);
162 321123 hist_rwlock_wrunlock(h);
163 321123 ▶ RETVAL = total;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = total; 321088 35 321123
164 OUTPUT:
165 RETVAL
166  
167 UV
168 record_many(self, values)
169 SV *self
170 SV *values
171 PREINIT:
172 19 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 19 0 19
EXTRACT(self); 0 19 19
EXTRACT(self); 0 19 19
173 AV *av;
174 IV top;
175 CODE:
176 19 ▶ if (h->readonly) croak("Data::Histogram::Shared->record_many: histogram is frozen (read-only)");
Branch: 1 branch
BranchTrueFalseTotal
if (h->readonly) croak("Data::Histogram::Shared->record_many: histogram is frozen (read-only)"); 2 17 19
177 17 ▶ SvGETMAGIC(values); /* a tied/overloaded scalar may FETCH to an arrayref */
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(values); /* a tied/overloaded scalar may FETCH to an arrayref */ 0 17 17
SvGETMAGIC(values); /* a tied/overloaded scalar may FETCH to an arrayref */ 0 0 0
178 17 ▶ if (!SvROK(values) || SvTYPE(SvRV(values)) != SVt_PVAV)
Branch: 2 branches
BranchTrueFalseTotal
if (!SvROK(values) || SvTYPE(SvRV(values)) != SVt_PVAV) 16 1 17
if (!SvROK(values) || SvTYPE(SvRV(values)) != SVt_PVAV) 1 15 16
179 2 croak("Data::Histogram::Shared->record_many: expected an array reference");
180 15 av = (AV *)SvRV(values);
181 15 sv_2mortal(SvREFCNT_inc((SV *)av)); /* pin the arrayref: element magic below cannot free it mid-loop */
182 15 top = av_len(av); /* last index, -1 if empty */
183 /* SvGETMAGIC(values) above, and av_len on a tied array (AvFILL -> mg_size
184 * -> FETCHSIZE), both run Perl that can have destroyed self. */
185 15 ▶ REEXTRACT(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT(self); 0 15 15
REEXTRACT(self); 0 15 15
186 {
187 15 ▶ STRLEN cnt = (top >= 0) ? (STRLEN)(top + 1) : 0, i;
Branch: 1 branch
BranchTrueFalseTotal
STRLEN cnt = (top >= 0) ? (STRLEN)(top + 1) : 0, i; 13 2 15
188 15 int64_t *vals = NULL;
189 15 ▶ if (cnt) { /* resolve + range-check ALL before locking */
Branch: 1 branch
BranchTrueFalseTotal
if (cnt) { /* resolve + range-check ALL before locking */ 13 2 15
190 13 ▶ Newx(vals, cnt, int64_t); SAVEFREEPV(vals); /* freed on return OR unwind */
Branch: 1 branch
BranchTrueFalseTotal
Newx(vals, cnt, int64_t); SAVEFREEPV(vals); /* freed on return OR unwind */ 0 13 13
191 3397 ▶ for (i = 0; i < cnt; i++) { /* a croak here holds NO lock; SAVEFREEPV cleans up */
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < cnt; i++) { /* a croak here holds NO lock; SAVEFREEPV cleans up */ 3387 10 3397
192 3387 SV **el = av_fetch(av, (SSize_t)i, 0);
193 3387 ▶ IV v = (el && *el) ? SvIV(*el) : 0;
Branch: 2 branches
BranchTrueFalseTotal
IV v = (el && *el) ? SvIV(*el) : 0; 3387 0 3387
IV v = (el && *el) ? SvIV(*el) : 0; 3387 0 3387
194 3387 ▶ if (v < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (v < 0) 1 3386 3387
195 1 croak("Data::Histogram::Shared->record_many: negative value (%lld)", (long long)v);
196 3386 ▶ REEXTRACT(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT(self); 0 3386 3386
REEXTRACT(self); 0 3386 3386
197 3386 ▶ if (hist_index_for(h, (int64_t)v) < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (hist_index_for(h, (int64_t)v) < 0) 2 3384 3386
198 2 croak("Data::Histogram::Shared->record_many: value %lld exceeds highest_trackable_value (%lld)",
199 (long long)v, (long long)h->hdr->highest);
200 3384 vals[i] = (int64_t)v;
201 }
202 }
203 /* The REEXTRACT inside the loop above only runs when cnt > 0; a tied
204 * FETCHSIZE reporting 0 skips the loop entirely and lands straight
205 * here, so re-check outside the `if (cnt)` block as well. */
206 12 ▶ REEXTRACT(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT(self); 0 12 12
REEXTRACT(self); 0 12 12
207 12 hist_rwlock_wrlock(h); /* locked region: NO croak-capable calls */
208 12 ▶ if (h->hdr->sealed) { hist_rwlock_wrunlock(h); croak("Data::Histogram::Shared->record_many: histogram is frozen (read-only)"); }
Branch: 1 branch
BranchTrueFalseTotal
if (h->hdr->sealed) { hist_rwlock_wrunlock(h); croak("Data::Histogram::Shared->record_many: histogram is frozen (read-only)"); } 1 11 12
209 3389 ▶ for (i = 0; i < cnt; i++) hist_record_locked(h, vals[i], 1);
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < cnt; i++) hist_record_locked(h, vals[i], 1); 3378 11 3389
210 11 __atomic_fetch_add(&h->hdr->stat_ops, 1, __ATOMIC_RELAXED); /* a call always counts, even an empty batch */
211 11 hist_rwlock_wrunlock(h);
212 11 ▶ RETVAL = (UV)cnt;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)cnt; 5 6 11
213 }
214 OUTPUT:
215 RETVAL
216  
217 IV
218 value_at_percentile(self, p)
219 SV *self
220 double p
221 PREINIT:
222 6050 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 6050 0 6050
EXTRACT(self); 0 6050 6050
EXTRACT(self); 0 6050 6050
223 IV v;
224 CODE:
225 6050 ▶ if (h->readonly) { /* frozen: immutable counts, no lock needed */
Branch: 1 branch
BranchTrueFalseTotal
if (h->readonly) { /* frozen: immutable counts, no lock needed */ 2 6048 6050
226 2 v = (IV)hist_value_at_percentile_locked(h, p);
227 } else {
228 6048 hist_rwlock_rdlock(h);
229 6048 v = (IV)hist_value_at_percentile_locked(h, p);
230 6048 hist_rwlock_rdunlock(h);
231 }
232 6050 ▶ RETVAL = v;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = v; 6035 15 6050
233 OUTPUT:
234 RETVAL
235  
236 IV
237 count_at_value(self, value)
238 SV *self
239 IV value
240 PREINIT:
241 36 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 36 0 36
EXTRACT(self); 0 36 36
EXTRACT(self); 0 36 36
242 int64_t idx;
243 IV c;
244 CODE:
245 36 ▶ if (value < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (value < 0) 1 35 36
246 1 croak("Data::Histogram::Shared->count_at_value: negative value (%lld)", (long long)value);
247 35 idx = hist_index_for(h, (int64_t)value);
248 35 ▶ if (idx < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (idx < 0) 1 34 35
249 1 croak("Data::Histogram::Shared->count_at_value: value %lld exceeds highest_trackable_value (%lld)",
250 (long long)value, (long long)h->hdr->highest);
251 34 ▶ if (h->readonly) { /* frozen: immutable counts, no lock needed */
Branch: 1 branch
BranchTrueFalseTotal
if (h->readonly) { /* frozen: immutable counts, no lock needed */ 1 33 34
252 1 ▶ c = (idx < hist_counts_capacity(h)) ? (IV)hist_counts(h)[idx] : 0; /* Layer B: reject OOB idx (untrusted geometry) */
Branch: 1 branch
BranchTrueFalseTotal
c = (idx < hist_counts_capacity(h)) ? (IV)hist_counts(h)[idx] : 0; /* Layer B: reject OOB idx (untrusted geometry) */ 1 0 1
253 } else {
254 33 hist_rwlock_rdlock(h);
255 33 ▶ c = (idx < hist_counts_capacity(h)) ? (IV)hist_counts(h)[idx] : 0; /* Layer B: reject OOB idx (untrusted geometry) */
Branch: 1 branch
BranchTrueFalseTotal
c = (idx < hist_counts_capacity(h)) ? (IV)hist_counts(h)[idx] : 0; /* Layer B: reject OOB idx (untrusted geometry) */ 33 0 33
256 33 hist_rwlock_rdunlock(h);
257 }
258 34 ▶ RETVAL = c;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = c; 18 16 34
259 OUTPUT:
260 RETVAL
261  
262 IV
263 min(self)
264 SV *self
265 PREINIT:
266 12 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 12 0 12
EXTRACT(self); 0 12 12
EXTRACT(self); 0 12 12
267 int64_t mn, total;
268 CODE:
269 12 ▶ if (h->readonly) { /* frozen: immutable, no lock needed */
Branch: 1 branch
BranchTrueFalseTotal
if (h->readonly) { /* frozen: immutable, no lock needed */ 1 11 12
270 1 total = h->hdr->total_count;
271 1 mn = h->hdr->min_value;
272 } else {
273 11 hist_rwlock_rdlock(h);
274 11 total = h->hdr->total_count;
275 11 mn = h->hdr->min_value;
276 11 hist_rwlock_rdunlock(h);
277 }
278 12 ▶ RETVAL = (IV)(total == 0 ? 0 : mn);
Branch: 2 branches
BranchTrueFalseTotal
RETVAL = (IV)(total == 0 ? 0 : mn); 11 1 12
RETVAL = (IV)(total == 0 ? 0 : mn); 0 12 12
279 OUTPUT:
280 RETVAL
281  
282 IV
283 max(self)
284 SV *self
285 PREINIT:
286 13 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 13 0 13
EXTRACT(self); 0 13 13
EXTRACT(self); 0 13 13
287 IV mx;
288 CODE:
289 13 ▶ if (h->readonly) { /* frozen: immutable, no lock needed */
Branch: 1 branch
BranchTrueFalseTotal
if (h->readonly) { /* frozen: immutable, no lock needed */ 1 12 13
290 1 mx = (IV)h->hdr->max_value;
291 } else {
292 12 hist_rwlock_rdlock(h);
293 12 mx = (IV)h->hdr->max_value;
294 12 hist_rwlock_rdunlock(h);
295 }
296 13 ▶ RETVAL = mx;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = mx; 0 13 13
297 OUTPUT:
298 RETVAL
299  
300 double
301 mean(self)
302 SV *self
303 PREINIT:
304 4 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 4 0 4
EXTRACT(self); 0 4 4
EXTRACT(self); 0 4 4
305 double m;
306 CODE:
307 4 ▶ if (h->readonly) { /* frozen: immutable counts, no lock needed */
Branch: 1 branch
BranchTrueFalseTotal
if (h->readonly) { /* frozen: immutable counts, no lock needed */ 1 3 4
308 1 m = hist_mean_locked(h);
309 } else {
310 3 hist_rwlock_rdlock(h);
311 3 m = hist_mean_locked(h);
312 3 hist_rwlock_rdunlock(h);
313 }
314 4 ▶ RETVAL = m;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = m; 0 4 4
315 OUTPUT:
316 RETVAL
317  
318 UV
319 total_count(self)
320 SV *self
321 PREINIT:
322 32 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 32 0 32
EXTRACT(self); 0 32 32
EXTRACT(self); 0 32 32
323 UV t;
324 CODE:
325 32 ▶ if (h->readonly) { /* frozen: immutable, no lock needed */
Branch: 1 branch
BranchTrueFalseTotal
if (h->readonly) { /* frozen: immutable, no lock needed */ 5 27 32
326 5 t = (UV)h->hdr->total_count;
327 } else {
328 27 hist_rwlock_rdlock(h);
329 27 t = (UV)h->hdr->total_count;
330 27 hist_rwlock_rdunlock(h);
331 }
332 32 ▶ RETVAL = t;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = t; 0 32 32
333 OUTPUT:
334 RETVAL
335  
336 void
337 merge(self, other)
338 SV *self
339 SV *other
340 PREINIT:
341 9 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 9 0 9
EXTRACT(self); 0 9 9
EXTRACT(self); 0 9 9
342 CODE:
343 9 ▶ if (h->readonly) croak("Data::Histogram::Shared->merge: histogram is frozen (read-only)");
Branch: 1 branch
BranchTrueFalseTotal
if (h->readonly) croak("Data::Histogram::Shared->merge: histogram is frozen (read-only)"); 2 7 9
344 7 ▶ if (!sv_isobject(other) || !sv_derived_from(other, "Data::Histogram::Shared"))
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(other) || !sv_derived_from(other, "Data::Histogram::Shared")) 7 0 7
if (!sv_isobject(other) || !sv_derived_from(other, "Data::Histogram::Shared")) 0 7 7
345 0 croak("Data::Histogram::Shared->merge: expected a Data::Histogram::Shared object");
346 7 HistHandle *o = INT2PTR(HistHandle*, SvIV(SvRV(other)));
347 7 ▶ if (!o) croak("Attempted to use a destroyed Data::Histogram::Shared object");
Branch: 1 branch
BranchTrueFalseTotal
if (!o) croak("Attempted to use a destroyed Data::Histogram::Shared object"); 0 7 7
348 /* sv_isobject/sv_derived_from above begin with SvGETMAGIC(other), so a tied
349 * `other` can have run Perl that destroyed self before h is used below.
350 * `o` was read after that magic and needs no re-read. */
351 7 ▶ REEXTRACT(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT(self); 0 7 7
REEXTRACT(self); 0 7 7
352  
353 /* Geometry is immutable after creation -- compare lock-free, croak BEFORE
354 * allocating, so a mismatch holds no lock and leaks no buffer. */
355 7 ▶ if (o->hdr->lowest != h->hdr->lowest ||
Branch: 1 branch
BranchTrueFalseTotal
if (o->hdr->lowest != h->hdr->lowest || 7 0 7
356 7 ▶ o->hdr->highest != h->hdr->highest ||
Branch: 1 branch
BranchTrueFalseTotal
o->hdr->highest != h->hdr->highest || 6 1 7
357 6 ▶ o->hdr->sig_figs != h->hdr->sig_figs ||
Branch: 1 branch
BranchTrueFalseTotal
o->hdr->sig_figs != h->hdr->sig_figs || 5 1 6
358 5 ▶ o->hdr->counts_len != h->hdr->counts_len ||
Branch: 1 branch
BranchTrueFalseTotal
o->hdr->counts_len != h->hdr->counts_len || 5 0 5
359 5 ▶ o->hdr->unit_magnitude != h->hdr->unit_magnitude ||
Branch: 1 branch
BranchTrueFalseTotal
o->hdr->unit_magnitude != h->hdr->unit_magnitude || 5 0 5
360 5 ▶ o->hdr->sub_bucket_mask != h->hdr->sub_bucket_mask)
Branch: 1 branch
BranchTrueFalseTotal
o->hdr->sub_bucket_mask != h->hdr->sub_bucket_mask) 0 5 5
361 2 croak("Data::Histogram::Shared->merge: geometry mismatch "
362 "(lowest=%lld/highest=%lld/sig=%d vs lowest=%lld/highest=%lld/sig=%d)",
363 (long long)h->hdr->lowest, (long long)h->hdr->highest, (int)h->hdr->sig_figs,
364 (long long)o->hdr->lowest, (long long)o->hdr->highest, (int)o->hdr->sig_figs);
365  
366 /* Snapshot the other's counts (+ total/min/max) under its read lock into a
367 * temp buffer, then release before taking self's write lock. Copying to a
368 * temp avoids holding two locks at once (deadlock-free regardless of
369 * acquisition order between two processes merging each other). */
370 {
371 5 int64_t counts_len = h->hdr->counts_len;
372 /* Layer B: never read from o's mapping nor write to h's past what each
373 * actually maps (file-stored counts_off/counts_len are untrusted). For a
374 * valid pair this is a no-op: counts_len == both capacities. */
375 5 int64_t h_cap = hist_counts_capacity(h), o_cap = hist_counts_capacity(o);
376 5 ▶ if (counts_len < 0) counts_len = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (counts_len < 0) counts_len = 0; 0 5 5
377 5 ▶ if (counts_len > h_cap) counts_len = h_cap;
Branch: 1 branch
BranchTrueFalseTotal
if (counts_len > h_cap) counts_len = h_cap; 0 5 5
378 5 ▶ if (counts_len > o_cap) counts_len = o_cap;
Branch: 1 branch
BranchTrueFalseTotal
if (counts_len > o_cap) counts_len = o_cap; 0 5 5
379 int64_t other_total, other_min, other_max;
380 int64_t *tmp;
381 5 ▶ Newx(tmp, (size_t)(counts_len ? counts_len : 1), int64_t);
Branch: 3 branches
BranchTrueFalseTotal
Newx(tmp, (size_t)(counts_len ? counts_len : 1), int64_t); 5 0 5
Newx(tmp, (size_t)(counts_len ? counts_len : 1), int64_t); 0 5 5
Newx(tmp, (size_t)(counts_len ? counts_len : 1), int64_t); 5 0 5
382 5 SAVEFREEPV(tmp); /* freed on normal return OR croak unwind */
383 5 ▶ if (o->readonly) { /* frozen other: immutable counts, no lock */
Branch: 1 branch
BranchTrueFalseTotal
if (o->readonly) { /* frozen other: immutable counts, no lock */ 1 4 5
384 1 ▶ if (counts_len > 0) memcpy(tmp, hist_counts(o), (size_t)counts_len * sizeof(int64_t));
Branch: 1 branch
BranchTrueFalseTotal
if (counts_len > 0) memcpy(tmp, hist_counts(o), (size_t)counts_len * sizeof(int64_t)); 1 0 1
385 1 other_total = o->hdr->total_count;
386 1 other_min = o->hdr->min_value;
387 1 other_max = o->hdr->max_value;
388 } else {
389 4 hist_rwlock_rdlock(o);
390 4 ▶ if (counts_len > 0) memcpy(tmp, hist_counts(o), (size_t)counts_len * sizeof(int64_t));
Branch: 1 branch
BranchTrueFalseTotal
if (counts_len > 0) memcpy(tmp, hist_counts(o), (size_t)counts_len * sizeof(int64_t)); 4 0 4
391 4 other_total = o->hdr->total_count;
392 4 other_min = o->hdr->min_value;
393 4 other_max = o->hdr->max_value;
394 4 hist_rwlock_rdunlock(o);
395 }
396  
397 5 hist_rwlock_wrlock(h);
398 5 ▶ if (h->hdr->sealed) { hist_rwlock_wrunlock(h); croak("Data::Histogram::Shared->merge: histogram is frozen (read-only)"); }
Branch: 1 branch
BranchTrueFalseTotal
if (h->hdr->sealed) { hist_rwlock_wrunlock(h); croak("Data::Histogram::Shared->merge: histogram is frozen (read-only)"); } 0 5 5
399 5 ▶ if (other_total > 0) hist_merge_counts(hist_counts(h), tmp, counts_len); /* empty other -> nothing to add */
Branch: 1 branch
BranchTrueFalseTotal
if (other_total > 0) hist_merge_counts(hist_counts(h), tmp, counts_len); /* empty other -> nothing to add */ 5 0 5
400 5 ▶ if (other_total > 0) { /* only adopt min/max if other actually recorded something */
Branch: 1 branch
BranchTrueFalseTotal
if (other_total > 0) { /* only adopt min/max if other actually recorded something */ 5 0 5
401 5 ▶ if (other_min < h->hdr->min_value) h->hdr->min_value = other_min;
Branch: 1 branch
BranchTrueFalseTotal
if (other_min < h->hdr->min_value) h->hdr->min_value = other_min; 2 3 5
402 5 ▶ if (other_max > h->hdr->max_value) h->hdr->max_value = other_max;
Branch: 1 branch
BranchTrueFalseTotal
if (other_max > h->hdr->max_value) h->hdr->max_value = other_max; 3 2 5
403 }
404 5 __atomic_signal_fence(__ATOMIC_SEQ_CST); /* the total goes last, as in hist_record_locked */
405 5 ▶ if (h->hdr->total_count > INT64_MAX - other_total) h->hdr->total_count = INT64_MAX;
Branch: 1 branch
BranchTrueFalseTotal
if (h->hdr->total_count > INT64_MAX - other_total) h->hdr->total_count = INT64_MAX; 0 5 5
406 5 else h->hdr->total_count += other_total;
407 5 __atomic_fetch_add(&h->hdr->stat_ops, 1, __ATOMIC_RELAXED);
408 5 hist_rwlock_wrunlock(h);
409 }
410  
411 void
412 reset(self)
413 SV *self
414 PREINIT:
415 4 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 4 0 4
EXTRACT(self); 0 4 4
EXTRACT(self); 0 4 4
416 CODE:
417 4 ▶ if (h->readonly) croak("Data::Histogram::Shared->reset: histogram is frozen (read-only)");
Branch: 1 branch
BranchTrueFalseTotal
if (h->readonly) croak("Data::Histogram::Shared->reset: histogram is frozen (read-only)"); 2 2 4
418 2 hist_rwlock_wrlock(h);
419 2 ▶ if (h->hdr->sealed) { hist_rwlock_wrunlock(h); croak("Data::Histogram::Shared->reset: histogram is frozen (read-only)"); }
Branch: 1 branch
BranchTrueFalseTotal
if (h->hdr->sealed) { hist_rwlock_wrunlock(h); croak("Data::Histogram::Shared->reset: histogram is frozen (read-only)"); } 1 1 2
420 1 hist_reset_locked(h);
421 1 __atomic_fetch_add(&h->hdr->stat_ops, 1, __ATOMIC_RELAXED);
422 1 hist_rwlock_wrunlock(h);
423  
424 void
425 freeze(self)
426 SV *self
427 PREINIT:
428 4 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 4 0 4
EXTRACT(self); 0 4 4
EXTRACT(self); 0 4 4
429 CODE:
430 4 ▶ if (h->readonly) croak("Data::Histogram::Shared->freeze: cannot freeze a read-only handle");
Branch: 1 branch
BranchTrueFalseTotal
if (h->readonly) croak("Data::Histogram::Shared->freeze: cannot freeze a read-only handle"); 2 2 4
431 2 ▶ if (hist_freeze(h) != 0) croak("Data::Histogram::Shared->freeze: msync: %s", strerror(errno));
Branch: 1 branch
BranchTrueFalseTotal
if (hist_freeze(h) != 0) croak("Data::Histogram::Shared->freeze: msync: %s", strerror(errno)); 0 2 2
432 2 h->readonly = 1; /* this handle now rejects mutation too (the file is sealed) */
433  
434 UV
435 frozen(self)
436 SV *self
437 PREINIT:
438 4 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 4 0 4
EXTRACT(self); 0 4 4
EXTRACT(self); 0 4 4
439 CODE:
440 4 ▶ RETVAL = __atomic_load_n(&h->hdr->sealed, __ATOMIC_ACQUIRE) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = __atomic_load_n(&h->hdr->sealed, __ATOMIC_ACQUIRE) ? 1 : 0; 0 4 4
441 OUTPUT:
442 RETVAL
443  
444 UV
445 readonly(self)
446 SV *self
447 PREINIT:
448 3 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 3 0 3
EXTRACT(self); 0 3 3
EXTRACT(self); 0 3 3
449 CODE:
450 3 ▶ RETVAL = h->readonly ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->readonly ? 1 : 0; 0 3 3
451 OUTPUT:
452 RETVAL
453  
454 IV
455 lowest(self)
456 SV *self
457 PREINIT:
458 4 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 4 0 4
EXTRACT(self); 0 4 4
EXTRACT(self); 0 4 4
459 CODE:
460 4 ▶ RETVAL = (IV)h->hdr->lowest;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (IV)h->hdr->lowest; 0 4 4
461 OUTPUT:
462 RETVAL
463  
464 IV
465 highest(self)
466 SV *self
467 PREINIT:
468 5 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 5 0 5
EXTRACT(self); 0 5 5
EXTRACT(self); 0 5 5
469 CODE:
470 5 ▶ RETVAL = (IV)h->hdr->highest;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (IV)h->hdr->highest; 0 5 5
471 OUTPUT:
472 RETVAL
473  
474 int
475 sig_figs(self)
476 SV *self
477 PREINIT:
478 5 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 5 0 5
EXTRACT(self); 0 5 5
EXTRACT(self); 0 5 5
479 CODE:
480 5 ▶ RETVAL = (int)h->hdr->sig_figs;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (int)h->hdr->sig_figs; 0 5 5
481 OUTPUT:
482 RETVAL
483  
484 IV
485 counts_len(self)
486 SV *self
487 PREINIT:
488 7 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 7 0 7
EXTRACT(self); 0 7 7
EXTRACT(self); 0 7 7
489 CODE:
490 7 ▶ RETVAL = (IV)h->hdr->counts_len;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (IV)h->hdr->counts_len; 0 7 7
491 OUTPUT:
492 RETVAL
493  
494 SV *
495 stats(self)
496 SV *self
497 PREINIT:
498 4 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 4 0 4
EXTRACT(self); 0 4 4
EXTRACT(self); 0 4 4
499 CODE:
500 {
501 int64_t total, mn, mx, counts_len, lowest, highest;
502 int32_t sig_figs, bucket_count, sub_bucket_count;
503 uint64_t ops;
504 double mean;
505 /* Snapshot under the lock; do all (croak-capable) Perl allocation after
506 releasing it -- so an OOM in newHV/newSV* can never strand the lock. */
507 4 ▶ if (!h->readonly) hist_rwlock_rdlock(h); /* frozen: immutable, no lock */
Branch: 1 branch
BranchTrueFalseTotal
if (!h->readonly) hist_rwlock_rdlock(h); /* frozen: immutable, no lock */ 3 1 4
508 4 total = h->hdr->total_count;
509 4 mn = h->hdr->min_value;
510 4 mx = h->hdr->max_value;
511 4 counts_len = h->hdr->counts_len;
512 4 lowest = h->hdr->lowest;
513 4 highest = h->hdr->highest;
514 4 sig_figs = h->hdr->sig_figs;
515 4 bucket_count = h->hdr->bucket_count;
516 4 sub_bucket_count = h->hdr->sub_bucket_count;
517 4 ops = h->hdr->stat_ops;
518 4 mean = hist_mean_locked(h);
519 4 ▶ if (!h->readonly) hist_rwlock_rdunlock(h);
Branch: 1 branch
BranchTrueFalseTotal
if (!h->readonly) hist_rwlock_rdunlock(h); 3 1 4
520  
521 4 HV *hv = newHV();
522 4 hv_stores(hv, "lowest", newSViv((IV)lowest));
523 4 hv_stores(hv, "highest", newSViv((IV)highest));
524 4 hv_stores(hv, "sig_figs", newSViv((IV)sig_figs));
525 4 hv_stores(hv, "count", newSViv((IV)total));
526 4 ▶ hv_stores(hv, "min", newSViv((IV)(total == 0 ? 0 : mn)));
Branch: 1 branch
BranchTrueFalseTotal
hv_stores(hv, "min", newSViv((IV)(total == 0 ? 0 : mn))); 4 0 4
527 4 hv_stores(hv, "max", newSViv((IV)mx));
528 4 hv_stores(hv, "mean", newSVnv(mean));
529 4 hv_stores(hv, "counts_len", newSViv((IV)counts_len));
530 4 hv_stores(hv, "bucket_count", newSViv((IV)bucket_count));
531 4 hv_stores(hv, "sub_bucket_count", newSViv((IV)sub_bucket_count));
532 4 hv_stores(hv, "ops", newSVuv((UV)ops));
533 4 hv_stores(hv, "mmap_size", newSVuv((UV)h->mmap_size));
534 4 hv_stores(hv, "frozen", newSVuv(__atomic_load_n(&h->hdr->sealed, __ATOMIC_ACQUIRE) ? 1 : 0));
535 4 hv_stores(hv, "readonly", newSVuv(h->readonly ? 1 : 0));
536 4 RETVAL = newRV_noinc((SV *)hv);
537 }
538 OUTPUT:
539 RETVAL
540  
541 SV *
542 path(self)
543 SV *self
544 PREINIT:
545 4 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 4 0 4
EXTRACT(self); 0 4 4
EXTRACT(self); 0 4 4
546 CODE:
547 4 ▶ RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef; 2 2 4
548 OUTPUT:
549 RETVAL
550  
551 int
552 memfd(self)
553 SV *self
554 PREINIT:
555 4 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 4 0 4
EXTRACT(self); 0 4 4
EXTRACT(self); 0 4 4
556 CODE:
557 4 ▶ RETVAL = h->backing_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->backing_fd; 0 4 4
558 OUTPUT:
559 RETVAL
560  
561 void
562 sync(self)
563 SV *self
564 PREINIT:
565 3 ▶ EXTRACT(self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT(self); 3 0 3
EXTRACT(self); 0 3 3
EXTRACT(self); 0 3 3
566 CODE:
567 3 ▶ if (!h->readonly && hist_msync(h) != 0) croak("sync: %s", strerror(errno));
Branch: 2 branches
BranchTrueFalseTotal
if (!h->readonly && hist_msync(h) != 0) croak("sync: %s", strerror(errno)); 2 1 3
if (!h->readonly && hist_msync(h) != 0) croak("sync: %s", strerror(errno)); 0 2 2
568  
569 void
570 unlink(self, ...)
571 SV *self
572 CODE:
573 3 ▶ if (sv_isobject(self) && sv_derived_from(self, "Data::Histogram::Shared")) {
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(self) && sv_derived_from(self, "Data::Histogram::Shared")) { 1 1 2
if (sv_isobject(self) && sv_derived_from(self, "Data::Histogram::Shared")) { 1 0 1
574 1 HistHandle *h = INT2PTR(HistHandle*, SvIV(SvRV(self)));
575 1 ▶ if (h && h->path && unlink(h->path) != 0 && errno != ENOENT)
Branch: 4 branches
BranchTrueFalseTotal
if (h && h->path && unlink(h->path) != 0 && errno != ENOENT) 1 0 1
if (h && h->path && unlink(h->path) != 0 && errno != ENOENT) 1 0 1
if (h && h->path && unlink(h->path) != 0 && errno != ENOENT) 0 1 1
if (h && h->path && unlink(h->path) != 0 && errno != ENOENT) 0 0 0
576 0 croak("Data::Histogram::Shared->unlink(%s): %s", h->path, strerror(errno));
577 1 ▶ } else if (items >= 2 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) {
Branch: 4 branches
BranchTrueFalseTotal
} else if (items >= 2 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 1 0 1
} else if (items >= 2 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 1 1
} else if (items >= 2 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 0 0
} else if (items >= 2 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 1 0 1
578 {
579 1 const char *up = SvPV_nolen(ST(1));
580 1 ▶ if (unlink(up) != 0 && errno != ENOENT)
Branch: 2 branches
BranchTrueFalseTotal
if (unlink(up) != 0 && errno != ENOENT) 0 1 1
if (unlink(up) != 0 && errno != ENOENT) 0 0 0
581 0 croak("Data::Histogram::Shared->unlink(%s): %s", up, strerror(errno));
582 }
583 }
« hist.h ↑ Summary