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