Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 638 lines (553 sloc) 20.603 kb
eb1102f Integrate mainline
Nick Ing-Simmons authored
1 /* XSUB.h
2 *
699a97d @rgs Update copyright years in .h files. Also, in .pl
rgs authored
3 * Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
1129b88 Update copyright years.
Nicholas Clark authored
4 * 2003, 2004, 2005, 2006, 2007, 2008 by Larry Wall and others
eb1102f Integrate mainline
Nick Ing-Simmons authored
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
b4ba0ab add include guard
Gurusamy Sarathy authored
11 #ifndef _INC_PERL_XSUB_H
12 #define _INC_PERL_XSUB_H 1
13
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
14 /* first, some documentation for xsubpp-generated items */
15
16 /*
ccfc67b @jhi Missed the =head1 additions.
jhi authored
17 =head1 Variables created by C<xsubpp> and C<xsubpp> internal functions
18
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
19 =for apidoc Amn|char*|CLASS
20 Variable which is setup by C<xsubpp> to indicate the
21 class name for a C++ XS constructor. This is always a C<char*>. See C<THIS>.
22
23 =for apidoc Amn|(whatever)|RETVAL
24 Variable which is setup by C<xsubpp> to hold the return value for an
25 XSUB. This is always the proper type for the XSUB. See
26 L<perlxs/"The RETVAL Variable">.
27
28 =for apidoc Amn|(whatever)|THIS
29 Variable which is setup by C<xsubpp> to designate the object in a C++
30 XSUB. This is always the proper type for the C++ object. See C<CLASS> and
31 L<perlxs/"Using XS With C++">.
32
9f2ea79 @dougm Re: ext/ + -Wall
dougm authored
33 =for apidoc Amn|I32|ax
34 Variable which is setup by C<xsubpp> to indicate the stack base offset,
35 used by the C<ST>, C<XSprePUSH> and C<XSRETURN> macros. The C<dMARK> macro
36 must be called prior to setup the C<MARK> variable.
37
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
38 =for apidoc Amn|I32|items
39 Variable which is setup by C<xsubpp> to indicate the number of
40 items on the stack. See L<perlxs/"Variable-length Parameter Lists">.
41
42 =for apidoc Amn|I32|ix
43 Variable which is setup by C<xsubpp> to indicate which of an
44 XSUB's aliases was used to invoke it. See L<perlxs/"The ALIAS: Keyword">.
45
46 =for apidoc Am|SV*|ST|int ix
47 Used to access elements on the XSUB's stack.
48
49 =for apidoc AmU||XS
50 Macro to declare an XSUB and its C parameter list. This is handled by
51 C<xsubpp>.
52
9f2ea79 @dougm Re: ext/ + -Wall
dougm authored
53 =for apidoc Ams||dAX
54 Sets up the C<ax> variable.
55 This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
56
557b887 [perl #33809] optimize macro dXSARGS
Sergey Skvortsov authored
57 =for apidoc Ams||dAXMARK
58 Sets up the C<ax> variable and stack marker variable C<mark>.
59 This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
60
9f2ea79 @dougm Re: ext/ + -Wall
dougm authored
61 =for apidoc Ams||dITEMS
62 Sets up the C<items> variable.
63 This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
64
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
65 =for apidoc Ams||dXSARGS
9f2ea79 @dougm Re: ext/ + -Wall
dougm authored
66 Sets up stack and mark pointers for an XSUB, calling dSP and dMARK.
67 Sets up the C<ax> and C<items> variables by calling C<dAX> and C<dITEMS>.
68 This is usually handled automatically by C<xsubpp>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
69
70 =for apidoc Ams||dXSI32
71 Sets up the C<ix> variable for an XSUB which has aliases. This is usually
72 handled automatically by C<xsubpp>.
73
88037a8 @rgs Add new dUNDERBAR and UNDERBAR macros, to help XS writers to
rgs authored
74 =for apidoc Ams||dUNDERBAR
483ce06 @vpit The UNDERBAR macro should use find_rundefsv() as well
vpit authored
75 Sets up any variable needed by the C<UNDERBAR> macro. It used to define
486ec47 Fix typos (spelling errors) in Perl sources.
Peter J. Acklam) (via RT authored
76 C<padoff_du>, but it is currently a noop. However, it is strongly advised
483ce06 @vpit The UNDERBAR macro should use find_rundefsv() as well
vpit authored
77 to still use it for ensuring past and future compatibility.
88037a8 @rgs Add new dUNDERBAR and UNDERBAR macros, to help XS writers to
rgs authored
78
79 =for apidoc AmU||UNDERBAR
80 The SV* corresponding to the $_ variable. Works even if there
81 is a lexical $_ in scope.
82
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
83 =cut
84 */
85
53c1dcc @petdance The continuing adventures of Constman and Localize Boy
petdance authored
86 #ifndef PERL_UNUSED_ARG
c99ffe5 @rgs Take splint into account for PERL_UNUSED_ARG (patch by Jarkko)
rgs authored
87 # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */
ad73156 @petdance Lint support
petdance authored
88 # include <note.h>
53c1dcc @petdance The continuing adventures of Constman and Localize Boy
petdance authored
89 # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x))
ad73156 @petdance Lint support
petdance authored
90 # else
53c1dcc @petdance The continuing adventures of Constman and Localize Boy
petdance authored
91 # define PERL_UNUSED_ARG(x) ((void)x)
ad73156 @petdance Lint support
petdance authored
92 # endif
93 #endif
53c1dcc @petdance The continuing adventures of Constman and Localize Boy
petdance authored
94 #ifndef PERL_UNUSED_VAR
95 # define PERL_UNUSED_VAR(x) ((void)x)
96 #endif
ad73156 @petdance Lint support
petdance authored
97
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
98 #define ST(off) PL_stack_base[ax + (off)]
a0d0e21 perl 5.000
Larry Wall authored
99
081304c SWIG uses XS() like this (in the perlrun.swg template):
Abhijit Menon-Sen authored
100 /* XSPROTO() is also used by SWIG like this:
101 *
102 * typedef XSPROTO(SwigPerlWrapper);
103 * typedef SwigPerlWrapper *SwigPerlWrapperPtr;
104 *
105 * This code needs to be compilable under both C and C++.
106 *
107 * Don't forget to change the __attribute__unused__ version of XS()
108 * below too if you change XSPROTO() here.
109 */
110 #define XSPROTO(name) void name(pTHX_ CV* cv)
111
27da23d @jhi Symbian port of Perl
jhi authored
112 #undef XS
d308986 use builtin __CYGWIN__ rather than -DCYGWIN (from Eric Fifer
Gurusamy Sarathy authored
113 #if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
081304c SWIG uses XS() like this (in the perlrun.swg template):
Abhijit Menon-Sen authored
114 # define XS(name) __declspec(dllexport) XSPROTO(name)
27da23d @jhi Symbian port of Perl
jhi authored
115 #endif
a0fd494 @jhi another Symbian update: Alan's fault :-)
jhi authored
116 #if defined(__SYMBIAN32__)
081304c SWIG uses XS() like this (in the perlrun.swg template):
Abhijit Menon-Sen authored
117 # define XS(name) EXPORT_C XSPROTO(name)
27da23d @jhi Symbian port of Perl
jhi authored
118 #endif
119 #ifndef XS
34659ad Problem compiling swigged c++ code with 5.8.8
Merijn Broeren authored
120 # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
0dbb158 @petdance Attribute configuration
petdance authored
121 # define XS(name) void name(pTHX_ CV* cv __attribute__unused__)
88d0195 @petdance XS() __attribute__
petdance authored
122 # else
a0c21aa @jhi Re: A large-ish C++ TODO (Re: [PATCH] g++ stage 1 reached)
jhi authored
123 # ifdef __cplusplus
081304c SWIG uses XS() like this (in the perlrun.swg template):
Abhijit Menon-Sen authored
124 # define XS(name) extern "C" XSPROTO(name)
a0c21aa @jhi Re: A large-ish C++ TODO (Re: [PATCH] g++ stage 1 reached)
jhi authored
125 # else
081304c SWIG uses XS() like this (in the perlrun.swg template):
Abhijit Menon-Sen authored
126 # define XS(name) XSPROTO(name)
a0c21aa @jhi Re: A large-ish C++ TODO (Re: [PATCH] g++ stage 1 reached)
jhi authored
127 # endif
88d0195 @petdance XS() __attribute__
petdance authored
128 # endif
a0d0e21 perl 5.000
Larry Wall authored
129 #endif
130
514696a @jandubois Cast markstack values to I32
jandubois authored
131 #define dAX const I32 ax = (I32)(MARK - PL_stack_base + 1)
9f2ea79 @dougm Re: ext/ + -Wall
dougm authored
132
557b887 [perl #33809] optimize macro dXSARGS
Sergey Skvortsov authored
133 #define dAXMARK \
a3b680e @petdance consting-eleventy.patch: More consts, plus actual bug fix
petdance authored
134 I32 ax = POPMARK; \
92800dc @jandubois mark cannot be const because MEXTEND() modifies it, and tkGlue.c uses ME...
jandubois authored
135 register SV **mark = PL_stack_base + ax++
557b887 [perl #33809] optimize macro dXSARGS
Sergey Skvortsov authored
136
514696a @jandubois Cast markstack values to I32
jandubois authored
137 #define dITEMS I32 items = (I32)(SP - MARK)
9f2ea79 @dougm Re: ext/ + -Wall
dougm authored
138
c99ffe5 @rgs Take splint into account for PERL_UNUSED_ARG (patch by Jarkko)
rgs authored
139 #if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */
53c1dcc @petdance The continuing adventures of Constman and Localize Boy
petdance authored
140 # define dXSARGS \
141 NOTE(ARGUNUSED(cv)) \
142 dSP; dAXMARK; dITEMS
143 #else
144 # define dXSARGS \
557b887 [perl #33809] optimize macro dXSARGS
Sergey Skvortsov authored
145 dSP; dAXMARK; dITEMS
53c1dcc @petdance The continuing adventures of Constman and Localize Boy
petdance authored
146 #endif
a0d0e21 perl 5.000
Larry Wall authored
147
a3b680e @petdance consting-eleventy.patch: More consts, plus actual bug fix
petdance authored
148 #define dXSTARG SV * const targ = ((PL_op->op_private & OPpENTERSUB_HASTARG) \
8a7fc0d s/dXS_TARGET/dXSTARG/ in change#4044 (to match dARGS vs dXSARGS
Gurusamy Sarathy authored
149 ? PAD_SV(PL_op->op_targ) : sv_newmortal())
150
b26a54d optimize XSUBs to use targets if the -nooptimize xsubpp option is
Gurusamy Sarathy authored
151 /* Should be used before final PUSHi etc. if not in PPCODE section. */
152 #define XSprePUSH (sp = PL_stack_base + ax - 1)
153
a0d0e21 perl 5.000
Larry Wall authored
154 #define XSANY CvXSUBANY(cv)
155
156 #define dXSI32 I32 ix = XSANY.any_i32
157
cfc0234 xsubpp enhancements ($CPAN/authors/id/ILYAZ/patches/diff_xsubpp_65), a
Ilya Zakharevich authored
158 #ifdef __cplusplus
159 # define XSINTERFACE_CVT(ret,name) ret (*name)(...)
4ef0c66 XSUB.h - silence MSVC6 compiler warning
Robert May authored
160 # define XSINTERFACE_CVT_ANON(ret) ret (*)(...)
cfc0234 xsubpp enhancements ($CPAN/authors/id/ILYAZ/patches/diff_xsubpp_65), a
Ilya Zakharevich authored
161 #else
162 # define XSINTERFACE_CVT(ret,name) ret (*name)()
4ef0c66 XSUB.h - silence MSVC6 compiler warning
Robert May authored
163 # define XSINTERFACE_CVT_ANON(ret) ret (*)()
cfc0234 xsubpp enhancements ($CPAN/authors/id/ILYAZ/patches/diff_xsubpp_65), a
Ilya Zakharevich authored
164 #endif
165 #define dXSFUNCTION(ret) XSINTERFACE_CVT(ret,XSFUNCTION)
4ef0c66 XSUB.h - silence MSVC6 compiler warning
Robert May authored
166 #define XSINTERFACE_FUNC(ret,cv,f) ((XSINTERFACE_CVT_ANON(ret))(f))
cfc0234 xsubpp enhancements ($CPAN/authors/id/ILYAZ/patches/diff_xsubpp_65), a
Ilya Zakharevich authored
167 #define XSINTERFACE_FUNC_SET(cv,f) \
a12c3db 5.8.0: two problems
Ilya Zakharevich authored
168 CvXSUBANY(cv).any_dxptr = (void (*) (pTHX_ void*))(f)
cfc0234 xsubpp enhancements ($CPAN/authors/id/ILYAZ/patches/diff_xsubpp_65), a
Ilya Zakharevich authored
169
483ce06 @vpit The UNDERBAR macro should use find_rundefsv() as well
vpit authored
170 #define dUNDERBAR dNOOP
171 #define UNDERBAR find_rundefsv()
88037a8 @rgs Add new dUNDERBAR and UNDERBAR macros, to help XS writers to
rgs authored
172
748a930 Perl 5.001
Larry Wall authored
173 /* Simple macros to put new mortal values onto the stack. */
174 /* Typically used to return values from XS functions. */
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
175
176 /*
ccfc67b @jhi Missed the =head1 additions.
jhi authored
177 =head1 Stack Manipulation Macros
178
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
179 =for apidoc Am|void|XST_mIV|int pos|IV iv
180 Place an integer into the specified position C<pos> on the stack. The
181 value is stored in a new mortal SV.
182
183 =for apidoc Am|void|XST_mNV|int pos|NV nv
184 Place a double into the specified position C<pos> on the stack. The value
185 is stored in a new mortal SV.
186
187 =for apidoc Am|void|XST_mPV|int pos|char* str
188 Place a copy of a string into the specified position C<pos> on the stack.
189 The value is stored in a new mortal SV.
190
191 =for apidoc Am|void|XST_mNO|int pos
192 Place C<&PL_sv_no> into the specified position C<pos> on the
193 stack.
194
195 =for apidoc Am|void|XST_mYES|int pos
196 Place C<&PL_sv_yes> into the specified position C<pos> on the
197 stack.
198
199 =for apidoc Am|void|XST_mUNDEF|int pos
200 Place C<&PL_sv_undef> into the specified position C<pos> on the
201 stack.
202
203 =for apidoc Am|void|XSRETURN|int nitems
204 Return from XSUB, indicating number of items on the stack. This is usually
205 handled by C<xsubpp>.
206
207 =for apidoc Am|void|XSRETURN_IV|IV iv
208 Return an integer from an XSUB immediately. Uses C<XST_mIV>.
209
108ccc4 @jhi XSRETURN_UV was missing.
jhi authored
210 =for apidoc Am|void|XSRETURN_UV|IV uv
211 Return an integer from an XSUB immediately. Uses C<XST_mUV>.
212
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
213 =for apidoc Am|void|XSRETURN_NV|NV nv
d1be940 a few typo fixes
Jeffrey Friedl authored
214 Return a double from an XSUB immediately. Uses C<XST_mNV>.
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
215
216 =for apidoc Am|void|XSRETURN_PV|char* str
217 Return a copy of a string from an XSUB immediately. Uses C<XST_mPV>.
218
219 =for apidoc Ams||XSRETURN_NO
220 Return C<&PL_sv_no> from an XSUB immediately. Uses C<XST_mNO>.
221
222 =for apidoc Ams||XSRETURN_YES
223 Return C<&PL_sv_yes> from an XSUB immediately. Uses C<XST_mYES>.
224
225 =for apidoc Ams||XSRETURN_UNDEF
226 Return C<&PL_sv_undef> from an XSUB immediately. Uses C<XST_mUNDEF>.
227
228 =for apidoc Ams||XSRETURN_EMPTY
229 Return an empty list from an XSUB immediately.
230
ccfc67b @jhi Missed the =head1 additions.
jhi authored
231 =head1 Variables created by C<xsubpp> and C<xsubpp> internal functions
232
c578083 Fix apidoc entries for PUSHMARK and newXSproto.
Marcus Holland-Moritz authored
233 =for apidoc AmU||newXSproto|char* name|XSUBADDR_t f|char* filename|const char *proto
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
234 Used by C<xsubpp> to hook up XSUBs as Perl subs. Adds Perl prototypes to
235 the subs.
236
237 =for apidoc AmU||XS_VERSION
238 The version identifier for an XS module. This is usually
239 handled automatically by C<ExtUtils::MakeMaker>. See C<XS_VERSION_BOOTCHECK>.
240
241 =for apidoc Ams||XS_VERSION_BOOTCHECK
242 Macro to verify that a PM module's $VERSION variable matches the XS
243 module's C<XS_VERSION> variable. This is usually handled automatically by
244 C<xsubpp>. See L<perlxs/"The VERSIONCHECK: Keyword">.
245
1e8125c @rafl Check API compatibility when loading xs modules
rafl authored
246 =for apidoc Ams||XS_APIVERSION_BOOTCHECK
247 Macro to verify that the perl api version an XS module has been compiled against
248 matches the api version of the perl interpreter it's being loaded into.
249
0ca3a87 Add simple exception handling macros for XS writers.
Marcus Holland-Moritz authored
250 =head1 Simple Exception Handling Macros
251
252 =for apidoc Ams||dXCPT
2dfe1b1 @rgs Another typo fix
rgs authored
253 Set up necessary local variables for exception handling.
0ca3a87 Add simple exception handling macros for XS writers.
Marcus Holland-Moritz authored
254 See L<perlguts/"Exception Handling">.
255
256 =for apidoc AmU||XCPT_TRY_START
257 Starts a try block. See L<perlguts/"Exception Handling">.
258
259 =for apidoc AmU||XCPT_TRY_END
260 Ends a try block. See L<perlguts/"Exception Handling">.
261
262 =for apidoc AmU||XCPT_CATCH
263 Introduces a catch block. See L<perlguts/"Exception Handling">.
264
265 =for apidoc Ams||XCPT_RETHROW
266 Rethrows a previously caught exception. See L<perlguts/"Exception Handling">.
267
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
268 =cut
269 */
270
4633a7c 5.002 beta 1
Larry Wall authored
271 #define XST_mIV(i,v) (ST(i) = sv_2mortal(newSViv(v)) )
108ccc4 @jhi XSRETURN_UV was missing.
jhi authored
272 #define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) )
4633a7c 5.002 beta 1
Larry Wall authored
273 #define XST_mNV(i,v) (ST(i) = sv_2mortal(newSVnv(v)) )
274 #define XST_mPV(i,v) (ST(i) = sv_2mortal(newSVpv(v,0)))
ad25789 Missed three sv_2mortal(newSVpvn(...))s in the headers.
Nicholas Clark authored
275 #define XST_mPVN(i,v,n) (ST(i) = newSVpvn_flags(v,n, SVs_TEMP))
3280af2 PL_ prefix to all perlvars, part1
Nick Ing-Simmons authored
276 #define XST_mNO(i) (ST(i) = &PL_sv_no )
277 #define XST_mYES(i) (ST(i) = &PL_sv_yes )
278 #define XST_mUNDEF(i) (ST(i) = &PL_sv_undef)
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
279
280 #define XSRETURN(off) \
281 STMT_START { \
61f9802 @petdance Consting dump.c
petdance authored
282 const IV tmpXSoff = (off); \
a02b223 @rgs Make the XSRETURN macro evaluate its argument only once.
rgs authored
283 PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1); \
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
284 return; \
285 } STMT_END
286
80b9223 Incorporate single-statement macros
Perl 5 Porters authored
287 #define XSRETURN_IV(v) STMT_START { XST_mIV(0,v); XSRETURN(1); } STMT_END
108ccc4 @jhi XSRETURN_UV was missing.
jhi authored
288 #define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END
80b9223 Incorporate single-statement macros
Perl 5 Porters authored
289 #define XSRETURN_NV(v) STMT_START { XST_mNV(0,v); XSRETURN(1); } STMT_END
290 #define XSRETURN_PV(v) STMT_START { XST_mPV(0,v); XSRETURN(1); } STMT_END
954c199 autogenerate API listing from comments in the source (from Benjamin
Gurusamy Sarathy authored
291 #define XSRETURN_PVN(v,n) STMT_START { XST_mPVN(0,v,n); XSRETURN(1); } STMT_END
80b9223 Incorporate single-statement macros
Perl 5 Porters authored
292 #define XSRETURN_NO STMT_START { XST_mNO(0); XSRETURN(1); } STMT_END
293 #define XSRETURN_YES STMT_START { XST_mYES(0); XSRETURN(1); } STMT_END
294 #define XSRETURN_UNDEF STMT_START { XST_mUNDEF(0); XSRETURN(1); } STMT_END
295 #define XSRETURN_EMPTY STMT_START { XSRETURN(0); } STMT_END
382b8d9 xsubpp 1.924
Paul Marquess authored
296
77004de Fix bug in DynaLoader, which has been passing a filename in dynamic
Nicholas Clark authored
297 #define newXSproto(a,b,c,d) newXS_flags(a,b,c,d,0)
720fb64 Updated to match xsubpp-1.929.
Perl 5 Porters authored
298
299 #ifdef XS_VERSION
ddb5125 @rafl Fix leaks in XS_VERSION_BOOTCHECK
rafl authored
300 # define XS_VERSION_BOOTCHECK \
e9b067d Convert the implementation of XS_VERSION_BOOTCHECK to a function from a ...
Nicholas Clark authored
301 Perl_xs_version_bootcheck(aTHX_ items, ax, STR_WITH_LEN(XS_VERSION))
720fb64 Updated to match xsubpp-1.929.
Perl 5 Porters authored
302 #else
c6af7a1 phase 2 of PERL_OBJECT cleanup; objXSUB.h autogeneration
Gurusamy Sarathy authored
303 # define XS_VERSION_BOOTCHECK
720fb64 Updated to match xsubpp-1.929.
Perl 5 Porters authored
304 #endif
76e3520 [asperl] added AS patch#2
Gurusamy Sarathy authored
305
1e8125c @rafl Check API compatibility when loading xs modules
rafl authored
306 #define XS_APIVERSION_BOOTCHECK \
379a890 Convert the implementation of XS_APIVERSION_BOOTCHECK to a function.
Nicholas Clark authored
307 Perl_xs_apiversion_bootcheck(aTHX_ ST(0), STR_WITH_LEN("v" PERL_API_VERSION_STRING))
1e8125c @rafl Check API compatibility when loading xs modules
rafl authored
308
9b5c382 Attempt to fix problems with new exception handling macros.
Marcus Holland-Moritz authored
309 #ifdef NO_XSLOCKS
310 # define dXCPT dJMPENV; int rEtV = 0
311 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0)
312 # define XCPT_TRY_END JMPENV_POP;
313 # define XCPT_CATCH if (rEtV != 0)
314 # define XCPT_RETHROW JMPENV_JUMP(rEtV)
315 #endif
0ca3a87 Add simple exception handling macros for XS writers.
Marcus Holland-Moritz authored
316
1e8125c @rafl Check API compatibility when loading xs modules
rafl authored
317 /*
318 The DBM_setFilter & DBM_ckFilter macros are only used by
319 the *DB*_File modules
6a31061 @pmqs Fix DBM filters
pmqs authored
320 */
321
322 #define DBM_setFilter(db_type,code) \
891c2e0 @smpeters Down with "warning: code has no effect"
smpeters authored
323 STMT_START { \
6a31061 @pmqs Fix DBM filters
pmqs authored
324 if (db_type) \
325 RETVAL = sv_mortalcopy(db_type) ; \
326 ST(0) = RETVAL ; \
327 if (db_type && (code == &PL_sv_undef)) { \
328 SvREFCNT_dec(db_type) ; \
329 db_type = NULL ; \
330 } \
331 else if (code) { \
332 if (db_type) \
333 sv_setsv(db_type, code) ; \
334 else \
335 db_type = newSVsv(code) ; \
336 } \
891c2e0 @smpeters Down with "warning: code has no effect"
smpeters authored
337 } STMT_END
6a31061 @pmqs Fix DBM filters
pmqs authored
338
339 #define DBM_ckFilter(arg,type,name) \
891c2e0 @smpeters Down with "warning: code has no effect"
smpeters authored
340 STMT_START { \
6a31061 @pmqs Fix DBM filters
pmqs authored
341 if (db->type) { \
342 if (db->filtering) { \
343 croak("recursion detected in %s", name) ; \
344 } \
345 ENTER ; \
346 SAVETMPS ; \
347 SAVEINT(db->filtering) ; \
348 db->filtering = TRUE ; \
414bf5a Assigning to DEFSV leaks if PL_defgv's gp_sv isn't set.
Marcus Holland-Moritz authored
349 SAVE_DEFSV ; \
5bbd429 @pmqs PATCH: *DB*_File
pmqs authored
350 if (name[7] == 's') \
351 arg = newSVsv(arg); \
414bf5a Assigning to DEFSV leaks if PL_defgv's gp_sv isn't set.
Marcus Holland-Moritz authored
352 DEFSV_set(arg) ; \
6a31061 @pmqs Fix DBM filters
pmqs authored
353 SvTEMP_off(arg) ; \
354 PUSHMARK(SP) ; \
355 PUTBACK ; \
356 (void) perl_call_sv(db->type, G_DISCARD); \
357 SPAGAIN ; \
358 PUTBACK ; \
359 FREETMPS ; \
360 LEAVE ; \
5bbd429 @pmqs PATCH: *DB*_File
pmqs authored
361 if (name[7] == 's'){ \
362 arg = sv_2mortal(arg); \
363 } \
891c2e0 @smpeters Down with "warning: code has no effect"
smpeters authored
364 } } STMT_END
6a31061 @pmqs Fix DBM filters
pmqs authored
365
5137154 more PERL_OBJECT cleanups (changes still untested on Unix!)
Gurusamy Sarathy authored
366 #if 1 /* for compatibility */
dc9e491 integrate changes#2120,2168,2218 from maint-5.005;
Gurusamy Sarathy authored
367 # define VTBL_sv &PL_vtbl_sv
368 # define VTBL_env &PL_vtbl_env
369 # define VTBL_envelem &PL_vtbl_envelem
370 # define VTBL_sigelem &PL_vtbl_sigelem
371 # define VTBL_pack &PL_vtbl_pack
372 # define VTBL_packelem &PL_vtbl_packelem
373 # define VTBL_dbline &PL_vtbl_dbline
374 # define VTBL_isa &PL_vtbl_isa
375 # define VTBL_isaelem &PL_vtbl_isaelem
376 # define VTBL_arylen &PL_vtbl_arylen
c696a6a @smpeters Revert change #27295, which I thought fixed builds on Win32.
smpeters authored
377 # define VTBL_glob &PL_vtbl_glob
dc9e491 integrate changes#2120,2168,2218 from maint-5.005;
Gurusamy Sarathy authored
378 # define VTBL_mglob &PL_vtbl_mglob
379 # define VTBL_nkeys &PL_vtbl_nkeys
380 # define VTBL_taint &PL_vtbl_taint
381 # define VTBL_substr &PL_vtbl_substr
382 # define VTBL_vec &PL_vtbl_vec
383 # define VTBL_pos &PL_vtbl_pos
384 # define VTBL_bm &PL_vtbl_bm
385 # define VTBL_fm &PL_vtbl_fm
386 # define VTBL_uvar &PL_vtbl_uvar
387 # define VTBL_defelem &PL_vtbl_defelem
388 # define VTBL_regexp &PL_vtbl_regexp
389 # define VTBL_regdata &PL_vtbl_regdata
390 # define VTBL_regdatum &PL_vtbl_regdatum
391 # ifdef USE_LOCALE_COLLATE
392 # define VTBL_collxfrm &PL_vtbl_collxfrm
393 # endif
9e7bc3e @jandubois remove OVERLOAD conditionals
jandubois authored
394 # define VTBL_amagic &PL_vtbl_amagic
395 # define VTBL_amagicelem &PL_vtbl_amagicelem
dc9e491 integrate changes#2120,2168,2218 from maint-5.005;
Gurusamy Sarathy authored
396 #endif
397
6f4183f enable function wrappers for access to globals under MULTIPLICITY
Gurusamy Sarathy authored
398 #include "perlapi.h"
c6af7a1 phase 2 of PERL_OBJECT cleanup; objXSUB.h autogeneration
Gurusamy Sarathy authored
399
e8ee377 win32 tweaks
Gurusamy Sarathy authored
400 #if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_NO_GET_CONTEXT) && !defined(PERL_CORE)
c5be433 yet more cleanups of the PERL_OBJECT, MULTIPLICITY and USE_THREADS
Gurusamy Sarathy authored
401 # undef aTHX
402 # undef aTHX_
54aff46 support USE_THREADS+MULTIPLICITY; source compat tweaks for
Gurusamy Sarathy authored
403 # define aTHX PERL_GET_THX
404 # define aTHX_ aTHX,
405 #endif
406
acfe0ab remove deprecated PERL_OBJECT cruft, it has long since stopped
Gurusamy Sarathy authored
407 #if defined(PERL_IMPLICIT_SYS) && !defined(PERL_CORE)
c6af7a1 phase 2 of PERL_OBJECT cleanup; objXSUB.h autogeneration
Gurusamy Sarathy authored
408 # ifndef NO_XSLOCKS
2986a63 @jhi NetWare port from Guruprasad S <SGURUPRASAD@novell.com>.
jhi authored
409 # if defined (NETWARE) && defined (USE_STDIO)
410 # define times PerlProc_times
411 # define setuid PerlProc_setuid
412 # define setgid PerlProc_setgid
413 # define getpid PerlProc_getpid
414 # define pause PerlProc_pause
415 # define exit PerlProc_exit
416 # define _exit PerlProc__exit
417 # else
c6af7a1 phase 2 of PERL_OBJECT cleanup; objXSUB.h autogeneration
Gurusamy Sarathy authored
418 # undef closedir
419 # undef opendir
420 # undef stdin
421 # undef stdout
422 # undef stderr
423 # undef feof
424 # undef ferror
425 # undef fgetpos
426 # undef ioctl
427 # undef getlogin
428 # undef setjmp
429 # undef getc
430 # undef ungetc
431 # undef fileno
432
cb69f87 @Tux from the non-ANSI comment police (was: it won't compile on win32)
Tux authored
433 /* Following symbols were giving redefinition errors while building extensions - sgp 17th Oct 2000 */
2986a63 @jhi NetWare port from Guruprasad S <SGURUPRASAD@novell.com>.
jhi authored
434 #ifdef NETWARE
435 # undef readdir
436 # undef fstat
437 # undef stat
438 # undef longjmp
439 # undef endhostent
440 # undef endnetent
441 # undef endprotoent
442 # undef endservent
443 # undef gethostbyaddr
444 # undef gethostbyname
445 # undef gethostent
446 # undef getnetbyaddr
447 # undef getnetbyname
448 # undef getnetent
449 # undef getprotobyname
450 # undef getprotobynumber
451 # undef getprotoent
452 # undef getservbyname
453 # undef getservbyport
454 # undef getservent
455 # undef inet_ntoa
456 # undef sethostent
457 # undef setnetent
458 # undef setprotoent
459 # undef setservent
460 #endif /* NETWARE */
461
fa58a56 @sisyphus Add mingw64 support
sisyphus authored
462 /* to avoid warnings: "xyz" redefined */
463 #ifdef WIN32
464 # undef popen
465 # undef pclose
466 #endif /* WIN32 */
467
1018e26 A mostly-stable version of "new" Win32 signal/kill support.
Nick Ing-Simmons authored
468 # undef socketpair
469
c6af7a1 phase 2 of PERL_OBJECT cleanup; objXSUB.h autogeneration
Gurusamy Sarathy authored
470 # define mkdir PerlDir_mkdir
471 # define chdir PerlDir_chdir
472 # define rmdir PerlDir_rmdir
473 # define closedir PerlDir_close
474 # define opendir PerlDir_open
475 # define readdir PerlDir_read
476 # define rewinddir PerlDir_rewind
477 # define seekdir PerlDir_seek
478 # define telldir PerlDir_tell
479 # define putenv PerlEnv_putenv
480 # define getenv PerlEnv_getenv
b2af26b support POSIX::uname() via win32_uname()
Gurusamy Sarathy authored
481 # define uname PerlEnv_uname
197357d PerlSIO_stderr et al are not functions
Gurusamy Sarathy authored
482 # define stdin PerlSIO_stdin
483 # define stdout PerlSIO_stdout
484 # define stderr PerlSIO_stderr
f9415d2 PERL_IMPLICIT_SYS does NOT vector PerlIO_xxx but PerlSIO_xxx, so
Nick Ing-Simmons authored
485 # define fopen PerlSIO_fopen
486 # define fclose PerlSIO_fclose
487 # define feof PerlSIO_feof
488 # define ferror PerlSIO_ferror
b6d726d Re: typo in checkin 18616
Nick Ing-Simmons authored
489 # define clearerr PerlSIO_clearerr
f9415d2 PERL_IMPLICIT_SYS does NOT vector PerlIO_xxx but PerlSIO_xxx, so
Nick Ing-Simmons authored
490 # define getc PerlSIO_getc
20c8f8f @jandubois XSUB.h is supposed to redefine fgets under PERL_IMPLICIT_SYS, but doesn'...
jandubois authored
491 # define fgets PerlSIO_fgets
f9415d2 PERL_IMPLICIT_SYS does NOT vector PerlIO_xxx but PerlSIO_xxx, so
Nick Ing-Simmons authored
492 # define fputc PerlSIO_fputc
493 # define fputs PerlSIO_fputs
494 # define fflush PerlSIO_fflush
495 # define ungetc PerlSIO_ungetc
496 # define fileno PerlSIO_fileno
497 # define fdopen PerlSIO_fdopen
498 # define freopen PerlSIO_freopen
499 # define fread PerlSIO_fread
500 # define fwrite PerlSIO_fwrite
22a46b6 setbuf / setvbuf are not PerlIO_ concepts
Nick Ing-Simmons authored
501 # define setbuf PerlSIO_setbuf
502 # define setvbuf PerlSIO_setvbuf
503 # define setlinebuf PerlSIO_setlinebuf
1f59ddd PerlIO_{stdoutf,vprintf} don't exist, should be PerlSIO_*
Gurusamy Sarathy authored
504 # define stdoutf PerlSIO_stdoutf
505 # define vfprintf PerlSIO_vprintf
f9415d2 PERL_IMPLICIT_SYS does NOT vector PerlIO_xxx but PerlSIO_xxx, so
Nick Ing-Simmons authored
506 # define ftell PerlSIO_ftell
507 # define fseek PerlSIO_fseek
508 # define fgetpos PerlSIO_fgetpos
509 # define fsetpos PerlSIO_fsetpos
510 # define frewind PerlSIO_rewind
511 # define tmpfile PerlSIO_tmpfile
c6af7a1 phase 2 of PERL_OBJECT cleanup; objXSUB.h autogeneration
Gurusamy Sarathy authored
512 # define access PerlLIO_access
513 # define chmod PerlLIO_chmod
514 # define chsize PerlLIO_chsize
515 # define close PerlLIO_close
516 # define dup PerlLIO_dup
517 # define dup2 PerlLIO_dup2
518 # define flock PerlLIO_flock
519 # define fstat PerlLIO_fstat
520 # define ioctl PerlLIO_ioctl
521 # define isatty PerlLIO_isatty
6b98017 @jandubois [5.005_62 PATCH] support link() on WinNT and NTFS
jandubois authored
522 # define link PerlLIO_link
c6af7a1 phase 2 of PERL_OBJECT cleanup; objXSUB.h autogeneration
Gurusamy Sarathy authored
523 # define lseek PerlLIO_lseek
524 # define lstat PerlLIO_lstat
525 # define mktemp PerlLIO_mktemp
526 # define open PerlLIO_open
527 # define read PerlLIO_read
528 # define rename PerlLIO_rename
529 # define setmode PerlLIO_setmode
4f49e16 File::Glob fixes for Windows
Gurusamy Sarathy authored
530 # define stat(buf,sb) PerlLIO_stat(buf,sb)
c6af7a1 phase 2 of PERL_OBJECT cleanup; objXSUB.h autogeneration
Gurusamy Sarathy authored
531 # define tmpnam PerlLIO_tmpnam
532 # define umask PerlLIO_umask
533 # define unlink PerlLIO_unlink
534 # define utime PerlLIO_utime
535 # define write PerlLIO_write
536 # define malloc PerlMem_malloc
537 # define realloc PerlMem_realloc
538 # define free PerlMem_free
539 # define abort PerlProc_abort
540 # define exit PerlProc_exit
541 # define _exit PerlProc__exit
542 # define execl PerlProc_execl
543 # define execv PerlProc_execv
544 # define execvp PerlProc_execvp
545 # define getuid PerlProc_getuid
546 # define geteuid PerlProc_geteuid
547 # define getgid PerlProc_getgid
548 # define getegid PerlProc_getegid
549 # define getlogin PerlProc_getlogin
550 # define kill PerlProc_kill
551 # define killpg PerlProc_killpg
552 # define pause PerlProc_pause
553 # define popen PerlProc_popen
554 # define pclose PerlProc_pclose
555 # define pipe PerlProc_pipe
556 # define setuid PerlProc_setuid
557 # define setgid PerlProc_setgid
558 # define sleep PerlProc_sleep
559 # define times PerlProc_times
560 # define wait PerlProc_wait
561 # define setjmp PerlProc_setjmp
562 # define longjmp PerlProc_longjmp
563 # define signal PerlProc_signal
7766f13 more complete pseudo-fork() support for Windows
Gurusamy Sarathy authored
564 # define getpid PerlProc_getpid
57ab3df make the gettimeofday() implementation in Time::HiRes available
Gurusamy Sarathy authored
565 # define gettimeofday PerlProc_gettimeofday
c6af7a1 phase 2 of PERL_OBJECT cleanup; objXSUB.h autogeneration
Gurusamy Sarathy authored
566 # define htonl PerlSock_htonl
567 # define htons PerlSock_htons
568 # define ntohl PerlSock_ntohl
569 # define ntohs PerlSock_ntohs
570 # define accept PerlSock_accept
571 # define bind PerlSock_bind
572 # define connect PerlSock_connect
573 # define endhostent PerlSock_endhostent
574 # define endnetent PerlSock_endnetent
575 # define endprotoent PerlSock_endprotoent
576 # define endservent PerlSock_endservent
577 # define gethostbyaddr PerlSock_gethostbyaddr
578 # define gethostbyname PerlSock_gethostbyname
579 # define gethostent PerlSock_gethostent
580 # define gethostname PerlSock_gethostname
581 # define getnetbyaddr PerlSock_getnetbyaddr
582 # define getnetbyname PerlSock_getnetbyname
583 # define getnetent PerlSock_getnetent
584 # define getpeername PerlSock_getpeername
585 # define getprotobyname PerlSock_getprotobyname
586 # define getprotobynumber PerlSock_getprotobynumber
587 # define getprotoent PerlSock_getprotoent
588 # define getservbyname PerlSock_getservbyname
589 # define getservbyport PerlSock_getservbyport
590 # define getservent PerlSock_getservent
591 # define getsockname PerlSock_getsockname
592 # define getsockopt PerlSock_getsockopt
593 # define inet_addr PerlSock_inet_addr
594 # define inet_ntoa PerlSock_inet_ntoa
595 # define listen PerlSock_listen
596 # define recv PerlSock_recv
597 # define recvfrom PerlSock_recvfrom
598 # define select PerlSock_select
599 # define send PerlSock_send
600 # define sendto PerlSock_sendto
601 # define sethostent PerlSock_sethostent
602 # define setnetent PerlSock_setnetent
603 # define setprotoent PerlSock_setprotoent
604 # define setservent PerlSock_setservent
605 # define setsockopt PerlSock_setsockopt
606 # define shutdown PerlSock_shutdown
607 # define socket PerlSock_socket
608 # define socketpair PerlSock_socketpair
2986a63 @jhi NetWare port from Guruprasad S <SGURUPRASAD@novell.com>.
jhi authored
609 # endif /* NETWARE && USE_STDIO */
21c5e94 @jhi Integrate #16971 from maint-5.6;
jhi authored
610
611 # ifdef USE_SOCKETS_AS_HANDLES
612 # undef fd_set
613 # undef FD_SET
614 # undef FD_CLR
615 # undef FD_ISSET
616 # undef FD_ZERO
617 # define fd_set Perl_fd_set
618 # define FD_SET(n,p) PERL_FD_SET(n,p)
619 # define FD_CLR(n,p) PERL_FD_CLR(n,p)
620 # define FD_ISSET(n,p) PERL_FD_ISSET(n,p)
621 # define FD_ZERO(p) PERL_FD_ZERO(p)
622 # endif /* USE_SOCKETS_AS_HANDLES */
623
c6af7a1 phase 2 of PERL_OBJECT cleanup; objXSUB.h autogeneration
Gurusamy Sarathy authored
624 # endif /* NO_XSLOCKS */
acfe0ab remove deprecated PERL_OBJECT cruft, it has long since stopped
Gurusamy Sarathy authored
625 #endif /* PERL_IMPLICIT_SYS && !PERL_CORE */
b4ba0ab add include guard
Gurusamy Sarathy authored
626
cfeeb02 @jhi Fix #endif.
jhi authored
627 #endif /* _INC_PERL_XSUB_H */ /* include guard */
ad73156 @petdance Lint support
petdance authored
628
629 /*
630 * Local variables:
631 * c-indentation-style: bsd
632 * c-basic-offset: 4
633 * indent-tabs-mode: t
634 * End:
635 *
636 * ex: set ts=8 sts=4 sw=4 noet:
637 */
Something went wrong with that request. Please try again.