SendFile.c

filter: Statementstmt 94.7% 18 / 19 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 84.0% 21 / 25 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
↑ Summary blib/lib/IO/SendFile.pm »
1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the
3 * contents of SendFile.xs. Do not edit this file, edit SendFile.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8  
9 #line 1 "SendFile.xs"
10 #include "EXTERN.h"
11 #include "perl.h"
12 #include "XSUB.h"
13  
14 #include <unistd.h>
15  
16  
17 #line 18 "SendFile.c"
18 #ifndef PERL_UNUSED_VAR
19 # define PERL_UNUSED_VAR(var) if (0) var = var
20 #endif
21  
22 #ifndef dVAR
23 # define dVAR dNOOP
24 #endif
25  
26  
27 /* This stuff is not part of the API! You have been warned. */
28 #ifndef PERL_VERSION_DECIMAL
29 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
30 #endif
31 #ifndef PERL_DECIMAL_VERSION
32 # define PERL_DECIMAL_VERSION \
33 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
34 #endif
35 #ifndef PERL_VERSION_GE
36 # define PERL_VERSION_GE(r,v,s) \
37 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
38 #endif
39 #ifndef PERL_VERSION_LE
40 # define PERL_VERSION_LE(r,v,s) \
41 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
42 #endif
43  
44 /* XS_INTERNAL is the explicit static-linkage variant of the default
45 * XS macro.
46 *
47 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
48 * "static", ie. it exports XSUB symbols. You probably don't want that
49 * for anything but the BOOT XSUB.
50 *
51 * See XSUB.h in core!
52 */
53  
54  
55 /* TODO: This might be compatible further back than 5.10.0. */
56 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
57 # undef XS_EXTERNAL
58 # undef XS_INTERNAL
59 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
60 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
61 # define XS_INTERNAL(name) static XSPROTO(name)
62 # endif
63 # if defined(__SYMBIAN32__)
64 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
65 # define XS_INTERNAL(name) EXPORT_C static XSPROTO(name)
66 # endif
67 # ifndef XS_EXTERNAL
68 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
69 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
70 # define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__)
71 # else
72 # ifdef __cplusplus
73 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
74 # define XS_INTERNAL(name) static XSPROTO(name)
75 # else
76 # define XS_EXTERNAL(name) XSPROTO(name)
77 # define XS_INTERNAL(name) static XSPROTO(name)
78 # endif
79 # endif
80 # endif
81 #endif
82  
83 /* perl >= 5.10.0 && perl <= 5.15.1 */
84  
85  
86 /* The XS_EXTERNAL macro is used for functions that must not be static
87 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
88 * macro defined, the best we can do is assume XS is the same.
89 * Dito for XS_INTERNAL.
90 */
91 #ifndef XS_EXTERNAL
92 # define XS_EXTERNAL(name) XS(name)
93 #endif
94 #ifndef XS_INTERNAL
95 # define XS_INTERNAL(name) XS(name)
96 #endif
97  
98 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
99 * internal macro that we're free to redefine for varying linkage due
100 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
101 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
102 */
103  
104 #undef XS_EUPXS
105 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
106 # define XS_EUPXS(name) XS_EXTERNAL(name)
107 #else
108 /* default to internal */
109 # define XS_EUPXS(name) XS_INTERNAL(name)
110 #endif
111  
112 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
113 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
114  
115 /* prototype to pass -Wmissing-prototypes */
116 static void
117 S_croak_xs_usage(const CV *const cv, const char *const params);
118  
119 static void
120 S_croak_xs_usage(const CV *const cv, const char *const params)
121 {
122 const GV *const gv = CvGV(cv);
123  
124 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
125  
126 if (gv) {
127 const char *const gvname = GvNAME(gv);
128 const HV *const stash = GvSTASH(gv);
129 const char *const hvname = stash ? HvNAME(stash) : NULL;
130  
131 if (hvname)
132 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
133 else
134 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
135 } else {
136 /* Pants. I don't think that it should be possible to get here. */
137 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
138 }
139 }
140 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
141  
142 #define croak_xs_usage S_croak_xs_usage
143  
144 #endif
145  
146 /* NOTE: the prototype of newXSproto() is different in versions of perls,
147 * so we define a portable version of newXSproto()
148 */
149 #ifdef newXS_flags
150 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
151 #else
152 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
153 #endif /* !defined(newXS_flags) */
154  
155 #if PERL_VERSION_LE(5, 21, 5)
156 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
157 #else
158 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
159 #endif
160  
161 /* simple backcompat versions of the TARGx() macros with no optimisation */
162 #ifndef TARGi
163 # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
164 # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
165 # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
166 #endif
167  
168 #line 169 "SendFile.c"
169  
170 XS_EUPXS(XS_IO__SendFile_sendfile); /* prototype to pass -Wmissing-prototypes */
171 1 XS_EUPXS(XS_IO__SendFile_sendfile)
172 {
173 1 dVAR; dXSARGS;
174 1 ▶ if (items != 4)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 4) 0 1 1
175 0 croak_xs_usage(cv, "out_fd, in_fd, offset, count");
176 {
177 1 int out_fd = (int)SvIV(ST(0))
178 ;
179 1 int in_fd = (int)SvIV(ST(1))
180 ;
181 1 off_t * offset = INT2PTR(off_t *,SvIV(ST(2)))
182 ;
183 1 size_t count = (size_t)SvUV(ST(3))
184 ;
185 ssize_t RETVAL;
186 1 ▶ dXSTARG;
Branch: 1 branch
BranchTrueFalseTotal
dXSTARG; 1 0 1
187  
188 1 RETVAL = sendfile(out_fd, in_fd, offset, count);
189 1 ▶ TARGi((IV)RETVAL, 1);
Branch: 1 branch
BranchTrueFalseTotal
TARGi((IV)RETVAL, 1); 0 1 1
190 1 ST(0) = TARG;
191 }
192 1 XSRETURN(1);
193 }
194  
195 #ifdef __cplusplus
196 extern "C" {
197 #endif
198 XS_EXTERNAL(boot_IO__SendFile); /* prototype to pass -Wmissing-prototypes */
199 1 XS_EXTERNAL(boot_IO__SendFile)
200 {
201 #if PERL_VERSION_LE(5, 21, 5)
202 dVAR; dXSARGS;
203 #else
204 1 dVAR; dXSBOOTARGSXSAPIVERCHK;
205 #endif
206 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
207 char* file = __FILE__;
208 #else
209 1 const char* file = __FILE__;
210 #endif
211  
212 PERL_UNUSED_VAR(file);
213  
214 PERL_UNUSED_VAR(cv); /* -W */
215 PERL_UNUSED_VAR(items); /* -W */
216 #if PERL_VERSION_LE(5, 21, 5)
217 XS_VERSION_BOOTCHECK;
218 # ifdef XS_APIVERSION_BOOTCHECK
219 XS_APIVERSION_BOOTCHECK;
220 # endif
221 #endif
222  
223 1 newXS_deffile("IO::SendFile::sendfile", XS_IO__SendFile_sendfile);
224 #if PERL_VERSION_LE(5, 21, 5)
225 # if PERL_VERSION_GE(5, 9, 0)
226 if (PL_unitcheckav)
227 call_list(PL_scopestack_ix, PL_unitcheckav);
228 # endif
229 XSRETURN_YES;
230 #else
231 1 Perl_xs_boot_epilog(aTHX_ ax);
232 #endif
233 1 }
234  
235 #ifdef __cplusplus
236 }
237 #endif
↑ Summary blib/lib/IO/SendFile.pm »