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