xs/abi.xs

filter: Statementstmt 100% 24 / 24 Branchbran 60.0% 18 / 30 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 77.7% 42 / 54 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« Hyperman.c ↑ Summary xs/bus.xs »
1 MODULE = Hyperman PACKAGE = Hyperman
2  
3 # Public C ABI entry point (hm_abi.h / hm_abi_impl.h): a DBI-style versioned
4 # function-pointer table for XS consumers (DBIx::Loop, ...). Resolved at
5 # runtime - call_pv("Hyperman::_abi_ptr"), INT2PTR, check abi_version.
6  
7 IV
8 _abi_ptr()
9 CODE:
10 2 ▶ RETVAL = PTR2IV(&hm_abi_table);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = PTR2IV(&hm_abi_table); 0 2 2
11 OUTPUT:
12 RETVAL
13  
14 # Resolve and exercise the whole table from C: future lifecycle (done, fail,
15 # on_ready, double-settle no-op), a C io watcher on a pipe, a cancelled timer,
16 # and a live timer, all pumped with run_until. 1 = every check passed.
17 IV
18 _abi_selftest()
19 CODE:
20 1 ▶ RETVAL = hm_abi_selftest(aTHX);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = hm_abi_selftest(aTHX); 0 1 1
21 OUTPUT:
22 RETVAL
23  
24 # The table's version, for tests and for a consumer that would rather ask
25 # than dereference the pointer itself.
26 IV
27 _abi_version()
28 CODE:
29 1 ▶ RETVAL = hm_abi_table.abi_version;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = hm_abi_table.abi_version; 0 1 1
30 OUTPUT:
31 RETVAL
32  
33 # v4 on_worker_start, for t/33-worker-start.t. Registering a C callback is not
34 # something Perl can do, so the test drives these two instead: install before
35 # run(), then have the application report the count from inside a worker.
36 IV
37 _abi_worker_hook_install()
38 CODE:
39 3 ▶ RETVAL = hm_abi_worker_hook_install(aTHX);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = hm_abi_worker_hook_install(aTHX); 0 3 3
40 OUTPUT:
41 RETVAL
42  
43 # How many times the hook fired IN THIS PROCESS, and whether it was handed a
44 # real loop every time (0 = it was not, which is a failure).
45 void
46 _abi_worker_hook_state()
47 PPCODE:
48 15 ▶ EXTEND(SP, 2);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 2); 0 15 15
49 15 mPUSHi(HM_ABI_ST_WORKER_N);
50 15 mPUSHi(HM_ABI_ST_WORKER_LOOP_OK);
51  
52 # v6 stream handles, for t/41-stream-abi.t. Everything below goes through the
53 # function-pointer table rather than calling hm_stream.h directly - a selftest
54 # that skipped the table would prove the implementation and not the ABI. An
55 # application drives these from inside a request; the transport is whatever
56 # that request arrived on, and none of it is named here, which is the point.
57  
58 IV
59 _abi_stream_open(env, status = 200, headers = NULL)
60 SV *env
61 int status
62 SV *headers
63 CODE:
64 14 ▶ # uncoverable branch true class:ignore_covered_err
Branch: 2 branches
BranchTrueFalseTotal
# uncoverable branch true class:ignore_covered_err 14 0 14
# uncoverable branch true class:ignore_covered_err 0 14 14
65 14 ▶ # uncoverable condition left count:1 class:ignore_covered_err
Branch: 1 branch
BranchTrueFalseTotal
# uncoverable condition left count:1 class:ignore_covered_err 0 14 14
66 # uncoverable condition right count:1 class:ignore_covered_err
67 # uncoverable condition left count:2 class:ignore_covered_err
68 if (headers && !SvOK(headers)) headers = NULL;
69 RETVAL = hm_abi_st_stream_open(aTHX_ env, status, headers);
70 OUTPUT:
71 RETVAL
72  
73 IV
74 _abi_stream_write(data)
75 SV *data
76 CODE:
77 18 ▶ RETVAL = hm_abi_st_stream_write(aTHX_ data);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = hm_abi_st_stream_write(aTHX_ data); 4 14 18
78 OUTPUT:
79 RETVAL
80  
81 IV
82 _abi_stream_close()
83 CODE:
84 12 ▶ RETVAL = hm_abi_st_stream_close(aTHX);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = hm_abi_st_stream_close(aTHX); 5 7 12
85 OUTPUT:
86 RETVAL
87  
88 # v7: the other ending. Stops the body so the peer can tell it was not
89 # finished - RST_STREAM on h2, a connection reset on HTTP/1.1 - and releases
90 # the handle the same way close does.
91 IV
92 _abi_stream_abort()
93 CODE:
94 1 ▶ RETVAL = hm_abi_st_stream_do_abort(aTHX);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = hm_abi_st_stream_do_abort(aTHX); 0 1 1
95 OUTPUT:
96 RETVAL
97  
98 # v8: register the read half on the open stream handle, so bytes the peer
99 # sends arrive by callback instead of being buffered into psgi.input.
100 IV
101 _abi_stream_read()
102 CODE:
103 9 ▶ RETVAL = hm_abi_st_stream_read(aTHX);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = hm_abi_st_stream_read(aTHX); 0 9 9
104 OUTPUT:
105 RETVAL
106  
107 # What the read half has been handed: (calls, bytes, the bytes themselves).
108 void
109 _abi_stream_rx()
110 PPCODE:
111 9 ▶ EXTEND(SP, 3);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 3); 0 9 9
112 9 mPUSHi(HM_ABI_ST_SH_RXN);
113 9 mPUSHi(HM_ABI_ST_SH_RXLEN);
114 9 mPUSHp(HM_ABI_ST_SH_RX, (STRLEN)HM_ABI_ST_SH_RXLEN);
115  
116 # Owe the open stream n chunks of 4KiB and produce them, pausing whenever the
117 # connection says it is full and resuming from the drain callback. The stream
118 # closes itself when the last chunk is out, so the caller returns immediately
119 # and the body finishes on the loop.
120 void
121 _abi_stream_produce(n)
122 IV n
123 CODE:
124 1 hm_abi_st_stream_produce(aTHX_ n);
125  
126 # open?, aborts, drains, accepted writes, times the connection said full -
127 # read back by a LATER request, which is the only way a Perl test can see a
128 # callback that fired in C.
129 void
130 _abi_stream_state()
131 PPCODE:
132 7 ▶ EXTEND(SP, 5);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 5); 0 7 7
133 7 ▶ mPUSHi(HM_ABI_ST_SH ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
mPUSHi(HM_ABI_ST_SH ? 1 : 0); 2 5 7
134 7 mPUSHi(HM_ABI_ST_SH_ABORTS);
135 7 mPUSHi(HM_ABI_ST_SH_DRAINS);
136 7 mPUSHi(HM_ABI_ST_SH_WRITES);
137 7 mPUSHi(HM_ABI_ST_SH_FULLS);
« Hyperman.c ↑ Summary xs/bus.xs »