Shared.xs

filter: Statementstmt 76.2% 189 / 248 Branchbran 40.2% 182 / 452 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 53.0% 371 / 700 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Data/Deque/Shared.pm ↑ Summary deque.h »
1 #define PERL_NO_GET_CONTEXT
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5 #include "ppport.h"
6 10 static int deq_wait_interrupted(void) { dTHX; return PL_sig_pending != 0; }
7 #define DEQ_WAIT_INTERRUPTED() deq_wait_interrupted()
8 #define DEQ_WAIT_POLL_NS 500000000L
9 #include "deque.h"
10  
11 /* Slot image of a Str value: u32 length (bit 31 = SvUTF8), then the bytes. */
12 48 static uint8_t *deq_str_elem(pTHX_ DeqHandle *h, SV *val, const char *s, STRLEN len) {
13 48 uint32_t max_len = h->elem_size - sizeof(uint32_t);
14 48 ▶ if (len > max_len)
Branch: 1 branch
BranchTrueFalseTotal
if (len > max_len) 8 40 48
15 8 croak("Data::Deque::Shared::Str: value of %" UVuf " bytes exceeds max_len %u",
16 (UV)len, (unsigned)max_len);
17 uint8_t *buf;
18 40 Newxz(buf, h->elem_size, uint8_t);
19 40 uint32_t l32 = (uint32_t)len | (SvUTF8(val) ? 0x80000000u : 0u);
20 40 memcpy(buf, &l32, sizeof l32);
21 40 memcpy(buf + sizeof l32, s, len);
22 40 return buf;
23 }
24  
25 36327 static inline int deq_is_object(pTHX_ SV *sv) {
26 36327 ▶ if (!sv_isobject(sv)) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!sv_isobject(sv)) return 0; 0 36327 36327
27 36327 HV *stash = SvSTASH(SvRV(sv));
28 36327 ▶ const char *name = HvNAME_get(stash);
Branch: 6 branches
BranchTrueFalseTotal
const char *name = HvNAME_get(stash); 36327 0 36327
const char *name = HvNAME_get(stash); 36327 0 36327
const char *name = HvNAME_get(stash); 0 36327 36327
const char *name = HvNAME_get(stash); 0 0 0
const char *name = HvNAME_get(stash); 36327 0 36327
const char *name = HvNAME_get(stash); 0 36327 36327
29 72654 ▶ return (name && HvNAMELEN_get(stash) == 24
Branch: 6 branches
BranchTrueFalseTotal
return (name && HvNAMELEN_get(stash) == 24 36327 0 36327
return (name && HvNAMELEN_get(stash) == 24 36327 0 36327
return (name && HvNAMELEN_get(stash) == 24 0 0 0
return (name && HvNAMELEN_get(stash) == 24 36327 0 36327
return (name && HvNAMELEN_get(stash) == 24 0 36327 36327
return (name && HvNAMELEN_get(stash) == 24 36323 4 36327
30 36323 ▶ && memEQ(name, "Data::Deque::Shared::", 21)
Branch: 1 branch
BranchTrueFalseTotal
&& memEQ(name, "Data::Deque::Shared::", 21) 36323 0 36323
31 36323 ▶ && (memEQ(name + 21, "Int", 3) || memEQ(name + 21, "Str", 3)))
Branch: 2 branches
BranchTrueFalseTotal
&& (memEQ(name + 21, "Int", 3) || memEQ(name + 21, "Str", 3))) 96 36227 36323
&& (memEQ(name + 21, "Int", 3) || memEQ(name + 21, "Str", 3))) 0 96 96
32 108981 ▶ || sv_derived_from(sv, "Data::Deque::Shared");
Branch: 3 branches
BranchTrueFalseTotal
|| sv_derived_from(sv, "Data::Deque::Shared"); 36327 0 36327
|| sv_derived_from(sv, "Data::Deque::Shared"); 0 36327 36327
|| sv_derived_from(sv, "Data::Deque::Shared"); 4 0 4
33 }
34  
35 #define EXTRACT_DEQ(sv) \
36 if (!deq_is_object(aTHX_ sv)) \
37 croak("Expected a Data::Deque::Shared object"); \
38 DeqHandle *h = INT2PTR(DeqHandle*, SvIV(SvRV(sv))); \
39 if (!h) croak("Attempted to use a destroyed Data::Deque::Shared object"); \
40 DeqHandle *h0 = h; PERL_UNUSED_VAR(h0); \
41 sv_2mortal(SvREFCNT_inc(SvRV(sv)))
42  
43 /* Re-read the handle after a call that can run Perl code (tied/overloaded
44 * argument magic). That code may call $obj->DESTROY explicitly, which frees
45 * the handle and zeroes the IV; EXTRACT_DEQ's mortal pins the referent only
46 * against refcount-driven destruction, not an explicit DESTROY, so the local
47 * `h` would dangle. Used only where magic can actually intervene between
48 * EXTRACT_DEQ and the first use of h. */
49 #define REEXTRACT_DEQ(sv) \
50 if (!SvROK(sv)) \
51 croak("Data::Deque::Shared object was replaced during the call"); \
52 h = INT2PTR(DeqHandle*, SvIV(SvRV(sv))); \
53 if (h != h0) croak("Data::Deque::Shared object replaced or destroyed during the call")
54  
55 #define MAKE_OBJ(class, handle) \
56 SV *obj = newSViv(PTR2IV(handle)); \
57 SV *ref = newRV_noinc(obj); \
58 sv_bless(ref, gv_stashpv(class, GV_ADD)); \
59 RETVAL = ref
60  
61 2 static int deq_perl_push_wait(pTHX_ SV *self, DeqHandle *h, const void *val, uint32_t len, int front, double timeout) {
62 2 DeqHandle *h0 = h;
63 struct timespec deadline, remaining;
64 2 ▶ if (timeout > 0) deq_make_deadline(timeout, &deadline);
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) deq_make_deadline(timeout, &deadline); 2 0 2
65 2 double seconds = timeout;
66 0 for (;;) {
67 2 int result = deq_push_wait(h, val, len, front, seconds);
68 2 ▶ if (result >= 0) return result;
Branch: 1 branch
BranchTrueFalseTotal
if (result >= 0) return result; 2 0 2
69 0 ▶ PERL_ASYNC_CHECK();
Branch: 1 branch
BranchTrueFalseTotal
PERL_ASYNC_CHECK(); 0 0 0
70 0 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 0 0
REEXTRACT_DEQ(self); 0 0 0
71 0 ▶ if (timeout > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) { 0 0 0
72 0 ▶ if (!deq_remaining(&deadline, &remaining)) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!deq_remaining(&deadline, &remaining)) return 0; 0 0 0
73 0 seconds = (double)remaining.tv_sec + (double)remaining.tv_nsec / 1e9;
74 }
75 }
76 }
77  
78 3 static int deq_perl_pop_wait(pTHX_ SV *self, DeqHandle *h, void *out, int back, double timeout) {
79 3 DeqHandle *h0 = h;
80 struct timespec deadline, remaining;
81 3 ▶ if (timeout > 0) deq_make_deadline(timeout, &deadline);
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) deq_make_deadline(timeout, &deadline); 3 0 3
82 3 double seconds = timeout;
83 0 for (;;) {
84 3 int result = deq_pop_wait(h, out, back, seconds);
85 3 ▶ if (result >= 0) return result;
Branch: 1 branch
BranchTrueFalseTotal
if (result >= 0) return result; 3 0 3
86 0 ▶ PERL_ASYNC_CHECK();
Branch: 1 branch
BranchTrueFalseTotal
PERL_ASYNC_CHECK(); 0 0 0
87 0 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 0 0
REEXTRACT_DEQ(self); 0 0 0
88 0 ▶ if (timeout > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) { 0 0 0
89 0 ▶ if (!deq_remaining(&deadline, &remaining)) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!deq_remaining(&deadline, &remaining)) return 0; 0 0 0
90 0 seconds = (double)remaining.tv_sec + (double)remaining.tv_nsec / 1e9;
91 }
92 }
93 }
94  
95 MODULE = Data::Deque::Shared PACKAGE = Data::Deque::Shared
96  
97 PROTOTYPES: DISABLE
98  
99 void
100 DESTROY(self)
101 SV *self
102 CODE:
103 49 ▶ if (!sv_isobject(self) || !sv_derived_from(self, "Data::Deque::Shared")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self) || !sv_derived_from(self, "Data::Deque::Shared")) return; 49 0 49
if (!sv_isobject(self) || !sv_derived_from(self, "Data::Deque::Shared")) return; 0 49 49
104 49 DeqHandle *h = INT2PTR(DeqHandle*, SvIV(SvRV(self)));
105 49 ▶ if (!h) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!h) return; 0 49 49
106 49 sv_setiv(SvRV(self), 0);
107 49 deq_destroy(h);
108  
109 UV
110 size(self)
111 SV *self
112 PREINIT:
113 19 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 19 19
EXTRACT_DEQ(self); 0 19 19
114 CODE:
115 19 ▶ RETVAL = (UV)deq_size(h);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)deq_size(h); 3 16 19
116 OUTPUT:
117 RETVAL
118  
119 UV
120 capacity(self)
121 SV *self
122 PREINIT:
123 10 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 10 10
EXTRACT_DEQ(self); 0 10 10
124 CODE:
125 10 ▶ RETVAL = (UV)h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)h->capacity; 0 10 10
126 OUTPUT:
127 RETVAL
128  
129 bool
130 is_empty(self)
131 SV *self
132 PREINIT:
133 10 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 10 10
EXTRACT_DEQ(self); 0 10 10
134 CODE:
135 10 ▶ RETVAL = deq_size(h) == 0;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = deq_size(h) == 0; 10 0 10
136 OUTPUT:
137 RETVAL
138  
139 bool
140 is_full(self)
141 SV *self
142 PREINIT:
143 3 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 3 3
EXTRACT_DEQ(self); 0 3 3
144 CODE:
145 3 ▶ RETVAL = deq_size(h) >= h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = deq_size(h) >= h->capacity; 3 0 3
146 OUTPUT:
147 RETVAL
148  
149 void
150 clear(self)
151 SV *self
152 PREINIT:
153 3 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 3 3
EXTRACT_DEQ(self); 0 3 3
154 CODE:
155 3 deq_clear(h);
156  
157 UV
158 drain(self)
159 SV *self
160 PREINIT:
161 4 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 4 4
EXTRACT_DEQ(self); 0 4 4
162 CODE:
163 4 ▶ RETVAL = (UV)deq_drain(h);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)deq_drain(h); 0 4 4
164 OUTPUT:
165 RETVAL
166  
167 SV *
168 path(self)
169 SV *self
170 PREINIT:
171 1 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 1 1
EXTRACT_DEQ(self); 0 1 1
172 CODE:
173 1 ▶ RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef; 1 0 1
174 OUTPUT:
175 RETVAL
176  
177 IV
178 memfd(self)
179 SV *self
180 PREINIT:
181 1 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 1 1
EXTRACT_DEQ(self); 0 1 1
182 CODE:
183 1 ▶ RETVAL = h->backing_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->backing_fd; 0 1 1
184 OUTPUT:
185 RETVAL
186  
187 IV
188 eventfd(self)
189 SV *self
190 PREINIT:
191 2 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 2 2
EXTRACT_DEQ(self); 0 2 2
192 CODE:
193 2 RETVAL = deq_create_eventfd(h);
194 2 ▶ if (RETVAL < 0) croak("eventfd: %s", strerror(errno));
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) croak("eventfd: %s", strerror(errno)); 0 2 2
195 OUTPUT:
196 RETVAL
197  
198 void
199 eventfd_set(self, fd)
200 SV *self
201 int fd
202 PREINIT:
203 3 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 3 3
EXTRACT_DEQ(self); 0 3 3
204 CODE:
205 3 ▶ if (h->notify_fd >= 0 && h->notify_fd != fd) close(h->notify_fd);
Branch: 2 branches
BranchTrueFalseTotal
if (h->notify_fd >= 0 && h->notify_fd != fd) close(h->notify_fd); 3 0 3
if (h->notify_fd >= 0 && h->notify_fd != fd) close(h->notify_fd); 2 1 3
206 3 h->notify_fd = fd;
207  
208 IV
209 fileno(self)
210 SV *self
211 PREINIT:
212 3 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 3 3
EXTRACT_DEQ(self); 0 3 3
213 CODE:
214 3 ▶ RETVAL = h->notify_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->notify_fd; 0 3 3
215 OUTPUT:
216 RETVAL
217  
218 bool
219 notify(self)
220 SV *self
221 PREINIT:
222 2 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 2 2
EXTRACT_DEQ(self); 0 2 2
223 CODE:
224 2 ▶ RETVAL = deq_notify(h);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = deq_notify(h); 2 0 2
225 OUTPUT:
226 RETVAL
227  
228 SV *
229 eventfd_consume(self)
230 SV *self
231 PREINIT:
232 2 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 2 2
EXTRACT_DEQ(self); 0 2 2
233 CODE:
234 2 int64_t v = deq_eventfd_consume(h);
235 2 ▶ RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef; 2 0 2
236 OUTPUT:
237 RETVAL
238  
239 void
240 sync(self)
241 SV *self
242 PREINIT:
243 1 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 1 1
EXTRACT_DEQ(self); 0 1 1
244 CODE:
245 1 ▶ if (deq_msync(h) != 0) croak("msync: %s", strerror(errno));
Branch: 1 branch
BranchTrueFalseTotal
if (deq_msync(h) != 0) croak("msync: %s", strerror(errno)); 0 1 1
246  
247 void
248 unlink(self_or_class, ...)
249 SV *self_or_class
250 CODE:
251 const char *p;
252 2 ▶ if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Deque::Shared")) {
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Deque::Shared")) { 2 0 2
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Deque::Shared")) { 2 0 2
253 2 DeqHandle *h = INT2PTR(DeqHandle*, SvIV(SvRV(self_or_class)));
254 2 ▶ if (!h) croak("Attempted to use a destroyed object");
Branch: 1 branch
BranchTrueFalseTotal
if (!h) croak("Attempted to use a destroyed object"); 0 2 2
255 2 p = h->path;
256 } else {
257 0 ▶ if (items < 2) croak("Usage: ...->unlink($path)");
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) croak("Usage: ...->unlink($path)"); 0 0 0
258 0 p = SvPV_nolen(ST(1));
259 }
260 2 ▶ if (!p) croak("cannot unlink anonymous or memfd object");
Branch: 1 branch
BranchTrueFalseTotal
if (!p) croak("cannot unlink anonymous or memfd object"); 0 2 2
261 2 ▶ if (unlink(p) != 0 && errno != ENOENT) croak("unlink(%s): %s", p, strerror(errno));
Branch: 2 branches
BranchTrueFalseTotal
if (unlink(p) != 0 && errno != ENOENT) croak("unlink(%s): %s", p, strerror(errno)); 0 2 2
if (unlink(p) != 0 && errno != ENOENT) croak("unlink(%s): %s", p, strerror(errno)); 0 0 0
262  
263 SV *
264 stats(self)
265 SV *self
266 PREINIT:
267 6 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 6 6
EXTRACT_DEQ(self); 0 6 6
268 CODE:
269 6 HV *hv = newHV();
270 6 DeqHeader *hdr = h->hdr;
271 6 hv_store(hv, "size", 4, newSVuv((UV)deq_size(h)), 0);
272 6 hv_store(hv, "capacity", 8, newSVuv((UV)h->capacity), 0);
273 6 hv_store(hv, "pushes", 6, newSVuv((UV)__atomic_load_n(&hdr->stat_pushes, __ATOMIC_RELAXED)), 0);
274 6 hv_store(hv, "pops", 4, newSVuv((UV)__atomic_load_n(&hdr->stat_pops, __ATOMIC_RELAXED)), 0);
275 6 hv_store(hv, "waits", 5, newSVuv((UV)__atomic_load_n(&hdr->stat_waits, __ATOMIC_RELAXED)), 0);
276 6 hv_store(hv, "timeouts", 8, newSVuv((UV)__atomic_load_n(&hdr->stat_timeouts, __ATOMIC_RELAXED)), 0);
277 6 hv_store(hv, "recoveries", 10, newSVuv((UV)__atomic_load_n(&hdr->stat_recoveries, __ATOMIC_RELAXED)), 0);
278 6 hv_store(hv, "mmap_size", 9, newSVuv((UV)h->mmap_size), 0);
279 6 RETVAL = newRV_noinc((SV *)hv);
280 OUTPUT:
281 RETVAL
282  
283  
284 MODULE = Data::Deque::Shared PACKAGE = Data::Deque::Shared::Int
285  
286 PROTOTYPES: DISABLE
287  
288 SV *
289 new(class, path, capacity, ...)
290 const char *class
291 SV *path
292 UV capacity
293 PREINIT:
294 char errbuf[DEQ_ERR_BUFLEN];
295 CODE:
296 35 ▶ mode_t mode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600;
Branch: 4 branches
BranchTrueFalseTotal
mode_t mode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 35 35
mode_t mode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
mode_t mode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
mode_t mode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
297 60 ▶ 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 35 35
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; 25 10 35
298 35 DeqHandle *h = deq_create(p, capacity, sizeof(int64_t), DEQ_VAR_INT, mode, errbuf);
299 35 ▶ if (!h) croak("Data::Deque::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Deque::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory"); 6 29 35
if (!h) croak("Data::Deque::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory"); 6 0 6
300 29 MAKE_OBJ(class, h);
301 OUTPUT:
302 RETVAL
303  
304 SV *
305 new_memfd(class, name, capacity)
306 const char *class
307 const char *name
308 UV capacity
309 PREINIT:
310 char errbuf[DEQ_ERR_BUFLEN];
311 CODE:
312 1 DeqHandle *h = deq_create_memfd(name, capacity, sizeof(int64_t), DEQ_VAR_INT, errbuf);
313 1 ▶ if (!h) croak("Data::Deque::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Deque::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 1 1
if (!h) croak("Data::Deque::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
314 1 MAKE_OBJ(class, h);
315 OUTPUT:
316 RETVAL
317  
318 SV *
319 new_from_fd(class, fd)
320 const char *class
321 int fd
322 PREINIT:
323 char errbuf[DEQ_ERR_BUFLEN];
324 CODE:
325 2 DeqHandle *h = deq_open_fd(fd, DEQ_VAR_INT, errbuf);
326 2 ▶ if (!h) croak("Data::Deque::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Deque::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 1 1 2
if (!h) croak("Data::Deque::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 1 0 1
327 1 MAKE_OBJ(class, h);
328 OUTPUT:
329 RETVAL
330  
331 bool
332 push_back(self, val)
333 SV *self
334 IV val
335 PREINIT:
336 107 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 107 107
EXTRACT_DEQ(self); 0 107 107
337 CODE:
338 107 int64_t v = (int64_t)val;
339 107 ▶ RETVAL = deq_try_push_back(h, &v, sizeof(v));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = deq_try_push_back(h, &v, sizeof(v)); 105 2 107
340 OUTPUT:
341 RETVAL
342  
343 bool
344 push_front(self, val)
345 SV *self
346 IV val
347 PREINIT:
348 10 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 10 10
EXTRACT_DEQ(self); 0 10 10
349 CODE:
350 10 int64_t v = (int64_t)val;
351 10 ▶ RETVAL = deq_try_push_front(h, &v, sizeof(v));
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = deq_try_push_front(h, &v, sizeof(v)); 8 2 10
352 OUTPUT:
353 RETVAL
354  
355 bool
356 push_back_wait(self, val, ...)
357 SV *self
358 IV val
359 PREINIT:
360 1 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 1 1
EXTRACT_DEQ(self); 0 1 1
361 1 double timeout = -1;
362 CODE:
363 1 ▶ if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 1 0 1
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 1 1
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 0 0
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 1 0 1
364 1 int64_t v = (int64_t)val;
365 1 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 1 1
REEXTRACT_DEQ(self); 0 1 1
366 1 ▶ RETVAL = deq_perl_push_wait(aTHX_ self, h, &v, sizeof(v), 0, timeout);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = deq_perl_push_wait(aTHX_ self, h, &v, sizeof(v), 0, timeout); 0 1 1
367 OUTPUT:
368 RETVAL
369  
370 bool
371 push_front_wait(self, val, ...)
372 SV *self
373 IV val
374 PREINIT:
375 1 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 1 1
EXTRACT_DEQ(self); 0 1 1
376 1 double timeout = -1;
377 CODE:
378 1 ▶ if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 1 0 1
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 1 1
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 0 0
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 1 0 1
379 1 int64_t v = (int64_t)val;
380 1 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 1 1
REEXTRACT_DEQ(self); 0 1 1
381 1 ▶ RETVAL = deq_perl_push_wait(aTHX_ self, h, &v, sizeof(v), 1, timeout);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = deq_perl_push_wait(aTHX_ self, h, &v, sizeof(v), 1, timeout); 0 1 1
382 OUTPUT:
383 RETVAL
384  
385 SV *
386 pop_front(self)
387 SV *self
388 PREINIT:
389 36041 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 36041 36041
EXTRACT_DEQ(self); 0 36041 36041
390 CODE:
391 int64_t v;
392 36041 ▶ RETVAL = deq_try_pop_front(h, &v) ? newSViv((IV)v) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = deq_try_pop_front(h, &v) ? newSViv((IV)v) : &PL_sv_undef; 36037 4 36041
393 OUTPUT:
394 RETVAL
395  
396 SV *
397 pop_back(self)
398 SV *self
399 PREINIT:
400 10 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 10 10
EXTRACT_DEQ(self); 0 10 10
401 CODE:
402 int64_t v;
403 10 ▶ RETVAL = deq_try_pop_back(h, &v) ? newSViv((IV)v) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = deq_try_pop_back(h, &v) ? newSViv((IV)v) : &PL_sv_undef; 9 1 10
404 OUTPUT:
405 RETVAL
406  
407 SV *
408 pop_front_wait(self, ...)
409 SV *self
410 PREINIT:
411 2 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 2 2
EXTRACT_DEQ(self); 0 2 2
412 2 double timeout = -1;
413 CODE:
414 2 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 2 0 2
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 2 2
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 2 0 2
415 int64_t v;
416 2 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 2 2
REEXTRACT_DEQ(self); 0 2 2
417 2 ▶ RETVAL = deq_perl_pop_wait(aTHX_ self, h, &v, 0, timeout) ? newSViv((IV)v) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = deq_perl_pop_wait(aTHX_ self, h, &v, 0, timeout) ? newSViv((IV)v) : &PL_sv_undef; 1 1 2
418 OUTPUT:
419 RETVAL
420  
421 SV *
422 pop_back_wait(self, ...)
423 SV *self
424 PREINIT:
425 1 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 1 1
EXTRACT_DEQ(self); 0 1 1
426 1 double timeout = -1;
427 CODE:
428 1 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 1 0 1
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 1 1
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 1 0 1
429 int64_t v;
430 1 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 1 1
REEXTRACT_DEQ(self); 0 1 1
431 1 ▶ RETVAL = deq_perl_pop_wait(aTHX_ self, h, &v, 1, timeout) ? newSViv((IV)v) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = deq_perl_pop_wait(aTHX_ self, h, &v, 1, timeout) ? newSViv((IV)v) : &PL_sv_undef; 0 1 1
432 OUTPUT:
433 RETVAL
434  
435 MODULE = Data::Deque::Shared PACKAGE = Data::Deque::Shared::Str
436  
437 PROTOTYPES: DISABLE
438  
439 SV *
440 new(class, path, capacity, max_len, ...)
441 const char *class
442 SV *path
443 UV capacity
444 UV max_len
445 PREINIT:
446 char errbuf[DEQ_ERR_BUFLEN];
447 CODE:
448 20 ▶ if (max_len == 0) croak("max_len must be > 0");
Branch: 1 branch
BranchTrueFalseTotal
if (max_len == 0) croak("max_len must be > 0"); 1 19 20
449 19 ▶ if (max_len >= 0x80000000u) /* bit 31 of the stored length is the UTF8 flag */
Branch: 1 branch
BranchTrueFalseTotal
if (max_len >= 0x80000000u) /* bit 31 of the stored length is the UTF8 flag */ 0 19 19
450 0 croak("max_len too large (>= 2 GiB)");
451 19 ▶ mode_t mode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600;
Branch: 4 branches
BranchTrueFalseTotal
mode_t mode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; 0 19 19
mode_t mode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; 0 0 0
mode_t mode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; 0 0 0
mode_t mode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; 0 0 0
452 19 uint32_t elem_size = (uint32_t)(sizeof(uint32_t) + max_len);
453 30 ▶ 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 19 19
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; 11 8 19
454 19 DeqHandle *h = deq_create(p, capacity, elem_size, DEQ_VAR_STR, mode, errbuf);
455 19 ▶ if (!h) croak("Data::Deque::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Deque::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory"); 1 18 19
if (!h) croak("Data::Deque::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory"); 1 0 1
456 18 MAKE_OBJ(class, h);
457 OUTPUT:
458 RETVAL
459  
460 SV *
461 new_memfd(class, name, capacity, max_len)
462 const char *class
463 const char *name
464 UV capacity
465 UV max_len
466 PREINIT:
467 char errbuf[DEQ_ERR_BUFLEN];
468 CODE:
469 0 ▶ if (max_len == 0) croak("max_len must be > 0");
Branch: 1 branch
BranchTrueFalseTotal
if (max_len == 0) croak("max_len must be > 0"); 0 0 0
470 0 ▶ if (max_len >= 0x80000000u) /* bit 31 of the stored length is the UTF8 flag */
Branch: 1 branch
BranchTrueFalseTotal
if (max_len >= 0x80000000u) /* bit 31 of the stored length is the UTF8 flag */ 0 0 0
471 0 croak("max_len too large (>= 2 GiB)");
472 0 uint32_t elem_size = (uint32_t)(sizeof(uint32_t) + max_len);
473 0 DeqHandle *h = deq_create_memfd(name, capacity, elem_size, DEQ_VAR_STR, errbuf);
474 0 ▶ if (!h) croak("Data::Deque::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Deque::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
if (!h) croak("Data::Deque::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
475 0 MAKE_OBJ(class, h);
476 OUTPUT:
477 RETVAL
478  
479 SV *
480 new_from_fd(class, fd)
481 const char *class
482 int fd
483 PREINIT:
484 char errbuf[DEQ_ERR_BUFLEN];
485 CODE:
486 0 DeqHandle *h = deq_open_fd(fd, DEQ_VAR_STR, errbuf);
487 0 ▶ if (!h) croak("Data::Deque::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Deque::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
if (!h) croak("Data::Deque::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
488 0 MAKE_OBJ(class, h);
489 OUTPUT:
490 RETVAL
491  
492 bool
493 push_back(self, val)
494 SV *self
495 SV *val
496 PREINIT:
497 33 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 33 33
EXTRACT_DEQ(self); 0 33 33
498 CODE:
499 STRLEN slen;
500 33 const char *s = SvPV(val, slen);
501 33 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 33 33
REEXTRACT_DEQ(self); 0 33 33
502 33 uint8_t *buf = deq_str_elem(aTHX_ h, val, s, slen);
503 31 RETVAL = deq_try_push_back(h, buf, h->elem_size);
504 31 Safefree(buf);
505 OUTPUT:
506 RETVAL
507  
508 bool
509 push_front(self, val)
510 SV *self
511 SV *val
512 PREINIT:
513 7 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 7 7
EXTRACT_DEQ(self); 0 7 7
514 CODE:
515 STRLEN slen;
516 7 const char *s = SvPV(val, slen);
517 7 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 7 7
REEXTRACT_DEQ(self); 0 7 7
518 7 uint8_t *buf = deq_str_elem(aTHX_ h, val, s, slen);
519 5 RETVAL = deq_try_push_front(h, buf, h->elem_size);
520 5 Safefree(buf);
521 OUTPUT:
522 RETVAL
523  
524 bool
525 push_back_wait(self, val, ...)
526 SV *self
527 SV *val
528 PREINIT:
529 4 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 4 4
EXTRACT_DEQ(self); 0 4 4
530 4 double timeout = -1;
531 CODE:
532 4 ▶ if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 4 4
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 0 0
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 0 0
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 0 0
533 STRLEN slen;
534 4 const char *s = SvPV(val, slen);
535 4 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 4 4
REEXTRACT_DEQ(self); 0 4 4
536 4 uint8_t *buf = deq_str_elem(aTHX_ h, val, s, slen);
537 2 RETVAL = deq_try_push_back(h, buf, h->elem_size);
538 2 ▶ if (RETVAL || timeout == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (RETVAL || timeout == 0) { 0 2 2
if (RETVAL || timeout == 0) { 0 0 0
539 2 Safefree(buf);
540 } else {
541 0 SAVEFREEPV(buf);
542 0 RETVAL = deq_perl_push_wait(aTHX_ self, h, buf, h->elem_size, 0, timeout);
543 }
544 OUTPUT:
545 RETVAL
546  
547 bool
548 push_front_wait(self, val, ...)
549 SV *self
550 SV *val
551 PREINIT:
552 4 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 4 4
EXTRACT_DEQ(self); 0 4 4
553 4 double timeout = -1;
554 CODE:
555 4 ▶ if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 4 4
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 0 0
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 0 0
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV_nomg(ST(2)); 0 0 0
556 STRLEN slen;
557 4 const char *s = SvPV(val, slen);
558 4 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 4 4
REEXTRACT_DEQ(self); 0 4 4
559 4 uint8_t *buf = deq_str_elem(aTHX_ h, val, s, slen);
560 2 RETVAL = deq_try_push_front(h, buf, h->elem_size);
561 2 ▶ if (RETVAL || timeout == 0) {
Branch: 2 branches
BranchTrueFalseTotal
if (RETVAL || timeout == 0) { 0 2 2
if (RETVAL || timeout == 0) { 0 0 0
562 2 Safefree(buf);
563 } else {
564 0 SAVEFREEPV(buf);
565 0 RETVAL = deq_perl_push_wait(aTHX_ self, h, buf, h->elem_size, 1, timeout);
566 }
567 OUTPUT:
568 RETVAL
569  
570 SV *
571 pop_front(self)
572 SV *self
573 PREINIT:
574 34 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 34 34
EXTRACT_DEQ(self); 0 34 34
575 CODE:
576 uint8_t *buf;
577 34 Newx(buf, h->elem_size, uint8_t);
578 34 SAVEFREEPV(buf);
579 34 ▶ if (deq_try_pop_front(h, buf)) {
Branch: 1 branch
BranchTrueFalseTotal
if (deq_try_pop_front(h, buf)) { 33 1 34
580 uint32_t l32;
581 33 memcpy(&l32, buf, sizeof(uint32_t));
582 33 int is_utf8 = (l32 & 0x80000000u) != 0;
583 33 uint32_t len = l32 & 0x7FFFFFFFu;
584 33 uint32_t max_len = h->elem_size - sizeof(uint32_t);
585 33 ▶ if (len > max_len) len = max_len;
Branch: 1 branch
BranchTrueFalseTotal
if (len > max_len) len = max_len; 0 33 33
586 33 RETVAL = newSVpvn((char *)buf + sizeof(uint32_t), len);
587 33 ▶ if (is_utf8) SvUTF8_on(RETVAL);
Branch: 1 branch
BranchTrueFalseTotal
if (is_utf8) SvUTF8_on(RETVAL); 4 29 33
588 } else {
589 1 RETVAL = &PL_sv_undef;
590 }
591 OUTPUT:
592 RETVAL
593  
594 SV *
595 pop_back(self)
596 SV *self
597 PREINIT:
598 2 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 2 2
EXTRACT_DEQ(self); 0 2 2
599 CODE:
600 uint8_t *buf;
601 2 Newx(buf, h->elem_size, uint8_t);
602 2 SAVEFREEPV(buf);
603 2 ▶ if (deq_try_pop_back(h, buf)) {
Branch: 1 branch
BranchTrueFalseTotal
if (deq_try_pop_back(h, buf)) { 1 1 2
604 uint32_t l32;
605 1 memcpy(&l32, buf, sizeof(uint32_t));
606 1 int is_utf8 = (l32 & 0x80000000u) != 0;
607 1 uint32_t len = l32 & 0x7FFFFFFFu;
608 1 uint32_t max_len = h->elem_size - sizeof(uint32_t);
609 1 ▶ if (len > max_len) len = max_len;
Branch: 1 branch
BranchTrueFalseTotal
if (len > max_len) len = max_len; 0 1 1
610 1 RETVAL = newSVpvn((char *)buf + sizeof(uint32_t), len);
611 1 ▶ if (is_utf8) SvUTF8_on(RETVAL);
Branch: 1 branch
BranchTrueFalseTotal
if (is_utf8) SvUTF8_on(RETVAL); 0 1 1
612 } else {
613 1 RETVAL = &PL_sv_undef;
614 }
615 OUTPUT:
616 RETVAL
617  
618 SV *
619 pop_front_wait(self, ...)
620 SV *self
621 PREINIT:
622 0 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 0 0
EXTRACT_DEQ(self); 0 0 0
623 0 double timeout = -1;
624 CODE:
625 0 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 0 0
626 uint8_t *buf;
627 0 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 0 0
REEXTRACT_DEQ(self); 0 0 0
628 0 Newx(buf, h->elem_size, uint8_t);
629 0 SAVEFREEPV(buf);
630 0 ▶ if (deq_perl_pop_wait(aTHX_ self, h, buf, 0, timeout)) {
Branch: 1 branch
BranchTrueFalseTotal
if (deq_perl_pop_wait(aTHX_ self, h, buf, 0, timeout)) { 0 0 0
631 uint32_t l32;
632 0 memcpy(&l32, buf, sizeof(uint32_t));
633 0 int is_utf8 = (l32 & 0x80000000u) != 0;
634 0 uint32_t len = l32 & 0x7FFFFFFFu;
635 0 uint32_t max_len = h->elem_size - sizeof(uint32_t);
636 0 ▶ if (len > max_len) len = max_len;
Branch: 1 branch
BranchTrueFalseTotal
if (len > max_len) len = max_len; 0 0 0
637 0 RETVAL = newSVpvn((char *)buf + sizeof(uint32_t), len);
638 0 ▶ if (is_utf8) SvUTF8_on(RETVAL);
Branch: 1 branch
BranchTrueFalseTotal
if (is_utf8) SvUTF8_on(RETVAL); 0 0 0
639 } else {
640 0 RETVAL = &PL_sv_undef;
641 }
642 OUTPUT:
643 RETVAL
644  
645 SV *
646 pop_back_wait(self, ...)
647 SV *self
648 PREINIT:
649 0 ▶ EXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
EXTRACT_DEQ(self); 0 0 0
EXTRACT_DEQ(self); 0 0 0
650 0 double timeout = -1;
651 CODE:
652 0 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV_nomg(ST(1)); 0 0 0
653 uint8_t *buf;
654 0 ▶ REEXTRACT_DEQ(self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_DEQ(self); 0 0 0
REEXTRACT_DEQ(self); 0 0 0
655 0 Newx(buf, h->elem_size, uint8_t);
656 0 SAVEFREEPV(buf);
657 0 ▶ if (deq_perl_pop_wait(aTHX_ self, h, buf, 1, timeout)) {
Branch: 1 branch
BranchTrueFalseTotal
if (deq_perl_pop_wait(aTHX_ self, h, buf, 1, timeout)) { 0 0 0
658 uint32_t l32;
659 0 memcpy(&l32, buf, sizeof(uint32_t));
660 0 int is_utf8 = (l32 & 0x80000000u) != 0;
661 0 uint32_t len = l32 & 0x7FFFFFFFu;
662 0 uint32_t max_len = h->elem_size - sizeof(uint32_t);
663 0 ▶ if (len > max_len) len = max_len;
Branch: 1 branch
BranchTrueFalseTotal
if (len > max_len) len = max_len; 0 0 0
664 0 RETVAL = newSVpvn((char *)buf + sizeof(uint32_t), len);
665 0 ▶ if (is_utf8) SvUTF8_on(RETVAL);
Branch: 1 branch
BranchTrueFalseTotal
if (is_utf8) SvUTF8_on(RETVAL); 0 0 0
666 } else {
667 0 RETVAL = &PL_sv_undef;
668 }
669 OUTPUT:
670 RETVAL
« blib/lib/Data/Deque/Shared.pm ↑ Summary deque.h »