Linux.c

filter: Statementstmt 42.8% 6 / 14 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 37.5% 6 / 16 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« const-c.inc ↑ Summary const-xs.inc »
1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the
3 * contents of Linux.xs. Do not edit this file, edit Linux.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8  
9 #line 1 "Linux.xs"
10 #define PERL_NO_GET_CONTEXT
11 #include "EXTERN.h"
12 #include "perl.h"
13 #include "XSUB.h"
14  
15 #include "ppport.h"
16  
17 #ifdef I_NETINET_TCP
18 # include <netinet/tcp.h>
19 #endif
20  
21 #include "const-c.inc"
22  
23 #line 24 "Linux.c"
24 #ifndef PERL_UNUSED_VAR
25 # define PERL_UNUSED_VAR(var) if (0) var = var
26 #endif
27  
28 #ifndef dVAR
29 # define dVAR dNOOP
30 #endif
31  
32  
33 /* This stuff is not part of the API! You have been warned. */
34 #ifndef PERL_VERSION_DECIMAL
35 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
36 #endif
37 #ifndef PERL_DECIMAL_VERSION
38 # define PERL_DECIMAL_VERSION \
39 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
40 #endif
41 #ifndef PERL_VERSION_GE
42 # define PERL_VERSION_GE(r,v,s) \
43 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
44 #endif
45 #ifndef PERL_VERSION_LE
46 # define PERL_VERSION_LE(r,v,s) \
47 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
48 #endif
49  
50 /* XS_INTERNAL is the explicit static-linkage variant of the default
51 * XS macro.
52 *
53 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
54 * "static", ie. it exports XSUB symbols. You probably don't want that
55 * for anything but the BOOT XSUB.
56 *
57 * See XSUB.h in core!
58 */
59  
60  
61 /* TODO: This might be compatible further back than 5.10.0. */
62 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
63 # undef XS_EXTERNAL
64 # undef XS_INTERNAL
65 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
66 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
67 # define XS_INTERNAL(name) static XSPROTO(name)
68 # endif
69 # if defined(__SYMBIAN32__)
70 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
71 # define XS_INTERNAL(name) EXPORT_C static XSPROTO(name)
72 # endif
73 # ifndef XS_EXTERNAL
74 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
75 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
76 # define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__)
77 # else
78 # ifdef __cplusplus
79 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
80 # define XS_INTERNAL(name) static XSPROTO(name)
81 # else
82 # define XS_EXTERNAL(name) XSPROTO(name)
83 # define XS_INTERNAL(name) static XSPROTO(name)
84 # endif
85 # endif
86 # endif
87 #endif
88  
89 /* perl >= 5.10.0 && perl <= 5.15.1 */
90  
91  
92 /* The XS_EXTERNAL macro is used for functions that must not be static
93 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
94 * macro defined, the best we can do is assume XS is the same.
95 * Dito for XS_INTERNAL.
96 */
97 #ifndef XS_EXTERNAL
98 # define XS_EXTERNAL(name) XS(name)
99 #endif
100 #ifndef XS_INTERNAL
101 # define XS_INTERNAL(name) XS(name)
102 #endif
103  
104 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
105 * internal macro that we're free to redefine for varying linkage due
106 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
107 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
108 */
109  
110 #undef XS_EUPXS
111 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
112 # define XS_EUPXS(name) XS_EXTERNAL(name)
113 #else
114 /* default to internal */
115 # define XS_EUPXS(name) XS_INTERNAL(name)
116 #endif
117  
118 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
119 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
120  
121 /* prototype to pass -Wmissing-prototypes */
122 static void
123 S_croak_xs_usage(const CV *const cv, const char *const params);
124  
125 static void
126 S_croak_xs_usage(const CV *const cv, const char *const params)
127 {
128 const GV *const gv = CvGV(cv);
129  
130 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
131  
132 if (gv) {
133 const char *const gvname = GvNAME(gv);
134 const HV *const stash = GvSTASH(gv);
135 const char *const hvname = stash ? HvNAME(stash) : NULL;
136  
137 if (hvname)
138 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
139 else
140 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
141 } else {
142 /* Pants. I don't think that it should be possible to get here. */
143 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
144 }
145 }
146 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
147  
148 #define croak_xs_usage S_croak_xs_usage
149  
150 #endif
151  
152 /* NOTE: the prototype of newXSproto() is different in versions of perls,
153 * so we define a portable version of newXSproto()
154 */
155 #ifdef newXS_flags
156 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
157 #else
158 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
159 #endif /* !defined(newXS_flags) */
160  
161 #if PERL_VERSION_LE(5, 21, 5)
162 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
163 #else
164 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
165 #endif
166  
167 /* simple backcompat versions of the TARGx() macros with no optimisation */
168 #ifndef TARGi
169 # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
170 # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
171 # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
172 #endif
173  
174 #line 175 "Linux.c"
175  
176 /* INCLUDE: Including 'const-xs.inc' from 'Linux.xs' */
177  
178  
179 XS_EUPXS(XS_Socket__Linux_constant); /* prototype to pass -Wmissing-prototypes */
180 0 XS_EUPXS(XS_Socket__Linux_constant)
181 {
182 0 dVAR; dXSARGS;
183 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
184 0 croak_xs_usage(cv, "sv");
185 PERL_UNUSED_VAR(ax); /* -Wall */
186 0 SP -= items;
187 {
188 0 SV * sv = ST(0)
189 ;
190 #line 186 "./const-xs.inc"
191 #ifndef SYMBIAN
192 /* It's not obvious how to calculate this at C pre-processor time.
193 However, any compiler optimiser worth its salt should be able to
194 remove the dead code, and hopefully the now-obviously-unused static
195 function too. */
196 HV *constant_missing = (C_ARRAY_LENGTH(values_for_notfound) > 1)
197 ? get_missing_hash(aTHX) : NULL;
198 if ((C_ARRAY_LENGTH(values_for_notfound) > 1)
199 ? hv_exists_ent(constant_missing, sv, 0) : 0) {
200 sv = newSVpvf("Your vendor has not defined Socket::Linux macro %" SVf
201 ", used", sv);
202 } else
203 #endif
204 {
205 sv = newSVpvf("%" SVf " is not a valid Socket::Linux macro",
206 sv);
207 }
208 PUSHs(sv_2mortal(sv));
209 #line 210 "Linux.c"
210 0 PUTBACK;
211 0 return;
212 }
213 }
214  
215  
216 /* INCLUDE: Returning to 'Linux.xs' from 'const-xs.inc' */
217  
218 #ifdef __cplusplus
219 extern "C" {
220 #endif
221 XS_EXTERNAL(boot_Socket__Linux); /* prototype to pass -Wmissing-prototypes */
222 1 XS_EXTERNAL(boot_Socket__Linux)
223 {
224 #if PERL_VERSION_LE(5, 21, 5)
225 dVAR; dXSARGS;
226 #else
227 1 dVAR; dXSBOOTARGSXSAPIVERCHK;
228 #endif
229 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
230 char* file = __FILE__;
231 #else
232 1 const char* file = __FILE__;
233 #endif
234  
235 PERL_UNUSED_VAR(file);
236  
237 PERL_UNUSED_VAR(cv); /* -W */
238 PERL_UNUSED_VAR(items); /* -W */
239 #if PERL_VERSION_LE(5, 21, 5)
240 XS_VERSION_BOOTCHECK;
241 # ifdef XS_APIVERSION_BOOTCHECK
242 XS_APIVERSION_BOOTCHECK;
243 # endif
244 #endif
245  
246 1 newXS_deffile("Socket::Linux::constant", XS_Socket__Linux_constant);
247  
248 /* Initialisation Section */
249  
250 #line 2 "./const-xs.inc"
251 {
252 #if defined(dTHX) && !defined(PERL_NO_GET_CONTEXT)
253 dTHX;
254 #endif
255 HV *symbol_table = get_hv("Socket::Linux::", GV_ADD);
256  
257 static const struct iv_s values_for_iv[] =
258 {
259 #ifdef TCP_NODELAY
260 { "TCP_NODELAY", 11, TCP_NODELAY },
261 #endif
262 #ifdef TCP_MAXSEG
263 { "TCP_MAXSEG", 10, TCP_MAXSEG },
264 #endif
265 #ifdef TCP_CORK
266 { "TCP_CORK", 8, TCP_CORK },
267 #endif
268 #ifdef TCP_KEEPIDLE
269 { "TCP_KEEPIDLE", 12, TCP_KEEPIDLE },
270 #endif
271 #ifdef TCP_KEEPINTVL
272 { "TCP_KEEPINTVL", 13, TCP_KEEPINTVL },
273 #endif
274 #ifdef TCP_KEEPCNT
275 { "TCP_KEEPCNT", 11, TCP_KEEPCNT },
276 #endif
277 #ifdef TCP_SYNCNT
278 { "TCP_SYNCNT", 10, TCP_SYNCNT },
279 #endif
280 #ifdef TCP_LINGER2
281 { "TCP_LINGER2", 11, TCP_LINGER2 },
282 #endif
283 #ifdef TCP_DEFER_ACCEPT
284 { "TCP_DEFER_ACCEPT", 16, TCP_DEFER_ACCEPT },
285 #endif
286 #ifdef TCP_WINDOW_CLAMP
287 { "TCP_WINDOW_CLAMP", 16, TCP_WINDOW_CLAMP },
288 #endif
289 #ifdef TCP_INFO
290 { "TCP_INFO", 8, TCP_INFO },
291 #endif
292 #ifdef TCP_QUICKACK
293 { "TCP_QUICKACK", 12, TCP_QUICKACK },
294 #endif
295 #ifdef TCP_CONGESTION
296 { "TCP_CONGESTION", 14, TCP_CONGESTION },
297 #endif
298 #ifdef TCP_MD5SIG
299 { "TCP_MD5SIG", 10, TCP_MD5SIG },
300 #endif
301 #ifdef TCPOPT_EOL
302 { "TCPOPT_EOL", 10, TCPOPT_EOL },
303 #endif
304 #ifdef TCPOPT_NOP
305 { "TCPOPT_NOP", 10, TCPOPT_NOP },
306 #endif
307 #ifdef TCPOPT_MAXSEG
308 { "TCPOPT_MAXSEG", 13, TCPOPT_MAXSEG },
309 #endif
310 #ifdef TCPOLEN_MAXSEG
311 { "TCPOLEN_MAXSEG", 14, TCPOLEN_MAXSEG },
312 #endif
313 #ifdef TCPOPT_WINDOW
314 { "TCPOPT_WINDOW", 13, TCPOPT_WINDOW },
315 #endif
316 #ifdef TCPOLEN_WINDOW
317 { "TCPOLEN_WINDOW", 14, TCPOLEN_WINDOW },
318 #endif
319 #ifdef TCPOPT_SACK_PERMITTED
320 { "TCPOPT_SACK_PERMITTED", 21, TCPOPT_SACK_PERMITTED },
321 #endif
322 #ifdef TCPOLEN_SACK_PERMITTED
323 { "TCPOLEN_SACK_PERMITTED", 22, TCPOLEN_SACK_PERMITTED },
324 #endif
325 #ifdef TCPOPT_SACK
326 { "TCPOPT_SACK", 11, TCPOPT_SACK },
327 #endif
328 #ifdef TCPOPT_TIMESTAMP
329 { "TCPOPT_TIMESTAMP", 16, TCPOPT_TIMESTAMP },
330 #endif
331 #ifdef TCPOLEN_TIMESTAMP
332 { "TCPOLEN_TIMESTAMP", 17, TCPOLEN_TIMESTAMP },
333 #endif
334 #ifdef TCPOLEN_TSTAMP_APPA
335 { "TCPOLEN_TSTAMP_APPA", 19, TCPOLEN_TSTAMP_APPA },
336 #endif
337 #ifdef TCPOPT_TSTAMP_HDR
338 { "TCPOPT_TSTAMP_HDR", 17, TCPOPT_TSTAMP_HDR },
339 #endif
340 #ifdef TCP_MSS
341 { "TCP_MSS", 7, TCP_MSS },
342 #endif
343 #ifdef TCP_MAXWIN
344 { "TCP_MAXWIN", 10, TCP_MAXWIN },
345 #endif
346 #ifdef TCP_MAX_WINSHIFT
347 { "TCP_MAX_WINSHIFT", 16, TCP_MAX_WINSHIFT },
348 #endif
349 #ifdef SOL_TCP
350 { "SOL_TCP", 7, SOL_TCP },
351 #endif
352 #ifdef TCPI_OPT_TIMESTAMPS
353 { "TCPI_OPT_TIMESTAMPS", 19, TCPI_OPT_TIMESTAMPS },
354 #endif
355 #ifdef TCPI_OPT_SACK
356 { "TCPI_OPT_SACK", 13, TCPI_OPT_SACK },
357 #endif
358 #ifdef TCPI_OPT_WSCALE
359 { "TCPI_OPT_WSCALE", 15, TCPI_OPT_WSCALE },
360 #endif
361 #ifdef TCPI_OPT_ECN
362 { "TCPI_OPT_ECN", 12, TCPI_OPT_ECN },
363 #endif
364 #ifdef TCP_MD5SIG_MAXKEYLEN
365 { "TCP_MD5SIG_MAXKEYLEN", 20, TCP_MD5SIG_MAXKEYLEN },
366 #endif
367 { NULL, 0, 0 } };
368 const struct iv_s *value_for_iv = values_for_iv;
369 while (value_for_iv->name) {
370 constant_add_symbol(aTHX_ symbol_table, value_for_iv->name,
371 value_for_iv->namelen, newSViv(value_for_iv->value));
372 ++value_for_iv;
373 }
374 if (C_ARRAY_LENGTH(values_for_notfound) > 1) {
375 #ifndef SYMBIAN
376 HV *const constant_missing = get_missing_hash(aTHX);
377 #endif
378 const struct notfound_s *value_for_notfound = values_for_notfound;
379 do {
380  
381 /* Need to add prototypes, else parsing will vary by platform. */
382 HE *he = (HE*) hv_common_key_len(symbol_table,
383 value_for_notfound->name,
384 value_for_notfound->namelen,
385 HV_FETCH_LVALUE, NULL, 0);
386 SV *sv;
387 #ifndef SYMBIAN
388 HEK *hek;
389 #endif
390 if (!he) {
391 croak("Couldn't add key '%s' to %%Socket::Linux::",
392 value_for_notfound->name);
393 }
394 sv = HeVAL(he);
395 if (!SvOK(sv) && SvTYPE(sv) != SVt_PVGV) {
396 /* Nothing was here before, so mark a prototype of "" */
397 sv_setpvn(sv, "", 0);
398 } else if (SvPOK(sv) && SvCUR(sv) == 0) {
399 /* There is already a prototype of "" - do nothing */
400 } else {
401 /* Someone has been here before us - have to make a real
402 typeglob. */
403 /* It turns out to be incredibly hard to deal with all the
404 corner cases of sub foo (); and reporting errors correctly,
405 so lets cheat a bit. Start with a constant subroutine */
406 CV *cv = newCONSTSUB(symbol_table,
407 value_for_notfound->name,
408 &PL_sv_yes);
409 /* and then turn it into a non constant declaration only. */
410 SvREFCNT_dec(CvXSUBANY(cv).any_ptr);
411 CvCONST_off(cv);
412 CvXSUB(cv) = NULL;
413 CvXSUBANY(cv).any_ptr = NULL;
414 }
415 #ifndef SYMBIAN
416 hek = HeKEY_hek(he);
417 if (!hv_common(constant_missing, NULL, HEK_KEY(hek),
418 HEK_LEN(hek), HEK_FLAGS(hek), HV_FETCH_ISSTORE,
419 &PL_sv_yes, HEK_HASH(hek)))
420 croak("Couldn't add key '%s' to missing_hash",
421 value_for_notfound->name);
422 #endif
423 } while ((++value_for_notfound)->name);
424 }
425 /* As we've been creating subroutines, we better invalidate any cached
426 methods */
427 mro_method_changed_in(symbol_table);
428 }
429  
430 #line 431 "Linux.c"
431  
432 /* End of Initialisation Section */
433  
434 #if PERL_VERSION_LE(5, 21, 5)
435 # if PERL_VERSION_GE(5, 9, 0)
436 if (PL_unitcheckav)
437 call_list(PL_scopestack_ix, PL_unitcheckav);
438 # endif
439 XSRETURN_YES;
440 #else
441 1 Perl_xs_boot_epilog(aTHX_ ax);
442 #endif
443 1 }
444  
445 #ifdef __cplusplus
446 }
447 #endif
« const-c.inc ↑ Summary const-xs.inc »