xref: /openbsd/gnu/usr.bin/perl/XSUB.h (revision 3d61058a)
1 /*    XSUB.h
2  *
3  *    Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4  *    2003, 2004, 2005, 2006, 2007, 2008 by Larry Wall and others
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 
11 #ifndef PERL_XSUB_H_
12 #define PERL_XSUB_H_ 1
13 
14 /* first, some documentation for xsubpp-generated items */
15 
16 /*
17 =for apidoc_section $XS
18 
19 F<xsubpp> compiles XS code into C.  See L<perlutil/xsubpp>.
20 
21 =for comment
22 Some variables below are flagged with 'u' because Devel::PPPort can't currently
23 readily test them as they spring into existence by compiling with xsubpp.
24 
25 =for apidoc Amnu|char*|CLASS
26 Variable which is setup by C<xsubpp> to indicate the
27 class name for a C++ XS constructor.  This is always a C<char*>.  See
28 C<L</THIS>>.
29 
30 =for apidoc Amnu|type|RETVAL
31 Variable which is setup by C<xsubpp> to hold the return value for an
32 XSUB.  This is always the proper type for the XSUB.  See
33 L<perlxs/"The RETVAL Variable">.
34 
35 =for apidoc Amnu|type|THIS
36 Variable which is setup by C<xsubpp> to designate the object in a C++
37 XSUB.  This is always the proper type for the C++ object.  See C<L</CLASS>> and
38 L<perlxs/"Using XS With C++">.
39 
40 =for apidoc Amn|Stack_off_t|ax
41 Variable which is setup by C<xsubpp> to indicate the stack base offset,
42 used by the C<ST>, C<XSprePUSH> and C<XSRETURN> macros.  The C<dMARK> macro
43 must be called prior to setup the C<MARK> variable.
44 
45 =for apidoc Amn|Stack_off_t|items
46 Variable which is setup by C<xsubpp> to indicate the number of
47 items on the stack.  See L<perlxs/"Variable-length Parameter Lists">.
48 
49 =for apidoc Amn|I32|ix
50 Variable which is setup by C<xsubpp> to indicate which of an
51 XSUB's aliases was used to invoke it.  See L<perlxs/"The ALIAS: Keyword">.
52 
53 =for apidoc Am|SV*|ST|int ix
54 Used to access elements on the XSUB's stack.
55 
56 =for apidoc Ay||XS|name
57 Macro to declare an XSUB and its C parameter list.  This is handled by
58 C<xsubpp>.  It is the same as using the more explicit C<XS_EXTERNAL> macro; the
59 latter is preferred.
60 
61 =for apidoc Ayu||XS_INTERNAL|name
62 Macro to declare an XSUB and its C parameter list without exporting the symbols.
63 This is handled by C<xsubpp> and generally preferable over exporting the XSUB
64 symbols unnecessarily.
65 
66 =for comment
67 XS_INTERNAL marked 'u' because declaring a function static within our test
68 function doesn't work
69 
70 =for apidoc Ay||XS_EXTERNAL|name
71 Macro to declare an XSUB and its C parameter list explicitly exporting the symbols.
72 
73 =for apidoc Ay||XSPROTO|name
74 Macro used by C<L</XS_INTERNAL>> and C<L</XS_EXTERNAL>> to declare a function
75 prototype.  You probably shouldn't be using this directly yourself.
76 
77 =for apidoc Amn;||dAX
78 Sets up the C<ax> variable.
79 This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
80 
81 =for apidoc Amn;||dAXMARK
82 Sets up the C<ax> variable and stack marker variable C<mark>.
83 This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
84 
85 =for apidoc Amn;||dITEMS
86 Sets up the C<items> variable.
87 This is usually handled automatically by C<xsubpp> by calling C<dXSARGS>.
88 
89 =for apidoc Amn;||dXSARGS
90 Sets up stack and mark pointers for an XSUB, calling C<dSP> and C<dMARK>.
91 Sets up the C<ax> and C<items> variables by calling C<dAX> and C<dITEMS>.
92 This is usually handled automatically by C<xsubpp>.
93 
94 =for apidoc Amn;||dXSI32
95 Sets up the C<ix> variable for an XSUB which has aliases.  This is usually
96 handled automatically by C<xsubpp>.
97 
98 =for apidoc Amn;||dUNDERBAR
99 Sets up any variable needed by the C<UNDERBAR> macro.  It used to define
100 C<padoff_du>, but it is currently a noop.  However, it is strongly advised
101 to still use it for ensuring past and future compatibility.
102 
103 =for apidoc AmnU||UNDERBAR
104 The SV* corresponding to the C<$_> variable.  Works even if there
105 is a lexical C<$_> in scope.
106 
107 =cut
108 */
109 
110 #ifndef PERL_UNUSED_ARG
111 #  define PERL_UNUSED_ARG(x) ((void)sizeof(x))
112 #endif
113 #ifndef PERL_UNUSED_VAR
114 #  define PERL_UNUSED_VAR(x) ((void)sizeof(x))
115 #endif
116 
117 #define ST(off) PL_stack_base[ax + (off)]
118 
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  */
129 
130 /* XS_INTERNAL is the explicit static-linkage variant of the default
131  * XS macro.
132  *
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.
135  */
136 
137 #define XSPROTO(name) void name(pTHX_ CV* cv __attribute__unused__)
138 
139 #undef XS
140 #undef XS_EXTERNAL
141 #undef XS_INTERNAL
142 #if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
143 #  define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
144 #  define XS_INTERNAL(name) STATIC XSPROTO(name)
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)
154 #endif
155 
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)
159 
160 #define dAX const Stack_off_t ax = (Stack_off_t)(MARK - PL_stack_base + 1)
161 
162 #define dAXMARK				\
163         Stack_off_t ax = POPMARK;	\
164         SV **mark = PL_stack_base + ax++
165 
166 #define dITEMS Stack_off_t items = (Stack_off_t)(SP - MARK)
167 
168 #define dXSARGS \
169         dSP; dAXMARK; dITEMS
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. */
176 #define dXSBOOTARGSXSAPIVERCHK  \
177         Stack_off_t ax = XS_BOTHVERSION_SETXSUBFN_POPMARK_BOOTCHECK;	\
178         SV **mark = PL_stack_base + ax - 1; dSP; dITEMS
179 #define dXSBOOTARGSAPIVERCHK  \
180         Stack_off_t ax = XS_APIVERSION_SETXSUBFN_POPMARK_BOOTCHECK;	\
181         SV **mark = PL_stack_base + ax - 1; dSP; dITEMS
182 /* dXSBOOTARGSNOVERCHK has no API in xsubpp to choose it so do
183 #undef dXSBOOTARGSXSAPIVERCHK
184 #define dXSBOOTARGSXSAPIVERCHK dXSBOOTARGSNOVERCHK */
185 #define dXSBOOTARGSNOVERCHK  \
186         Stack_off_t ax = XS_SETXSUBFN_POPMARK;  \
187         SV **mark = PL_stack_base + ax - 1; dSP; dITEMS
188 
189 #define dXSTARG SV * const targ = ((PL_op->op_private & OPpENTERSUB_HASTARG) \
190                              ? PAD_SV(PL_op->op_targ) : sv_newmortal())
191 
192 /* Should be used before final PUSHi etc. if not in PPCODE section. */
193 #define XSprePUSH (sp = PL_stack_base + ax - 1)
194 
195 #define XSANY CvXSUBANY(cv)
196 
197 #define dXSI32 I32 ix = XSANY.any_i32
198 
199 #ifdef __cplusplus
200 #  define XSINTERFACE_CVT(ret,name) ret (*name)(...)
201 #  define XSINTERFACE_CVT_ANON(ret) ret (*)(...)
202 #else
203 #  define XSINTERFACE_CVT(ret,name) ret (*name)()
204 #  define XSINTERFACE_CVT_ANON(ret) ret (*)()
205 #endif
206 #define dXSFUNCTION(ret)		XSINTERFACE_CVT(ret,XSFUNCTION)
207 #define XSINTERFACE_FUNC(ret,cv,f)     ((XSINTERFACE_CVT_ANON(ret))(f))
208 #define XSINTERFACE_FUNC_SET(cv,f)	\
209                 CvXSUBANY(cv).any_dxptr = (void (*) (pTHX_ void*))(f)
210 
211 #define dUNDERBAR dNOOP
212 #define UNDERBAR  find_rundefsv()
213 
214 /* Simple macros to put new mortal values onto the stack.   */
215 /* Typically used to return values from XS functions.       */
216 
217 /*
218 =for apidoc_section $stack
219 
220 =for apidoc Am|void|XST_mIV|int pos|IV iv
221 Place an integer into the specified position C<pos> on the stack.  The
222 value is stored in a new mortal SV.
223 
224 =for apidoc Am|void|XST_mNV|int pos|NV nv
225 Place a double into the specified position C<pos> on the stack.  The value
226 is stored in a new mortal SV.
227 
228 =for apidoc Am|void|XST_mPV|int pos|char* str
229 Place a copy of a string into the specified position C<pos> on the stack.
230 The value is stored in a new mortal SV.
231 
232 =for apidoc Am|void|XST_mUV|int pos|UV uv
233 Place an unsigned integer into the specified position C<pos> on the stack.  The
234 value is stored in a new mortal SV.
235 
236 =for apidoc Am|void|XST_mNO|int pos
237 Place C<&PL_sv_no> into the specified position C<pos> on the
238 stack.
239 
240 =for apidoc Am|void|XST_mYES|int pos
241 Place C<&PL_sv_yes> into the specified position C<pos> on the
242 stack.
243 
244 =for apidoc Am|void|XST_mUNDEF|int pos
245 Place C<&PL_sv_undef> into the specified position C<pos> on the
246 stack.
247 
248 =for apidoc Am|void|XSRETURN|int nitems
249 Return from XSUB, indicating number of items on the stack.  This is usually
250 handled by C<xsubpp>.
251 
252 =for apidoc Am|void|XSRETURN_IV|IV iv
253 Return an integer from an XSUB immediately.  Uses C<XST_mIV>.
254 
255 =for apidoc Am|void|XSRETURN_UV|IV uv
256 Return an integer from an XSUB immediately.  Uses C<XST_mUV>.
257 
258 =for apidoc Am|void|XSRETURN_NV|NV nv
259 Return a double from an XSUB immediately.  Uses C<XST_mNV>.
260 
261 =for apidoc Am|void|XSRETURN_PV|char* str
262 Return a copy of a string from an XSUB immediately.  Uses C<XST_mPV>.
263 
264 =for apidoc Amn;||XSRETURN_NO
265 Return C<&PL_sv_no> from an XSUB immediately.  Uses C<XST_mNO>.
266 
267 =for apidoc Amn;||XSRETURN_YES
268 Return C<&PL_sv_yes> from an XSUB immediately.  Uses C<XST_mYES>.
269 
270 =for apidoc Amn;||XSRETURN_UNDEF
271 Return C<&PL_sv_undef> from an XSUB immediately.  Uses C<XST_mUNDEF>.
272 
273 =for apidoc Amn;||XSRETURN_EMPTY
274 Return an empty list from an XSUB immediately.
275 
276 =for apidoc AmU||newXSproto|char* name|XSUBADDR_t f|char* filename|const char *proto
277 Used by C<xsubpp> to hook up XSUBs as Perl subs.  Adds Perl prototypes to
278 the subs.
279 
280 =for apidoc AmnU||XS_VERSION
281 The version identifier for an XS module.  This is usually
282 handled automatically by C<ExtUtils::MakeMaker>.  See
283 C<L</XS_VERSION_BOOTCHECK>>.
284 
285 =for apidoc Amn;||XS_VERSION_BOOTCHECK
286 Macro to verify that a PM module's C<$VERSION> variable matches the XS
287 module's C<XS_VERSION> variable.  This is usually handled automatically by
288 C<xsubpp>.  See L<perlxs/"The VERSIONCHECK: Keyword">.
289 
290 =for apidoc Amn;||XS_APIVERSION_BOOTCHECK
291 Macro to verify that the perl api version an XS module has been compiled against
292 matches the api version of the perl interpreter it's being loaded into.
293 
294 =for apidoc_section $exceptions
295 
296 =for apidoc Amn;||dXCPT
297 Set up necessary local variables for exception handling.
298 See L<perlguts/"Exception Handling">.
299 
300 =for apidoc AmnU||XCPT_TRY_START
301 Starts a try block.  See L<perlguts/"Exception Handling">.
302 
303 =for apidoc AmnU||XCPT_TRY_END
304 Ends a try block.  See L<perlguts/"Exception Handling">.
305 
306 =for apidoc AmnU||XCPT_CATCH
307 Introduces a catch block.  See L<perlguts/"Exception Handling">.
308 
309 =for apidoc Amn;||XCPT_RETHROW
310 Rethrows a previously caught exception.  See L<perlguts/"Exception Handling">.
311 
312 =cut
313 */
314 
315 #define XST_mIV(i,v)  (ST(i) = sv_2mortal(newSViv(v))  )
316 #define XST_mUV(i,v)  (ST(i) = sv_2mortal(newSVuv(v))  )
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)))
319 #define XST_mPVN(i,v,n)  (ST(i) = newSVpvn_flags(v,n, SVs_TEMP))
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)
323 
324 #define XSRETURN(off)					\
325     STMT_START {					\
326         const IV tmpXSoff = (off);			\
327         assert(tmpXSoff >= 0);\
328         PL_stack_sp = PL_stack_base + ax + (tmpXSoff - 1);	\
329         return;						\
330     } STMT_END
331 
332 #define XSRETURN_IV(v)    STMT_START { XST_mIV(0,v);    XSRETURN(1); } STMT_END
333 #define XSRETURN_UV(v)    STMT_START { XST_mUV(0,v);    XSRETURN(1); } STMT_END
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
336 #define XSRETURN_PVN(v,n) STMT_START { XST_mPVN(0,v,n); XSRETURN(1); } STMT_END
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
341 
342 #define newXSproto(a,b,c,d)	newXS_flags(a,b,c,d,0)
343 
344 #ifdef XS_VERSION
345 #  define XS_VERSION_BOOTCHECK						\
346     Perl_xs_handshake(HS_KEY(FALSE, FALSE, "", XS_VERSION), HS_CXT, __FILE__,	\
347         items, ax, XS_VERSION)
348 #else
349 #  define XS_VERSION_BOOTCHECK
350 #endif
351 
352 #define XS_APIVERSION_BOOTCHECK						\
353     Perl_xs_handshake(HS_KEY(FALSE, FALSE, "v" PERL_API_VERSION_STRING, ""),	\
354         HS_CXT, __FILE__, items, ax, "v" PERL_API_VERSION_STRING)
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						\
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)
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 */
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)
370 #ifdef XS_VERSION
371 #  define XS_BOTHVERSION_POPMARK_BOOTCHECK					\
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)
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
378 
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 
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
405 
406 /*
407    The DBM_setFilter & DBM_ckFilter macros are only used by
408    the *DB*_File modules
409 */
410 
411 #define DBM_setFilter(db_type,code)				\
412         STMT_START {						\
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_NN(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             }	    						\
426         } STMT_END
427 
428 #define DBM_ckFilter(arg,type,name)				\
429     STMT_START {						\
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 ;				\
438             SAVE_DEFSV ;					\
439             if (name[7] == 's')                                 \
440                 arg = newSVsv(arg);                             \
441             DEFSV_set(arg) ;					\
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 ;						\
450             if (name[7] == 's'){                                \
451                 arg = sv_2mortal(arg);                          \
452             }                                                   \
453         }                                                       \
454     } STMT_END
455 
456 #if 1		/* for compatibility */
457 #  define VTBL_sv		&PL_vtbl_sv
458 #  define VTBL_env		&PL_vtbl_env
459 #  define VTBL_envelem		&PL_vtbl_envelem
460 #  define VTBL_sigelem		&PL_vtbl_sigelem
461 #  define VTBL_pack		&PL_vtbl_pack
462 #  define VTBL_packelem		&PL_vtbl_packelem
463 #  define VTBL_dbline		&PL_vtbl_dbline
464 #  define VTBL_isa		&PL_vtbl_isa
465 #  define VTBL_isaelem		&PL_vtbl_isaelem
466 #  define VTBL_arylen		&PL_vtbl_arylen
467 #  define VTBL_glob		&PL_vtbl_glob
468 #  define VTBL_mglob		&PL_vtbl_mglob
469 #  define VTBL_nkeys		&PL_vtbl_nkeys
470 #  define VTBL_taint		&PL_vtbl_taint
471 #  define VTBL_substr		&PL_vtbl_substr
472 #  define VTBL_vec		&PL_vtbl_vec
473 #  define VTBL_pos		&PL_vtbl_pos
474 #  define VTBL_bm		&PL_vtbl_bm
475 #  define VTBL_fm		&PL_vtbl_fm
476 #  define VTBL_uvar		&PL_vtbl_uvar
477 #  define VTBL_defelem		&PL_vtbl_defelem
478 #  define VTBL_regexp		&PL_vtbl_regexp
479 #  define VTBL_regdata		&PL_vtbl_regdata
480 #  define VTBL_regdatum		&PL_vtbl_regdatum
481 #  ifdef USE_LOCALE_COLLATE
482 #    define VTBL_collxfrm	&PL_vtbl_collxfrm
483 #  endif
484 #  define VTBL_amagic		&PL_vtbl_amagic
485 #  define VTBL_amagicelem	&PL_vtbl_amagicelem
486 #endif
487 
488 #if defined(MULTIPLICITY) && !defined(PERL_NO_GET_CONTEXT) && !defined(PERL_CORE)
489 #  undef aTHX
490 #  undef aTHX_
491 #  define aTHX		PERL_GET_THX
492 #  define aTHX_		aTHX,
493 #endif
494 
495 #if defined(PERL_IMPLICIT_SYS) && !defined(PERL_CORE)
496 #  ifndef NO_XSLOCKS
497 #    undef closedir
498 #    undef opendir
499 #    undef stdin
500 #    undef stdout
501 #    undef stderr
502 #    undef feof
503 #    undef ferror
504 #    undef fgetpos
505 #    undef ioctl
506 #    undef getlogin
507 #    undef getc
508 #    undef ungetc
509 #    undef fileno
510 
511 /* to avoid warnings: "xyz" redefined */
512 #ifdef WIN32
513 #    undef  popen
514 #    undef  pclose
515 #endif /* WIN32 */
516 
517 #    undef  socketpair
518 
519 #    define mkdir		PerlDir_mkdir
520 #    define chdir		PerlDir_chdir
521 #    define rmdir		PerlDir_rmdir
522 #    define closedir		PerlDir_close
523 #    define opendir		PerlDir_open
524 #    define readdir		PerlDir_read
525 #    define rewinddir		PerlDir_rewind
526 #    define seekdir		PerlDir_seek
527 #    define telldir		PerlDir_tell
528 #    define putenv		PerlEnv_putenv
529 #    define getenv		PerlEnv_getenv
530 #    define uname		PerlEnv_uname
531 #    define stdin		PerlSIO_stdin
532 #    define stdout		PerlSIO_stdout
533 #    define stderr		PerlSIO_stderr
534 #    define fopen		PerlSIO_fopen
535 #    define fclose		PerlSIO_fclose
536 #    define feof		PerlSIO_feof
537 #    define ferror		PerlSIO_ferror
538 #    define clearerr		PerlSIO_clearerr
539 #    define getc		PerlSIO_getc
540 #    define fgets		PerlSIO_fgets
541 #    define fputc		PerlSIO_fputc
542 #    define fputs		PerlSIO_fputs
543 #    define fflush		PerlSIO_fflush
544 #    define ungetc		PerlSIO_ungetc
545 #    define fileno		PerlSIO_fileno
546 #    define fdopen		PerlSIO_fdopen
547 #    define freopen		PerlSIO_freopen
548 #    define fread		PerlSIO_fread
549 #    define fwrite		PerlSIO_fwrite
550 #    define setbuf		PerlSIO_setbuf
551 #    define setvbuf		PerlSIO_setvbuf
552 #    define setlinebuf		PerlSIO_setlinebuf
553 #    define stdoutf		PerlSIO_stdoutf
554 #    define vfprintf		PerlSIO_vprintf
555 #    define ftell		PerlSIO_ftell
556 #    define fseek		PerlSIO_fseek
557 #    define fgetpos		PerlSIO_fgetpos
558 #    define fsetpos		PerlSIO_fsetpos
559 #    define frewind		PerlSIO_rewind
560 #    define tmpfile		PerlSIO_tmpfile
561 #    define access		PerlLIO_access
562 #    define chmod		PerlLIO_chmod
563 #    define chsize		PerlLIO_chsize
564 #    define close		PerlLIO_close
565 #    define dup			PerlLIO_dup
566 #    define dup2		PerlLIO_dup2
567 #    define flock		PerlLIO_flock
568 #    define fstat		PerlLIO_fstat
569 #    define ioctl		PerlLIO_ioctl
570 #    define isatty		PerlLIO_isatty
571 #    define link                PerlLIO_link
572 #    define lseek		PerlLIO_lseek
573 #    define lstat		PerlLIO_lstat
574 #    define mktemp		PerlLIO_mktemp
575 #    define open		PerlLIO_open
576 #    define read		PerlLIO_read
577 #    define rename		PerlLIO_rename
578 #    define setmode		PerlLIO_setmode
579 #    define stat(buf,sb)	PerlLIO_stat(buf,sb)
580 #    define tmpnam		PerlLIO_tmpnam
581 #    define umask		PerlLIO_umask
582 #    define unlink		PerlLIO_unlink
583 #    define utime		PerlLIO_utime
584 #    define write		PerlLIO_write
585 #    define malloc		PerlMem_malloc
586 #    define calloc              PerlMem_calloc
587 #    define realloc		PerlMem_realloc
588 #    define free		PerlMem_free
589 #    define abort		PerlProc_abort
590 #    define exit		PerlProc_exit
591 #    define _exit		PerlProc__exit
592 #    define execl		PerlProc_execl
593 #    define execv		PerlProc_execv
594 #    define execvp		PerlProc_execvp
595 #    define getuid		PerlProc_getuid
596 #    define geteuid		PerlProc_geteuid
597 #    define getgid		PerlProc_getgid
598 #    define getegid		PerlProc_getegid
599 #    define getlogin		PerlProc_getlogin
600 #    define kill		PerlProc_kill
601 #    define killpg		PerlProc_killpg
602 #    define pause		PerlProc_pause
603 #    define popen		PerlProc_popen
604 #    define pclose		PerlProc_pclose
605 #    define pipe		PerlProc_pipe
606 #    define setuid		PerlProc_setuid
607 #    define setgid		PerlProc_setgid
608 #    define sleep		PerlProc_sleep
609 #    define times		PerlProc_times
610 #    define wait		PerlProc_wait
611 #    define signal		PerlProc_signal
612 #    define getpid		PerlProc_getpid
613 #    define gettimeofday	PerlProc_gettimeofday
614 #    define htonl		PerlSock_htonl
615 #    define htons		PerlSock_htons
616 #    define ntohl		PerlSock_ntohl
617 #    define ntohs		PerlSock_ntohs
618 #    define accept		PerlSock_accept
619 #    define bind		PerlSock_bind
620 #    define connect		PerlSock_connect
621 #    define endhostent		PerlSock_endhostent
622 #    define endnetent		PerlSock_endnetent
623 #    define endprotoent		PerlSock_endprotoent
624 #    define endservent		PerlSock_endservent
625 #    define gethostbyaddr	PerlSock_gethostbyaddr
626 #    define gethostbyname	PerlSock_gethostbyname
627 #    define gethostent		PerlSock_gethostent
628 #    define gethostname		PerlSock_gethostname
629 #    define getnetbyaddr	PerlSock_getnetbyaddr
630 #    define getnetbyname	PerlSock_getnetbyname
631 #    define getnetent		PerlSock_getnetent
632 #    define getpeername		PerlSock_getpeername
633 #    define getprotobyname	PerlSock_getprotobyname
634 #    define getprotobynumber	PerlSock_getprotobynumber
635 #    define getprotoent		PerlSock_getprotoent
636 #    define getservbyname	PerlSock_getservbyname
637 #    define getservbyport	PerlSock_getservbyport
638 #    define getservent		PerlSock_getservent
639 #    define getsockname		PerlSock_getsockname
640 #    define getsockopt		PerlSock_getsockopt
641 #    define inet_addr		PerlSock_inet_addr
642 #    define inet_ntoa		PerlSock_inet_ntoa
643 #    define listen		PerlSock_listen
644 #    define recv		PerlSock_recv
645 #    define recvfrom		PerlSock_recvfrom
646 #    define select		PerlSock_select
647 #    define send		PerlSock_send
648 #    define sendto		PerlSock_sendto
649 #    define sethostent		PerlSock_sethostent
650 #    define setnetent		PerlSock_setnetent
651 #    define setprotoent		PerlSock_setprotoent
652 #    define setservent		PerlSock_setservent
653 #    define setsockopt		PerlSock_setsockopt
654 #    define shutdown		PerlSock_shutdown
655 #    define socket		PerlSock_socket
656 #    define socketpair		PerlSock_socketpair
657 
658 #    undef fd_set
659 #    undef FD_SET
660 #    undef FD_CLR
661 #    undef FD_ISSET
662 #    undef FD_ZERO
663 #    define fd_set		Perl_fd_set
664 #    define FD_SET(n,p)		PERL_FD_SET(n,p)
665 #    define FD_CLR(n,p)		PERL_FD_CLR(n,p)
666 #    define FD_ISSET(n,p)	PERL_FD_ISSET(n,p)
667 #    define FD_ZERO(p)		PERL_FD_ZERO(p)
668 
669 #  endif  /* NO_XSLOCKS */
670 #endif  /* PERL_IMPLICIT_SYS && !PERL_CORE */
671 
672 #endif /* PERL_XSUB_H_ */		/* include guard */
673 
674 /*
675  * ex: set ts=8 sts=4 sw=4 et:
676  */
677