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