Branch Coverage

Shared.xs
Criterion Covered Total %
branch 301 552 54.5


line true false branch
44 1 2 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
46 0 3 if (!h) croak("Data::Pool::Shared->new: %s", errbuf);
61 0 1 if (!h) croak("Data::Pool::Shared->new_memfd: %s", errbuf);
74 0 1 if (!h) croak("Data::Pool::Shared->new_from_fd: %s", errbuf);
83 0 47 if (!SvROK(self)) return;
85 0 47 if (!h) return;
93 904 0 EXTRACT_POOL(self);
0 904 EXTRACT_POOL(self);
0 904 EXTRACT_POOL(self);
96 11 893 if (items > 1) timeout = SvNV(ST(1));
98 902 2 RETVAL = (slot >= 0) ? newSViv((IV)slot) : &PL_sv_undef;
106 17 0 EXTRACT_POOL(self);
0 17 EXTRACT_POOL(self);
0 17 EXTRACT_POOL(self);
109 6 11 RETVAL = (slot >= 0) ? newSViv((IV)slot) : &PL_sv_undef;
118 692 0 EXTRACT_POOL(self);
0 692 EXTRACT_POOL(self);
0 692 EXTRACT_POOL(self);
120 1 691 CHECK_SLOT(h, slot);
121 689 2 RETVAL = pool_free_slot(h, slot);
130 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
132 1 3 CHECK_SLOT(h, slot);
133 1 2 CHECK_ALLOCATED(h, slot);
144 5 0 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
146 1 4 CHECK_SLOT(h, slot);
147 0 4 CHECK_ALLOCATED(h, slot);
150 0 4 if (len > h->hdr->elem_size)
153 1 3 if (len < h->hdr->elem_size)
161 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
163 1 5 CHECK_SLOT(h, slot);
164 3 2 RETVAL = pool_is_allocated(h, slot);
172 11 0 EXTRACT_POOL(self);
0 11 EXTRACT_POOL(self);
0 11 EXTRACT_POOL(self);
174 7 4 RETVAL = (UV)h->hdr->capacity;
182 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
184 0 3 RETVAL = h->hdr->elem_size;
192 36 0 EXTRACT_POOL(self);
0 36 EXTRACT_POOL(self);
0 36 EXTRACT_POOL(self);
194 14 22 RETVAL = __atomic_load_n(&h->hdr->used, __ATOMIC_RELAXED);
202 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
204 0 2 RETVAL = (UV)h->hdr->capacity - __atomic_load_n(&h->hdr->used, __ATOMIC_RELAXED);
213 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
215 1 1 CHECK_SLOT(h, slot);
216 0 1 RETVAL = __atomic_load_n(&h->owners[slot], __ATOMIC_RELAXED);
224 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
226 0 2 RETVAL = pool_recover_stale(h);
234 10 0 EXTRACT_POOL(self);
0 10 EXTRACT_POOL(self);
0 10 EXTRACT_POOL(self);
242 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
244 1 2 RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
252 5 0 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
254 0 5 RETVAL = h->backing_fd;
262 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
264 0 2 RETVAL = pool_create_eventfd(h);
273 0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
275 0 0 if (h->notify_fd >= 0 && h->notify_fd != fd) close(h->notify_fd);
0 0 if (h->notify_fd >= 0 && h->notify_fd != fd) close(h->notify_fd);
282 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
284 0 3 RETVAL = h->notify_fd;
292 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
294 3 0 RETVAL = pool_notify(h);
302 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
305 2 1 RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef;
313 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
322 2 1 if (sv_isobject(self_or_class)) {
324 0 2 if (!h) croak("Attempted to use a destroyed object");
327 0 1 if (items < 2) croak("Usage: ...->unlink($path)");
330 1 2 if (!p) croak("cannot unlink anonymous or memfd object");
331 0 2 if (unlink(p) != 0)
338 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
364 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
367 1 2 if (items > 2) timeout = SvNV(ST(2));
368 1 2 if (count == 0) {
372 0 2 Newx(buf, count, uint64_t);
373 1 1 if (pool_alloc_n(h, buf, (uint32_t)count, timeout)) {
376 3 1 for (UV i = 0; i < count; i++)
392 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
394 2 1 if (!SvROK(slots_av) || SvTYPE(SvRV(slots_av)) != SVt_PVAV)
0 2 if (!SvROK(slots_av) || SvTYPE(SvRV(slots_av)) != SVt_PVAV)
397 0 2 SSize_t len = av_top_index(av) + 1;
398 1 1 if (len <= 0) {
402 0 1 Newx(buf, len, uint64_t);
403 3 1 for (SSize_t i = 0; i < len; i++) {
405 3 0 buf[i] = svp ? (uint64_t)SvUV(*svp) : 0;
417 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
422 7 6 for (uint32_t widx = 0; widx < nwords; widx++) {
424 29 7 while (word) {
427 29 0 if (slot < cap)
441 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
443 1 2 CHECK_SLOT(h, slot);
444 1 1 CHECK_ALLOCATED(h, slot);
445 0 1 RETVAL = PTR2UV(pool_slot_ptr(h, slot));
453 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
455 0 1 RETVAL = PTR2UV(h->data);
464 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
466 0 4 CHECK_SLOT(h, slot);
467 1 3 CHECK_ALLOCATED(h, slot);
491 8 16 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
493 0 24 if (!h) croak("Data::Pool::Shared::I64->new: %s", errbuf);
507 0 2 if (!h) croak("Data::Pool::Shared::I64->new_memfd: %s", errbuf);
520 0 1 if (!h) croak("Data::Pool::Shared::I64->new_from_fd: %s", errbuf);
530 64 0 EXTRACT_POOL(self);
0 64 EXTRACT_POOL(self);
0 64 EXTRACT_POOL(self);
532 1 63 CHECK_SLOT(h, slot);
533 1 62 CHECK_ALLOCATED(h, slot);
544 615 0 EXTRACT_POOL(self);
0 615 EXTRACT_POOL(self);
0 615 EXTRACT_POOL(self);
546 1 614 CHECK_SLOT(h, slot);
547 1 613 CHECK_ALLOCATED(h, slot);
557 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
559 0 4 CHECK_SLOT(h, slot);
560 1 3 CHECK_ALLOCATED(h, slot);
561 2 1 RETVAL = pool_cas_i64(h, slot, (int64_t)expected, (int64_t)desired);
572 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
574 0 2 CHECK_SLOT(h, slot);
575 0 2 CHECK_ALLOCATED(h, slot);
586 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
588 0 1 CHECK_SLOT(h, slot);
589 0 1 CHECK_ALLOCATED(h, slot);
600 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
602 0 3 CHECK_SLOT(h, slot);
603 1 2 CHECK_ALLOCATED(h, slot);
613 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
615 0 4 CHECK_SLOT(h, slot);
616 1 3 CHECK_ALLOCATED(h, slot);
626 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
628 0 3 CHECK_SLOT(h, slot);
629 1 2 CHECK_ALLOCATED(h, slot);
647 0 2 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
649 0 2 if (!h) croak("Data::Pool::Shared::F64->new: %s", errbuf);
663 0 1 if (!h) croak("Data::Pool::Shared::F64->new_memfd: %s", errbuf);
676 0 1 if (!h) croak("Data::Pool::Shared::F64->new_from_fd: %s", errbuf);
686 7 0 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
688 0 7 CHECK_SLOT(h, slot);
689 0 7 CHECK_ALLOCATED(h, slot);
700 7 0 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
702 0 7 CHECK_SLOT(h, slot);
703 0 7 CHECK_ALLOCATED(h, slot);
719 0 3 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
721 0 3 if (!h) croak("Data::Pool::Shared::I32->new: %s", errbuf);
735 0 1 if (!h) croak("Data::Pool::Shared::I32->new_memfd: %s", errbuf);
748 0 1 if (!h) croak("Data::Pool::Shared::I32->new_from_fd: %s", errbuf);
758 5 0 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
760 0 5 CHECK_SLOT(h, slot);
761 0 5 CHECK_ALLOCATED(h, slot);
762 0 5 RETVAL = (IV)pool_get_i32(h, slot);
772 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
774 0 6 CHECK_SLOT(h, slot);
775 0 6 CHECK_ALLOCATED(h, slot);
785 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
787 0 1 CHECK_SLOT(h, slot);
788 0 1 CHECK_ALLOCATED(h, slot);
789 1 0 RETVAL = pool_cas_i32(h, slot, (int32_t)expected, (int32_t)desired);
800 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
802 0 2 CHECK_SLOT(h, slot);
803 0 2 CHECK_ALLOCATED(h, slot);
804 0 2 RETVAL = (IV)pool_cmpxchg_i32(h, slot, (int32_t)expected, (int32_t)desired);
814 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
816 0 1 CHECK_SLOT(h, slot);
817 0 1 CHECK_ALLOCATED(h, slot);
818 0 1 RETVAL = (IV)pool_xchg_i32(h, slot, (int32_t)val);
828 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
830 0 2 CHECK_SLOT(h, slot);
831 0 2 CHECK_ALLOCATED(h, slot);
832 0 2 RETVAL = (IV)pool_add_i32(h, slot, (int32_t)delta);
841 0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
843 0 0 CHECK_SLOT(h, slot);
844 0 0 CHECK_ALLOCATED(h, slot);
845 0 0 RETVAL = (IV)pool_add_i32(h, slot, 1);
854 0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
856 0 0 CHECK_SLOT(h, slot);
857 0 0 CHECK_ALLOCATED(h, slot);
858 0 0 RETVAL = (IV)pool_add_i32(h, slot, -1);
876 0 4 if (max_len == 0) croak("Data::Pool::Shared::Str->new: max_len must be > 0");
877 0 4 if (max_len > (UV)(UINT32_MAX - sizeof(uint32_t)))
880 2 2 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
882 0 4 if (!h) croak("Data::Pool::Shared::Str->new: %s", errbuf);
896 0 1 if (max_len == 0) croak("Data::Pool::Shared::Str->new_memfd: max_len must be > 0");
897 0 1 if (max_len > (UV)(UINT32_MAX - sizeof(uint32_t)))
901 0 1 if (!h) croak("Data::Pool::Shared::Str->new_memfd: %s", errbuf);
914 0 1 if (!h) croak("Data::Pool::Shared::Str->new_from_fd: %s", errbuf);
924 11 0 EXTRACT_POOL(self);
0 11 EXTRACT_POOL(self);
0 11 EXTRACT_POOL(self);
926 0 11 CHECK_SLOT(h, slot);
927 0 11 CHECK_ALLOCATED(h, slot);
939 8 0 EXTRACT_POOL(self);
0 8 EXTRACT_POOL(self);
0 8 EXTRACT_POOL(self);
941 0 8 CHECK_SLOT(h, slot);
942 0 8 CHECK_ALLOCATED(h, slot);
951 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
953 0 1 RETVAL = h->hdr->elem_size - sizeof(uint32_t);