Sysexits.c

filter: Statementstmt 93.3% 14 / 15 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 84.2% 16 / 19 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« const-c.inc ↑ Summary
1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the
3 * contents of Sysexits.xs. Do not edit this file, edit Sysexits.xs instead.
4 *
5 * ANY CHANGES MADE HERE WILL BE LOST!
6 *
7 */
8  
9 #line 1 "Sysexits.xs"
10 #include "EXTERN.h"
11 #include "perl.h"
12 #include "XSUB.h"
13  
14 #include "ppport.h"
15  
16 #include <sysexits.h>
17  
18 #include "const-c.inc"
19  
20 #line 21 "Sysexits.c"
21 #ifndef PERL_UNUSED_VAR
22 # define PERL_UNUSED_VAR(var) if (0) var = var
23 #endif
24  
25 #ifndef dVAR
26 # define dVAR dNOOP
27 #endif
28  
29  
30 /* This stuff is not part of the API! You have been warned. */
31 #ifndef PERL_VERSION_DECIMAL
32 # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
33 #endif
34 #ifndef PERL_DECIMAL_VERSION
35 # define PERL_DECIMAL_VERSION \
36 PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
37 #endif
38 #ifndef PERL_VERSION_GE
39 # define PERL_VERSION_GE(r,v,s) \
40 (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
41 #endif
42 #ifndef PERL_VERSION_LE
43 # define PERL_VERSION_LE(r,v,s) \
44 (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
45 #endif
46  
47 /* XS_INTERNAL is the explicit static-linkage variant of the default
48 * XS macro.
49 *
50 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
51 * "static", ie. it exports XSUB symbols. You probably don't want that
52 * for anything but the BOOT XSUB.
53 *
54 * See XSUB.h in core!
55 */
56  
57  
58 /* TODO: This might be compatible further back than 5.10.0. */
59 #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
60 # undef XS_EXTERNAL
61 # undef XS_INTERNAL
62 # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
63 # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
64 # define XS_INTERNAL(name) static XSPROTO(name)
65 # endif
66 # if defined(__SYMBIAN32__)
67 # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
68 # define XS_INTERNAL(name) EXPORT_C static XSPROTO(name)
69 # endif
70 # ifndef XS_EXTERNAL
71 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
72 # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
73 # define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__)
74 # else
75 # ifdef __cplusplus
76 # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
77 # define XS_INTERNAL(name) static XSPROTO(name)
78 # else
79 # define XS_EXTERNAL(name) XSPROTO(name)
80 # define XS_INTERNAL(name) static XSPROTO(name)
81 # endif
82 # endif
83 # endif
84 #endif
85  
86 /* perl >= 5.10.0 && perl <= 5.15.1 */
87  
88  
89 /* The XS_EXTERNAL macro is used for functions that must not be static
90 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
91 * macro defined, the best we can do is assume XS is the same.
92 * Dito for XS_INTERNAL.
93 */
94 #ifndef XS_EXTERNAL
95 # define XS_EXTERNAL(name) XS(name)
96 #endif
97 #ifndef XS_INTERNAL
98 # define XS_INTERNAL(name) XS(name)
99 #endif
100  
101 /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
102 * internal macro that we're free to redefine for varying linkage due
103 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
104 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
105 */
106  
107 #undef XS_EUPXS
108 #if defined(PERL_EUPXS_ALWAYS_EXPORT)
109 # define XS_EUPXS(name) XS_EXTERNAL(name)
110 #else
111 /* default to internal */
112 # define XS_EUPXS(name) XS_INTERNAL(name)
113 #endif
114  
115 #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
116 #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
117  
118 /* prototype to pass -Wmissing-prototypes */
119 static void
120 S_croak_xs_usage(const CV *const cv, const char *const params);
121  
122 static void
123 S_croak_xs_usage(const CV *const cv, const char *const params)
124 {
125 const GV *const gv = CvGV(cv);
126  
127 PERL_ARGS_ASSERT_CROAK_XS_USAGE;
128  
129 if (gv) {
130 const char *const gvname = GvNAME(gv);
131 const HV *const stash = GvSTASH(gv);
132 const char *const hvname = stash ? HvNAME(stash) : NULL;
133  
134 if (hvname)
135 Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
136 else
137 Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
138 } else {
139 /* Pants. I don't think that it should be possible to get here. */
140 Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
141 }
142 }
143 #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
144  
145 #define croak_xs_usage S_croak_xs_usage
146  
147 #endif
148  
149 /* NOTE: the prototype of newXSproto() is different in versions of perls,
150 * so we define a portable version of newXSproto()
151 */
152 #ifdef newXS_flags
153 #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
154 #else
155 #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
156 #endif /* !defined(newXS_flags) */
157  
158 #if PERL_VERSION_LE(5, 21, 5)
159 # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
160 #else
161 # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
162 #endif
163  
164 /* simple backcompat versions of the TARGx() macros with no optimisation */
165 #ifndef TARGi
166 # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
167 # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
168 # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
169 #endif
170  
171 #line 172 "Sysexits.c"
172  
173 /* INCLUDE: Including 'const-xs.inc' from 'Sysexits.xs' */
174  
175  
176 XS_EUPXS(XS_Unix__Sysexits_constant); /* prototype to pass -Wmissing-prototypes */
177 18 XS_EUPXS(XS_Unix__Sysexits_constant)
178 {
179 18 dVAR; dXSARGS;
180 18 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 18 18
181 0 croak_xs_usage(cv, "sv");
182 PERL_UNUSED_VAR(ax); /* -Wall */
183 18 ▶ SP -= items;
Branch: 1 branch
BranchTrueFalseTotal
SP -= items; 18 0 18
184 {
185 #line 4 "./const-xs.inc"
186 #ifdef dXSTARG
187 dXSTARG; /* Faster if we have it. */
188 #else
189 dTARGET;
190 #endif
191 STRLEN len;
192 int type;
193 IV iv = 0; /* avoid uninit var warning */
194 /* NV nv; Uncomment this if you need to return NVs */
195 /* const char *pv; Uncomment this if you need to return PVs */
196 #line 197 "Sysexits.c"
197 18 SV * sv = ST(0)
198 ;
199 18 const char * s = SvPV(sv, len);
200 #line 18 "./const-xs.inc"
201 /* Change this to constant(aTHX_ s, len, &iv, &nv);
202 if you need to return both NVs and IVs */
203 type = constant(aTHX_ s, len, &iv);
204 /* Return 1 or 2 items. First is error message, or undef if no error.
205 Second, if present, is found value */
206 switch (type) {
207 case PERL_constant_NOTFOUND:
208 sv =
209 sv_2mortal(newSVpvf("%s is not a valid Unix::Sysexits macro", s));
210 PUSHs(sv);
211 break;
212 case PERL_constant_NOTDEF:
213 sv = sv_2mortal(newSVpvf(
214 "Your vendor has not defined Unix::Sysexits macro %s, used",
215 s));
216 PUSHs(sv);
217 break;
218 case PERL_constant_ISIV:
219 EXTEND(SP, 2);
220 PUSHs(&PL_sv_undef);
221 PUSHi(iv);
222 break;
223 /* Uncomment this if you need to return NOs
224 case PERL_constant_ISNO:
225 EXTEND(SP, 2);
226 PUSHs(&PL_sv_undef);
227 PUSHs(&PL_sv_no);
228 break; */
229 /* Uncomment this if you need to return NVs
230 case PERL_constant_ISNV:
231 EXTEND(SP, 2);
232 PUSHs(&PL_sv_undef);
233 PUSHn(nv);
234 break; */
235 /* Uncomment this if you need to return PVs
236 case PERL_constant_ISPV:
237 EXTEND(SP, 2);
238 PUSHs(&PL_sv_undef);
239 PUSHp(pv, strlen(pv));
240 break; */
241 /* Uncomment this if you need to return PVNs
242 case PERL_constant_ISPVN:
243 EXTEND(SP, 2);
244 PUSHs(&PL_sv_undef);
245 PUSHp(pv, iv);
246 break; */
247 /* Uncomment this if you need to return SVs
248 case PERL_constant_ISSV:
249 EXTEND(SP, 2);
250 PUSHs(&PL_sv_undef);
251 PUSHs(sv);
252 break; */
253 /* Uncomment this if you need to return UNDEFs
254 case PERL_constant_ISUNDEF:
255 break; */
256 /* Uncomment this if you need to return UVs
257 case PERL_constant_ISUV:
258 EXTEND(SP, 2);
259 PUSHs(&PL_sv_undef);
260 PUSHu((UV)iv);
261 break; */
262 /* Uncomment this if you need to return YESs
263 case PERL_constant_ISYES:
264 EXTEND(SP, 2);
265 PUSHs(&PL_sv_undef);
266 PUSHs(&PL_sv_yes);
267 break; */
268 default:
269 sv = sv_2mortal(newSVpvf(
270 "Unexpected return type %d while processing Unix::Sysexits macro %s, used",
271 type, s));
272 PUSHs(sv);
273 }
274 #line 275 "Sysexits.c"
275 18 PUTBACK;
276 18 return;
277 }
278 }
279  
280  
281 /* INCLUDE: Returning to 'Sysexits.xs' from 'const-xs.inc' */
282  
283 #ifdef __cplusplus
284 extern "C" {
285 #endif
286 XS_EXTERNAL(boot_Unix__Sysexits); /* prototype to pass -Wmissing-prototypes */
287 1 XS_EXTERNAL(boot_Unix__Sysexits)
288 {
289 #if PERL_VERSION_LE(5, 21, 5)
290 dVAR; dXSARGS;
291 #else
292 1 dVAR; dXSBOOTARGSXSAPIVERCHK;
293 #endif
294 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
295 char* file = __FILE__;
296 #else
297 1 const char* file = __FILE__;
298 #endif
299  
300 PERL_UNUSED_VAR(file);
301  
302 PERL_UNUSED_VAR(cv); /* -W */
303 PERL_UNUSED_VAR(items); /* -W */
304 #if PERL_VERSION_LE(5, 21, 5)
305 XS_VERSION_BOOTCHECK;
306 # ifdef XS_APIVERSION_BOOTCHECK
307 XS_APIVERSION_BOOTCHECK;
308 # endif
309 #endif
310  
311 1 newXS_deffile("Unix::Sysexits::constant", XS_Unix__Sysexits_constant);
312 #if PERL_VERSION_LE(5, 21, 5)
313 # if PERL_VERSION_GE(5, 9, 0)
314 if (PL_unitcheckav)
315 call_list(PL_scopestack_ix, PL_unitcheckav);
316 # endif
317 XSRETURN_YES;
318 #else
319 1 Perl_xs_boot_epilog(aTHX_ ax);
320 #endif
321 1 }
322  
323 #ifdef __cplusplus
324 }
325 #endif
« const-c.inc ↑ Summary