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