Shared.xs

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