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