1 #define ST(off) PL_stack_base[ax + (off)]
3 #if defined(CYGWIN) && defined(USE_DYNAMIC_LOADING)
4 # define XS(name) __declspec(dllexport) void name(pTHXo_ CV* cv)
6 # define XS(name) void name(pTHXo_ CV* cv)
11 I32 ax = mark - PL_stack_base + 1; \
14 #define dXSTARG SV * targ = ((PL_op->op_private & OPpENTERSUB_HASTARG) \
15 ? PAD_SV(PL_op->op_targ) : sv_newmortal())
17 #define XSANY CvXSUBANY(cv)
19 #define dXSI32 I32 ix = XSANY.any_i32
22 # define XSINTERFACE_CVT(ret,name) ret (*name)(...)
24 # define XSINTERFACE_CVT(ret,name) ret (*name)()
26 #define dXSFUNCTION(ret) XSINTERFACE_CVT(ret,XSFUNCTION)
27 #define XSINTERFACE_FUNC(ret,cv,f) ((XSINTERFACE_CVT(ret,cv))(f))
28 #define XSINTERFACE_FUNC_SET(cv,f) \
29 CvXSUBANY(cv).any_dptr = (void (*) (pTHXo_ void*))(f)
31 #define XSRETURN(off) \
33 PL_stack_sp = PL_stack_base + ax + ((off) - 1); \
37 /* Simple macros to put new mortal values onto the stack. */
38 /* Typically used to return values from XS functions. */
39 #define XST_mIV(i,v) (ST(i) = sv_2mortal(newSViv(v)) )
40 #define XST_mNV(i,v) (ST(i) = sv_2mortal(newSVnv(v)) )
41 #define XST_mPV(i,v) (ST(i) = sv_2mortal(newSVpv(v,0)))
42 #define XST_mPVN(i,v,n) (ST(i) = sv_2mortal(newSVpvn(v,n)))
43 #define XST_mNO(i) (ST(i) = &PL_sv_no )
44 #define XST_mYES(i) (ST(i) = &PL_sv_yes )
45 #define XST_mUNDEF(i) (ST(i) = &PL_sv_undef)
47 #define XSRETURN_IV(v) STMT_START { XST_mIV(0,v); XSRETURN(1); } STMT_END
48 #define XSRETURN_NV(v) STMT_START { XST_mNV(0,v); XSRETURN(1); } STMT_END
49 #define XSRETURN_PV(v) STMT_START { XST_mPV(0,v); XSRETURN(1); } STMT_END
50 #define XSRETURN_PVN(v) STMT_START { XST_mPVN(0,v,n); XSRETURN(1); } STMT_END
51 #define XSRETURN_NO STMT_START { XST_mNO(0); XSRETURN(1); } STMT_END
52 #define XSRETURN_YES STMT_START { XST_mYES(0); XSRETURN(1); } STMT_END
53 #define XSRETURN_UNDEF STMT_START { XST_mUNDEF(0); XSRETURN(1); } STMT_END
54 #define XSRETURN_EMPTY STMT_START { XSRETURN(0); } STMT_END
56 #define newXSproto(a,b,c,d) sv_setpv((SV*)newXS(a,b,c), d)
59 # define XS_VERSION_BOOTCHECK \
61 SV *tmpsv; STRLEN n_a; \
62 char *vn = Nullch, *module = SvPV(ST(0),n_a); \
63 if (items >= 2) /* version supplied as bootstrap arg */ \
66 /* XXX GV_ADDWARN */ \
67 tmpsv = get_sv(Perl_form(aTHX_ "%s::%s", module, \
68 vn = "XS_VERSION"), FALSE); \
69 if (!tmpsv || !SvOK(tmpsv)) \
70 tmpsv = get_sv(Perl_form(aTHX_ "%s::%s", module, \
71 vn = "VERSION"), FALSE); \
73 if (tmpsv && (!SvOK(tmpsv) || strNE(XS_VERSION, SvPV(tmpsv, n_a)))) \
74 Perl_croak(aTHX_ "%s object version %s does not match %s%s%s%s %_", \
76 vn ? "$" : "", vn ? module : "", vn ? "::" : "", \
77 vn ? vn : "bootstrap parameter", tmpsv); \
80 # define XS_VERSION_BOOTCHECK
83 #if 1 /* for compatibility */
84 # define VTBL_sv &PL_vtbl_sv
85 # define VTBL_env &PL_vtbl_env
86 # define VTBL_envelem &PL_vtbl_envelem
87 # define VTBL_sig &PL_vtbl_sig
88 # define VTBL_sigelem &PL_vtbl_sigelem
89 # define VTBL_pack &PL_vtbl_pack
90 # define VTBL_packelem &PL_vtbl_packelem
91 # define VTBL_dbline &PL_vtbl_dbline
92 # define VTBL_isa &PL_vtbl_isa
93 # define VTBL_isaelem &PL_vtbl_isaelem
94 # define VTBL_arylen &PL_vtbl_arylen
95 # define VTBL_glob &PL_vtbl_glob
96 # define VTBL_mglob &PL_vtbl_mglob
97 # define VTBL_nkeys &PL_vtbl_nkeys
98 # define VTBL_taint &PL_vtbl_taint
99 # define VTBL_substr &PL_vtbl_substr
100 # define VTBL_vec &PL_vtbl_vec
101 # define VTBL_pos &PL_vtbl_pos
102 # define VTBL_bm &PL_vtbl_bm
103 # define VTBL_fm &PL_vtbl_fm
104 # define VTBL_uvar &PL_vtbl_uvar
105 # define VTBL_defelem &PL_vtbl_defelem
106 # define VTBL_regexp &PL_vtbl_regexp
107 # define VTBL_regdata &PL_vtbl_regdata
108 # define VTBL_regdatum &PL_vtbl_regdatum
109 # ifdef USE_LOCALE_COLLATE
110 # define VTBL_collxfrm &PL_vtbl_collxfrm
112 # define VTBL_amagic &PL_vtbl_amagic
113 # define VTBL_amagicelem &PL_vtbl_amagicelem
116 #if defined(PERL_OBJECT) || defined(PERL_CAPI)
117 # include "perlapi.h"
118 # include "objXSUB.h"
119 #endif /* PERL_OBJECT || PERL_CAPI */
121 #if defined(PERL_IMPLICIT_CONTEXT) && !defined(PERL_NO_GET_CONTEXT) && !defined(PERL_CORE)
124 # define aTHX PERL_GET_THX
128 #if defined(PERL_CAPI)
145 # define mkdir PerlDir_mkdir
146 # define chdir PerlDir_chdir
147 # define rmdir PerlDir_rmdir
148 # define closedir PerlDir_close
149 # define opendir PerlDir_open
150 # define readdir PerlDir_read
151 # define rewinddir PerlDir_rewind
152 # define seekdir PerlDir_seek
153 # define telldir PerlDir_tell
154 # define putenv PerlEnv_putenv
155 # define getenv PerlEnv_getenv
156 # define uname PerlEnv_uname
157 # define stdin PerlIO_stdin()
158 # define stdout PerlIO_stdout()
159 # define stderr PerlIO_stderr()
160 # define fopen PerlIO_open
161 # define fclose PerlIO_close
162 # define feof PerlIO_eof
163 # define ferror PerlIO_error
164 # define fclearerr PerlIO_clearerr
165 # define getc PerlIO_getc
166 # define fputc(c, f) PerlIO_putc(f,c)
167 # define fputs(s, f) PerlIO_puts(f,s)
168 # define fflush PerlIO_flush
169 # define ungetc(c, f) PerlIO_ungetc((f),(c))
170 # define fileno PerlIO_fileno
171 # define fdopen PerlIO_fdopen
172 # define freopen PerlIO_reopen
173 # define fread(b,s,c,f) PerlIO_read((f),(b),(s*c))
174 # define fwrite(b,s,c,f) PerlIO_write((f),(b),(s*c))
175 # define setbuf PerlIO_setbuf
176 # define setvbuf PerlIO_setvbuf
177 # define setlinebuf PerlIO_setlinebuf
178 # define stdoutf PerlIO_stdoutf
179 # define vfprintf PerlIO_vprintf
180 # define ftell PerlIO_tell
181 # define fseek PerlIO_seek
182 # define fgetpos PerlIO_getpos
183 # define fsetpos PerlIO_setpos
184 # define frewind PerlIO_rewind
185 # define tmpfile PerlIO_tmpfile
186 # define access PerlLIO_access
187 # define chmod PerlLIO_chmod
188 # define chsize PerlLIO_chsize
189 # define close PerlLIO_close
190 # define dup PerlLIO_dup
191 # define dup2 PerlLIO_dup2
192 # define flock PerlLIO_flock
193 # define fstat PerlLIO_fstat
194 # define ioctl PerlLIO_ioctl
195 # define isatty PerlLIO_isatty
196 # define lseek PerlLIO_lseek
197 # define lstat PerlLIO_lstat
198 # define mktemp PerlLIO_mktemp
199 # define open PerlLIO_open
200 # define read PerlLIO_read
201 # define rename PerlLIO_rename
202 # define setmode PerlLIO_setmode
203 # define stat PerlLIO_stat
204 # define tmpnam PerlLIO_tmpnam
205 # define umask PerlLIO_umask
206 # define unlink PerlLIO_unlink
207 # define utime PerlLIO_utime
208 # define write PerlLIO_write
209 # define malloc PerlMem_malloc
210 # define realloc PerlMem_realloc
211 # define free PerlMem_free
212 # define abort PerlProc_abort
213 # define exit PerlProc_exit
214 # define _exit PerlProc__exit
215 # define execl PerlProc_execl
216 # define execv PerlProc_execv
217 # define execvp PerlProc_execvp
218 # define getuid PerlProc_getuid
219 # define geteuid PerlProc_geteuid
220 # define getgid PerlProc_getgid
221 # define getegid PerlProc_getegid
222 # define getlogin PerlProc_getlogin
223 # define kill PerlProc_kill
224 # define killpg PerlProc_killpg
225 # define pause PerlProc_pause
226 # define popen PerlProc_popen
227 # define pclose PerlProc_pclose
228 # define pipe PerlProc_pipe
229 # define setuid PerlProc_setuid
230 # define setgid PerlProc_setgid
231 # define sleep PerlProc_sleep
232 # define times PerlProc_times
233 # define wait PerlProc_wait
234 # define setjmp PerlProc_setjmp
235 # define longjmp PerlProc_longjmp
236 # define signal PerlProc_signal
237 # define htonl PerlSock_htonl
238 # define htons PerlSock_htons
239 # define ntohl PerlSock_ntohl
240 # define ntohs PerlSock_ntohs
241 # define accept PerlSock_accept
242 # define bind PerlSock_bind
243 # define connect PerlSock_connect
244 # define endhostent PerlSock_endhostent
245 # define endnetent PerlSock_endnetent
246 # define endprotoent PerlSock_endprotoent
247 # define endservent PerlSock_endservent
248 # define gethostbyaddr PerlSock_gethostbyaddr
249 # define gethostbyname PerlSock_gethostbyname
250 # define gethostent PerlSock_gethostent
251 # define gethostname PerlSock_gethostname
252 # define getnetbyaddr PerlSock_getnetbyaddr
253 # define getnetbyname PerlSock_getnetbyname
254 # define getnetent PerlSock_getnetent
255 # define getpeername PerlSock_getpeername
256 # define getprotobyname PerlSock_getprotobyname
257 # define getprotobynumber PerlSock_getprotobynumber
258 # define getprotoent PerlSock_getprotoent
259 # define getservbyname PerlSock_getservbyname
260 # define getservbyport PerlSock_getservbyport
261 # define getservent PerlSock_getservent
262 # define getsockname PerlSock_getsockname
263 # define getsockopt PerlSock_getsockopt
264 # define inet_addr PerlSock_inet_addr
265 # define inet_ntoa PerlSock_inet_ntoa
266 # define listen PerlSock_listen
267 # define recv PerlSock_recv
268 # define recvfrom PerlSock_recvfrom
269 # define select PerlSock_select
270 # define send PerlSock_send
271 # define sendto PerlSock_sendto
272 # define sethostent PerlSock_sethostent
273 # define setnetent PerlSock_setnetent
274 # define setprotoent PerlSock_setprotoent
275 # define setservent PerlSock_setservent
276 # define setsockopt PerlSock_setsockopt
277 # define shutdown PerlSock_shutdown
278 # define socket PerlSock_socket
279 # define socketpair PerlSock_socketpair
280 # endif /* NO_XSLOCKS */
281 #endif /* PERL_CAPI */