xs/abi.xs

filter: Statementstmt 96.0% 24 / 25 Branchbran 56.2% 18 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 73.6% 42 / 57 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/hyperman/hm_sa.h ↑ Summary Hyperman.c »
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 # v10: end the open stream handle with trailer fields, through the table.
89 # Returns what stream_close_trailers returned: 0 ok, -2 gone, -3 the list
90 # was refused and the handle is still open for a later close or abort.
91 IV
92 _abi_stream_close_trailers(trailers = &PL_sv_undef)
93 SV *trailers
94 CODE:
95 0 ▶ RETVAL = hm_abi_st_stream_close_trailers(aTHX_ trailers);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = hm_abi_st_stream_close_trailers(aTHX_ trailers); 0 0 0
96 OUTPUT:
97 RETVAL
98  
99 # v7: the other ending. Stops the body so the peer can tell it was not
100 # finished - RST_STREAM on h2, a connection reset on HTTP/1.1 - and releases
101 # the handle the same way close does.
102 IV
103 _abi_stream_abort()
104 CODE:
105 1 ▶ RETVAL = hm_abi_st_stream_do_abort(aTHX);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = hm_abi_st_stream_do_abort(aTHX); 0 1 1
106 OUTPUT:
107 RETVAL
108  
109 # v8: register the read half on the open stream handle, so bytes the peer
110 # sends arrive by callback instead of being buffered into psgi.input.
111 IV
112 _abi_stream_read()
113 CODE:
114 9 ▶ RETVAL = hm_abi_st_stream_read(aTHX);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = hm_abi_st_stream_read(aTHX); 0 9 9
115 OUTPUT:
116 RETVAL
117  
118 # What the read half has been handed: (calls, bytes, the bytes themselves).
119 void
120 _abi_stream_rx()
121 PPCODE:
122 9 ▶ EXTEND(SP, 3);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 3); 0 9 9
123 9 mPUSHi(HM_ABI_ST_SH_RXN);
124 9 mPUSHi(HM_ABI_ST_SH_RXLEN);
125 9 mPUSHp(HM_ABI_ST_SH_RX, (STRLEN)HM_ABI_ST_SH_RXLEN);
126  
127 # Owe the open stream n chunks of 4KiB and produce them, pausing whenever the
128 # connection says it is full and resuming from the drain callback. The stream
129 # closes itself when the last chunk is out, so the caller returns immediately
130 # and the body finishes on the loop.
131 void
132 _abi_stream_produce(n)
133 IV n
134 CODE:
135 1 hm_abi_st_stream_produce(aTHX_ n);
136  
137 # open?, aborts, drains, accepted writes, times the connection said full -
138 # read back by a LATER request, which is the only way a Perl test can see a
139 # callback that fired in C.
140 void
141 _abi_stream_state()
142 PPCODE:
143 7 ▶ EXTEND(SP, 5);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 5); 0 7 7
144 7 ▶ mPUSHi(HM_ABI_ST_SH ? 1 : 0);
Branch: 1 branch
BranchTrueFalseTotal
mPUSHi(HM_ABI_ST_SH ? 1 : 0); 2 5 7
145 7 mPUSHi(HM_ABI_ST_SH_ABORTS);
146 7 mPUSHi(HM_ABI_ST_SH_DRAINS);
147 7 mPUSHi(HM_ABI_ST_SH_WRITES);
148 7 mPUSHi(HM_ABI_ST_SH_FULLS);
« include/hyperman/hm_sa.h ↑ Summary Hyperman.c »