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