Branch Coverage

Shared.xs
Criterion Covered Total %
branch 311 558 55.7


line true false branch
13 4 0 if (mg->mg_obj) SvREFCNT_dec(mg->mg_obj);
56 1 4 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
58 0 5 if (!h) croak("Data::Pool::Shared->new: %s", errbuf);
73 0 1 if (!h) croak("Data::Pool::Shared->new_memfd: %s", errbuf);
86 0 1 if (!h) croak("Data::Pool::Shared->new_from_fd: %s", errbuf);
95 0 49 if (!SvROK(self)) return;
97 0 49 if (!h) return;
105 908 0 EXTRACT_POOL(self);
0 908 EXTRACT_POOL(self);
0 908 EXTRACT_POOL(self);
108 11 897 if (items > 1) timeout = SvNV(ST(1));
110 906 2 RETVAL = (slot >= 0) ? newSViv((IV)slot) : &PL_sv_undef;
118 17 0 EXTRACT_POOL(self);
0 17 EXTRACT_POOL(self);
0 17 EXTRACT_POOL(self);
121 6 11 RETVAL = (slot >= 0) ? newSViv((IV)slot) : &PL_sv_undef;
130 692 0 EXTRACT_POOL(self);
0 692 EXTRACT_POOL(self);
0 692 EXTRACT_POOL(self);
132 1 691 CHECK_SLOT(h, slot);
133 689 2 RETVAL = pool_free_slot(h, slot);
142 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
144 1 3 CHECK_SLOT(h, slot);
145 1 2 CHECK_ALLOCATED(h, slot);
156 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
158 1 5 CHECK_SLOT(h, slot);
159 0 5 CHECK_ALLOCATED(h, slot);
162 0 5 if (len > h->hdr->elem_size)
165 1 4 if (len < h->hdr->elem_size)
173 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
175 1 5 CHECK_SLOT(h, slot);
176 3 2 RETVAL = pool_is_allocated(h, slot);
184 11 0 EXTRACT_POOL(self);
0 11 EXTRACT_POOL(self);
0 11 EXTRACT_POOL(self);
186 7 4 RETVAL = (UV)h->hdr->capacity;
194 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
196 0 3 RETVAL = h->hdr->elem_size;
204 36 0 EXTRACT_POOL(self);
0 36 EXTRACT_POOL(self);
0 36 EXTRACT_POOL(self);
206 14 22 RETVAL = __atomic_load_n(&h->hdr->used, __ATOMIC_RELAXED);
214 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
216 0 2 RETVAL = (UV)h->hdr->capacity - __atomic_load_n(&h->hdr->used, __ATOMIC_RELAXED);
225 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
227 1 1 CHECK_SLOT(h, slot);
228 0 1 RETVAL = __atomic_load_n(&h->owners[slot], __ATOMIC_RELAXED);
236 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
238 0 2 RETVAL = pool_recover_stale(h);
246 10 0 EXTRACT_POOL(self);
0 10 EXTRACT_POOL(self);
0 10 EXTRACT_POOL(self);
254 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
256 1 2 RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
264 5 0 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
266 0 5 RETVAL = h->backing_fd;
274 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
277 0 3 if (RETVAL < 0) croak("eventfd: %s", strerror(errno));
286 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
288 3 0 if (h->notify_fd >= 0 && h->notify_fd != fd) close(h->notify_fd);
2 1 if (h->notify_fd >= 0 && h->notify_fd != fd) close(h->notify_fd);
295 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
297 0 6 RETVAL = h->notify_fd;
305 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
307 4 0 RETVAL = pool_notify(h);
315 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
318 3 1 RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef;
326 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
328 0 1 if (pool_msync(h) != 0) croak("msync: %s", strerror(errno));
335 2 1 if (sv_isobject(self_or_class)) {
337 0 2 if (!h) croak("Attempted to use a destroyed object");
340 0 1 if (items < 2) croak("Usage: ...->unlink($path)");
343 1 2 if (!p) croak("cannot unlink anonymous or memfd object");
344 0 2 if (unlink(p) != 0)
351 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
377 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
380 1 2 if (items > 2) timeout = SvNV(ST(2));
381 1 2 if (count == 0) {
385 0 2 Newx(buf, count, uint64_t);
386 1 1 if (pool_alloc_n(h, buf, (uint32_t)count, timeout)) {
389 3 1 for (UV i = 0; i < count; i++)
405 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
407 5 1 if (!SvROK(slots_av) || SvTYPE(SvRV(slots_av)) != SVt_PVAV)
0 5 if (!SvROK(slots_av) || SvTYPE(SvRV(slots_av)) != SVt_PVAV)
410 0 5 SSize_t len = av_top_index(av) + 1;
411 1 4 if (len <= 0) {
415 0 4 Newx(buf, len, uint64_t);
416 9 2 for (SSize_t i = 0; i < len; i++) {
418 9 0 if (!svp || !SvOK(*svp)) {
2 7 if (!svp || !SvOK(*svp)) {
434 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
439 7 6 for (uint32_t widx = 0; widx < nwords; widx++) {
441 29 7 while (word) {
444 29 0 if (slot < cap)
458 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
460 1 2 CHECK_SLOT(h, slot);
461 1 1 CHECK_ALLOCATED(h, slot);
462 0 1 RETVAL = PTR2UV(pool_slot_ptr(h, slot));
470 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
472 0 1 RETVAL = PTR2UV(h->data);
481 5 0 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
483 0 5 CHECK_SLOT(h, slot);
484 1 4 CHECK_ALLOCATED(h, slot);
511 8 16 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
513 0 24 if (!h) croak("Data::Pool::Shared::I64->new: %s", errbuf);
527 0 2 if (!h) croak("Data::Pool::Shared::I64->new_memfd: %s", errbuf);
540 0 1 if (!h) croak("Data::Pool::Shared::I64->new_from_fd: %s", errbuf);
550 64 0 EXTRACT_POOL(self);
0 64 EXTRACT_POOL(self);
0 64 EXTRACT_POOL(self);
552 1 63 CHECK_SLOT(h, slot);
553 1 62 CHECK_ALLOCATED(h, slot);
564 615 0 EXTRACT_POOL(self);
0 615 EXTRACT_POOL(self);
0 615 EXTRACT_POOL(self);
566 1 614 CHECK_SLOT(h, slot);
567 1 613 CHECK_ALLOCATED(h, slot);
577 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
579 0 4 CHECK_SLOT(h, slot);
580 1 3 CHECK_ALLOCATED(h, slot);
581 2 1 RETVAL = pool_cas_i64(h, slot, (int64_t)expected, (int64_t)desired);
592 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
594 0 2 CHECK_SLOT(h, slot);
595 0 2 CHECK_ALLOCATED(h, slot);
606 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
608 0 1 CHECK_SLOT(h, slot);
609 0 1 CHECK_ALLOCATED(h, slot);
620 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
622 0 3 CHECK_SLOT(h, slot);
623 1 2 CHECK_ALLOCATED(h, slot);
633 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
635 0 4 CHECK_SLOT(h, slot);
636 1 3 CHECK_ALLOCATED(h, slot);
646 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
648 0 3 CHECK_SLOT(h, slot);
649 1 2 CHECK_ALLOCATED(h, slot);
667 0 2 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
669 0 2 if (!h) croak("Data::Pool::Shared::F64->new: %s", errbuf);
683 0 1 if (!h) croak("Data::Pool::Shared::F64->new_memfd: %s", errbuf);
696 0 1 if (!h) croak("Data::Pool::Shared::F64->new_from_fd: %s", errbuf);
706 7 0 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
708 0 7 CHECK_SLOT(h, slot);
709 0 7 CHECK_ALLOCATED(h, slot);
720 7 0 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
722 0 7 CHECK_SLOT(h, slot);
723 0 7 CHECK_ALLOCATED(h, slot);
739 0 3 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
741 0 3 if (!h) croak("Data::Pool::Shared::I32->new: %s", errbuf);
755 0 1 if (!h) croak("Data::Pool::Shared::I32->new_memfd: %s", errbuf);
768 0 1 if (!h) croak("Data::Pool::Shared::I32->new_from_fd: %s", errbuf);
778 5 0 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
780 0 5 CHECK_SLOT(h, slot);
781 0 5 CHECK_ALLOCATED(h, slot);
782 0 5 RETVAL = (IV)pool_get_i32(h, slot);
792 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
794 0 6 CHECK_SLOT(h, slot);
795 0 6 CHECK_ALLOCATED(h, slot);
805 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
807 0 1 CHECK_SLOT(h, slot);
808 0 1 CHECK_ALLOCATED(h, slot);
809 1 0 RETVAL = pool_cas_i32(h, slot, (int32_t)expected, (int32_t)desired);
820 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
822 0 2 CHECK_SLOT(h, slot);
823 0 2 CHECK_ALLOCATED(h, slot);
824 0 2 RETVAL = (IV)pool_cmpxchg_i32(h, slot, (int32_t)expected, (int32_t)desired);
834 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
836 0 1 CHECK_SLOT(h, slot);
837 0 1 CHECK_ALLOCATED(h, slot);
838 0 1 RETVAL = (IV)pool_xchg_i32(h, slot, (int32_t)val);
848 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
850 0 2 CHECK_SLOT(h, slot);
851 0 2 CHECK_ALLOCATED(h, slot);
852 0 2 RETVAL = (IV)pool_add_i32(h, slot, (int32_t)delta);
861 0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
863 0 0 CHECK_SLOT(h, slot);
864 0 0 CHECK_ALLOCATED(h, slot);
865 0 0 RETVAL = (IV)pool_add_i32(h, slot, 1);
874 0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
876 0 0 CHECK_SLOT(h, slot);
877 0 0 CHECK_ALLOCATED(h, slot);
878 0 0 RETVAL = (IV)pool_add_i32(h, slot, -1);
896 0 4 if (max_len == 0) croak("Data::Pool::Shared::Str->new: max_len must be > 0");
897 0 4 if (max_len > (UV)(UINT32_MAX - sizeof(uint32_t)))
900 2 2 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
902 0 4 if (!h) croak("Data::Pool::Shared::Str->new: %s", errbuf);
916 0 1 if (max_len == 0) croak("Data::Pool::Shared::Str->new_memfd: max_len must be > 0");
917 0 1 if (max_len > (UV)(UINT32_MAX - sizeof(uint32_t)))
921 0 1 if (!h) croak("Data::Pool::Shared::Str->new_memfd: %s", errbuf);
934 0 1 if (!h) croak("Data::Pool::Shared::Str->new_from_fd: %s", errbuf);
944 11 0 EXTRACT_POOL(self);
0 11 EXTRACT_POOL(self);
0 11 EXTRACT_POOL(self);
946 0 11 CHECK_SLOT(h, slot);
947 0 11 CHECK_ALLOCATED(h, slot);
959 8 0 EXTRACT_POOL(self);
0 8 EXTRACT_POOL(self);
0 8 EXTRACT_POOL(self);
961 0 8 CHECK_SLOT(h, slot);
962 0 8 CHECK_ALLOCATED(h, slot);
971 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
973 0 1 RETVAL = h->hdr->elem_size - sizeof(uint32_t);