File Coverage

TempChdir.c
Criterion Covered Total %
statement 6 12 50.0
branch 0 2 0.0
condition n/a
subroutine n/a
pod n/a
total 6 14 42.8


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