1 #define ST(off) PL_stack_base[ax + (off)]
5 # define XS(name) void name(CV* cv, CPerlObj* pPerl)
7 # if defined(CYGWIN32) && defined(USE_DYNAMIC_LOADING)
8 # define XS(name) __declspec(dllexport) void name(CV* cv)
9 extern struct _reent *_impure_ptr;
10 void impure_setup(struct _reent *_impure_ptrMain);
12 # define XS(name) void name(CV* cv)
16 # define XS(name) void name(cv) CV* cv;
21 I32 ax = mark - PL_stack_base + 1; \
24 #define XSANY CvXSUBANY(cv)
26 #define dXSI32 I32 ix = XSANY.any_i32
29 # define XSINTERFACE_CVT(ret,name) ret (*name)(...)
31 # define XSINTERFACE_CVT(ret,name) ret (*name)()
33 #define dXSFUNCTION(ret) XSINTERFACE_CVT(ret,XSFUNCTION)
34 #define XSINTERFACE_FUNC(ret,cv,f) ((XSINTERFACE_CVT(ret,))(f))
35 #define XSINTERFACE_FUNC_SET(cv,f) \
36 CvXSUBANY(cv).any_dptr = (void (*) _((void*)))(f)
38 #define XSRETURN(off) \
40 PL_stack_sp = PL_stack_base + ax + ((off) - 1); \
44 /* Simple macros to put new mortal values onto the stack. */
45 /* Typically used to return values from XS functions. */
46 #define XST_mIV(i,v) (ST(i) = sv_2mortal(newSViv(v)) )
47 #define XST_mNV(i,v) (ST(i) = sv_2mortal(newSVnv(v)) )
48 #define XST_mPV(i,v) (ST(i) = sv_2mortal(newSVpv(v,0)))
49 #define XST_mPVN(i,v,n) (ST(i) = sv_2mortal(newSVpvn(v,n)))
50 #define XST_mNO(i) (ST(i) = &PL_sv_no )
51 #define XST_mYES(i) (ST(i) = &PL_sv_yes )
52 #define XST_mUNDEF(i) (ST(i) = &PL_sv_undef)
54 #define XSRETURN_IV(v) STMT_START { XST_mIV(0,v); XSRETURN(1); } STMT_END
55 #define XSRETURN_NV(v) STMT_START { XST_mNV(0,v); XSRETURN(1); } STMT_END
56 #define XSRETURN_PV(v) STMT_START { XST_mPV(0,v); XSRETURN(1); } STMT_END
57 #define XSRETURN_PVN(v) STMT_START { XST_mPVN(0,v,n); XSRETURN(1); } STMT_END
58 #define XSRETURN_NO STMT_START { XST_mNO(0); XSRETURN(1); } STMT_END
59 #define XSRETURN_YES STMT_START { XST_mYES(0); XSRETURN(1); } STMT_END
60 #define XSRETURN_UNDEF STMT_START { XST_mUNDEF(0); XSRETURN(1); } STMT_END
61 #define XSRETURN_EMPTY STMT_START { XSRETURN(0); } STMT_END
63 #define newXSproto(a,b,c,d) sv_setpv((SV*)newXS(a,b,c), d)
66 # define XS_VERSION_BOOTCHECK \
68 SV *tmpsv; STRLEN n_a; \
69 char *vn = Nullch, *module = SvPV(ST(0),n_a); \
70 if (items >= 2) /* version supplied as bootstrap arg */ \
73 /* XXX GV_ADDWARN */ \
74 tmpsv = perl_get_sv(form("%s::%s", module, \
75 vn = "XS_VERSION"), FALSE); \
76 if (!tmpsv || !SvOK(tmpsv)) \
77 tmpsv = perl_get_sv(form("%s::%s", module, \
78 vn = "VERSION"), FALSE); \
80 if (tmpsv && (!SvOK(tmpsv) || strNE(XS_VERSION, SvPV(tmpsv, n_a)))) \
81 croak("%s object version %s does not match %s%s%s%s %_", \
83 vn ? "$" : "", vn ? module : "", vn ? "::" : "", \
84 vn ? vn : "bootstrap parameter", tmpsv); \
87 # define XS_VERSION_BOOTCHECK
91 # define VTBL_sv get_vtbl(want_vtbl_sv)
92 # define VTBL_env get_vtbl(want_vtbl_env)
93 # define VTBL_envelem get_vtbl(want_vtbl_envelem)
94 # define VTBL_sig get_vtbl(want_vtbl_sig)
95 # define VTBL_sigelem get_vtbl(want_vtbl_sigelem)
96 # define VTBL_pack get_vtbl(want_vtbl_pack)
97 # define VTBL_packelem get_vtbl(want_vtbl_packelem)
98 # define VTBL_dbline get_vtbl(want_vtbl_dbline)
99 # define VTBL_isa get_vtbl(want_vtbl_isa)
100 # define VTBL_isaelem get_vtbl(want_vtbl_isaelem)
101 # define VTBL_arylen get_vtbl(want_vtbl_arylen)
102 # define VTBL_glob get_vtbl(want_vtbl_glob)
103 # define VTBL_mglob get_vtbl(want_vtbl_mglob)
104 # define VTBL_nkeys get_vtbl(want_vtbl_nkeys)
105 # define VTBL_taint get_vtbl(want_vtbl_taint)
106 # define VTBL_substr get_vtbl(want_vtbl_substr)
107 # define VTBL_vec get_vtbl(want_vtbl_vec)
108 # define VTBL_pos get_vtbl(want_vtbl_pos)
109 # define VTBL_bm get_vtbl(want_vtbl_bm)
110 # define VTBL_fm get_vtbl(want_vtbl_fm)
111 # define VTBL_uvar get_vtbl(want_vtbl_uvar)
112 # define VTBL_defelem get_vtbl(want_vtbl_defelem)
113 # define VTBL_regexp get_vtbl(want_vtbl_regexp)
114 # define VTBL_regdata get_vtbl(want_vtbl_regdata)
115 # define VTBL_regdatum get_vtbl(want_vtbl_regdatum)
116 # ifdef USE_LOCALE_COLLATE
117 # define VTBL_collxfrm get_vtbl(want_vtbl_collxfrm)
119 # define VTBL_amagic get_vtbl(want_vtbl_amagic)
120 # define VTBL_amagicelem get_vtbl(want_vtbl_amagicelem)
122 # define VTBL_sv &PL_vtbl_sv
123 # define VTBL_env &PL_vtbl_env
124 # define VTBL_envelem &PL_vtbl_envelem
125 # define VTBL_sig &PL_vtbl_sig
126 # define VTBL_sigelem &PL_vtbl_sigelem
127 # define VTBL_pack &PL_vtbl_pack
128 # define VTBL_packelem &PL_vtbl_packelem
129 # define VTBL_dbline &PL_vtbl_dbline
130 # define VTBL_isa &PL_vtbl_isa
131 # define VTBL_isaelem &PL_vtbl_isaelem
132 # define VTBL_arylen &PL_vtbl_arylen
133 # define VTBL_glob &PL_vtbl_glob
134 # define VTBL_mglob &PL_vtbl_mglob
135 # define VTBL_nkeys &PL_vtbl_nkeys
136 # define VTBL_taint &PL_vtbl_taint
137 # define VTBL_substr &PL_vtbl_substr
138 # define VTBL_vec &PL_vtbl_vec
139 # define VTBL_pos &PL_vtbl_pos
140 # define VTBL_bm &PL_vtbl_bm
141 # define VTBL_fm &PL_vtbl_fm
142 # define VTBL_uvar &PL_vtbl_uvar
143 # define VTBL_defelem &PL_vtbl_defelem
144 # define VTBL_regexp &PL_vtbl_regexp
145 # define VTBL_regdata &PL_vtbl_regdata
146 # define VTBL_regdatum &PL_vtbl_regdatum
147 # ifdef USE_LOCALE_COLLATE
148 # define VTBL_collxfrm &PL_vtbl_collxfrm
150 # define VTBL_amagic &PL_vtbl_amagic
151 # define VTBL_amagicelem &PL_vtbl_amagicelem
155 # include "objXSUB.h"
157 # undef PERL_OBJECT_THIS
158 # define PERL_OBJECT_THIS pPerl
159 # undef PERL_OBJECT_THIS_
160 # define PERL_OBJECT_THIS_ pPerl,
162 # undef SAVEDESTRUCTOR
163 # define SAVEDESTRUCTOR(f,p) \
164 pPerl->Perl_save_destructor((FUNC_NAME_TO_PTR(f)),(p))
167 # ifndef WIN32IO_IS_STDIO
169 # define errno ErrorNo()
172 # define ErrorNo pPerl->ErrorNo
174 # define NtCrypt pPerl->NtCrypt
176 # define NtGetLib pPerl->NtGetLib
178 # define NtGetArchLib pPerl->NtGetArchLib
180 # define NtGetSiteLib pPerl->NtGetSiteLib
182 # define NtGetBin pPerl->NtGetBin
183 # undef NtGetDebugScriptStr
184 # define NtGetDebugScriptStr pPerl->NtGetDebugScriptStr
203 # define mkdir PerlDir_mkdir
204 # define chdir PerlDir_chdir
205 # define rmdir PerlDir_rmdir
206 # define closedir PerlDir_close
207 # define opendir PerlDir_open
208 # define readdir PerlDir_read
209 # define rewinddir PerlDir_rewind
210 # define seekdir PerlDir_seek
211 # define telldir PerlDir_tell
212 # define putenv PerlEnv_putenv
213 # define getenv PerlEnv_getenv
214 # define uname PerlEnv_uname
215 # define stdin PerlIO_stdin()
216 # define stdout PerlIO_stdout()
217 # define stderr PerlIO_stderr()
218 # define fopen PerlIO_open
219 # define fclose PerlIO_close
220 # define feof PerlIO_eof
221 # define ferror PerlIO_error
222 # define fclearerr PerlIO_clearerr
223 # define getc PerlIO_getc
224 # define fputc(c, f) PerlIO_putc(f,c)
225 # define fputs(s, f) PerlIO_puts(f,s)
226 # define fflush PerlIO_flush
227 # define ungetc(c, f) PerlIO_ungetc((f),(c))
228 # define fileno PerlIO_fileno
229 # define fdopen PerlIO_fdopen
230 # define freopen PerlIO_reopen
231 # define fread(b,s,c,f) PerlIO_read((f),(b),(s*c))
232 # define fwrite(b,s,c,f) PerlIO_write((f),(b),(s*c))
233 # define setbuf PerlIO_setbuf
234 # define setvbuf PerlIO_setvbuf
235 # define setlinebuf PerlIO_setlinebuf
236 # define stdoutf PerlIO_stdoutf
237 # define vfprintf PerlIO_vprintf
238 # define ftell PerlIO_tell
239 # define fseek PerlIO_seek
240 # define fgetpos PerlIO_getpos
241 # define fsetpos PerlIO_setpos
242 # define frewind PerlIO_rewind
243 # define tmpfile PerlIO_tmpfile
244 # define access PerlLIO_access
245 # define chmod PerlLIO_chmod
246 # define chsize PerlLIO_chsize
247 # define close PerlLIO_close
248 # define dup PerlLIO_dup
249 # define dup2 PerlLIO_dup2
250 # define flock PerlLIO_flock
251 # define fstat PerlLIO_fstat
252 # define ioctl PerlLIO_ioctl
253 # define isatty PerlLIO_isatty
254 # define lseek PerlLIO_lseek
255 # define lstat PerlLIO_lstat
256 # define mktemp PerlLIO_mktemp
257 # define open PerlLIO_open
258 # define read PerlLIO_read
259 # define rename PerlLIO_rename
260 # define setmode PerlLIO_setmode
261 # define stat PerlLIO_stat
262 # define tmpnam PerlLIO_tmpnam
263 # define umask PerlLIO_umask
264 # define unlink PerlLIO_unlink
265 # define utime PerlLIO_utime
266 # define write PerlLIO_write
267 # define malloc PerlMem_malloc
268 # define realloc PerlMem_realloc
269 # define free PerlMem_free
270 # define abort PerlProc_abort
271 # define exit PerlProc_exit
272 # define _exit PerlProc__exit
273 # define execl PerlProc_execl
274 # define execv PerlProc_execv
275 # define execvp PerlProc_execvp
276 # define getuid PerlProc_getuid
277 # define geteuid PerlProc_geteuid
278 # define getgid PerlProc_getgid
279 # define getegid PerlProc_getegid
280 # define getlogin PerlProc_getlogin
281 # define kill PerlProc_kill
282 # define killpg PerlProc_killpg
283 # define pause PerlProc_pause
284 # define popen PerlProc_popen
285 # define pclose PerlProc_pclose
286 # define pipe PerlProc_pipe
287 # define setuid PerlProc_setuid
288 # define setgid PerlProc_setgid
289 # define sleep PerlProc_sleep
290 # define times PerlProc_times
291 # define wait PerlProc_wait
292 # define setjmp PerlProc_setjmp
293 # define longjmp PerlProc_longjmp
294 # define signal PerlProc_signal
295 # define htonl PerlSock_htonl
296 # define htons PerlSock_htons
297 # define ntohl PerlSock_ntohl
298 # define ntohs PerlSock_ntohs
299 # define accept PerlSock_accept
300 # define bind PerlSock_bind
301 # define connect PerlSock_connect
302 # define endhostent PerlSock_endhostent
303 # define endnetent PerlSock_endnetent
304 # define endprotoent PerlSock_endprotoent
305 # define endservent PerlSock_endservent
306 # define gethostbyaddr PerlSock_gethostbyaddr
307 # define gethostbyname PerlSock_gethostbyname
308 # define gethostent PerlSock_gethostent
309 # define gethostname PerlSock_gethostname
310 # define getnetbyaddr PerlSock_getnetbyaddr
311 # define getnetbyname PerlSock_getnetbyname
312 # define getnetent PerlSock_getnetent
313 # define getpeername PerlSock_getpeername
314 # define getprotobyname PerlSock_getprotobyname
315 # define getprotobynumber PerlSock_getprotobynumber
316 # define getprotoent PerlSock_getprotoent
317 # define getservbyname PerlSock_getservbyname
318 # define getservbyport PerlSock_getservbyport
319 # define getservent PerlSock_getservent
320 # define getsockname PerlSock_getsockname
321 # define getsockopt PerlSock_getsockopt
322 # define inet_addr PerlSock_inet_addr
323 # define inet_ntoa PerlSock_inet_ntoa
324 # define listen PerlSock_listen
325 # define recv PerlSock_recv
326 # define recvfrom PerlSock_recvfrom
327 # define select PerlSock_select
328 # define send PerlSock_send
329 # define sendto PerlSock_sendto
330 # define sethostent PerlSock_sethostent
331 # define setnetent PerlSock_setnetent
332 # define setprotoent PerlSock_setprotoent
333 # define setservent PerlSock_setservent
334 # define setsockopt PerlSock_setsockopt
335 # define shutdown PerlSock_shutdown
336 # define socket PerlSock_socket
337 # define socketpair PerlSock_socketpair
342 # endif /* NO_XSLOCKS */
345 # include "perlCAPI.h"
347 #endif /* PERL_OBJECT */