HAMT.xs

filter: Statementstmt 96.6% 29 / 30 Branchbran 60.0% 12 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 82.0% 41 / 50 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/hamt/hamt_check.h ↑ Summary include/hamt/hamt_abi_impl.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 29 static uint64_t hamt_boot_seed(pTHX) {
30 static const char salt[] = "HAMT::seed";
31 U32 ph;
32 uint64_t s;
33 29 PERL_HASH(ph, salt, sizeof(salt) - 1);
34 29 s = (uint64_t)ph * HAMT_M1;
35 29 s ^= (uint64_t)PTR2UV(&ph) * HAMT_M2;
36 29 s ^= (uint64_t)PerlProc_getpid() << 32;
37 29 s ^= (uint64_t)time(NULL) * HAMT_M3;
38 29 s ^= s >> 29;
39 29 return s;
40 }
41  
42 #ifndef HAMT_NO_POOL
43 29 static void hamt_pool_atexit(pTHX_ void *arg) {
44 PERL_UNUSED_ARG(arg);
45 29 ▶ 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); 29 0 29
46 29 }
47 #endif
48  
49 /* The first interpreter to load the library has the pool. */
50 29 static void hamt_pool_boot(pTHX) {
51 #ifndef HAMT_NO_POOL
52 29 ▶ if (hamt_pool_one.open) return;
Branch: 1 branch
BranchTrueFalseTotal
if (hamt_pool_one.open) return; 0 29 29
53 29 hamt_pool_open(&hamt_pool_one);
54 29 hamt_pool_owner = HAMT_CX;
55 29 Perl_call_atexit(aTHX_ hamt_pool_atexit, NULL);
56 #else
57 PERL_UNUSED_CONTEXT;
58 #endif
59 }
60  
61 MODULE = HAMT PACKAGE = HAMT
62  
63 PROTOTYPES: DISABLE
64  
65 BOOT:
66 29 hamt_seed = hamt_boot_seed(aTHX);
67 29 hamt_pool_boot(aTHX);
68  
69 # The warning filter a walk puts in $SIG{__WARN__}: see hamt_xs_walk_enter.
70 void
71 _warn_filter(...)
72 PREINIT:
73 SV *msg, *prev;
74 STRLEN len;
75 const char *p;
76 PPCODE:
77 373 ▶ msg = items ? ST(0) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
msg = items ? ST(0) : &PL_sv_undef; 373 0 373
78 373 ▶ if (!SvROK(msg)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvROK(msg)) { 373 0 373
79 373 p = SvPV(msg, len);
80 373 ▶ 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 1 373
if (len >= 17 && memEQ(p, "Exiting eval via ", 17)) XSRETURN_EMPTY; 186 186 372
81 }
82 187 prev = get_sv("HAMT::_warn_prev", 0);
83 187 ▶ if (prev && SvOK(prev)) {
Branch: 2 branches
BranchTrueFalseTotal
if (prev && SvOK(prev)) { 187 0 187
if (prev && SvOK(prev)) { 187 0 187
84 187 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 187 187
85 187 ▶ XPUSHs(msg);
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(msg); 0 187 187
86 187 PUTBACK;
87 187 call_sv(prev, G_DISCARD);
88 }
89 else {
90 0 Perl_warn(aTHX_ "%" SVf, SVfARG(msg));
91 }
92 187 XSRETURN_EMPTY;
93  
94 INCLUDE: xs/map.xs
95 INCLUDE: xs/map_transient.xs
96 INCLUDE: xs/set.xs
97 INCLUDE: xs/set_transient.xs
98 INCLUDE: xs/vector.xs
99 INCLUDE: xs/vector_transient.xs
100 INCLUDE: xs/test.xs
101 INCLUDE: xs/abi.xs
102 INCLUDE: xs/ops.xs
« include/hamt/hamt_check.h ↑ Summary include/hamt/hamt_abi_impl.h »