This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Further simplify the sockatmark().
[perl5.git] / dist / IO / IO.xs
CommitLineData
cf7fe8a2
GS
1/*
2 * Copyright (c) 1997-8 Graham Barr <gbarr@pobox.com>. All rights reserved.
3 * This program is free software; you can redistribute it and/or
4 * modify it under the same terms as Perl itself.
5 */
6
6e22d046
JH
7#define PERL_EXT_IO
8
c5be433b 9#define PERL_NO_GET_CONTEXT
8add82fc 10#include "EXTERN.h"
760ac839 11#define PERLIO_NOT_STDIO 1
8add82fc
PP
12#include "perl.h"
13#include "XSUB.h"
cf7fe8a2 14#include "poll.h"
8add82fc
PP
15#ifdef I_UNISTD
16# include <unistd.h>
17#endif
cf7fe8a2 18#if defined(I_FCNTL) || defined(HAS_FCNTL)
760ac839
LW
19# include <fcntl.h>
20#endif
8add82fc 21
63a347c7
JH
22#ifndef SIOCATMARK
23# ifdef I_SYS_SOCKIO
24# include <sys/sockio.h>
25# endif
26#endif
27
2a0cf753 28#ifdef PerlIO
eb44fba6 29#if defined(MACOS_TRADITIONAL) && defined(USE_SFIO)
824215e2
JH
30#define PERLIO_IS_STDIO 1
31#undef setbuf
32#undef setvbuf
33#define setvbuf _stdsetvbuf
34#define setbuf(f,b) ( __sf_setbuf(f,b) )
35#endif
8add82fc 36typedef int SysRet;
760ac839
LW
37typedef PerlIO * InputStream;
38typedef PerlIO * OutputStream;
2a0cf753
PP
39#else
40#define PERLIO_IS_STDIO 1
41typedef int SysRet;
42typedef FILE * InputStream;
43typedef FILE * OutputStream;
44#endif
8add82fc 45
cceca5ed 46#define MY_start_subparse(fmt,flags) start_subparse(fmt,flags)
cf7fe8a2
GS
47
48#ifndef gv_stashpvn
49#define gv_stashpvn(str,len,flags) gv_stashpv(str,flags)
50#endif
51
35a60386
RGS
52#ifndef __attribute__noreturn__
53# define __attribute__noreturn__
54#endif
55
56#ifndef NORETURN_FUNCTION_END
57# define NORETURN_FUNCTION_END /* NOT REACHED */ return 0
58#endif
59
986a805c
FC
60#ifndef dVAR
61# define dVAR dNOOP
62#endif
63
7698c435 64static int not_here(const char *s) __attribute__noreturn__;
8add82fc 65static int
7698c435 66not_here(const char *s)
8add82fc
PP
67{
68 croak("%s not implemented on this architecture", s);
c38693a5 69 NORETURN_FUNCTION_END;
8add82fc
PP
70}
71
6ed60307
KW
72#ifndef UVCHR_IS_INVARIANT /* For use with Perls without this macro */
73# if ('A' == 65)
74# define UVCHR_IS_INVARIANT(cp) ((cp) < 128)
75# elif (defined(NATIVE_IS_INVARIANT)) /* EBCDIC on old Perl */
76# define UVCHR_IS_INVARIANT(cp) ((cp) < 256 && NATIVE_IS_INVARIANT(cp))
77# elif defined(isASCII) /* EBCDIC on very old Perl */
78 /* In EBCDIC, the invariants are the code points corresponding to ASCII,
79 * plus all the controls. All but one EBCDIC control is below SPACE; it
80 * varies depending on the code page, determined by the ord of '^' */
81# define UVCHR_IS_INVARIANT(cp) (isASCII(cp) \
82 || (cp) < ' ' \
83 || (('^' == 106) /* POSIX-BC */ \
84 ? (cp) == 95 \
85 : (cp) == 0xFF)) /* 1047 or 037 */
86# else /* EBCDIC on very very old Perl */
87 /* This assumes isascii() is available, but that could be fixed by
88 * having the macro test for each printable ASCII char */
89# define UVCHR_IS_INVARIANT(cp) (isascii(cp) \
90 || (cp) < ' ' \
91 || (('^' == 106) /* POSIX-BC */ \
92 ? (cp) == 95 \
93 : (cp) == 0xFF)) /* 1047 or 037 */
94# endif
95#endif
96
cf7fe8a2
GS
97
98#ifndef PerlIO
99#define PerlIO_fileno(f) fileno(f)
8add82fc 100#endif
cf7fe8a2
GS
101
102static int
e87a358a 103io_blocking(pTHX_ InputStream f, int block)
cf7fe8a2 104{
375ed12a 105 int fd = -1;
91f3b821 106#if defined(HAS_FCNTL)
cf7fe8a2 107 int RETVAL;
375ed12a 108 if (!f) {
cf7fe8a2
GS
109 errno = EBADF;
110 return -1;
111 }
375ed12a
JH
112 fd = PerlIO_fileno(f);
113 if (fd < 0) {
114 errno = EBADF;
115 return -1;
116 }
117 RETVAL = fcntl(fd, F_GETFL, 0);
cf7fe8a2
GS
118 if (RETVAL >= 0) {
119 int mode = RETVAL;
3b2f3eeb 120 int newmode = mode;
cf7fe8a2 121#ifdef O_NONBLOCK
766a733e 122 /* POSIX style */
cf7fe8a2 123
3b2f3eeb
BD
124# ifndef O_NDELAY
125# define O_NDELAY O_NONBLOCK
126# endif
127 /* Note: UNICOS and UNICOS/mk a F_GETFL returns an O_NDELAY
6fd254a4
JH
128 * after a successful F_SETFL of an O_NONBLOCK. */
129 RETVAL = RETVAL & (O_NONBLOCK | O_NDELAY) ? 0 : 1;
130
3b2f3eeb
BD
131 if (block == 0) {
132 newmode &= ~O_NDELAY;
133 newmode |= O_NONBLOCK;
134 } else if (block > 0) {
135 newmode &= ~(O_NDELAY|O_NONBLOCK);
cf7fe8a2 136 }
8add82fc 137#else
cf7fe8a2
GS
138 /* Not POSIX - better have O_NDELAY or we can't cope.
139 * for BSD-ish machines this is an acceptable alternative
766a733e 140 * for SysV we can't tell "would block" from EOF but that is
cf7fe8a2
GS
141 * the way SysV is...
142 */
143 RETVAL = RETVAL & O_NDELAY ? 0 : 1;
144
3b2f3eeb
BD
145 if (block == 0) {
146 newmode |= O_NDELAY;
147 } else if (block > 0) {
148 newmode &= ~O_NDELAY;
149 }
150#endif
151 if (newmode != mode) {
375ed12a 152 const int ret = fcntl(fd, F_SETFL, newmode);
3b2f3eeb 153 if (ret < 0)
cf7fe8a2 154 RETVAL = ret;
3b2f3eeb 155 }
cf7fe8a2
GS
156 }
157 return RETVAL;
8add82fc 158#else
20caf59d 159# ifdef WIN32
f5458e3a 160 if (block >= 0) {
1320cbfc 161 unsigned long flags = !block;
f5458e3a 162 /* ioctl claims to take char* but really needs a u_long sized buffer */
375ed12a 163 const int ret = ioctl(fd, FIONBIO, (char*)&flags);
f5458e3a
SO
164 if (ret != 0)
165 return -1;
166 /* Win32 has no way to get the current blocking status of a socket.
167 * However, we don't want to just return undef, because there's no way
168 * to tell that the ioctl succeeded.
169 */
170 return flags;
171 }
172 /* TODO: Perhaps set $! to ENOTSUP? */
173 return -1;
20caf59d 174# else
91f3b821 175 return -1;
20caf59d 176# endif
8add82fc 177#endif
8add82fc
PP
178}
179
986a805c
FC
180static OP *
181io_pp_nextstate(pTHX)
182{
183 dVAR;
184 COP *old_curcop = PL_curcop;
185 OP *next = PL_ppaddr[PL_op->op_type](aTHX);
186 PL_curcop = old_curcop;
187 return next;
188}
189
190static OP *
191io_ck_lineseq(pTHX_ OP *o)
192{
193 OP *kid = cBINOPo->op_first;
194 for (; kid; kid = kid->op_sibling)
195 if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE)
196 kid->op_ppaddr = io_pp_nextstate;
197 return o;
198}
199
200
8add82fc
PP
201MODULE = IO PACKAGE = IO::Seekable PREFIX = f
202
8063af02 203void
8add82fc
PP
204fgetpos(handle)
205 InputStream handle
206 CODE:
8add82fc 207 if (handle) {
2a0cf753 208#ifdef PerlIO
35a60386 209#if PERL_VERSION < 8
86413ec0
SH
210 Fpos_t pos;
211 ST(0) = sv_newmortal();
35a60386
RGS
212 if (PerlIO_getpos(handle, &pos) != 0) {
213 ST(0) = &PL_sv_undef;
214 }
215 else {
216 sv_setpvn(ST(0), (char *)&pos, sizeof(Fpos_t));
217 }
218#else
86413ec0 219 ST(0) = sv_newmortal();
766a733e
NIS
220 if (PerlIO_getpos(handle, ST(0)) != 0) {
221 ST(0) = &PL_sv_undef;
222 }
35a60386 223#endif
2a0cf753 224#else
35a60386 225 Fpos_t pos;
766a733e 226 if (fgetpos(handle, &pos)) {
a6a714bd
NC
227 ST(0) = &PL_sv_undef;
228 } else {
c7cffa0b
NC
229# if PERL_VERSION >= 11
230 ST(0) = newSVpvn_flags((char*)&pos, sizeof(Fpos_t), SVs_TEMP);
231# else
35a60386 232 ST(0) = sv_2mortal(newSVpvn((char*)&pos, sizeof(Fpos_t)));
c7cffa0b 233# endif
a6a714bd 234 }
766a733e 235#endif
8add82fc
PP
236 }
237 else {
8add82fc 238 errno = EINVAL;
35a60386 239 ST(0) = &PL_sv_undef;
8add82fc 240 }
8add82fc
PP
241
242SysRet
243fsetpos(handle, pos)
244 InputStream handle
245 SV * pos
246 CODE:
766a733e 247 if (handle) {
2a0cf753 248#ifdef PerlIO
35a60386
RGS
249#if PERL_VERSION < 8
250 char *p;
251 STRLEN len;
252 if (SvOK(pos) && (p = SvPV(pos,len)) && len == sizeof(Fpos_t)) {
253 RETVAL = PerlIO_setpos(handle, (Fpos_t*)p);
254 }
255 else {
256 RETVAL = -1;
257 errno = EINVAL;
258 }
259#else
766a733e 260 RETVAL = PerlIO_setpos(handle, pos);
35a60386 261#endif
2a0cf753 262#else
766a733e
NIS
263 char *p;
264 STRLEN len;
265 if ((p = SvPV(pos,len)) && len == sizeof(Fpos_t)) {
266 RETVAL = fsetpos(handle, (Fpos_t*)p);
267 }
268 else {
269 RETVAL = -1;
270 errno = EINVAL;
271 }
2a0cf753 272#endif
766a733e 273 }
8add82fc
PP
274 else {
275 RETVAL = -1;
276 errno = EINVAL;
277 }
8add82fc
PP
278 OUTPUT:
279 RETVAL
280
281MODULE = IO PACKAGE = IO::File PREFIX = f
282
8063af02 283void
8add82fc 284new_tmpfile(packname = "IO::File")
3e946625 285 const char * packname
a375a877
GB
286 PREINIT:
287 OutputStream fp;
288 GV *gv;
8add82fc 289 CODE:
2a0cf753 290#ifdef PerlIO
a375a877 291 fp = PerlIO_tmpfile();
2a0cf753 292#else
a375a877 293 fp = tmpfile();
2a0cf753 294#endif
a375a877 295 gv = (GV*)SvREFCNT_inc(newGVgen(packname));
71cd1c3f 296 if (gv)
c33e8be1 297 (void) hv_delete(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), G_DISCARD);
71cd1c3f 298 if (gv && do_open(gv, "+>&", 3, FALSE, 0, 0, fp)) {
6d5cdeed 299 ST(0) = sv_2mortal(newRV((SV*)gv));
a375a877 300 sv_bless(ST(0), gv_stashpv(packname, TRUE));
cf7fe8a2 301 SvREFCNT_dec(gv); /* undo increment in newRV() */
a375a877
GB
302 }
303 else {
a1ea39dc 304 ST(0) = &PL_sv_undef;
a375a877
GB
305 SvREFCNT_dec(gv);
306 }
8add82fc 307
cf7fe8a2
GS
308MODULE = IO PACKAGE = IO::Poll
309
766a733e 310void
cf7fe8a2
GS
311_poll(timeout,...)
312 int timeout;
313PPCODE:
314{
315#ifdef HAS_POLL
7698c435 316 const int nfd = (items - 1) / 2;
cf7fe8a2
GS
317 SV *tmpsv = NEWSV(999,nfd * sizeof(struct pollfd));
318 struct pollfd *fds = (struct pollfd *)SvPVX(tmpsv);
319 int i,j,ret;
320 for(i=1, j=0 ; j < nfd ; j++) {
321 fds[j].fd = SvIV(ST(i));
322 i++;
7c436af3 323 fds[j].events = (short)SvIV(ST(i));
cf7fe8a2
GS
324 i++;
325 fds[j].revents = 0;
326 }
327 if((ret = poll(fds,nfd,timeout)) >= 0) {
328 for(i=1, j=0 ; j < nfd ; j++) {
329 sv_setiv(ST(i), fds[j].fd); i++;
330 sv_setiv(ST(i), fds[j].revents); i++;
331 }
332 }
333 SvREFCNT_dec(tmpsv);
334 XSRETURN_IV(ret);
335#else
336 not_here("IO::Poll::poll");
337#endif
338}
339
340MODULE = IO PACKAGE = IO::Handle PREFIX = io_
341
342void
343io_blocking(handle,blk=-1)
344 InputStream handle
345 int blk
346PROTOTYPE: $;$
347CODE:
348{
7698c435 349 const int ret = io_blocking(aTHX_ handle, items == 1 ? -1 : blk ? 1 : 0);
cf7fe8a2
GS
350 if(ret >= 0)
351 XSRETURN_IV(ret);
352 else
353 XSRETURN_UNDEF;
354}
355
8add82fc
PP
356MODULE = IO PACKAGE = IO::Handle PREFIX = f
357
8add82fc
PP
358int
359ungetc(handle, c)
360 InputStream handle
10e621bc 361 SV * c
8add82fc 362 CODE:
10e621bc 363 if (handle) {
2a0cf753 364#ifdef PerlIO
10e621bc
CH
365 UV v;
366
367 if ((SvIOK_notUV(c) && SvIV(c) < 0) || (SvNOK(c) && SvNV(c) < 0.0))
368 croak("Negative character number in ungetc()");
369
370 v = SvUV(c);
6f2d5cbc 371 if (UVCHR_IS_INVARIANT(v) || (v <= 0xFF && !PerlIO_isutf8(handle)))
10e621bc
CH
372 RETVAL = PerlIO_ungetc(handle, (int)v);
373 else {
374 U8 buf[UTF8_MAXBYTES + 1], *end;
375 Size_t len;
376
377 if (!PerlIO_isutf8(handle))
378 croak("Wide character number in ungetc()");
379
380 /* This doesn't warn for non-chars, surrogate, and
381 * above-Unicodes */
382 end = uvchr_to_utf8_flags(buf, v, 0);
383 len = end - buf;
13142853 384 if ((Size_t)PerlIO_unread(handle, &buf, len) == len)
10e621bc
CH
385 XSRETURN_UV(v);
386 else
387 RETVAL = EOF;
388 }
2a0cf753 389#else
10e621bc 390 RETVAL = ungetc((int)SvIV(c), handle);
2a0cf753 391#endif
10e621bc 392 }
8add82fc
PP
393 else {
394 RETVAL = -1;
395 errno = EINVAL;
396 }
397 OUTPUT:
398 RETVAL
399
400int
401ferror(handle)
402 InputStream handle
403 CODE:
404 if (handle)
2a0cf753 405#ifdef PerlIO
760ac839 406 RETVAL = PerlIO_error(handle);
2a0cf753
PP
407#else
408 RETVAL = ferror(handle);
409#endif
410 else {
411 RETVAL = -1;
412 errno = EINVAL;
413 }
414 OUTPUT:
415 RETVAL
416
417int
418clearerr(handle)
419 InputStream handle
420 CODE:
421 if (handle) {
422#ifdef PerlIO
423 PerlIO_clearerr(handle);
424#else
425 clearerr(handle);
426#endif
427 RETVAL = 0;
428 }
8add82fc
PP
429 else {
430 RETVAL = -1;
59629a13
RR
431 errno = EINVAL;
432 }
433 OUTPUT:
434 RETVAL
435
436int
437untaint(handle)
438 SV * handle
439 CODE:
7a4c00b4 440#ifdef IOf_UNTAINT
59629a13
RR
441 IO * io;
442 io = sv_2io(handle);
443 if (io) {
444 IoFLAGS(io) |= IOf_UNTAINT;
445 RETVAL = 0;
446 }
447 else {
7a4c00b4 448#endif
59629a13 449 RETVAL = -1;
8add82fc 450 errno = EINVAL;
7a4c00b4 451#ifdef IOf_UNTAINT
8add82fc 452 }
7a4c00b4 453#endif
8add82fc
PP
454 OUTPUT:
455 RETVAL
456
457SysRet
458fflush(handle)
459 OutputStream handle
460 CODE:
461 if (handle)
2a0cf753 462#ifdef PerlIO
760ac839 463 RETVAL = PerlIO_flush(handle);
2a0cf753
PP
464#else
465 RETVAL = Fflush(handle);
466#endif
8add82fc
PP
467 else {
468 RETVAL = -1;
469 errno = EINVAL;
470 }
471 OUTPUT:
472 RETVAL
473
474void
c46a0ec2 475setbuf(handle, ...)
8add82fc 476 OutputStream handle
8add82fc
PP
477 CODE:
478 if (handle)
760ac839 479#ifdef PERLIO_IS_STDIO
c46a0ec2
JH
480 {
481 char *buf = items == 2 && SvPOK(ST(1)) ?
482 sv_grow(ST(1), BUFSIZ) : 0;
8add82fc 483 setbuf(handle, buf);
c46a0ec2 484 }
760ac839
LW
485#else
486 not_here("IO::Handle::setbuf");
487#endif
8add82fc
PP
488
489SysRet
c46a0ec2 490setvbuf(...)
8add82fc 491 CODE:
c46a0ec2
JH
492 if (items != 4)
493 Perl_croak(aTHX_ "Usage: IO::Handle::setvbuf(handle, buf, type, size)");
1eeb0f31 494#if defined(PERLIO_IS_STDIO) && defined(_IOFBF) && defined(HAS_SETVBUF)
c46a0ec2
JH
495 {
496 OutputStream handle = 0;
497 char * buf = SvPOK(ST(1)) ? sv_grow(ST(1), SvIV(ST(3))) : 0;
498 int type;
499 int size;
500
501 if (items == 4) {
502 handle = IoOFP(sv_2io(ST(0)));
503 buf = SvPOK(ST(1)) ? sv_grow(ST(1), SvIV(ST(3))) : 0;
504 type = (int)SvIV(ST(2));
505 size = (int)SvIV(ST(3));
506 }
d924de76
IZ
507 if (!handle) /* Try input stream. */
508 handle = IoIFP(sv_2io(ST(0)));
c46a0ec2 509 if (items == 4 && handle)
8add82fc
PP
510 RETVAL = setvbuf(handle, buf, type, size);
511 else {
512 RETVAL = -1;
513 errno = EINVAL;
514 }
c46a0ec2 515 }
8add82fc 516#else
61839fa9 517 RETVAL = (SysRet) not_here("IO::Handle::setvbuf");
760ac839 518#endif
8add82fc
PP
519 OUTPUT:
520 RETVAL
521
522
cf7fe8a2 523SysRet
2ba489e6
EM
524fsync(arg)
525 SV * arg
526 PREINIT:
527 OutputStream handle = NULL;
cf7fe8a2
GS
528 CODE:
529#ifdef HAS_FSYNC
2ba489e6
EM
530 handle = IoOFP(sv_2io(arg));
531 if (!handle)
532 handle = IoIFP(sv_2io(arg));
375ed12a
JH
533 if (handle) {
534 int fd = PerlIO_fileno(handle);
535 if (fd >= 0) {
536 RETVAL = fsync(fd);
537 } else {
538 RETVAL = -1;
539 errno = EBADF;
540 }
541 } else {
cf7fe8a2
GS
542 RETVAL = -1;
543 errno = EINVAL;
544 }
545#else
546 RETVAL = (SysRet) not_here("IO::Handle::sync");
547#endif
548 OUTPUT:
549 RETVAL
550
986a805c
FC
551SV *
552_create_getline_subs(const char *code)
986a805c
FC
553 CODE:
554 OP *(*io_old_ck_lineseq)(pTHX_ OP *) = PL_check[OP_LINESEQ];
555 PL_check[OP_LINESEQ] = io_ck_lineseq;
556 RETVAL = SvREFCNT_inc(eval_pv(code,FALSE));
557 PL_check[OP_LINESEQ] = io_old_ck_lineseq;
558 OUTPUT:
559 RETVAL
560
cf7fe8a2 561
63a347c7
JH
562MODULE = IO PACKAGE = IO::Socket
563
564SysRet
565sockatmark (sock)
566 InputStream sock
567 PROTOTYPE: $
568 PREINIT:
9ae155c4 569 int fd;
63a347c7 570 CODE:
9ae155c4 571 fd = PerlIO_fileno(sock);
375ed12a
JH
572 if (fd < 0) {
573 errno = EBADF;
574 RETVAL = -1;
9ae155c4
JH
575 }
576#ifdef HAS_SOCKATMARK
577 else {
375ed12a
JH
578 RETVAL = sockatmark(fd);
579 }
63a347c7 580#else
fa9804ae 581 else {
06c912bc 582 int flag = 0;
6d087280 583# ifdef SIOCATMARK
6e22d046 584# if defined(NETWARE) || defined(WIN32)
2c2a0333 585 if (ioctl(fd, SIOCATMARK, (char*)&flag) != 0)
f754b6e0
GS
586# else
587 if (ioctl(fd, SIOCATMARK, &flag) != 0)
588# endif
06c912bc 589 XSRETURN_UNDEF;
63a347c7 590# else
06c912bc
JH
591 not_here("IO::Socket::atmark");
592# endif
593 RETVAL = flag;
594 }
63a347c7 595#endif
63a347c7
JH
596 OUTPUT:
597 RETVAL
598
cf7fe8a2
GS
599BOOT:
600{
601 HV *stash;
602 /*
603 * constant subs for IO::Poll
604 */
605 stash = gv_stashpvn("IO::Poll", 8, TRUE);
606#ifdef POLLIN
607 newCONSTSUB(stash,"POLLIN",newSViv(POLLIN));
608#endif
609#ifdef POLLPRI
610 newCONSTSUB(stash,"POLLPRI", newSViv(POLLPRI));
611#endif
612#ifdef POLLOUT
613 newCONSTSUB(stash,"POLLOUT", newSViv(POLLOUT));
614#endif
615#ifdef POLLRDNORM
616 newCONSTSUB(stash,"POLLRDNORM", newSViv(POLLRDNORM));
617#endif
618#ifdef POLLWRNORM
619 newCONSTSUB(stash,"POLLWRNORM", newSViv(POLLWRNORM));
620#endif
621#ifdef POLLRDBAND
622 newCONSTSUB(stash,"POLLRDBAND", newSViv(POLLRDBAND));
623#endif
624#ifdef POLLWRBAND
625 newCONSTSUB(stash,"POLLWRBAND", newSViv(POLLWRBAND));
626#endif
627#ifdef POLLNORM
628 newCONSTSUB(stash,"POLLNORM", newSViv(POLLNORM));
629#endif
630#ifdef POLLERR
631 newCONSTSUB(stash,"POLLERR", newSViv(POLLERR));
632#endif
633#ifdef POLLHUP
634 newCONSTSUB(stash,"POLLHUP", newSViv(POLLHUP));
635#endif
636#ifdef POLLNVAL
637 newCONSTSUB(stash,"POLLNVAL", newSViv(POLLNVAL));
638#endif
639 /*
640 * constant subs for IO::Handle
641 */
642 stash = gv_stashpvn("IO::Handle", 10, TRUE);
643#ifdef _IOFBF
644 newCONSTSUB(stash,"_IOFBF", newSViv(_IOFBF));
645#endif
646#ifdef _IOLBF
647 newCONSTSUB(stash,"_IOLBF", newSViv(_IOLBF));
648#endif
649#ifdef _IONBF
650 newCONSTSUB(stash,"_IONBF", newSViv(_IONBF));
651#endif
652#ifdef SEEK_SET
653 newCONSTSUB(stash,"SEEK_SET", newSViv(SEEK_SET));
654#endif
655#ifdef SEEK_CUR
656 newCONSTSUB(stash,"SEEK_CUR", newSViv(SEEK_CUR));
657#endif
658#ifdef SEEK_END
659 newCONSTSUB(stash,"SEEK_END", newSViv(SEEK_END));
660#endif
cf7fe8a2 661}
63a347c7 662