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