Commit | Line | Data |
---|---|---|
eb1102fc NIS |
1 | /* XSUB.h |
2 | * | |
699a97de | 3 | * Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
1129b882 | 4 | * 2003, 2004, 2005, 2006, 2007, 2008 by Larry Wall and others |
eb1102fc NIS |
5 | * |
6 | * You may distribute under the terms of either the GNU General Public | |
7 | * License or the Artistic License, as specified in the README file. | |
8 | * | |
9 | */ | |
10 | ||
b4ba0ab9 GS |
11 | #ifndef _INC_PERL_XSUB_H |
12 | #define _INC_PERL_XSUB_H 1 | |
13 | ||
954c1994 GS |
14 | /* first, some documentation for xsubpp-generated items */ |
15 | ||
16 | /* | |
ccfc67b7 JH |
17 | =head1 Variables created by C<xsubpp> and C<xsubpp> internal functions |
18 | ||
954c1994 GS |
19 | =for apidoc Amn|char*|CLASS |
20 | Variable which is setup by C<xsubpp> to indicate the | |
21 | class name for a C++ XS constructor. This is always a C<char*>. See C<THIS>. | |
22 | ||
23 | =for apidoc Amn|(whatever)|RETVAL | |
24 | Variable which is setup by C<xsubpp> to hold the return value for an | |
25 | XSUB. This is always the proper type for the XSUB. See | |
26 | L<perlxs/"The RETVAL Variable">. | |
27 | ||
28 | =for apidoc Amn|(whatever)|THIS | |
29 | Variable which is setup by C<xsubpp> to designate the object in a C++ | |
30 | XSUB. This is always the proper type for the C++ object. See C<CLASS> and | |
31 | L<perlxs/"Using XS With C++">. | |
32 | ||
9f2ea798 DM |
33 | =for apidoc Amn|I32|ax |
34 | Variable which is setup by C<xsubpp> to indicate the stack base offset, | |
35 | used by the C<ST>, C<XSprePUSH> and C<XSRETURN> macros. The C<dMARK> macro | |
36 | must be called prior to setup the C<MARK> variable. | |
37 | ||
954c1994 GS |
38 | =for apidoc Amn|I32|items |
39 | Variable which is setup by C<xsubpp> to indicate the number of | |
40 | items on the stack. See L<perlxs/"Variable-length Parameter Lists">. | |
41 | ||
42 | =for apidoc Amn|I32|ix | |
43 | Variable which is setup by C<xsubpp> to indicate which of an | |
44 | XSUB's aliases was used to invoke it. See L<perlxs/"The ALIAS: Keyword">. | |
45 | ||
46 | =for apidoc Am|SV*|ST|int ix | |
47 | Used to access elements on the XSUB's stack. | |
48 | ||
49 | =for apidoc AmU||XS | |
50 | Macro to declare an XSUB and its C parameter list. This is handled by | |
51 | C<xsubpp>. | |
52 | ||
9f2ea798 DM |
53 | =for apidoc Ams||dAX |
54 | Sets up the C<ax> variable. | |
55 | This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>. | |
56 | ||
557b887a SS |
57 | =for apidoc Ams||dAXMARK |
58 | Sets up the C<ax> variable and stack marker variable C<mark>. | |
59 | This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>. | |
60 | ||
9f2ea798 DM |
61 | =for apidoc Ams||dITEMS |
62 | Sets up the C<items> variable. | |
63 | This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>. | |
64 | ||
954c1994 | 65 | =for apidoc Ams||dXSARGS |
9f2ea798 DM |
66 | Sets up stack and mark pointers for an XSUB, calling dSP and dMARK. |
67 | Sets up the C<ax> and C<items> variables by calling C<dAX> and C<dITEMS>. | |
68 | This is usually handled automatically by C<xsubpp>. | |
954c1994 GS |
69 | |
70 | =for apidoc Ams||dXSI32 | |
71 | Sets up the C<ix> variable for an XSUB which has aliases. This is usually | |
72 | handled automatically by C<xsubpp>. | |
73 | ||
88037a85 | 74 | =for apidoc Ams||dUNDERBAR |
483ce06a VP |
75 | Sets up any variable needed by the C<UNDERBAR> macro. It used to define |
76 | C<padoff_du>, but it is currently a noop. However, it is strongly adviced | |
77 | to still use it for ensuring past and future compatibility. | |
88037a85 RGS |
78 | |
79 | =for apidoc AmU||UNDERBAR | |
80 | The SV* corresponding to the $_ variable. Works even if there | |
81 | is a lexical $_ in scope. | |
82 | ||
954c1994 GS |
83 | =cut |
84 | */ | |
85 | ||
53c1dcc0 | 86 | #ifndef PERL_UNUSED_ARG |
c99ffe5e | 87 | # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ |
ad73156c | 88 | # include <note.h> |
53c1dcc0 | 89 | # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) |
ad73156c | 90 | # else |
53c1dcc0 | 91 | # define PERL_UNUSED_ARG(x) ((void)x) |
ad73156c AL |
92 | # endif |
93 | #endif | |
53c1dcc0 AL |
94 | #ifndef PERL_UNUSED_VAR |
95 | # define PERL_UNUSED_VAR(x) ((void)x) | |
96 | #endif | |
ad73156c | 97 | |
3280af22 | 98 | #define ST(off) PL_stack_base[ax + (off)] |
a0d0e21e | 99 | |
081304ca AMS |
100 | /* XSPROTO() is also used by SWIG like this: |
101 | * | |
102 | * typedef XSPROTO(SwigPerlWrapper); | |
103 | * typedef SwigPerlWrapper *SwigPerlWrapperPtr; | |
104 | * | |
105 | * This code needs to be compilable under both C and C++. | |
106 | * | |
107 | * Don't forget to change the __attribute__unused__ version of XS() | |
108 | * below too if you change XSPROTO() here. | |
109 | */ | |
110 | #define XSPROTO(name) void name(pTHX_ CV* cv) | |
111 | ||
27da23d5 | 112 | #undef XS |
d308986b | 113 | #if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING) |
081304ca | 114 | # define XS(name) __declspec(dllexport) XSPROTO(name) |
27da23d5 | 115 | #endif |
a0fd4948 | 116 | #if defined(__SYMBIAN32__) |
081304ca | 117 | # define XS(name) EXPORT_C XSPROTO(name) |
27da23d5 JH |
118 | #endif |
119 | #ifndef XS | |
34659ad4 | 120 | # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus) |
0dbb1585 | 121 | # define XS(name) void name(pTHX_ CV* cv __attribute__unused__) |
88d01955 | 122 | # else |
a0c21aa1 | 123 | # ifdef __cplusplus |
081304ca | 124 | # define XS(name) extern "C" XSPROTO(name) |
a0c21aa1 | 125 | # else |
081304ca | 126 | # define XS(name) XSPROTO(name) |
a0c21aa1 | 127 | # endif |
88d01955 | 128 | # endif |
a0d0e21e LW |
129 | #endif |
130 | ||
514696af | 131 | #define dAX const I32 ax = (I32)(MARK - PL_stack_base + 1) |
9f2ea798 | 132 | |
557b887a | 133 | #define dAXMARK \ |
a3b680e6 | 134 | I32 ax = POPMARK; \ |
92800dc8 | 135 | register SV **mark = PL_stack_base + ax++ |
557b887a | 136 | |
514696af | 137 | #define dITEMS I32 items = (I32)(SP - MARK) |
9f2ea798 | 138 | |
c99ffe5e | 139 | #if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ |
53c1dcc0 AL |
140 | # define dXSARGS \ |
141 | NOTE(ARGUNUSED(cv)) \ | |
142 | dSP; dAXMARK; dITEMS | |
143 | #else | |
144 | # define dXSARGS \ | |
557b887a | 145 | dSP; dAXMARK; dITEMS |
53c1dcc0 | 146 | #endif |
a0d0e21e | 147 | |
a3b680e6 | 148 | #define dXSTARG SV * const targ = ((PL_op->op_private & OPpENTERSUB_HASTARG) \ |
8a7fc0dc GS |
149 | ? PAD_SV(PL_op->op_targ) : sv_newmortal()) |
150 | ||
b26a54d0 GS |
151 | /* Should be used before final PUSHi etc. if not in PPCODE section. */ |
152 | #define XSprePUSH (sp = PL_stack_base + ax - 1) | |
153 | ||
a0d0e21e LW |
154 | #define XSANY CvXSUBANY(cv) |
155 | ||
156 | #define dXSI32 I32 ix = XSANY.any_i32 | |
157 | ||
cfc02341 IZ |
158 | #ifdef __cplusplus |
159 | # define XSINTERFACE_CVT(ret,name) ret (*name)(...) | |
4ef0c66e | 160 | # define XSINTERFACE_CVT_ANON(ret) ret (*)(...) |
cfc02341 IZ |
161 | #else |
162 | # define XSINTERFACE_CVT(ret,name) ret (*name)() | |
4ef0c66e | 163 | # define XSINTERFACE_CVT_ANON(ret) ret (*)() |
cfc02341 IZ |
164 | #endif |
165 | #define dXSFUNCTION(ret) XSINTERFACE_CVT(ret,XSFUNCTION) | |
4ef0c66e | 166 | #define XSINTERFACE_FUNC(ret,cv,f) ((XSINTERFACE_CVT_ANON(ret))(f)) |
cfc02341 | 167 | #define XSINTERFACE_FUNC_SET(cv,f) \ |
a12c3db7 | 168 | CvXSUBANY(cv).any_dxptr = (void (*) (pTHX_ void*))(f) |
cfc02341 | 169 | |
483ce06a VP |
170 | #define dUNDERBAR dNOOP |
171 | #define UNDERBAR find_rundefsv() | |
88037a85 | 172 | |
748a9306 LW |
173 | /* Simple macros to put new mortal values onto the stack. */ |
174 | /* Typically used to return values from XS functions. */ | |
954c1994 GS |
175 | |
176 | /* | |
ccfc67b7 JH |
177 | =head1 Stack Manipulation Macros |
178 | ||
954c1994 GS |
179 | =for apidoc Am|void|XST_mIV|int pos|IV iv |
180 | Place an integer into the specified position C<pos> on the stack. The | |
181 | value is stored in a new mortal SV. | |
182 | ||
183 | =for apidoc Am|void|XST_mNV|int pos|NV nv | |
184 | Place a double into the specified position C<pos> on the stack. The value | |
185 | is stored in a new mortal SV. | |
186 | ||
187 | =for apidoc Am|void|XST_mPV|int pos|char* str | |
188 | Place a copy of a string into the specified position C<pos> on the stack. | |
189 | The value is stored in a new mortal SV. | |
190 | ||
191 | =for apidoc Am|void|XST_mNO|int pos | |
192 | Place C<&PL_sv_no> into the specified position C<pos> on the | |
193 | stack. | |
194 | ||
195 | =for apidoc Am|void|XST_mYES|int pos | |
196 | Place C<&PL_sv_yes> into the specified position C<pos> on the | |
197 | stack. | |
198 | ||
199 | =for apidoc Am|void|XST_mUNDEF|int pos | |
200 | Place C<&PL_sv_undef> into the specified position C<pos> on the | |
201 | stack. | |
202 | ||
203 | =for apidoc Am|void|XSRETURN|int nitems | |
204 | Return from XSUB, indicating number of items on the stack. This is usually | |
205 | handled by C<xsubpp>. | |
206 | ||
207 | =for apidoc Am|void|XSRETURN_IV|IV iv | |
208 | Return an integer from an XSUB immediately. Uses C<XST_mIV>. | |
209 | ||
108ccc45 JH |
210 | =for apidoc Am|void|XSRETURN_UV|IV uv |
211 | Return an integer from an XSUB immediately. Uses C<XST_mUV>. | |
212 | ||
954c1994 | 213 | =for apidoc Am|void|XSRETURN_NV|NV nv |
d1be9408 | 214 | Return a double from an XSUB immediately. Uses C<XST_mNV>. |
954c1994 GS |
215 | |
216 | =for apidoc Am|void|XSRETURN_PV|char* str | |
217 | Return a copy of a string from an XSUB immediately. Uses C<XST_mPV>. | |
218 | ||
219 | =for apidoc Ams||XSRETURN_NO | |
220 | Return C<&PL_sv_no> from an XSUB immediately. Uses C<XST_mNO>. | |
221 | ||
222 | =for apidoc Ams||XSRETURN_YES | |
223 | Return C<&PL_sv_yes> from an XSUB immediately. Uses C<XST_mYES>. | |
224 | ||
225 | =for apidoc Ams||XSRETURN_UNDEF | |
226 | Return C<&PL_sv_undef> from an XSUB immediately. Uses C<XST_mUNDEF>. | |
227 | ||
228 | =for apidoc Ams||XSRETURN_EMPTY | |
229 | Return an empty list from an XSUB immediately. | |
230 | ||
ccfc67b7 JH |
231 | =head1 Variables created by C<xsubpp> and C<xsubpp> internal functions |
232 | ||
c578083c | 233 | =for apidoc AmU||newXSproto|char* name|XSUBADDR_t f|char* filename|const char *proto |
954c1994 GS |
234 | Used by C<xsubpp> to hook up XSUBs as Perl subs. Adds Perl prototypes to |
235 | the subs. | |
236 | ||
237 | =for apidoc AmU||XS_VERSION | |
238 | The version identifier for an XS module. This is usually | |
239 | handled automatically by C<ExtUtils::MakeMaker>. See C<XS_VERSION_BOOTCHECK>. | |
240 | ||
241 | =for apidoc Ams||XS_VERSION_BOOTCHECK | |
242 | Macro to verify that a PM module's $VERSION variable matches the XS | |
243 | module's C<XS_VERSION> variable. This is usually handled automatically by | |
244 | C<xsubpp>. See L<perlxs/"The VERSIONCHECK: Keyword">. | |
245 | ||
1e8125c6 FR |
246 | =for apidoc Ams||XS_APIVERSION_BOOTCHECK |
247 | Macro to verify that the perl api version an XS module has been compiled against | |
248 | matches the api version of the perl interpreter it's being loaded into. | |
249 | ||
0ca3a874 MHM |
250 | =head1 Simple Exception Handling Macros |
251 | ||
252 | =for apidoc Ams||dXCPT | |
2dfe1b17 | 253 | Set up necessary local variables for exception handling. |
0ca3a874 MHM |
254 | See L<perlguts/"Exception Handling">. |
255 | ||
256 | =for apidoc AmU||XCPT_TRY_START | |
257 | Starts a try block. See L<perlguts/"Exception Handling">. | |
258 | ||
259 | =for apidoc AmU||XCPT_TRY_END | |
260 | Ends a try block. See L<perlguts/"Exception Handling">. | |
261 | ||
262 | =for apidoc AmU||XCPT_CATCH | |
263 | Introduces a catch block. See L<perlguts/"Exception Handling">. | |
264 | ||
265 | =for apidoc Ams||XCPT_RETHROW | |
266 | Rethrows a previously caught exception. See L<perlguts/"Exception Handling">. | |
267 | ||
954c1994 GS |
268 | =cut |
269 | */ | |
270 | ||
4633a7c4 | 271 | #define XST_mIV(i,v) (ST(i) = sv_2mortal(newSViv(v)) ) |
108ccc45 | 272 | #define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) |
4633a7c4 LW |
273 | #define XST_mNV(i,v) (ST(i) = sv_2mortal(newSVnv(v)) ) |
274 | #define XST_mPV(i,v) (ST(i) = sv_2mortal(newSVpv(v,0))) | |
ad25789c | 275 | #define XST_mPVN(i,v,n) (ST(i) = newSVpvn_flags(v,n, SVs_TEMP)) |
3280af22 NIS |
276 | #define XST_mNO(i) (ST(i) = &PL_sv_no ) |
277 | #define XST_mYES(i) (ST(i) = &PL_sv_yes ) | |
278 | #define XST_mUNDEF(i) (ST(i) = &PL_sv_undef) | |
954c1994 GS |
279 | |
280 | #define XSRETURN(off) \ | |
281 | STMT_START { \ | |
61f9802b | 282 | const IV tmpXSoff = (off); \ |
a02b2239 | 283 | PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); \ |
954c1994 GS |
284 | return; \ |
285 | } STMT_END | |
286 | ||
80b92232 | 287 | #define XSRETURN_IV(v) STMT_START { XST_mIV(0,v); XSRETURN(1); } STMT_END |
108ccc45 | 288 | #define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END |
80b92232 | 289 | #define XSRETURN_NV(v) STMT_START { XST_mNV(0,v); XSRETURN(1); } STMT_END |
290 | #define XSRETURN_PV(v) STMT_START { XST_mPV(0,v); XSRETURN(1); } STMT_END | |
954c1994 | 291 | #define XSRETURN_PVN(v,n) STMT_START { XST_mPVN(0,v,n); XSRETURN(1); } STMT_END |
80b92232 | 292 | #define XSRETURN_NO STMT_START { XST_mNO(0); XSRETURN(1); } STMT_END |
293 | #define XSRETURN_YES STMT_START { XST_mYES(0); XSRETURN(1); } STMT_END | |
294 | #define XSRETURN_UNDEF STMT_START { XST_mUNDEF(0); XSRETURN(1); } STMT_END | |
295 | #define XSRETURN_EMPTY STMT_START { XSRETURN(0); } STMT_END | |
382b8d97 | 296 | |
77004dee | 297 | #define newXSproto(a,b,c,d) newXS_flags(a,b,c,d,0) |
720fb644 | 298 | |
299 | #ifdef XS_VERSION | |
ddb5125f | 300 | # define XS_VERSION_BOOTCHECK \ |
774d564b | 301 | STMT_START { \ |
95fad918 | 302 | SV *_sv; \ |
bd61b366 | 303 | const char *vn = NULL, *module = SvPV_nolen_const(ST(0)); \ |
774d564b | 304 | if (items >= 2) /* version supplied as bootstrap arg */ \ |
3de3296f | 305 | _sv = ST(1); \ |
774d564b | 306 | else { \ |
46fc3d4c | 307 | /* XXX GV_ADDWARN */ \ |
3de3296f | 308 | _sv = get_sv(Perl_form(aTHX_ "%s::%s", module, \ |
69f85790 | 309 | vn = "XS_VERSION"), 0); \ |
3de3296f | 310 | if (!_sv || !SvOK(_sv)) \ |
ddb5125f | 311 | _sv = get_sv(Perl_form(aTHX_ "%s::%s", module, \ |
69f85790 | 312 | vn = "VERSION"), 0); \ |
774d564b | 313 | } \ |
639e8c3d | 314 | if (_sv) { \ |
ddb5125f FR |
315 | SV *xpt = NULL; \ |
316 | SV *xssv = Perl_newSVpvn(aTHX_ STR_WITH_LEN(XS_VERSION)); \ | |
317 | SV *pmsv = sv_derived_from(_sv, "version") \ | |
318 | ? SvREFCNT_inc_simple_NN(_sv) \ | |
319 | : new_version(_sv); \ | |
320 | xssv = upg_version(xssv, 0); \ | |
321 | if ( vcmp(pmsv,xssv) ) { \ | |
322 | xpt = Perl_newSVpvf(aTHX_ "%s object version %"SVf \ | |
323 | " does not match %s%s%s%s %"SVf, \ | |
324 | module, \ | |
325 | SVfARG(Perl_sv_2mortal(aTHX_ vstringify(xssv))), \ | |
326 | vn ? "$" : "", vn ? module : "", \ | |
327 | vn ? "::" : "", \ | |
328 | vn ? vn : "bootstrap parameter", \ | |
329 | SVfARG(Perl_sv_2mortal(aTHX_ vstringify(pmsv)))); \ | |
330 | Perl_sv_2mortal(aTHX_ xpt); \ | |
331 | } \ | |
332 | SvREFCNT_dec(xssv); \ | |
333 | SvREFCNT_dec(pmsv); \ | |
334 | if (xpt) \ | |
335 | Perl_croak_sv(aTHX_ xpt); \ | |
639e8c3d | 336 | } \ |
80b92232 | 337 | } STMT_END |
720fb644 | 338 | #else |
c6af7a1a | 339 | # define XS_VERSION_BOOTCHECK |
720fb644 | 340 | #endif |
76e3520e | 341 | |
1e8125c6 FR |
342 | #define XS_APIVERSION_BOOTCHECK \ |
343 | STMT_START { \ | |
344 | SV *_xpt = NULL; \ | |
345 | SV *_compver = Perl_newSVpv(aTHX_ "v" PERL_API_VERSION_STRING, 0); \ | |
346 | SV *_runver = new_version(PL_apiversion); \ | |
347 | _compver = upg_version(_compver, 0); \ | |
348 | if (vcmp(_compver, _runver)) { \ | |
349 | _xpt = Perl_newSVpvf(aTHX_ "Perl API version %"SVf \ | |
350 | " of %s does not match %"SVf, \ | |
351 | SVfARG(Perl_sv_2mortal(aTHX_ vstringify(_compver))), \ | |
352 | SvPV_nolen_const(ST(0)), \ | |
353 | SVfARG(Perl_sv_2mortal(aTHX_ vstringify(_runver)))); \ | |
354 | Perl_sv_2mortal(aTHX_ _xpt); \ | |
355 | } \ | |
356 | SvREFCNT_dec(_compver); \ | |
357 | SvREFCNT_dec(_runver); \ | |
358 | if (_xpt) \ | |
359 | Perl_croak_sv(aTHX_ _xpt); \ | |
360 | } STMT_END | |
361 | ||
9b5c3821 MHM |
362 | #ifdef NO_XSLOCKS |
363 | # define dXCPT dJMPENV; int rEtV = 0 | |
364 | # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0) | |
365 | # define XCPT_TRY_END JMPENV_POP; | |
366 | # define XCPT_CATCH if (rEtV != 0) | |
367 | # define XCPT_RETHROW JMPENV_JUMP(rEtV) | |
368 | #endif | |
0ca3a874 | 369 | |
1e8125c6 FR |
370 | /* |
371 | The DBM_setFilter & DBM_ckFilter macros are only used by | |
372 | the *DB*_File modules | |
6a31061a PM |
373 | */ |
374 | ||
375 | #define DBM_setFilter(db_type,code) \ | |
891c2e08 | 376 | STMT_START { \ |
6a31061a PM |
377 | if (db_type) \ |
378 | RETVAL = sv_mortalcopy(db_type) ; \ | |
379 | ST(0) = RETVAL ; \ | |
380 | if (db_type && (code == &PL_sv_undef)) { \ | |
381 | SvREFCNT_dec(db_type) ; \ | |
382 | db_type = NULL ; \ | |
383 | } \ | |
384 | else if (code) { \ | |
385 | if (db_type) \ | |
386 | sv_setsv(db_type, code) ; \ | |
387 | else \ | |
388 | db_type = newSVsv(code) ; \ | |
389 | } \ | |
891c2e08 | 390 | } STMT_END |
6a31061a PM |
391 | |
392 | #define DBM_ckFilter(arg,type,name) \ | |
891c2e08 | 393 | STMT_START { \ |
6a31061a PM |
394 | if (db->type) { \ |
395 | if (db->filtering) { \ | |
396 | croak("recursion detected in %s", name) ; \ | |
397 | } \ | |
398 | ENTER ; \ | |
399 | SAVETMPS ; \ | |
400 | SAVEINT(db->filtering) ; \ | |
401 | db->filtering = TRUE ; \ | |
414bf5ae | 402 | SAVE_DEFSV ; \ |
5bbd4290 PM |
403 | if (name[7] == 's') \ |
404 | arg = newSVsv(arg); \ | |
414bf5ae | 405 | DEFSV_set(arg) ; \ |
6a31061a PM |
406 | SvTEMP_off(arg) ; \ |
407 | PUSHMARK(SP) ; \ | |
408 | PUTBACK ; \ | |
409 | (void) perl_call_sv(db->type, G_DISCARD); \ | |
410 | SPAGAIN ; \ | |
411 | PUTBACK ; \ | |
412 | FREETMPS ; \ | |
413 | LEAVE ; \ | |
5bbd4290 PM |
414 | if (name[7] == 's'){ \ |
415 | arg = sv_2mortal(arg); \ | |
416 | } \ | |
891c2e08 | 417 | } } STMT_END |
6a31061a | 418 | |
51371543 | 419 | #if 1 /* for compatibility */ |
dc9e4912 GS |
420 | # define VTBL_sv &PL_vtbl_sv |
421 | # define VTBL_env &PL_vtbl_env | |
422 | # define VTBL_envelem &PL_vtbl_envelem | |
423 | # define VTBL_sig &PL_vtbl_sig | |
424 | # define VTBL_sigelem &PL_vtbl_sigelem | |
425 | # define VTBL_pack &PL_vtbl_pack | |
426 | # define VTBL_packelem &PL_vtbl_packelem | |
427 | # define VTBL_dbline &PL_vtbl_dbline | |
428 | # define VTBL_isa &PL_vtbl_isa | |
429 | # define VTBL_isaelem &PL_vtbl_isaelem | |
430 | # define VTBL_arylen &PL_vtbl_arylen | |
c696a6a4 | 431 | # define VTBL_glob &PL_vtbl_glob |
dc9e4912 GS |
432 | # define VTBL_mglob &PL_vtbl_mglob |
433 | # define VTBL_nkeys &PL_vtbl_nkeys | |
434 | # define VTBL_taint &PL_vtbl_taint | |
435 | # define VTBL_substr &PL_vtbl_substr | |
436 | # define VTBL_vec &PL_vtbl_vec | |
437 | # define VTBL_pos &PL_vtbl_pos | |
438 | # define VTBL_bm &PL_vtbl_bm | |
439 | # define VTBL_fm &PL_vtbl_fm | |
440 | # define VTBL_uvar &PL_vtbl_uvar | |
441 | # define VTBL_defelem &PL_vtbl_defelem | |
442 | # define VTBL_regexp &PL_vtbl_regexp | |
443 | # define VTBL_regdata &PL_vtbl_regdata | |
444 | # define VTBL_regdatum &PL_vtbl_regdatum | |
445 | # ifdef USE_LOCALE_COLLATE | |
446 | # define VTBL_collxfrm &PL_vtbl_collxfrm | |
447 | # endif | |
9e7bc3e8 JD |
448 | # define VTBL_amagic &PL_vtbl_amagic |
449 | # define VTBL_amagicelem &PL_vtbl_amagicelem | |
dc9e4912 GS |
450 | #endif |
451 | ||
6f4183fe | 452 | #include "perlapi.h" |
c6af7a1a | 453 | |
e8ee3774 | 454 | #if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_NO_GET_CONTEXT) && !defined(PERL_CORE) |
c5be433b GS |
455 | # undef aTHX |
456 | # undef aTHX_ | |
54aff467 GS |
457 | # define aTHX PERL_GET_THX |
458 | # define aTHX_ aTHX, | |
54aff467 GS |
459 | #endif |
460 | ||
acfe0abc | 461 | #if defined(PERL_IMPLICIT_SYS) && !defined(PERL_CORE) |
c6af7a1a | 462 | # ifndef NO_XSLOCKS |
2986a63f JH |
463 | # if defined (NETWARE) && defined (USE_STDIO) |
464 | # define times PerlProc_times | |
465 | # define setuid PerlProc_setuid | |
466 | # define setgid PerlProc_setgid | |
467 | # define getpid PerlProc_getpid | |
468 | # define pause PerlProc_pause | |
469 | # define exit PerlProc_exit | |
470 | # define _exit PerlProc__exit | |
471 | # else | |
c6af7a1a GS |
472 | # undef closedir |
473 | # undef opendir | |
474 | # undef stdin | |
475 | # undef stdout | |
476 | # undef stderr | |
477 | # undef feof | |
478 | # undef ferror | |
479 | # undef fgetpos | |
480 | # undef ioctl | |
481 | # undef getlogin | |
482 | # undef setjmp | |
483 | # undef getc | |
484 | # undef ungetc | |
485 | # undef fileno | |
486 | ||
cb69f87a | 487 | /* Following symbols were giving redefinition errors while building extensions - sgp 17th Oct 2000 */ |
2986a63f JH |
488 | #ifdef NETWARE |
489 | # undef readdir | |
490 | # undef fstat | |
491 | # undef stat | |
492 | # undef longjmp | |
493 | # undef endhostent | |
494 | # undef endnetent | |
495 | # undef endprotoent | |
496 | # undef endservent | |
497 | # undef gethostbyaddr | |
498 | # undef gethostbyname | |
499 | # undef gethostent | |
500 | # undef getnetbyaddr | |
501 | # undef getnetbyname | |
502 | # undef getnetent | |
503 | # undef getprotobyname | |
504 | # undef getprotobynumber | |
505 | # undef getprotoent | |
506 | # undef getservbyname | |
507 | # undef getservbyport | |
508 | # undef getservent | |
509 | # undef inet_ntoa | |
510 | # undef sethostent | |
511 | # undef setnetent | |
512 | # undef setprotoent | |
513 | # undef setservent | |
514 | #endif /* NETWARE */ | |
515 | ||
fa58a56f S |
516 | /* to avoid warnings: "xyz" redefined */ |
517 | #ifdef WIN32 | |
518 | # undef popen | |
519 | # undef pclose | |
520 | #endif /* WIN32 */ | |
521 | ||
1018e26f NIS |
522 | # undef socketpair |
523 | ||
c6af7a1a GS |
524 | # define mkdir PerlDir_mkdir |
525 | # define chdir PerlDir_chdir | |
526 | # define rmdir PerlDir_rmdir | |
527 | # define closedir PerlDir_close | |
528 | # define opendir PerlDir_open | |
529 | # define readdir PerlDir_read | |
530 | # define rewinddir PerlDir_rewind | |
531 | # define seekdir PerlDir_seek | |
532 | # define telldir PerlDir_tell | |
533 | # define putenv PerlEnv_putenv | |
534 | # define getenv PerlEnv_getenv | |
b2af26b1 | 535 | # define uname PerlEnv_uname |
197357d0 GS |
536 | # define stdin PerlSIO_stdin |
537 | # define stdout PerlSIO_stdout | |
538 | # define stderr PerlSIO_stderr | |
f9415d23 NIS |
539 | # define fopen PerlSIO_fopen |
540 | # define fclose PerlSIO_fclose | |
541 | # define feof PerlSIO_feof | |
542 | # define ferror PerlSIO_ferror | |
b6d726d6 | 543 | # define clearerr PerlSIO_clearerr |
f9415d23 | 544 | # define getc PerlSIO_getc |
20c8f8f9 | 545 | # define fgets PerlSIO_fgets |
f9415d23 NIS |
546 | # define fputc PerlSIO_fputc |
547 | # define fputs PerlSIO_fputs | |
548 | # define fflush PerlSIO_fflush | |
549 | # define ungetc PerlSIO_ungetc | |
550 | # define fileno PerlSIO_fileno | |
551 | # define fdopen PerlSIO_fdopen | |
552 | # define freopen PerlSIO_freopen | |
553 | # define fread PerlSIO_fread | |
554 | # define fwrite PerlSIO_fwrite | |
22a46b6e NIS |
555 | # define setbuf PerlSIO_setbuf |
556 | # define setvbuf PerlSIO_setvbuf | |
557 | # define setlinebuf PerlSIO_setlinebuf | |
1f59ddd9 GS |
558 | # define stdoutf PerlSIO_stdoutf |
559 | # define vfprintf PerlSIO_vprintf | |
f9415d23 NIS |
560 | # define ftell PerlSIO_ftell |
561 | # define fseek PerlSIO_fseek | |
562 | # define fgetpos PerlSIO_fgetpos | |
563 | # define fsetpos PerlSIO_fsetpos | |
564 | # define frewind PerlSIO_rewind | |
565 | # define tmpfile PerlSIO_tmpfile | |
c6af7a1a GS |
566 | # define access PerlLIO_access |
567 | # define chmod PerlLIO_chmod | |
568 | # define chsize PerlLIO_chsize | |
569 | # define close PerlLIO_close | |
570 | # define dup PerlLIO_dup | |
571 | # define dup2 PerlLIO_dup2 | |
572 | # define flock PerlLIO_flock | |
573 | # define fstat PerlLIO_fstat | |
574 | # define ioctl PerlLIO_ioctl | |
575 | # define isatty PerlLIO_isatty | |
6b980173 | 576 | # define link PerlLIO_link |
c6af7a1a GS |
577 | # define lseek PerlLIO_lseek |
578 | # define lstat PerlLIO_lstat | |
579 | # define mktemp PerlLIO_mktemp | |
580 | # define open PerlLIO_open | |
581 | # define read PerlLIO_read | |
582 | # define rename PerlLIO_rename | |
583 | # define setmode PerlLIO_setmode | |
4f49e16e | 584 | # define stat(buf,sb) PerlLIO_stat(buf,sb) |
c6af7a1a GS |
585 | # define tmpnam PerlLIO_tmpnam |
586 | # define umask PerlLIO_umask | |
587 | # define unlink PerlLIO_unlink | |
588 | # define utime PerlLIO_utime | |
589 | # define write PerlLIO_write | |
590 | # define malloc PerlMem_malloc | |
591 | # define realloc PerlMem_realloc | |
592 | # define free PerlMem_free | |
593 | # define abort PerlProc_abort | |
594 | # define exit PerlProc_exit | |
595 | # define _exit PerlProc__exit | |
596 | # define execl PerlProc_execl | |
597 | # define execv PerlProc_execv | |
598 | # define execvp PerlProc_execvp | |
599 | # define getuid PerlProc_getuid | |
600 | # define geteuid PerlProc_geteuid | |
601 | # define getgid PerlProc_getgid | |
602 | # define getegid PerlProc_getegid | |
603 | # define getlogin PerlProc_getlogin | |
604 | # define kill PerlProc_kill | |
605 | # define killpg PerlProc_killpg | |
606 | # define pause PerlProc_pause | |
607 | # define popen PerlProc_popen | |
608 | # define pclose PerlProc_pclose | |
609 | # define pipe PerlProc_pipe | |
610 | # define setuid PerlProc_setuid | |
611 | # define setgid PerlProc_setgid | |
612 | # define sleep PerlProc_sleep | |
613 | # define times PerlProc_times | |
614 | # define wait PerlProc_wait | |
615 | # define setjmp PerlProc_setjmp | |
616 | # define longjmp PerlProc_longjmp | |
617 | # define signal PerlProc_signal | |
7766f137 | 618 | # define getpid PerlProc_getpid |
57ab3dfe | 619 | # define gettimeofday PerlProc_gettimeofday |
c6af7a1a GS |
620 | # define htonl PerlSock_htonl |
621 | # define htons PerlSock_htons | |
622 | # define ntohl PerlSock_ntohl | |
623 | # define ntohs PerlSock_ntohs | |
624 | # define accept PerlSock_accept | |
625 | # define bind PerlSock_bind | |
626 | # define connect PerlSock_connect | |
627 | # define endhostent PerlSock_endhostent | |
628 | # define endnetent PerlSock_endnetent | |
629 | # define endprotoent PerlSock_endprotoent | |
630 | # define endservent PerlSock_endservent | |
631 | # define gethostbyaddr PerlSock_gethostbyaddr | |
632 | # define gethostbyname PerlSock_gethostbyname | |
633 | # define gethostent PerlSock_gethostent | |
634 | # define gethostname PerlSock_gethostname | |
635 | # define getnetbyaddr PerlSock_getnetbyaddr | |
636 | # define getnetbyname PerlSock_getnetbyname | |
637 | # define getnetent PerlSock_getnetent | |
638 | # define getpeername PerlSock_getpeername | |
639 | # define getprotobyname PerlSock_getprotobyname | |
640 | # define getprotobynumber PerlSock_getprotobynumber | |
641 | # define getprotoent PerlSock_getprotoent | |
642 | # define getservbyname PerlSock_getservbyname | |
643 | # define getservbyport PerlSock_getservbyport | |
644 | # define getservent PerlSock_getservent | |
645 | # define getsockname PerlSock_getsockname | |
646 | # define getsockopt PerlSock_getsockopt | |
647 | # define inet_addr PerlSock_inet_addr | |
648 | # define inet_ntoa PerlSock_inet_ntoa | |
649 | # define listen PerlSock_listen | |
650 | # define recv PerlSock_recv | |
651 | # define recvfrom PerlSock_recvfrom | |
652 | # define select PerlSock_select | |
653 | # define send PerlSock_send | |
654 | # define sendto PerlSock_sendto | |
655 | # define sethostent PerlSock_sethostent | |
656 | # define setnetent PerlSock_setnetent | |
657 | # define setprotoent PerlSock_setprotoent | |
658 | # define setservent PerlSock_setservent | |
659 | # define setsockopt PerlSock_setsockopt | |
660 | # define shutdown PerlSock_shutdown | |
661 | # define socket PerlSock_socket | |
662 | # define socketpair PerlSock_socketpair | |
2986a63f | 663 | # endif /* NETWARE && USE_STDIO */ |
21c5e947 JH |
664 | |
665 | # ifdef USE_SOCKETS_AS_HANDLES | |
666 | # undef fd_set | |
667 | # undef FD_SET | |
668 | # undef FD_CLR | |
669 | # undef FD_ISSET | |
670 | # undef FD_ZERO | |
671 | # define fd_set Perl_fd_set | |
672 | # define FD_SET(n,p) PERL_FD_SET(n,p) | |
673 | # define FD_CLR(n,p) PERL_FD_CLR(n,p) | |
674 | # define FD_ISSET(n,p) PERL_FD_ISSET(n,p) | |
675 | # define FD_ZERO(p) PERL_FD_ZERO(p) | |
676 | # endif /* USE_SOCKETS_AS_HANDLES */ | |
677 | ||
c6af7a1a | 678 | # endif /* NO_XSLOCKS */ |
acfe0abc | 679 | #endif /* PERL_IMPLICIT_SYS && !PERL_CORE */ |
b4ba0ab9 | 680 | |
cfeeb022 | 681 | #endif /* _INC_PERL_XSUB_H */ /* include guard */ |
ad73156c AL |
682 | |
683 | /* | |
684 | * Local variables: | |
685 | * c-indentation-style: bsd | |
686 | * c-basic-offset: 4 | |
687 | * indent-tabs-mode: t | |
688 | * End: | |
689 | * | |
690 | * ex: set ts=8 sts=4 sw=4 noet: | |
691 | */ |