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