#define PERL_IN_PERLIO_C
#include "perl.h"
+#ifdef PERL_IMPLICIT_CONTEXT
+#undef dSYS
+#define dSYS dTHX
+#endif
+
#include "XSUB.h"
int
}
PerlIO *
-PerlIO_fdupopen(pTHX_ PerlIO *f, CLONE_PARAMS *param)
+PerlIO_fdupopen(pTHX_ PerlIO *f, CLONE_PARAMS *param, int flags)
{
+#ifndef PERL_MICRO
if (f) {
int fd = PerlLIO_dup(PerlIO_fileno(f));
if (fd >= 0) {
else {
SETERRNO(EBADF, SS$_IVCHAN);
}
+#endif
return NULL;
}
PerlIO_openn(pTHX_ const char *layers, const char *mode, int fd,
int imode, int perm, PerlIO *old, int narg, SV **args)
{
- if (narg == 1) {
+ if (narg) {
+ if (narg > 1) {
+ Perl_croak(aTHX_ "More than one argument to open");
+ }
if (*args == &PL_sv_undef)
return PerlIO_tmpfile();
else {
#undef PerlIO_fdupopen
PerlIO *
-PerlIO_fdupopen(pTHX_ PerlIO *f, CLONE_PARAMS *param)
+PerlIO_fdupopen(pTHX_ PerlIO *f, CLONE_PARAMS *param, int flags)
{
if (f && *f) {
PerlIO_funcs *tab = PerlIOBase(f)->tab;
PerlIO *new;
- PerlIO_debug("fdupopen f=%p param=%p\n",f,param);
- new = (*tab->Dup)(aTHX_ PerlIO_allocate(aTHX),f,param);
+ PerlIO_debug("fdupopen f=%p param=%p\n",(void*)f,(void*)param);
+ new = (*tab->Dup)(aTHX_ PerlIO_allocate(aTHX),f,param, flags);
return new;
}
else {
PerlIO_list_t *
PerlIO_clone_list(pTHX_ PerlIO_list_t *proto, CLONE_PARAMS *param)
{
- int i;
- PerlIO_list_t *list = PerlIO_list_alloc(aTHX);
- for (i=0; i < proto->cur; i++) {
- SV *arg = Nullsv;
- if (proto->array[i].arg)
- arg = PerlIO_sv_dup(aTHX_ proto->array[i].arg,param);
- PerlIO_list_push(aTHX_ list, proto->array[i].funcs, arg);
+ PerlIO_list_t *list = (PerlIO_list_t *) NULL;
+ if (proto) {
+ int i;
+ list = PerlIO_list_alloc(aTHX);
+ for (i=0; i < proto->cur; i++) {
+ SV *arg = Nullsv;
+ if (proto->array[i].arg)
+ arg = PerlIO_sv_dup(aTHX_ proto->array[i].arg,param);
+ PerlIO_list_push(aTHX_ list, proto->array[i].funcs, arg);
+ }
}
return list;
}
PL_known_layers = PerlIO_clone_list(aTHX_ proto->Iknown_layers, param);
PL_def_layerlist = PerlIO_clone_list(aTHX_ proto->Idef_layerlist, param);
PerlIO_allocate(aTHX); /* root slot is never used */
+ PerlIO_debug("Clone %p from %p\n",aTHX,proto);
while ((f = *table)) {
int i;
table = (PerlIO **) (f++);
for (i = 1; i < PERLIO_TABLE_SIZE; i++) {
if (*f) {
- PerlIO_fdupopen(aTHX_ f, param);
+ (void) fp_dup(f, 0, param);
}
f++;
}
}
void
-PerlIO_cleanup(pTHX)
-{
- PerlIO_cleantable(aTHX_ &PL_perlio);
-}
-
-void
PerlIO_destruct(pTHX)
{
PerlIO **table = &PL_perlio;
PerlIO *f;
+#ifdef USE_ITHREADS
+ PerlIO_debug("Destruct %p\n",aTHX);
+#endif
while ((f = *table)) {
int i;
table = (PerlIO **) (f++);
{
PerlIOl *l = *f;
if (l) {
- PerlIO_debug("PerlIO_pop f=%p %s\n", f, l->tab->name);
+ PerlIO_debug("PerlIO_pop f=%p %s\n", (void*)f, l->tab->name);
if (l->tab->Popped) {
/*
* If popped returns non-zero do not free its layer structure
for (i = 0; i < PL_known_layers->cur; i++) {
PerlIO_funcs *f = PL_known_layers->array[i].funcs;
if (memEQ(f->name, name, len)) {
- PerlIO_debug("%.*s => %p\n", (int) len, name, f);
+ PerlIO_debug("%.*s => %p\n", (int) len, name, (void*)f);
return f;
}
}
if (!PL_known_layers)
PL_known_layers = PerlIO_list_alloc(aTHX);
PerlIO_list_push(aTHX_ PL_known_layers, tab, Nullsv);
- PerlIO_debug("define %s %p\n", tab->name, tab);
+ PerlIO_debug("define %s %p\n", tab->name, (void*)tab);
}
int
*/
char q = ((*s == '\'') ? '"' : '\'');
Perl_warn(aTHX_
- "perlio: invalid separator character %c%c%c in layer specification list",
- q, *s, q);
+ "perlio: invalid separator character %c%c%c in layer specification list %s",
+ q, *s, q, s);
return -1;
}
do {
PerlIO_default_buffer(pTHX_ PerlIO_list_t *av)
{
PerlIO_funcs *tab = &PerlIO_perlio;
- if (O_BINARY != O_TEXT) {
- tab = &PerlIO_crlf;
- }
- else {
- if (PerlIO_stdio.Set_ptrcnt) {
- tab = &PerlIO_stdio;
- }
- }
+#ifdef PERLIO_USING_CRLF
+ tab = &PerlIO_crlf;
+#else
+ if (PerlIO_stdio.Set_ptrcnt)
+ tab = &PerlIO_stdio;
+#endif
PerlIO_debug("Pushing %s\n", tab->name);
PerlIO_list_push(aTHX_ av, PerlIO_find_layer(aTHX_ tab->name, 0, 0),
&PL_sv_undef);
{
PerlIOl *l = NULL;
Newc('L',l,tab->size,char,PerlIOl);
- if (l) {
+ if (l && f) {
Zero(l, tab->size, char);
l->next = *f;
l->tab = tab;
*f = l;
- PerlIO_debug("PerlIO_push f=%p %s %s %p\n", f, tab->name,
- (mode) ? mode : "(Null)", arg);
+ PerlIO_debug("PerlIO_push f=%p %s %s %p\n", (void*)f, tab->name,
+ (mode) ? mode : "(Null)", (void*)arg);
if ((*l->tab->Pushed) (f, mode, arg) != 0) {
PerlIO_pop(aTHX_ f);
return NULL;
break;
}
}
- PerlIO_debug(":raw f=%p :%s\n", f, PerlIOBase(f)->tab->name);
+ PerlIO_debug(":raw f=%p :%s\n", (void*)f, PerlIOBase(f)->tab->name);
return 0;
}
return -1;
PerlIO_apply_layers(pTHX_ PerlIO *f, const char *mode, const char *names)
{
int code = 0;
- if (names) {
+ if (f && names) {
PerlIO_list_t *layers = PerlIO_list_alloc(aTHX);
code = PerlIO_parse_layers(aTHX_ layers, names);
if (code == 0) {
PerlIO_binmode(pTHX_ PerlIO *f, int iotype, int mode, const char *names)
{
PerlIO_debug("PerlIO_binmode f=%p %s %c %x %s\n",
- f, PerlIOBase(f)->tab->name, iotype, mode,
+ (void*)f, PerlIOBase(f)->tab->name, iotype, mode,
(names) ? names : "(Null)");
- PerlIO_flush(f);
- if (!names && (O_TEXT != O_BINARY && (mode & O_BINARY))) {
- PerlIO *top = f;
- while (*top) {
- if (PerlIOBase(top)->tab == &PerlIO_crlf) {
- PerlIOBase(top)->flags &= ~PERLIO_F_CRLF;
- break;
+ /* Can't flush if switching encodings. */
+ if (!(names && memEQ(names, ":encoding(", 10))) {
+ PerlIO_flush(f);
+#ifdef PERLIO_USING_CRLF
+ if (!names && (mode & O_BINARY)) {
+ PerlIO *top = f;
+ while (*top) {
+ if (PerlIOBase(top)->tab == &PerlIO_crlf) {
+ PerlIOBase(top)->flags &= ~PERLIO_F_CRLF;
+ break;
+ }
+ top = PerlIONext(top);
+ PerlIO_flush(top);
}
- top = PerlIONext(top);
- PerlIO_flush(top);
}
+#endif
}
return PerlIO_apply_layers(aTHX_ f, NULL, names) == 0 ? TRUE : FALSE;
}
while (l) {
SV *arg =
(l->tab->Getarg) ? (*l->tab->
- Getarg) (&l) : &PL_sv_undef;
+ Getarg) (aTHX_ &l, NULL, 0) : &PL_sv_undef;
PerlIO_list_push(aTHX_ layera, l->tab, arg);
l = *PerlIONext(&l);
}
/*
* Found that layer 'n' can do opens - call it
*/
+ if (narg > 1 && !(tab->kind & PERLIO_K_MULTIARG)) {
+ Perl_croak(aTHX_ "More than one argument to open(,':%s')",tab->name);
+ }
PerlIO_debug("openn(%s,'%s','%s',%d,%x,%o,%p,%d,%p)\n",
- tab->name, layers, mode, fd, imode, perm, f, narg,
- args);
+ tab->name, layers, mode, fd, imode, perm,
+ (void*)f, narg, (void*)args);
f = (*tab->Open) (aTHX_ tab, layera, n, mode, fd, imode, perm,
f, narg, args);
if (f) {
return (*tab->Flush) (f);
}
else {
- PerlIO_debug("Cannot flush f=%p :%s\n", f, tab->name);
+ PerlIO_debug("Cannot flush f=%p :%s\n", (void*)f, tab->name);
SETERRNO(EBADF, SS$_IVCHAN);
return -1;
}
}
else {
- PerlIO_debug("Cannot flush f=%p\n", f);
+ PerlIO_debug("Cannot flush f=%p\n", (void*)f);
SETERRNO(EBADF, SS$_IVCHAN);
return -1;
}
*s++ = '+';
}
}
-#if O_TEXT != O_BINARY
+#ifdef PERLIO_USING_CRLF
if (!(flags & PERLIO_F_CRLF))
*s++ = 'b';
#endif
}
}
+SV *
+PerlIO_sv_dup(pTHX_ SV *arg, CLONE_PARAMS *param)
+{
+ if (!arg)
+ return Nullsv;
+#ifdef sv_dup
+ if (param) {
+ return sv_dup(arg, param);
+ }
+ else {
+ return newSVsv(arg);
+ }
+#else
+ return newSVsv(arg);
+#endif
+}
+
+PerlIO *
+PerlIOBase_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags)
+{
+ PerlIO *nexto = PerlIONext(o);
+ if (*nexto) {
+ PerlIO_funcs *tab = PerlIOBase(nexto)->tab;
+ f = (*tab->Dup)(aTHX_ f, nexto, param, flags);
+ }
+ if (f) {
+ PerlIO_funcs *self = PerlIOBase(o)->tab;
+ SV *arg = Nullsv;
+ char buf[8];
+ PerlIO_debug("PerlIOBase_dup %s f=%p o=%p param=%p\n",
+ self->name, (void*)f, (void*)o, (void*)param);
+ if (self->Getarg) {
+ arg = (*self->Getarg)(aTHX_ o,param,flags);
+ }
+ f = PerlIO_push(aTHX_ f, self, PerlIO_modestr(o,buf), arg);
+ if (arg) {
+ SvREFCNT_dec(arg);
+ }
+ }
+ return f;
+}
+
+#define PERLIO_MAX_REFCOUNTABLE_FD 2048
+#ifdef USE_THREADS
+perl_mutex PerlIO_mutex;
+#endif
+int PerlIO_fd_refcnt[PERLIO_MAX_REFCOUNTABLE_FD];
+
+void
+PerlIO_init(pTHX)
+{
+ /* Place holder for stdstreams call ??? */
+#ifdef USE_THREADS
+ MUTEX_INIT(&PerlIO_mutex);
+#endif
+}
+
+void
+PerlIOUnix_refcnt_inc(int fd)
+{
+ if (fd >= 0 && fd < PERLIO_MAX_REFCOUNTABLE_FD) {
+#ifdef USE_THREADS
+ MUTEX_LOCK(&PerlIO_mutex);
+#endif
+ PerlIO_fd_refcnt[fd]++;
+ PerlIO_debug("fd %d refcnt=%d\n",fd,PerlIO_fd_refcnt[fd]);
+#ifdef USE_THREADS
+ MUTEX_UNLOCK(&PerlIO_mutex);
+#endif
+ }
+}
+
+int
+PerlIOUnix_refcnt_dec(int fd)
+{
+ int cnt = 0;
+ if (fd >= 0 && fd < PERLIO_MAX_REFCOUNTABLE_FD) {
+#ifdef USE_THREADS
+ MUTEX_LOCK(&PerlIO_mutex);
+#endif
+ cnt = --PerlIO_fd_refcnt[fd];
+ PerlIO_debug("fd %d refcnt=%d\n",fd,cnt);
+#ifdef USE_THREADS
+ MUTEX_UNLOCK(&PerlIO_mutex);
+#endif
+ }
+ return cnt;
+}
+
+void
+PerlIO_cleanup(pTHX)
+{
+ int i;
+#ifdef USE_ITHREADS
+ PerlIO_debug("Cleanup %p\n",aTHX);
+#endif
+ /* Raise STDIN..STDERR refcount so we don't close them */
+ for (i=0; i < 3; i++)
+ PerlIOUnix_refcnt_inc(i);
+ PerlIO_cleantable(aTHX_ &PL_perlio);
+ /* Restore STDIN..STDERR refcount */
+ for (i=0; i < 3; i++)
+ PerlIOUnix_refcnt_dec(i);
+}
+
+
+
/*--------------------------------------------------------------------------------------*/
/*
* Bottom-most level for UNIX-like case
PerlIOUnix_pushed(PerlIO *f, const char *mode, SV *arg)
{
IV code = PerlIOBase_pushed(f, mode, arg);
+ PerlIOUnix *s = PerlIOSelf(f, PerlIOUnix);
if (*PerlIONext(f)) {
- PerlIOUnix *s = PerlIOSelf(f, PerlIOUnix);
s->fd = PerlIO_fileno(PerlIONext(f));
/*
* XXX could (or should) we retrieve the oflags from the open file
s->fd = fd;
s->oflags = imode;
PerlIOBase(f)->flags |= PERLIO_F_OPEN;
+ PerlIOUnix_refcnt_inc(fd);
return f;
}
else {
}
}
-SV *
-PerlIO_sv_dup(pTHX_ SV *arg, CLONE_PARAMS *param)
-{
- if (!arg)
- return Nullsv;
-#ifdef sv_dup
- if (param) {
- return sv_dup(arg, param);
- }
- else {
- return newSVsv(arg);
- }
-#else
- return newSVsv(arg);
-#endif
-}
-
PerlIO *
-PerlIOBase_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param)
-{
- PerlIO *nexto = PerlIONext(o);
- if (*nexto) {
- PerlIO_funcs *tab = PerlIOBase(nexto)->tab;
- f = (*tab->Dup)(aTHX_ f, nexto, param);
- }
- if (f) {
- PerlIO_funcs *self = PerlIOBase(o)->tab;
- SV *arg = Nullsv;
- char buf[8];
- PerlIO_debug("PerlIOBase_dup %s f=%p o=%p param=%p\n",self->name,f,o,param);
- if (self->Getarg) {
- arg = (*self->Getarg)(o);
- if (arg) {
- arg = PerlIO_sv_dup(aTHX_ arg, param);
- }
- }
- f = PerlIO_push(aTHX_ f, self, PerlIO_modestr(o,buf), arg);
- if (!f && arg) {
- SvREFCNT_dec(arg);
- }
- }
- return f;
-}
-
-PerlIO *
-PerlIOUnix_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param)
+PerlIOUnix_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags)
{
PerlIOUnix *os = PerlIOSelf(o, PerlIOUnix);
- int fd = PerlLIO_dup(os->fd);
- if (fd >= 0) {
- f = PerlIOBase_dup(aTHX_ f, o, param);
+ int fd = os->fd;
+ if (flags & PERLIO_DUP_FD) {
+ fd = PerlLIO_dup(fd);
+ }
+ if (fd >= 0 && fd < PERLIO_MAX_REFCOUNTABLE_FD) {
+ f = PerlIOBase_dup(aTHX_ f, o, param, flags);
if (f) {
/* If all went well overwrite fd in dup'ed lay with the dup()'ed fd */
PerlIOUnix *s = PerlIOSelf(f, PerlIOUnix);
s->fd = fd;
+ PerlIOUnix_refcnt_inc(fd);
return f;
}
- else {
- PerlLIO_close(fd);
- }
}
return NULL;
}
dTHX;
int fd = PerlIOSelf(f, PerlIOUnix)->fd;
int code = 0;
+ if (PerlIOBase(f)->flags & PERLIO_F_OPEN) {
+ if (PerlIOUnix_refcnt_dec(fd) > 0) {
+ PerlIOBase(f)->flags &= ~PERLIO_F_OPEN;
+ return 0;
+ }
+ }
+ else {
+ SETERRNO(EBADF,SS$_IVCHAN);
+ return -1;
+ }
while (PerlLIO_close(fd) != 0) {
if (errno != EINTR) {
code = -1;
while (*mode) {
*tmode++ = *mode++;
}
- if (O_BINARY != O_TEXT) {
- *tmode++ = 'b';
- }
+#ifdef PERLIO_USING_CRLF
+ *tmode++ = 'b';
+#endif
*tmode = '\0';
return ret;
}
if (f) {
char *path = SvPV_nolen(*args);
PerlIOStdio *s = PerlIOSelf(f, PerlIOStdio);
- FILE *stdio =
- PerlSIO_freopen(path, (mode = PerlIOStdio_mode(mode, tmode)),
+ FILE *stdio;
+ PerlIOUnix_refcnt_dec(fileno(s->stdio));
+ stdio = PerlSIO_freopen(path, (mode = PerlIOStdio_mode(mode, tmode)),
s->stdio);
if (!s->stdio)
return NULL;
s->stdio = stdio;
+ PerlIOUnix_refcnt_inc(fileno(s->stdio));
return f;
}
else {
PerlIOArg),
PerlIOStdio);
s->stdio = stdio;
+ PerlIOUnix_refcnt_inc(fileno(s->stdio));
}
return f;
}
(aTHX_(f = PerlIO_allocate(aTHX)), self,
mode, PerlIOArg), PerlIOStdio);
s->stdio = stdio;
+ PerlIOUnix_refcnt_inc(fileno(s->stdio));
return f;
}
}
return NULL;
}
+PerlIO *
+PerlIOStdio_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags)
+{
+ /* This assumes no layers underneath - which is what
+ happens, but is not how I remember it. NI-S 2001/10/16
+ */
+ if ((f = PerlIOBase_dup(aTHX_ f, o, param, flags))) {
+ FILE *stdio = PerlIOSelf(o, PerlIOStdio)->stdio;
+ if (flags & PERLIO_DUP_FD) {
+ int fd = PerlLIO_dup(fileno(stdio));
+ if (fd >= 0) {
+ char mode[8];
+ stdio = fdopen(fd, PerlIO_modestr(o,mode));
+ }
+ else {
+ /* FIXME: To avoid messy error recovery if dup fails
+ re-use the existing stdio as though flag was not set
+ */
+ }
+ }
+ PerlIOSelf(f, PerlIOStdio)->stdio = stdio;
+ PerlIOUnix_refcnt_inc(fileno(stdio));
+ }
+ return f;
+}
+
+IV
+PerlIOStdio_close(PerlIO *f)
+{
+ dSYS;
+#ifdef SOCKS5_VERSION_NAME
+ int optval;
+ Sock_size_t optlen = sizeof(int);
+#endif
+ FILE *stdio = PerlIOSelf(f, PerlIOStdio)->stdio;
+ if (PerlIOUnix_refcnt_dec(fileno(stdio)) > 0) {
+ /* Do not close it but do flush any buffers */
+ PerlIO_flush(f);
+ return 0;
+ }
+ return (
+#ifdef SOCKS5_VERSION_NAME
+ (getsockopt
+ (PerlIO_fileno(f), SOL_SOCKET, SO_TYPE, (void *) &optval,
+ &optlen) <
+ 0) ? PerlSIO_fclose(stdio) : close(PerlIO_fileno(f))
+#else
+ PerlSIO_fclose(stdio)
+#endif
+ );
+
+}
+
+
+
SSize_t
PerlIOStdio_read(PerlIO *f, void *vbuf, Size_t count)
{
}
IV
-PerlIOStdio_close(PerlIO *f)
-{
- dSYS;
-#ifdef SOCKS5_VERSION_NAME
- int optval;
- Sock_size_t optlen = sizeof(int);
-#endif
- FILE *stdio = PerlIOSelf(f, PerlIOStdio)->stdio;
- return (
-#ifdef SOCKS5_VERSION_NAME
- (getsockopt
- (PerlIO_fileno(f), SOL_SOCKET, SO_TYPE, (void *) &optval,
- &optlen) <
- 0) ? PerlSIO_fclose(stdio) : close(PerlIO_fileno(f))
-#else
- PerlSIO_fclose(stdio)
-#endif
- );
-
-}
-
-IV
PerlIOStdio_flush(PerlIO *f)
{
dSYS;
#endif
-PerlIO *
-PerlIOStdio_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param)
-{
- /* This assumes no layers underneath - which is what
- happens, but is not how I remember it. NI-S 2001/10/16
- */
- int fd = PerlLIO_dup(PerlIO_fileno(o));
- if (fd >= 0) {
- char buf[8];
- FILE *stdio = PerlSIO_fdopen(fd, PerlIO_modestr(o, buf));
- if (stdio) {
- if ((f = PerlIOBase_dup(aTHX_ f, o, param))) {
- PerlIOSelf(f, PerlIOStdio)->stdio = stdio;
- }
- else {
- PerlSIO_fclose(stdio);
- }
- }
- else {
- PerlLIO_close(fd);
- f = NULL;
- }
- }
- return f;
-}
-
PerlIO_funcs PerlIO_stdio = {
"stdio",
sizeof(PerlIOStdio),
f = (*tab->Open) (aTHX_ tab, layers, n - 1, mode, fd, imode, perm,
NULL, narg, args);
if (f) {
- PerlIO_push(aTHX_ f, self, mode, PerlIOArg);
- fd = PerlIO_fileno(f);
-#if O_BINARY != O_TEXT
- /*
- * do something about failing setmode()? --jhi
- */
- PerlLIO_setmode(fd, O_BINARY);
-#endif
- if (init && fd == 2) {
+ if (PerlIO_push(aTHX_ f, self, mode, PerlIOArg) == 0) {
/*
- * Initial stderr is unbuffered
+ * if push fails during open, open fails. close will pop us.
*/
- PerlIOBase(f)->flags |= PERLIO_F_UNBUF;
+ PerlIO_close (f);
+ return NULL;
+ } else {
+ fd = PerlIO_fileno(f);
+#ifdef PERLIO_USING_CRLF
+ /*
+ * do something about failing setmode()? --jhi
+ */
+ PerlLIO_setmode(fd, O_BINARY);
+#endif
+ if (init && fd == 2) {
+ /*
+ * Initial stderr is unbuffered
+ */
+ PerlIOBase(f)->flags |= PERLIO_F_UNBUF;
+ }
}
}
}
}
PerlIO *
-PerlIOBuf_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param)
+PerlIOBuf_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags)
{
- return PerlIOBase_dup(aTHX_ f, o, param);
+ return PerlIOBase_dup(aTHX_ f, o, param, flags);
}
int code;
b->ptr++; /* say we have read it as far as
* flush() is concerned */
- b->buf++; /* Leave space an front of buffer */
+ b->buf++; /* Leave space in front of buffer */
b->bufsiz--; /* Buffer is thus smaller */
code = PerlIO_fill(f); /* Fetch some more */
b->bufsiz++; /* Restore size for next time */
if (flags & PERLIO_F_CANREAD) {
PerlIOBuf *b = PerlIOSelf(f, PerlIOBuf);
int fd = PerlIO_fileno(f);
- struct stat st;
- code = fstat(fd, &st);
+ Stat_t st;
+ code = Fstat(fd, &st);
if (code == 0 && S_ISREG(st.st_mode)) {
SSize_t len = st.st_size - b->posn;
if (len > 0) {
}
PerlIO *
-PerlIOMmap_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param)
+PerlIOMmap_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param, int flags)
{
- return PerlIOBase_dup(aTHX_ f, o, param);
+ return PerlIOBase_dup(aTHX_ f, o, param, flags);
}
#endif /* HAS_MMAP */
-void
-PerlIO_init(pTHX)
-{
- /* Place holder for stdstreams call ??? */
-}
-
#undef PerlIO_stdin
PerlIO *
PerlIO_stdin(void)
}
#endif
+
+
+
+