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