Branch Coverage

Shared.xs
Criterion Covered Total %
branch 314 564 55.6


line true false branch
13 4 0 if (mg->mg_obj) SvREFCNT_dec(mg->mg_obj);
56 1 10 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
58 0 11 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 58 if (!SvROK(self)) return;
97 0 58 if (!h) return;
105 919 0 EXTRACT_POOL(self);
0 919 EXTRACT_POOL(self);
0 919 EXTRACT_POOL(self);
108 11 908 if (items > 1) timeout = SvNV(ST(1));
110 917 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 38 0 EXTRACT_POOL(self);
0 38 EXTRACT_POOL(self);
0 38 EXTRACT_POOL(self);
206 14 24 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 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
238 0 3 RETVAL = pool_recover_stale(h);
246 10 0 EXTRACT_POOL(self);
0 10 EXTRACT_POOL(self);
0 10 EXTRACT_POOL(self);
255 8 0 EXTRACT_POOL(self);
0 8 EXTRACT_POOL(self);
0 8 EXTRACT_POOL(self);
263 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
265 1 2 RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
273 5 0 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
275 0 5 RETVAL = h->backing_fd;
283 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
286 0 3 if (RETVAL < 0) croak("eventfd: %s", strerror(errno));
295 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
297 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);
304 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
306 0 6 RETVAL = h->notify_fd;
314 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
316 4 0 RETVAL = pool_notify(h);
324 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
327 3 1 RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef;
335 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
337 0 1 if (pool_msync(h) != 0) croak("msync: %s", strerror(errno));
344 2 1 if (sv_isobject(self_or_class)) {
346 0 2 if (!h) croak("Attempted to use a destroyed object");
349 0 1 if (items < 2) croak("Usage: ...->unlink($path)");
352 1 2 if (!p) croak("cannot unlink anonymous or memfd object");
353 0 2 if (unlink(p) != 0)
360 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
386 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
389 1 2 if (items > 2) timeout = SvNV(ST(2));
390 1 2 if (count == 0) {
394 0 2 Newx(buf, count, uint64_t);
396 1 1 if (pool_alloc_n(h, buf, (uint32_t)count, timeout)) {
399 3 1 for (UV i = 0; i < count; i++)
414 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
416 5 1 if (!SvROK(slots_av) || SvTYPE(SvRV(slots_av)) != SVt_PVAV)
0 5 if (!SvROK(slots_av) || SvTYPE(SvRV(slots_av)) != SVt_PVAV)
419 0 5 SSize_t len = av_top_index(av) + 1;
420 1 4 if (len <= 0) {
424 0 4 Newx(buf, len, uint64_t);
426 9 2 for (SSize_t i = 0; i < len; i++) {
428 9 0 if (!svp || !SvOK(*svp))
2 7 if (!svp || !SvOK(*svp))
441 7 0 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
446 8 7 for (uint32_t widx = 0; widx < nwords; widx++) {
448 29 8 while (word) {
451 29 0 if (slot < cap)
465 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
467 1 2 CHECK_SLOT(h, slot);
468 1 1 CHECK_ALLOCATED(h, slot);
469 0 1 RETVAL = PTR2UV(pool_slot_ptr(h, slot));
477 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
479 0 1 RETVAL = PTR2UV(h->data);
488 5 0 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
490 0 5 CHECK_SLOT(h, slot);
491 1 4 CHECK_ALLOCATED(h, slot);
518 9 18 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
520 0 27 if (!h) croak("Data::Pool::Shared::I64->new: %s", errbuf);
534 0 2 if (!h) croak("Data::Pool::Shared::I64->new_memfd: %s", errbuf);
547 0 1 if (!h) croak("Data::Pool::Shared::I64->new_from_fd: %s", errbuf);
557 64 0 EXTRACT_POOL(self);
0 64 EXTRACT_POOL(self);
0 64 EXTRACT_POOL(self);
559 1 63 CHECK_SLOT(h, slot);
560 1 62 CHECK_ALLOCATED(h, slot);
571 615 0 EXTRACT_POOL(self);
0 615 EXTRACT_POOL(self);
0 615 EXTRACT_POOL(self);
573 1 614 CHECK_SLOT(h, slot);
574 1 613 CHECK_ALLOCATED(h, slot);
584 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
586 0 4 CHECK_SLOT(h, slot);
587 1 3 CHECK_ALLOCATED(h, slot);
588 2 1 RETVAL = pool_cas_i64(h, slot, (int64_t)expected, (int64_t)desired);
599 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
601 0 2 CHECK_SLOT(h, slot);
602 0 2 CHECK_ALLOCATED(h, slot);
613 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
615 0 1 CHECK_SLOT(h, slot);
616 0 1 CHECK_ALLOCATED(h, slot);
627 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
629 0 3 CHECK_SLOT(h, slot);
630 1 2 CHECK_ALLOCATED(h, slot);
640 4 0 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
0 4 EXTRACT_POOL(self);
642 0 4 CHECK_SLOT(h, slot);
643 1 3 CHECK_ALLOCATED(h, slot);
653 3 0 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
0 3 EXTRACT_POOL(self);
655 0 3 CHECK_SLOT(h, slot);
656 1 2 CHECK_ALLOCATED(h, slot);
674 0 2 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
676 0 2 if (!h) croak("Data::Pool::Shared::F64->new: %s", errbuf);
690 0 1 if (!h) croak("Data::Pool::Shared::F64->new_memfd: %s", errbuf);
703 0 1 if (!h) croak("Data::Pool::Shared::F64->new_from_fd: %s", errbuf);
713 7 0 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
715 0 7 CHECK_SLOT(h, slot);
716 0 7 CHECK_ALLOCATED(h, slot);
727 7 0 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
0 7 EXTRACT_POOL(self);
729 0 7 CHECK_SLOT(h, slot);
730 0 7 CHECK_ALLOCATED(h, slot);
746 0 3 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
748 0 3 if (!h) croak("Data::Pool::Shared::I32->new: %s", errbuf);
762 0 1 if (!h) croak("Data::Pool::Shared::I32->new_memfd: %s", errbuf);
775 0 1 if (!h) croak("Data::Pool::Shared::I32->new_from_fd: %s", errbuf);
785 5 0 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
0 5 EXTRACT_POOL(self);
787 0 5 CHECK_SLOT(h, slot);
788 0 5 CHECK_ALLOCATED(h, slot);
789 0 5 RETVAL = (IV)pool_get_i32(h, slot);
799 6 0 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
0 6 EXTRACT_POOL(self);
801 0 6 CHECK_SLOT(h, slot);
802 0 6 CHECK_ALLOCATED(h, slot);
812 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
814 0 1 CHECK_SLOT(h, slot);
815 0 1 CHECK_ALLOCATED(h, slot);
816 1 0 RETVAL = pool_cas_i32(h, slot, (int32_t)expected, (int32_t)desired);
827 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
829 0 2 CHECK_SLOT(h, slot);
830 0 2 CHECK_ALLOCATED(h, slot);
831 0 2 RETVAL = (IV)pool_cmpxchg_i32(h, slot, (int32_t)expected, (int32_t)desired);
841 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
843 0 1 CHECK_SLOT(h, slot);
844 0 1 CHECK_ALLOCATED(h, slot);
845 0 1 RETVAL = (IV)pool_xchg_i32(h, slot, (int32_t)val);
855 2 0 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
0 2 EXTRACT_POOL(self);
857 0 2 CHECK_SLOT(h, slot);
858 0 2 CHECK_ALLOCATED(h, slot);
859 0 2 RETVAL = (IV)pool_add_i32(h, slot, (int32_t)delta);
868 0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
870 0 0 CHECK_SLOT(h, slot);
871 0 0 CHECK_ALLOCATED(h, slot);
872 0 0 RETVAL = (IV)pool_add_i32(h, slot, 1);
881 0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
0 0 EXTRACT_POOL(self);
883 0 0 CHECK_SLOT(h, slot);
884 0 0 CHECK_ALLOCATED(h, slot);
885 0 0 RETVAL = (IV)pool_add_i32(h, slot, -1);
903 0 4 if (max_len == 0) croak("Data::Pool::Shared::Str->new: max_len must be > 0");
904 0 4 if (max_len > (UV)(UINT32_MAX - sizeof(uint32_t)))
907 2 2 const char *p = SvOK(path) ? SvPV_nolen(path) : NULL;
909 0 4 if (!h) croak("Data::Pool::Shared::Str->new: %s", errbuf);
923 0 1 if (max_len == 0) croak("Data::Pool::Shared::Str->new_memfd: max_len must be > 0");
924 0 1 if (max_len > (UV)(UINT32_MAX - sizeof(uint32_t)))
928 0 1 if (!h) croak("Data::Pool::Shared::Str->new_memfd: %s", errbuf);
941 0 1 if (!h) croak("Data::Pool::Shared::Str->new_from_fd: %s", errbuf);
951 11 0 EXTRACT_POOL(self);
0 11 EXTRACT_POOL(self);
0 11 EXTRACT_POOL(self);
953 0 11 CHECK_SLOT(h, slot);
954 0 11 CHECK_ALLOCATED(h, slot);
966 8 0 EXTRACT_POOL(self);
0 8 EXTRACT_POOL(self);
0 8 EXTRACT_POOL(self);
968 0 8 CHECK_SLOT(h, slot);
969 0 8 CHECK_ALLOCATED(h, slot);
978 1 0 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
0 1 EXTRACT_POOL(self);
980 0 1 RETVAL = h->hdr->elem_size - sizeof(uint32_t);