This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlapi: Document UVf, as deprecated
[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/*
3f620621 17=for apidoc_section $XS
ccfc67b7 18
6e488466
KW
19F<xsubpp> compiles XS code into C. See L<perlutil/xsubpp>.
20
e439aacb
KW
21=for comment
22Some variables below are flagged with 'u' because Devel::PPPort can't currently
23readily test them as they spring into existence by compiling with xsubpp.
24
25=for apidoc Amnu|char*|CLASS
954c1994 26Variable which is setup by C<xsubpp> to indicate the
fbe13c60
KW
27class name for a C++ XS constructor. This is always a C<char*>. See
28C<L</THIS>>.
954c1994 29
e439aacb 30=for apidoc Amnu|type|RETVAL
954c1994 31Variable which is setup by C<xsubpp> to hold the return value for an
72d33970 32XSUB. This is always the proper type for the XSUB. See
954c1994
GS
33L<perlxs/"The RETVAL Variable">.
34
e439aacb 35=for apidoc Amnu|type|THIS
954c1994 36Variable which is setup by C<xsubpp> to designate the object in a C++
fbe13c60 37XSUB. This is always the proper type for the C++ object. See C<L</CLASS>> and
954c1994
GS
38L<perlxs/"Using XS With C++">.
39
9f2ea798
DM
40=for apidoc Amn|I32|ax
41Variable which is setup by C<xsubpp> to indicate the stack base offset,
42used by the C<ST>, C<XSprePUSH> and C<XSRETURN> macros. The C<dMARK> macro
43must be called prior to setup the C<MARK> variable.
44
954c1994
GS
45=for apidoc Amn|I32|items
46Variable which is setup by C<xsubpp> to indicate the number of
47items on the stack. See L<perlxs/"Variable-length Parameter Lists">.
48
49=for apidoc Amn|I32|ix
50Variable which is setup by C<xsubpp> to indicate which of an
51XSUB's aliases was used to invoke it. See L<perlxs/"The ALIAS: Keyword">.
52
53=for apidoc Am|SV*|ST|int ix
54Used to access elements on the XSUB's stack.
55
e439aacb 56=for apidoc Ay||XS|name
954c1994 57Macro to declare an XSUB and its C parameter list. This is handled by
56e94d98
KW
58C<xsubpp>. It is the same as using the more explicit C<XS_EXTERNAL> macro; the
59latter is preferred.
954c1994 60
e439aacb 61=for apidoc Ayu||XS_INTERNAL|name
e64345f8
S
62Macro to declare an XSUB and its C parameter list without exporting the symbols.
63This is handled by C<xsubpp> and generally preferable over exporting the XSUB
0cb93b3a 64symbols unnecessarily.
e64345f8 65
e439aacb
KW
66=for comment
67XS_INTERNAL marked 'u' because declaring a function static within our test
68function doesn't work
69
70=for apidoc Ay||XS_EXTERNAL|name
e64345f8 71Macro to declare an XSUB and its C parameter list explicitly exporting the symbols.
e64345f8 72
e439aacb 73=for apidoc Ay||XSPROTO|name
dbb22d67
KW
74Macro used by C<L</XS_INTERNAL>> and C<L</XS_EXTERNAL>> to declare a function
75prototype. You probably shouldn't be using this directly yourself.
76
4e5171e9 77=for apidoc Amns||dAX
9f2ea798
DM
78Sets up the C<ax> variable.
79This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
80
4e5171e9 81=for apidoc Amns||dAXMARK
557b887a
SS
82Sets up the C<ax> variable and stack marker variable C<mark>.
83This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
84
4e5171e9 85=for apidoc Amns||dITEMS
9f2ea798
DM
86Sets up the C<items> variable.
87This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
88
4e5171e9 89=for apidoc Amns||dXSARGS
796b6530 90Sets up stack and mark pointers for an XSUB, calling C<dSP> and C<dMARK>.
9f2ea798
DM
91Sets up the C<ax> and C<items> variables by calling C<dAX> and C<dITEMS>.
92This is usually handled automatically by C<xsubpp>.
954c1994 93
4e5171e9 94=for apidoc Amns||dXSI32
954c1994
GS
95Sets up the C<ix> variable for an XSUB which has aliases. This is usually
96handled automatically by C<xsubpp>.
97
4e5171e9 98=for apidoc Amns||dUNDERBAR
72d33970
FC
99Sets up any variable needed by the C<UNDERBAR> macro. It used to define
100C<padoff_du>, but it is currently a noop. However, it is strongly advised
483ce06a 101to still use it for ensuring past and future compatibility.
88037a85 102
78342678 103=for apidoc AmnU||UNDERBAR
796b6530
KW
104The SV* corresponding to the C<$_> variable. Works even if there
105is a lexical C<$_> in scope.
88037a85 106
954c1994
GS
107=cut
108*/
109
53c1dcc0 110#ifndef PERL_UNUSED_ARG
c707756e 111# define PERL_UNUSED_ARG(x) ((void)x)
ad73156c 112#endif
53c1dcc0
AL
113#ifndef PERL_UNUSED_VAR
114# define PERL_UNUSED_VAR(x) ((void)x)
115#endif
ad73156c 116
3280af22 117#define ST(off) PL_stack_base[ax + (off)]
a0d0e21e 118
081304ca
AMS
119/* XSPROTO() is also used by SWIG like this:
120 *
121 * typedef XSPROTO(SwigPerlWrapper);
122 * typedef SwigPerlWrapper *SwigPerlWrapperPtr;
123 *
124 * This code needs to be compilable under both C and C++.
125 *
126 * Don't forget to change the __attribute__unused__ version of XS()
127 * below too if you change XSPROTO() here.
128 */
e64345f8 129
ab1478f7
S
130/* XS_INTERNAL is the explicit static-linkage variant of the default
131 * XS macro.
e64345f8 132 *
ab1478f7
S
133 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
134 * "STATIC", ie. it exports XSUB symbols. You probably don't want that.
e64345f8
S
135 */
136
53dfb2b7 137#define XSPROTO(name) void name(pTHX_ CV* cv __attribute__unused__)
081304ca 138
27da23d5 139#undef XS
e64345f8
S
140#undef XS_EXTERNAL
141#undef XS_INTERNAL
d308986b 142#if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
ab1478f7 143# define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
fe6ca737 144# define XS_INTERNAL(name) STATIC XSPROTO(name)
f12ee906
AC
145#elif defined(__cplusplus)
146# define XS_EXTERNAL(name) extern "C" XSPROTO(name)
147# define XS_INTERNAL(name) static XSPROTO(name)
148#elif defined(HASATTRIBUTE_UNUSED)
149# define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
150# define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
151#else
152# define XS_EXTERNAL(name) XSPROTO(name)
153# define XS_INTERNAL(name) STATIC XSPROTO(name)
a0d0e21e
LW
154#endif
155
0cb93b3a
S
156/* We do export xsub symbols by default for the public XS macro.
157 * Try explicitly using XS_INTERNAL/XS_EXTERNAL instead, please. */
158#define XS(name) XS_EXTERNAL(name)
e64345f8 159
514696af 160#define dAX const I32 ax = (I32)(MARK - PL_stack_base + 1)
9f2ea798 161
557b887a 162#define dAXMARK \
a3b680e6 163 I32 ax = POPMARK; \
eb578fdb 164 SV **mark = PL_stack_base + ax++
557b887a 165
514696af 166#define dITEMS I32 items = (I32)(SP - MARK)
9f2ea798 167
c707756e 168#define dXSARGS \
557b887a 169 dSP; dAXMARK; dITEMS
9a189793
DD
170/* These 3 macros are replacements for dXSARGS macro only in bootstrap.
171 They factor out common code in every BOOT XSUB. Computation of vars mark
172 and items will optimize away in most BOOT functions. Var ax can never be
173 optimized away since BOOT must return &PL_sv_yes by default from xsubpp.
174 Note these macros are not drop in replacements for dXSARGS since they set
175 PL_xsubfilename. */
c707756e 176#define dXSBOOTARGSXSAPIVERCHK \
9a189793 177 I32 ax = XS_BOTHVERSION_SETXSUBFN_POPMARK_BOOTCHECK; \
31346494 178 SV **mark = PL_stack_base + ax - 1; dSP; dITEMS
c707756e 179#define dXSBOOTARGSAPIVERCHK \
9a189793 180 I32 ax = XS_APIVERSION_SETXSUBFN_POPMARK_BOOTCHECK; \
31346494 181 SV **mark = PL_stack_base + ax - 1; dSP; dITEMS
9a189793
DD
182/* dXSBOOTARGSNOVERCHK has no API in xsubpp to choose it so do
183#undef dXSBOOTARGSXSAPIVERCHK
184#define dXSBOOTARGSXSAPIVERCHK dXSBOOTARGSNOVERCHK */
c707756e 185#define dXSBOOTARGSNOVERCHK \
9a189793 186 I32 ax = XS_SETXSUBFN_POPMARK; \
31346494 187 SV **mark = PL_stack_base + ax - 1; dSP; dITEMS
a0d0e21e 188
a3b680e6 189#define dXSTARG SV * const targ = ((PL_op->op_private & OPpENTERSUB_HASTARG) \
8a7fc0dc
GS
190 ? PAD_SV(PL_op->op_targ) : sv_newmortal())
191
b26a54d0
GS
192/* Should be used before final PUSHi etc. if not in PPCODE section. */
193#define XSprePUSH (sp = PL_stack_base + ax - 1)
194
a0d0e21e
LW
195#define XSANY CvXSUBANY(cv)
196
197#define dXSI32 I32 ix = XSANY.any_i32
198
cfc02341
IZ
199#ifdef __cplusplus
200# define XSINTERFACE_CVT(ret,name) ret (*name)(...)
4ef0c66e 201# define XSINTERFACE_CVT_ANON(ret) ret (*)(...)
cfc02341
IZ
202#else
203# define XSINTERFACE_CVT(ret,name) ret (*name)()
4ef0c66e 204# define XSINTERFACE_CVT_ANON(ret) ret (*)()
cfc02341
IZ
205#endif
206#define dXSFUNCTION(ret) XSINTERFACE_CVT(ret,XSFUNCTION)
4ef0c66e 207#define XSINTERFACE_FUNC(ret,cv,f) ((XSINTERFACE_CVT_ANON(ret))(f))
cfc02341 208#define XSINTERFACE_FUNC_SET(cv,f) \
a12c3db7 209 CvXSUBANY(cv).any_dxptr = (void (*) (pTHX_ void*))(f)
cfc02341 210
483ce06a
VP
211#define dUNDERBAR dNOOP
212#define UNDERBAR find_rundefsv()
88037a85 213
748a9306
LW
214/* Simple macros to put new mortal values onto the stack. */
215/* Typically used to return values from XS functions. */
954c1994
GS
216
217/*
3f620621 218=for apidoc_section $stack
ccfc67b7 219
954c1994
GS
220=for apidoc Am|void|XST_mIV|int pos|IV iv
221Place an integer into the specified position C<pos> on the stack. The
222value is stored in a new mortal SV.
223
224=for apidoc Am|void|XST_mNV|int pos|NV nv
225Place a double into the specified position C<pos> on the stack. The value
226is stored in a new mortal SV.
227
228=for apidoc Am|void|XST_mPV|int pos|char* str
229Place a copy of a string into the specified position C<pos> on the stack.
230The value is stored in a new mortal SV.
231
022f6832
KW
232=for apidoc Am|void|XST_mUV|int pos|UV uv
233Place an unsigned integer into the specified position C<pos> on the stack. The
234value is stored in a new mortal SV.
235
954c1994
GS
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
4e5171e9 264=for apidoc Amns||XSRETURN_NO
954c1994
GS
265Return C<&PL_sv_no> from an XSUB immediately. Uses C<XST_mNO>.
266
4e5171e9 267=for apidoc Amns||XSRETURN_YES
954c1994
GS
268Return C<&PL_sv_yes> from an XSUB immediately. Uses C<XST_mYES>.
269
4e5171e9 270=for apidoc Amns||XSRETURN_UNDEF
954c1994
GS
271Return C<&PL_sv_undef> from an XSUB immediately. Uses C<XST_mUNDEF>.
272
4e5171e9 273=for apidoc Amns||XSRETURN_EMPTY
954c1994
GS
274Return an empty list from an XSUB immediately.
275
c578083c 276=for apidoc AmU||newXSproto|char* name|XSUBADDR_t f|char* filename|const char *proto
954c1994
GS
277Used by C<xsubpp> to hook up XSUBs as Perl subs. Adds Perl prototypes to
278the subs.
279
78342678 280=for apidoc AmnU||XS_VERSION
954c1994 281The version identifier for an XS module. This is usually
fbe13c60
KW
282handled automatically by C<ExtUtils::MakeMaker>. See
283C<L</XS_VERSION_BOOTCHECK>>.
954c1994 284
4e5171e9 285=for apidoc Amns||XS_VERSION_BOOTCHECK
796b6530 286Macro to verify that a PM module's C<$VERSION> variable matches the XS
954c1994
GS
287module's C<XS_VERSION> variable. This is usually handled automatically by
288C<xsubpp>. See L<perlxs/"The VERSIONCHECK: Keyword">.
289
4e5171e9 290=for apidoc Amns||XS_APIVERSION_BOOTCHECK
1e8125c6
FR
291Macro to verify that the perl api version an XS module has been compiled against
292matches the api version of the perl interpreter it's being loaded into.
293
3f620621 294=for apidoc_section $exceptions
0ca3a874 295
4e5171e9 296=for apidoc Amns||dXCPT
2dfe1b17 297Set up necessary local variables for exception handling.
0ca3a874
MHM
298See L<perlguts/"Exception Handling">.
299
78342678 300=for apidoc AmnU||XCPT_TRY_START
0ca3a874
MHM
301Starts a try block. See L<perlguts/"Exception Handling">.
302
78342678 303=for apidoc AmnU||XCPT_TRY_END
0ca3a874
MHM
304Ends a try block. See L<perlguts/"Exception Handling">.
305
78342678 306=for apidoc AmnU||XCPT_CATCH
0ca3a874
MHM
307Introduces a catch block. See L<perlguts/"Exception Handling">.
308
4e5171e9 309=for apidoc Amns||XCPT_RETHROW
0ca3a874
MHM
310Rethrows a previously caught exception. See L<perlguts/"Exception Handling">.
311
954c1994
GS
312=cut
313*/
314
4633a7c4 315#define XST_mIV(i,v) (ST(i) = sv_2mortal(newSViv(v)) )
108ccc45 316#define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) )
4633a7c4
LW
317#define XST_mNV(i,v) (ST(i) = sv_2mortal(newSVnv(v)) )
318#define XST_mPV(i,v) (ST(i) = sv_2mortal(newSVpv(v,0)))
ad25789c 319#define XST_mPVN(i,v,n) (ST(i) = newSVpvn_flags(v,n, SVs_TEMP))
3280af22
NIS
320#define XST_mNO(i) (ST(i) = &PL_sv_no )
321#define XST_mYES(i) (ST(i) = &PL_sv_yes )
322#define XST_mUNDEF(i) (ST(i) = &PL_sv_undef)
954c1994
GS
323
324#define XSRETURN(off) \
325 STMT_START { \
61f9802b 326 const IV tmpXSoff = (off); \
9e77582c 327 assert(tmpXSoff >= 0);\
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 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 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 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)) { \
1cbe4e6f 417 SvREFCNT_dec_NN(db_type) ; \
6a31061a
PM
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
e8ee3774 487#if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_NO_GET_CONTEXT) && !defined(PERL_CORE)
c5be433b
GS
488# undef aTHX
489# undef aTHX_
54aff467
GS
490# define aTHX PERL_GET_THX
491# define aTHX_ aTHX,
54aff467
GS
492#endif
493
acfe0abc 494#if defined(PERL_IMPLICIT_SYS) && !defined(PERL_CORE)
c6af7a1a 495# ifndef NO_XSLOCKS
2986a63f
JH
496# if defined (NETWARE) && defined (USE_STDIO)
497# define times PerlProc_times
498# define setuid PerlProc_setuid
499# define setgid PerlProc_setgid
500# define getpid PerlProc_getpid
501# define pause PerlProc_pause
502# define exit PerlProc_exit
503# define _exit PerlProc__exit
504# else
c6af7a1a
GS
505# undef closedir
506# undef opendir
507# undef stdin
508# undef stdout
509# undef stderr
510# undef feof
511# undef ferror
512# undef fgetpos
513# undef ioctl
514# undef getlogin
515# undef setjmp
516# undef getc
517# undef ungetc
518# undef fileno
519
cb69f87a 520/* Following symbols were giving redefinition errors while building extensions - sgp 17th Oct 2000 */
2986a63f
JH
521#ifdef NETWARE
522# undef readdir
523# undef fstat
524# undef stat
525# undef longjmp
526# undef endhostent
527# undef endnetent
528# undef endprotoent
529# undef endservent
530# undef gethostbyaddr
531# undef gethostbyname
532# undef gethostent
533# undef getnetbyaddr
534# undef getnetbyname
535# undef getnetent
536# undef getprotobyname
537# undef getprotobynumber
538# undef getprotoent
539# undef getservbyname
540# undef getservbyport
541# undef getservent
542# undef inet_ntoa
543# undef sethostent
544# undef setnetent
545# undef setprotoent
546# undef setservent
547#endif /* NETWARE */
548
fa58a56f
S
549/* to avoid warnings: "xyz" redefined */
550#ifdef WIN32
551# undef popen
552# undef pclose
553#endif /* WIN32 */
554
1018e26f
NIS
555# undef socketpair
556
c6af7a1a
GS
557# define mkdir PerlDir_mkdir
558# define chdir PerlDir_chdir
559# define rmdir PerlDir_rmdir
560# define closedir PerlDir_close
561# define opendir PerlDir_open
562# define readdir PerlDir_read
563# define rewinddir PerlDir_rewind
564# define seekdir PerlDir_seek
565# define telldir PerlDir_tell
566# define putenv PerlEnv_putenv
567# define getenv PerlEnv_getenv
b2af26b1 568# define uname PerlEnv_uname
197357d0
GS
569# define stdin PerlSIO_stdin
570# define stdout PerlSIO_stdout
571# define stderr PerlSIO_stderr
f9415d23
NIS
572# define fopen PerlSIO_fopen
573# define fclose PerlSIO_fclose
574# define feof PerlSIO_feof
575# define ferror PerlSIO_ferror
b6d726d6 576# define clearerr PerlSIO_clearerr
f9415d23 577# define getc PerlSIO_getc
20c8f8f9 578# define fgets PerlSIO_fgets
f9415d23
NIS
579# define fputc PerlSIO_fputc
580# define fputs PerlSIO_fputs
581# define fflush PerlSIO_fflush
582# define ungetc PerlSIO_ungetc
583# define fileno PerlSIO_fileno
584# define fdopen PerlSIO_fdopen
585# define freopen PerlSIO_freopen
586# define fread PerlSIO_fread
587# define fwrite PerlSIO_fwrite
22a46b6e
NIS
588# define setbuf PerlSIO_setbuf
589# define setvbuf PerlSIO_setvbuf
590# define setlinebuf PerlSIO_setlinebuf
1f59ddd9
GS
591# define stdoutf PerlSIO_stdoutf
592# define vfprintf PerlSIO_vprintf
f9415d23
NIS
593# define ftell PerlSIO_ftell
594# define fseek PerlSIO_fseek
595# define fgetpos PerlSIO_fgetpos
596# define fsetpos PerlSIO_fsetpos
597# define frewind PerlSIO_rewind
598# define tmpfile PerlSIO_tmpfile
c6af7a1a
GS
599# define access PerlLIO_access
600# define chmod PerlLIO_chmod
601# define chsize PerlLIO_chsize
602# define close PerlLIO_close
603# define dup PerlLIO_dup
604# define dup2 PerlLIO_dup2
605# define flock PerlLIO_flock
606# define fstat PerlLIO_fstat
607# define ioctl PerlLIO_ioctl
608# define isatty PerlLIO_isatty
6b980173 609# define link PerlLIO_link
c6af7a1a
GS
610# define lseek PerlLIO_lseek
611# define lstat PerlLIO_lstat
612# define mktemp PerlLIO_mktemp
613# define open PerlLIO_open
614# define read PerlLIO_read
615# define rename PerlLIO_rename
616# define setmode PerlLIO_setmode
4f49e16e 617# define stat(buf,sb) PerlLIO_stat(buf,sb)
c6af7a1a
GS
618# define tmpnam PerlLIO_tmpnam
619# define umask PerlLIO_umask
620# define unlink PerlLIO_unlink
621# define utime PerlLIO_utime
622# define write PerlLIO_write
623# define malloc PerlMem_malloc
5ace197f 624# define calloc PerlMem_calloc
c6af7a1a
GS
625# define realloc PerlMem_realloc
626# define free PerlMem_free
627# define abort PerlProc_abort
628# define exit PerlProc_exit
629# define _exit PerlProc__exit
630# define execl PerlProc_execl
631# define execv PerlProc_execv
632# define execvp PerlProc_execvp
633# define getuid PerlProc_getuid
634# define geteuid PerlProc_geteuid
635# define getgid PerlProc_getgid
636# define getegid PerlProc_getegid
637# define getlogin PerlProc_getlogin
638# define kill PerlProc_kill
639# define killpg PerlProc_killpg
640# define pause PerlProc_pause
641# define popen PerlProc_popen
642# define pclose PerlProc_pclose
643# define pipe PerlProc_pipe
644# define setuid PerlProc_setuid
645# define setgid PerlProc_setgid
646# define sleep PerlProc_sleep
647# define times PerlProc_times
648# define wait PerlProc_wait
649# define setjmp PerlProc_setjmp
650# define longjmp PerlProc_longjmp
651# define signal PerlProc_signal
7766f137 652# define getpid PerlProc_getpid
57ab3dfe 653# define gettimeofday PerlProc_gettimeofday
c6af7a1a
GS
654# define htonl PerlSock_htonl
655# define htons PerlSock_htons
656# define ntohl PerlSock_ntohl
657# define ntohs PerlSock_ntohs
658# define accept PerlSock_accept
659# define bind PerlSock_bind
660# define connect PerlSock_connect
661# define endhostent PerlSock_endhostent
662# define endnetent PerlSock_endnetent
663# define endprotoent PerlSock_endprotoent
664# define endservent PerlSock_endservent
665# define gethostbyaddr PerlSock_gethostbyaddr
666# define gethostbyname PerlSock_gethostbyname
667# define gethostent PerlSock_gethostent
668# define gethostname PerlSock_gethostname
669# define getnetbyaddr PerlSock_getnetbyaddr
670# define getnetbyname PerlSock_getnetbyname
671# define getnetent PerlSock_getnetent
672# define getpeername PerlSock_getpeername
673# define getprotobyname PerlSock_getprotobyname
674# define getprotobynumber PerlSock_getprotobynumber
675# define getprotoent PerlSock_getprotoent
676# define getservbyname PerlSock_getservbyname
677# define getservbyport PerlSock_getservbyport
678# define getservent PerlSock_getservent
679# define getsockname PerlSock_getsockname
680# define getsockopt PerlSock_getsockopt
681# define inet_addr PerlSock_inet_addr
682# define inet_ntoa PerlSock_inet_ntoa
683# define listen PerlSock_listen
684# define recv PerlSock_recv
685# define recvfrom PerlSock_recvfrom
686# define select PerlSock_select
687# define send PerlSock_send
688# define sendto PerlSock_sendto
689# define sethostent PerlSock_sethostent
690# define setnetent PerlSock_setnetent
691# define setprotoent PerlSock_setprotoent
692# define setservent PerlSock_setservent
693# define setsockopt PerlSock_setsockopt
694# define shutdown PerlSock_shutdown
695# define socket PerlSock_socket
696# define socketpair PerlSock_socketpair
2986a63f 697# endif /* NETWARE && USE_STDIO */
21c5e947 698
72e6b643
SH
699# undef fd_set
700# undef FD_SET
701# undef FD_CLR
702# undef FD_ISSET
703# undef FD_ZERO
704# define fd_set Perl_fd_set
705# define FD_SET(n,p) PERL_FD_SET(n,p)
706# define FD_CLR(n,p) PERL_FD_CLR(n,p)
707# define FD_ISSET(n,p) PERL_FD_ISSET(n,p)
708# define FD_ZERO(p) PERL_FD_ZERO(p)
21c5e947 709
c6af7a1a 710# endif /* NO_XSLOCKS */
acfe0abc 711#endif /* PERL_IMPLICIT_SYS && !PERL_CORE */
b4ba0ab9 712
6a5bc5ac 713#endif /* PERL_XSUB_H_ */ /* include guard */
ad73156c
AL
714
715/*
14d04a33 716 * ex: set ts=8 sts=4 sw=4 et:
ad73156c 717 */