HAMT.xs

filter: Statementstmt 100% 30 / 30 Branchbran 75.0% 14 / 20 (1 uncoverable) Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 90.0% 44 / 50 (1 uncoverable) CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/abi.xs ↑ Summary include/hamt/hamt_pool.h »
1 #define PERL_NO_GET_CONTEXT
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5  
6 #include "hamt/hamt_sv.h"
7 #include "hamt/hamt_compat.h"
8 #include "hamt/hamt_val.h"
9 #include "hamt/hamt_alloc.h"
10 #include "hamt/hamt_hash.h"
11 #include "hamt/hamt_entry.h"
12 #include "hamt/hamt_node.h"
13 #include "hamt/hamt_map.h"
14 #include "hamt/hamt_mut.h"
15 #include "hamt/hamt_iter.h"
16 #include "hamt/hamt_algebra.h"
17 #include "hamt/hamt_vec.h"
18 #include "hamt/hamt_check.h"
19 #include "hamt/hamt_xs.h"
20 #include "hamt/hamt_ops.h"
21  
22 #include "hamt_abi.h"
23 #include "hamt/hamt_abi_impl.h"
24 #include "hamt/hamt_abi_selftest.h"
25  
26 /* A seed nobody outside the process can compute. perl's own hash of a fixed
27 * string carries perl's per-process seed where it has one; the address of a
28 * local and the clock cover a perl built without. */
29 32 static uint64_t hamt_boot_seed(pTHX) {
30 static const char salt[] = "HAMT::seed";
31 U32 ph;
32 uint64_t s;
33 32 PERL_HASH(ph, salt, sizeof(salt) - 1);
34 32 s = (uint64_t)ph * HAMT_M1;
35 32 s ^= (uint64_t)PTR2UV(&ph) * HAMT_M2;
36 32 s ^= (uint64_t)PerlProc_getpid() << 32;
37 32 s ^= (uint64_t)time(NULL) * HAMT_M3;
38 32 s ^= s >> 29;
39 32 return s;
40 }
41  
42 #ifndef HAMT_NO_POOL
43 32 static void hamt_pool_atexit(pTHX_ void *arg) {
44 PERL_UNUSED_ARG(arg);
45 32 ▶ if (hamt_pool_owner == HAMT_CX) hamt_pool_close(&hamt_pool_one);
Branch: 1 branch
BranchTrueFalseTotal
if (hamt_pool_owner == HAMT_CX) hamt_pool_close(&hamt_pool_one); 32 0 32
46 32 }
47 #endif
48  
49 /* The first interpreter to load the library has the pool. */
50 32 static void hamt_pool_boot(pTHX) {
51 #ifndef HAMT_NO_POOL
52 /*
53 # uncoverable branch true
54 # uncoverable condition left count:1 */
55 32 ▶ if (hamt_pool_one.open) return;
Branch: 1 branch
BranchTrueFalseTotal
if (hamt_pool_one.open) return; 0 32 32
56 32 hamt_pool_open(&hamt_pool_one);
57 32 hamt_pool_owner = HAMT_CX;
58 32 Perl_call_atexit(aTHX_ hamt_pool_atexit, NULL);
59 #else
60 PERL_UNUSED_CONTEXT;
61 #endif
62 }
63  
64 MODULE = HAMT PACKAGE = HAMT
65  
66 PROTOTYPES: DISABLE
67  
68 BOOT:
69 32 hamt_seed = hamt_boot_seed(aTHX);
70 32 hamt_pool_boot(aTHX);
71  
72 # The warning filter a walk puts in $SIG{__WARN__}: see hamt_xs_walk_enter.
73 void
74 _warn_filter(...)
75 PREINIT:
76 SV *msg, *prev;
77 STRLEN len;
78 const char *p;
79 PPCODE:
80 376 ▶ msg = items ? ST(0) : &PL_sv_undef; /* # uncoverable condition right count:1 */
Branch: 1 branch
BranchTrueFalseTotal
msg = items ? ST(0) : &PL_sv_undef; /* # uncoverable condition right count:1 */ 376 0 376
81 376 ▶ if (!SvROK(msg)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvROK(msg)) { 374 2 376
82 374 p = SvPV(msg, len);
83 374 ▶ if (len >= 17 && memEQ(p, "Exiting eval via ", 17)) XSRETURN_EMPTY;
Branch: 2 branches
BranchTrueFalseTotal
if (len >= 17 && memEQ(p, "Exiting eval via ", 17)) XSRETURN_EMPTY; 372 2 374
if (len >= 17 && memEQ(p, "Exiting eval via ", 17)) XSRETURN_EMPTY; 186 186 372
84 }
85 190 prev = get_sv("HAMT::_warn_prev", 0);
86 190 ▶ if (prev && SvOK(prev)) { /* # uncoverable condition right count:1 */
Branch: 2 branches
BranchTrueFalseTotal
if (prev && SvOK(prev)) { /* # uncoverable condition right count:1 */ 190 0 190
if (prev && SvOK(prev)) { /* # uncoverable condition right count:1 */ 188 2 190
87 188 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 188 188
88 188 ▶ XPUSHs(msg);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(msg); 0 188 188
89 188 PUTBACK;
90 188 call_sv(prev, G_DISCARD);
91 }
92 else {
93 2 Perl_warn(aTHX_ "%" SVf, SVfARG(msg));
94 }
95 190 XSRETURN_EMPTY;
96  
97 INCLUDE: xs/map.xs
98 INCLUDE: xs/map_transient.xs
99 INCLUDE: xs/set.xs
100 INCLUDE: xs/set_transient.xs
101 INCLUDE: xs/vector.xs
102 INCLUDE: xs/vector_transient.xs
103 INCLUDE: xs/test.xs
104 INCLUDE: xs/abi.xs
105 INCLUDE: xs/ops.xs
« xs/abi.xs ↑ Summary include/hamt/hamt_pool.h »