From: Nick Ing-Simmons Date: Sun, 3 Dec 2000 22:57:46 +0000 (+0000) Subject: PERL_IMPLICIT_SYS compiles but does not work. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=adb71456d0ff53391c88789f315f1e66b14373d5;p=p5sagit%2Fp5-mst-13.2.git PERL_IMPLICIT_SYS compiles but does not work. p4raw-id: //depot/perlio@7970 --- diff --git a/iperlsys.h b/iperlsys.h index 1019784..a7bd2b5 100644 --- a/iperlsys.h +++ b/iperlsys.h @@ -82,20 +82,18 @@ typedef char* (*LPGets)(struct IPerlStdIO*, FILE*, char*, int); typedef int (*LPPutc)(struct IPerlStdIO*, FILE*, int); typedef int (*LPPuts)(struct IPerlStdIO*, FILE*, const char*); typedef int (*LPFlush)(struct IPerlStdIO*, FILE*); -typedef int (*LPUngetc)(struct IPerlStdIO*, FILE*,int); +typedef int (*LPUngetc)(struct IPerlStdIO*, int,FILE*); typedef int (*LPFileno)(struct IPerlStdIO*, FILE*); typedef FILE* (*LPFdopen)(struct IPerlStdIO*, int, const char*); typedef FILE* (*LPReopen)(struct IPerlStdIO*, const char*, const char*, FILE*); -typedef SSize_t (*LPRead)(struct IPerlStdIO*, FILE*, void*, Size_t); -typedef SSize_t (*LPWrite)(struct IPerlStdIO*, FILE*, const void*, - Size_t); +typedef SSize_t (*LPRead)(struct IPerlStdIO*, void*, Size_t, Size_t, FILE *); +typedef SSize_t (*LPWrite)(struct IPerlStdIO*, const void*, Size_t, Size_t, FILE *); typedef void (*LPSetBuf)(struct IPerlStdIO*, FILE*, char*); typedef int (*LPSetVBuf)(struct IPerlStdIO*, FILE*, char*, int, Size_t); typedef void (*LPSetCnt)(struct IPerlStdIO*, FILE*, int); -typedef void (*LPSetPtrCnt)(struct IPerlStdIO*, FILE*, char*, - int); +typedef void (*LPSetPtr)(struct IPerlStdIO*, FILE*, char*); typedef void (*LPSetlinebuf)(struct IPerlStdIO*, FILE*); typedef int (*LPPrintf)(struct IPerlStdIO*, FILE*, const char*, ...); @@ -140,7 +138,7 @@ struct IPerlStdIO LPSetBuf pSetBuf; LPSetVBuf pSetVBuf; LPSetCnt pSetCnt; - LPSetPtrCnt pSetPtrCnt; + LPSetPtr pSetPtr; LPSetlinebuf pSetlinebuf; LPPrintf pPrintf; LPVprintf pVprintf; @@ -230,8 +228,8 @@ struct IPerlStdIOInfo (*PL_StdIO->pFlush)(PL_StdIO, (f)) #define PerlSIO_fgets(s, n, fp) \ (*PL_StdIO->pGets)(PL_StdIO, (fp), s, n) -#define PerlSIO_ungetc(f,c) \ - (*PL_StdIO->pUngetc)(PL_StdIO, (f),(c)) +#define PerlSIO_ungetc(c,f) \ + (*PL_StdIO->pUngetc)(PL_StdIO, (c),(f)) #define PerlSIO_fileno(f) \ (*PL_StdIO->pFileno)(PL_StdIO, (f)) #define PerlSIO_fdopen(f, s) \ @@ -239,17 +237,17 @@ struct IPerlStdIOInfo #define PerlSIO_freopen(p, m, f) \ (*PL_StdIO->pReopen)(PL_StdIO, (p), (m), (f)) #define PerlSIO_fread(buf,sz,count,f) \ - (SSize_t)(*PL_StdIO->pRead)(PL_StdIO, (sz), (buf), (count), (f)) -#define PerlSIO_write(buf,sz,count,f) \ - (*PL_StdIO->pWrite)(PL_StdIO, (sz), (buf), (count), (f)) + (*PL_StdIO->pRead)(PL_StdIO, (buf), (sz), (count), (f)) +#define PerlSIO_fwrite(buf,sz,count,f) \ + (*PL_StdIO->pWrite)(PL_StdIO, (buf), (sz), (count), (f)) #define PerlSIO_setbuf(f,b) \ (*PL_StdIO->pSetBuf)(PL_StdIO, (f), (b)) #define PerlSIO_setvbuf(f,b,t,s) \ (*PL_StdIO->pSetVBuf)(PL_StdIO, (f),(b),(t),(s)) #define PerlSIO_set_cnt(f,c) \ (*PL_StdIO->pSetCnt)(PL_StdIO, (f), (c)) -#define PerlSIO_set_ptrcnt(f,p,c) \ - (*PL_StdIO->pSetPtrCnt)(PL_StdIO, (f), (p), (c)) +#define PerlSIO_set_ptr(f,p) \ + (*PL_StdIO->pSetPtr)(PL_StdIO, (f), (p)) #define PerlSIO_setlinebuf(f) \ (*PL_StdIO->pSetlinebuf)(PL_StdIO, (f)) #define PerlSIO_printf Perl_fprintf_nocontext @@ -305,7 +303,7 @@ struct IPerlStdIOInfo #define PerlSIO_fputs(f,s) fputs(s,f) #define PerlSIO_fflush(f) Fflush(f) #define PerlSIO_fgets(s, n, fp) fgets(s,n,fp) -#define PerlSIO_ungetc(f,c) ungetc(f,c) +#define PerlSIO_ungetc(c,f) ungetc(c,f) #define PerlSIO_fileno(f) fileno(f) #define PerlSIO_fdopen(f, s) fdopen(f,s) #define PerlSIO_freopen(p, m, f) freopen(p,m,f) @@ -333,8 +331,6 @@ struct IPerlStdIOInfo #define PerlSIO_fsetpos(f,p) fsetpos(f,p) #define PerlSIO_rewind(f) rewind(f) #define PerlSIO_tmpfile() tmpfile() -#undef init_os_extras -#define init_os_extras() #define PerlSIO_fdupopen(f) (f) #endif /* PERL_IMPLICIT_SYS */ diff --git a/perlio.c b/perlio.c index 69d9283..b0517e3 100644 --- a/perlio.c +++ b/perlio.c @@ -95,7 +95,6 @@ PerlIO_binmode(pTHX_ PerlIO *fp, int iotype, int mode, const char *names) #endif -#if !defined(PERL_IMPLICIT_SYS) #ifdef PERLIO_IS_STDIO @@ -172,6 +171,7 @@ void PerlIO_debug(const char *fmt,...) __attribute__((format(__printf__,1,2))); void PerlIO_debug(const char *fmt,...) { + dTHX; static int dbg = 0; va_list ap; va_start(ap,fmt); @@ -1162,6 +1162,7 @@ PerlIOUnix_fdopen(PerlIO_funcs *self, int fd,const char *mode) PerlIO * PerlIOUnix_open(PerlIO_funcs *self, const char *path,const char *mode) { + dTHX; PerlIO *f = NULL; int oflags = PerlIOUnix_oflags(mode); if (oflags != -1) @@ -1187,6 +1188,7 @@ PerlIOUnix_reopen(const char *path, const char *mode, PerlIO *f) (*PerlIOBase(f)->tab->Close)(f); if (oflags != -1) { + dTHX; int fd = PerlLIO_open3(path,oflags,0666); if (fd >= 0) { @@ -1202,6 +1204,7 @@ PerlIOUnix_reopen(const char *path, const char *mode, PerlIO *f) SSize_t PerlIOUnix_read(PerlIO *f, void *vbuf, Size_t count) { + dTHX; int fd = PerlIOSelf(f,PerlIOUnix)->fd; if (!(PerlIOBase(f)->flags & PERLIO_F_CANREAD)) return 0; @@ -1222,6 +1225,7 @@ PerlIOUnix_read(PerlIO *f, void *vbuf, Size_t count) SSize_t PerlIOUnix_write(PerlIO *f, const void *vbuf, Size_t count) { + dTHX; int fd = PerlIOSelf(f,PerlIOUnix)->fd; while (1) { @@ -1238,6 +1242,7 @@ PerlIOUnix_write(PerlIO *f, const void *vbuf, Size_t count) IV PerlIOUnix_seek(PerlIO *f, Off_t offset, int whence) { + dTHX; Off_t new = PerlLIO_lseek(PerlIOSelf(f,PerlIOUnix)->fd,offset,whence); PerlIOBase(f)->flags &= ~PERLIO_F_EOF; return (new == (Off_t) -1) ? -1 : 0; @@ -1246,12 +1251,14 @@ PerlIOUnix_seek(PerlIO *f, Off_t offset, int whence) Off_t PerlIOUnix_tell(PerlIO *f) { + dTHX; return PerlLIO_lseek(PerlIOSelf(f,PerlIOUnix)->fd,0,SEEK_CUR); } IV PerlIOUnix_close(PerlIO *f) { + dTHX; int fd = PerlIOSelf(f,PerlIOUnix)->fd; int code = 0; while (PerlLIO_close(fd) != 0) @@ -1310,6 +1317,7 @@ typedef struct IV PerlIOStdio_fileno(PerlIO *f) { + dTHX; return PerlSIO_fileno(PerlIOSelf(f,PerlIOStdio)->stdio); } @@ -1333,6 +1341,7 @@ PerlIOStdio_mode(const char *mode,char *tmode) PerlIO * PerlIOStdio_fdopen(PerlIO_funcs *self, int fd,const char *mode) { + dTHX; PerlIO *f = NULL; int init = 0; char tmode[8]; @@ -1388,6 +1397,7 @@ PerlIO_importFILE(FILE *stdio, int fl) PerlIO * PerlIOStdio_open(PerlIO_funcs *self, const char *path,const char *mode) { + dTHX; PerlIO *f = NULL; FILE *stdio = PerlSIO_fopen(path,mode); if (stdio) @@ -1404,6 +1414,7 @@ PerlIOStdio_open(PerlIO_funcs *self, const char *path,const char *mode) int PerlIOStdio_reopen(const char *path, const char *mode, PerlIO *f) { + dTHX; PerlIOStdio *s = PerlIOSelf(f,PerlIOStdio); char tmode[8]; FILE *stdio = PerlSIO_freopen(path,(mode = PerlIOStdio_mode(mode,tmode)),s->stdio); @@ -1416,6 +1427,7 @@ PerlIOStdio_reopen(const char *path, const char *mode, PerlIO *f) SSize_t PerlIOStdio_read(PerlIO *f, void *vbuf, Size_t count) { + dTHX; FILE *s = PerlIOSelf(f,PerlIOStdio)->stdio; SSize_t got = 0; if (count == 1) @@ -1439,6 +1451,7 @@ PerlIOStdio_read(PerlIO *f, void *vbuf, Size_t count) SSize_t PerlIOStdio_unread(PerlIO *f, const void *vbuf, Size_t count) { + dTHX; FILE *s = PerlIOSelf(f,PerlIOStdio)->stdio; STDCHAR *buf = ((STDCHAR *)vbuf)+count-1; SSize_t unread = 0; @@ -1456,12 +1469,14 @@ PerlIOStdio_unread(PerlIO *f, const void *vbuf, Size_t count) SSize_t PerlIOStdio_write(PerlIO *f, const void *vbuf, Size_t count) { + dTHX; return PerlSIO_fwrite(vbuf,1,count,PerlIOSelf(f,PerlIOStdio)->stdio); } IV PerlIOStdio_seek(PerlIO *f, Off_t offset, int whence) { + dTHX; FILE *stdio = PerlIOSelf(f,PerlIOStdio)->stdio; return PerlSIO_fseek(stdio,offset,whence); } @@ -1469,6 +1484,7 @@ PerlIOStdio_seek(PerlIO *f, Off_t offset, int whence) Off_t PerlIOStdio_tell(PerlIO *f) { + dTHX; FILE *stdio = PerlIOSelf(f,PerlIOStdio)->stdio; return PerlSIO_ftell(stdio); } @@ -1476,6 +1492,7 @@ PerlIOStdio_tell(PerlIO *f) IV PerlIOStdio_close(PerlIO *f) { + dTHX; int optval, optlen = sizeof(int); FILE *stdio = PerlIOSelf(f,PerlIOStdio)->stdio; return( @@ -1487,6 +1504,7 @@ PerlIOStdio_close(PerlIO *f) IV PerlIOStdio_flush(PerlIO *f) { + dTHX; FILE *stdio = PerlIOSelf(f,PerlIOStdio)->stdio; if (PerlIOBase(f)->flags & PERLIO_F_CANWRITE) { @@ -1512,6 +1530,7 @@ PerlIOStdio_flush(PerlIO *f) IV PerlIOStdio_fill(PerlIO *f) { + dTHX; FILE *stdio = PerlIOSelf(f,PerlIOStdio)->stdio; int c; /* fflush()ing read-only streams can cause trouble on some stdio-s */ @@ -1529,24 +1548,28 @@ PerlIOStdio_fill(PerlIO *f) IV PerlIOStdio_eof(PerlIO *f) { + dTHX; return PerlSIO_feof(PerlIOSelf(f,PerlIOStdio)->stdio); } IV PerlIOStdio_error(PerlIO *f) { + dTHX; return PerlSIO_ferror(PerlIOSelf(f,PerlIOStdio)->stdio); } void PerlIOStdio_clearerr(PerlIO *f) { + dTHX; PerlSIO_clearerr(PerlIOSelf(f,PerlIOStdio)->stdio); } void PerlIOStdio_setlinebuf(PerlIO *f) { + dTHX; #ifdef HAS_SETLINEBUF PerlSIO_setlinebuf(PerlIOSelf(f,PerlIOStdio)->stdio); #else @@ -1558,6 +1581,7 @@ PerlIOStdio_setlinebuf(PerlIO *f) STDCHAR * PerlIOStdio_get_base(PerlIO *f) { + dTHX; FILE *stdio = PerlIOSelf(f,PerlIOStdio)->stdio; return PerlSIO_get_base(stdio); } @@ -1565,6 +1589,7 @@ PerlIOStdio_get_base(PerlIO *f) Size_t PerlIOStdio_get_bufsiz(PerlIO *f) { + dTHX; FILE *stdio = PerlIOSelf(f,PerlIOStdio)->stdio; return PerlSIO_get_bufsiz(stdio); } @@ -1574,6 +1599,7 @@ PerlIOStdio_get_bufsiz(PerlIO *f) STDCHAR * PerlIOStdio_get_ptr(PerlIO *f) { + dTHX; FILE *stdio = PerlIOSelf(f,PerlIOStdio)->stdio; return PerlSIO_get_ptr(stdio); } @@ -1581,6 +1607,7 @@ PerlIOStdio_get_ptr(PerlIO *f) SSize_t PerlIOStdio_get_cnt(PerlIO *f) { + dTHX; FILE *stdio = PerlIOSelf(f,PerlIOStdio)->stdio; return PerlSIO_get_cnt(stdio); } @@ -1588,6 +1615,7 @@ PerlIOStdio_get_cnt(PerlIO *f) void PerlIOStdio_set_ptrcnt(PerlIO *f,STDCHAR *ptr,SSize_t cnt) { + dTHX; FILE *stdio = PerlIOSelf(f,PerlIOStdio)->stdio; if (ptr != NULL) { @@ -1702,6 +1730,7 @@ PerlIOBuf_pushed(PerlIO *f, const char *mode) PerlIO * PerlIOBuf_fdopen(PerlIO_funcs *self, int fd, const char *mode) { + dTHX; PerlIO_funcs *tab = PerlIO_default_btm(); int init = 0; PerlIO *f; @@ -3017,6 +3046,7 @@ PerlIO_tmpfile(void) { /* I have no idea how portable mkstemp() is ... */ #if defined(WIN32) || !defined(HAVE_MKSTEMP) + dTHX; PerlIO *f = NULL; FILE *stdio = PerlSIO_tmpfile(); if (stdio) @@ -3150,5 +3180,4 @@ PerlIO_sprintf(char *s, int n, const char *fmt,...) } #endif -#endif /* !PERL_IMPLICIT_SYS */ diff --git a/perlio.h b/perlio.h index f277dde..b2aa0aa 100644 --- a/perlio.h +++ b/perlio.h @@ -161,6 +161,8 @@ extern void PerlIO_pop (PerlIO *f); /* --------------------- Now prototypes for functions --------------- */ +START_EXTERN_C + #ifndef NEXT30_NO_ATTRIBUTE #ifndef HASATTRIBUTE /* disable GNU-cc attribute checking? */ #ifdef __attribute__ /* Avoid possible redefinition errors */ @@ -316,6 +318,10 @@ extern int PerlIO_apply_layers (pTHX_ PerlIO *f, const char *mode, const char *n extern int PerlIO_binmode (pTHX_ PerlIO *f, int iotype, int omode, const char *names); #endif +extern void PerlIO_cleanup(void); + extern void PerlIO_debug(const char *fmt,...); +END_EXTERN_C + #endif /* _PERLIO_H */ diff --git a/win32/makefile.mk b/win32/makefile.mk index fd9cdfa..97b580c 100644 --- a/win32/makefile.mk +++ b/win32/makefile.mk @@ -50,21 +50,21 @@ INST_ARCH *= \$(ARCHNAME) # uncomment to enable multiple interpreters. This is need for fork() # emulation. # -#USE_MULTI *= define +USE_MULTI *= define # # Beginnings of interpreter cloning/threads; still very incomplete. # This should be enabled to get the fork() emulation. This needs # USE_MULTI as well. # -#USE_ITHREADS *= define +USE_ITHREADS *= define # # uncomment to enable the implicit "host" layer for all system calls # made by perl. This needs USE_MULTI above. This is also needed to # get fork(). # -#USE_IMP_SYS *= define +USE_IMP_SYS *= define # # WARNING! This option is deprecated and will eventually go away (enable @@ -364,6 +364,7 @@ LIB32 = ar rc IMPLIB = dlltool RSC = rc +i = .i o = .o a = .a @@ -498,11 +499,14 @@ LKPOST = ) # Rules # -.SUFFIXES : .c $(o) .dll $(a) .exe .rc .res +.SUFFIXES : .c .i $(o) .dll $(a) .exe .rc .res .c$(o): $(CC) -c $(null,$(<:d) $(NULL) -I$(<:d)) $(CFLAGS_O) $(OBJOUT_FLAG)$@ $< +.c.i: + $(CC) -c $(null,$(<:d) $(NULL) -I$(<:d)) $(CFLAGS_O) -E $< >$@ + .y.c: $(NOOP) diff --git a/win32/perlhost.h b/win32/perlhost.h index 7807495..28f0168 100644 --- a/win32/perlhost.h +++ b/win32/perlhost.h @@ -522,65 +522,65 @@ struct IPerlEnv perlEnv = #define IPERL2HOST(x) IPerlStdIO2Host(x) /* PerlStdIO */ -PerlIO* +FILE* PerlStdIOStdin(struct IPerlStdIO* piPerl) { - return (PerlIO*)win32_stdin(); + return win32_stdin(); } -PerlIO* +FILE* PerlStdIOStdout(struct IPerlStdIO* piPerl) { - return (PerlIO*)win32_stdout(); + return win32_stdout(); } -PerlIO* +FILE* PerlStdIOStderr(struct IPerlStdIO* piPerl) { - return (PerlIO*)win32_stderr(); + return win32_stderr(); } -PerlIO* +FILE* PerlStdIOOpen(struct IPerlStdIO* piPerl, const char *path, const char *mode) { - return (PerlIO*)win32_fopen(path, mode); + return win32_fopen(path, mode); } int -PerlStdIOClose(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOClose(struct IPerlStdIO* piPerl, FILE* pf) { - return win32_fclose(((FILE*)pf)); + return win32_fclose((pf)); } int -PerlStdIOEof(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOEof(struct IPerlStdIO* piPerl, FILE* pf) { - return win32_feof((FILE*)pf); + return win32_feof(pf); } int -PerlStdIOError(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOError(struct IPerlStdIO* piPerl, FILE* pf) { - return win32_ferror((FILE*)pf); + return win32_ferror(pf); } void -PerlStdIOClearerr(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOClearerr(struct IPerlStdIO* piPerl, FILE* pf) { - win32_clearerr((FILE*)pf); + win32_clearerr(pf); } int -PerlStdIOGetc(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOGetc(struct IPerlStdIO* piPerl, FILE* pf) { - return win32_getc((FILE*)pf); + return win32_getc(pf); } char* -PerlStdIOGetBase(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOGetBase(struct IPerlStdIO* piPerl, FILE* pf) { #ifdef FILE_base - FILE *f = (FILE*)pf; + FILE *f = pf; return FILE_base(f); #else return Nullch; @@ -588,10 +588,10 @@ PerlStdIOGetBase(struct IPerlStdIO* piPerl, PerlIO* pf) } int -PerlStdIOGetBufsiz(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOGetBufsiz(struct IPerlStdIO* piPerl, FILE* pf) { #ifdef FILE_bufsiz - FILE *f = (FILE*)pf; + FILE *f = pf; return FILE_bufsiz(f); #else return (-1); @@ -599,10 +599,10 @@ PerlStdIOGetBufsiz(struct IPerlStdIO* piPerl, PerlIO* pf) } int -PerlStdIOGetCnt(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOGetCnt(struct IPerlStdIO* piPerl, FILE* pf) { #ifdef USE_STDIO_PTR - FILE *f = (FILE*)pf; + FILE *f = pf; return FILE_cnt(f); #else return (-1); @@ -610,10 +610,10 @@ PerlStdIOGetCnt(struct IPerlStdIO* piPerl, PerlIO* pf) } char* -PerlStdIOGetPtr(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOGetPtr(struct IPerlStdIO* piPerl, FILE* pf) { #ifdef USE_STDIO_PTR - FILE *f = (FILE*)pf; + FILE *f = pf; return FILE_ptr(f); #else return Nullch; @@ -621,150 +621,149 @@ PerlStdIOGetPtr(struct IPerlStdIO* piPerl, PerlIO* pf) } char* -PerlStdIOGets(struct IPerlStdIO* piPerl, PerlIO* pf, char* s, int n) +PerlStdIOGets(struct IPerlStdIO* piPerl, FILE* pf, char* s, int n) { - return win32_fgets(s, n, (FILE*)pf); + return win32_fgets(s, n, pf); } int -PerlStdIOPutc(struct IPerlStdIO* piPerl, PerlIO* pf, int c) +PerlStdIOPutc(struct IPerlStdIO* piPerl, FILE* pf, int c) { - return win32_fputc(c, (FILE*)pf); + return win32_fputc(c, pf); } int -PerlStdIOPuts(struct IPerlStdIO* piPerl, PerlIO* pf, const char *s) +PerlStdIOPuts(struct IPerlStdIO* piPerl, FILE* pf, const char *s) { - return win32_fputs(s, (FILE*)pf); + return win32_fputs(s, pf); } int -PerlStdIOFlush(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOFlush(struct IPerlStdIO* piPerl, FILE* pf) { - return win32_fflush((FILE*)pf); + return win32_fflush(pf); } int -PerlStdIOUngetc(struct IPerlStdIO* piPerl, PerlIO* pf,int c) +PerlStdIOUngetc(struct IPerlStdIO* piPerl,int c, FILE* pf) { - return win32_ungetc(c, (FILE*)pf); + return win32_ungetc(c, pf); } int -PerlStdIOFileno(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOFileno(struct IPerlStdIO* piPerl, FILE* pf) { - return win32_fileno((FILE*)pf); + return win32_fileno(pf); } -PerlIO* +FILE* PerlStdIOFdopen(struct IPerlStdIO* piPerl, int fd, const char *mode) { - return (PerlIO*)win32_fdopen(fd, mode); + return win32_fdopen(fd, mode); } -PerlIO* -PerlStdIOReopen(struct IPerlStdIO* piPerl, const char*path, const char*mode, PerlIO* pf) +FILE* +PerlStdIOReopen(struct IPerlStdIO* piPerl, const char*path, const char*mode, FILE* pf) { - return (PerlIO*)win32_freopen(path, mode, (FILE*)pf); + return win32_freopen(path, mode, (FILE*)pf); } SSize_t -PerlStdIORead(struct IPerlStdIO* piPerl, PerlIO* pf, void *buffer, Size_t size) +PerlStdIORead(struct IPerlStdIO* piPerl, void *buffer, Size_t size, Size_t count, FILE* pf) { - return win32_fread(buffer, 1, size, (FILE*)pf); + return win32_fread(buffer, size, count, pf); } SSize_t -PerlStdIOWrite(struct IPerlStdIO* piPerl, PerlIO* pf, const void *buffer, Size_t size) +PerlStdIOWrite(struct IPerlStdIO* piPerl, const void *buffer, Size_t size, Size_t count, FILE* pf) { - return win32_fwrite(buffer, 1, size, (FILE*)pf); + return win32_fwrite(buffer, size, count, pf); } void -PerlStdIOSetBuf(struct IPerlStdIO* piPerl, PerlIO* pf, char* buffer) +PerlStdIOSetBuf(struct IPerlStdIO* piPerl, FILE* pf, char* buffer) { - win32_setbuf((FILE*)pf, buffer); + win32_setbuf(pf, buffer); } int -PerlStdIOSetVBuf(struct IPerlStdIO* piPerl, PerlIO* pf, char* buffer, int type, Size_t size) +PerlStdIOSetVBuf(struct IPerlStdIO* piPerl, FILE* pf, char* buffer, int type, Size_t size) { - return win32_setvbuf((FILE*)pf, buffer, type, size); + return win32_setvbuf(pf, buffer, type, size); } void -PerlStdIOSetCnt(struct IPerlStdIO* piPerl, PerlIO* pf, int n) +PerlStdIOSetCnt(struct IPerlStdIO* piPerl, FILE* pf, int n) { #ifdef STDIO_CNT_LVALUE - FILE *f = (FILE*)pf; + FILE *f = pf; FILE_cnt(f) = n; #endif } void -PerlStdIOSetPtrCnt(struct IPerlStdIO* piPerl, PerlIO* pf, char * ptr, int n) +PerlStdIOSetPtr(struct IPerlStdIO* piPerl, FILE* pf, char * ptr) { #ifdef STDIO_PTR_LVALUE - FILE *f = (FILE*)pf; + FILE *f = pf; FILE_ptr(f) = ptr; - FILE_cnt(f) = n; #endif } void -PerlStdIOSetlinebuf(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOSetlinebuf(struct IPerlStdIO* piPerl, FILE* pf) { - win32_setvbuf((FILE*)pf, NULL, _IOLBF, 0); + win32_setvbuf(pf, NULL, _IOLBF, 0); } int -PerlStdIOPrintf(struct IPerlStdIO* piPerl, PerlIO* pf, const char *format,...) +PerlStdIOPrintf(struct IPerlStdIO* piPerl, FILE* pf, const char *format,...) { va_list(arglist); va_start(arglist, format); - return win32_vfprintf((FILE*)pf, format, arglist); + return win32_vfprintf(pf, format, arglist); } int -PerlStdIOVprintf(struct IPerlStdIO* piPerl, PerlIO* pf, const char *format, va_list arglist) +PerlStdIOVprintf(struct IPerlStdIO* piPerl, FILE* pf, const char *format, va_list arglist) { - return win32_vfprintf((FILE*)pf, format, arglist); + return win32_vfprintf(pf, format, arglist); } long -PerlStdIOTell(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIOTell(struct IPerlStdIO* piPerl, FILE* pf) { - return win32_ftell((FILE*)pf); + return win32_ftell(pf); } int -PerlStdIOSeek(struct IPerlStdIO* piPerl, PerlIO* pf, off_t offset, int origin) +PerlStdIOSeek(struct IPerlStdIO* piPerl, FILE* pf, off_t offset, int origin) { - return win32_fseek((FILE*)pf, offset, origin); + return win32_fseek(pf, offset, origin); } void -PerlStdIORewind(struct IPerlStdIO* piPerl, PerlIO* pf) +PerlStdIORewind(struct IPerlStdIO* piPerl, FILE* pf) { - win32_rewind((FILE*)pf); + win32_rewind(pf); } -PerlIO* +FILE* PerlStdIOTmpfile(struct IPerlStdIO* piPerl) { - return (PerlIO*)win32_tmpfile(); + return win32_tmpfile(); } int -PerlStdIOGetpos(struct IPerlStdIO* piPerl, PerlIO* pf, Fpos_t *p) +PerlStdIOGetpos(struct IPerlStdIO* piPerl, FILE* pf, Fpos_t *p) { - return win32_fgetpos((FILE*)pf, p); + return win32_fgetpos(pf, p); } int -PerlStdIOSetpos(struct IPerlStdIO* piPerl, PerlIO* pf, const Fpos_t *p) +PerlStdIOSetpos(struct IPerlStdIO* piPerl, FILE* pf, const Fpos_t *p) { - return win32_fsetpos((FILE*)pf, p); + return win32_fsetpos(pf, p); } void PerlStdIOInit(struct IPerlStdIO* piPerl) @@ -789,39 +788,39 @@ PerlStdIOGetOSfhandle(struct IPerlStdIO* piPerl, int filenum) return win32_get_osfhandle(filenum); } -PerlIO* -PerlStdIOFdupopen(struct IPerlStdIO* piPerl, PerlIO* pf) +FILE* +PerlStdIOFdupopen(struct IPerlStdIO* piPerl, FILE* pf) { - PerlIO* pfdup; + FILE* pfdup; fpos_t pos; char mode[3]; - int fileno = win32_dup(win32_fileno((FILE*)pf)); + int fileno = win32_dup(win32_fileno(pf)); /* open the file in the same mode */ #ifdef __BORLANDC__ - if(((FILE*)pf)->flags & _F_READ) { + if((pf)->flags & _F_READ) { mode[0] = 'r'; mode[1] = 0; } - else if(((FILE*)pf)->flags & _F_WRIT) { + else if((pf)->flags & _F_WRIT) { mode[0] = 'a'; mode[1] = 0; } - else if(((FILE*)pf)->flags & _F_RDWR) { + else if((pf)->flags & _F_RDWR) { mode[0] = 'r'; mode[1] = '+'; mode[2] = 0; } #else - if(((FILE*)pf)->_flag & _IOREAD) { + if((pf)->_flag & _IOREAD) { mode[0] = 'r'; mode[1] = 0; } - else if(((FILE*)pf)->_flag & _IOWRT) { + else if((pf)->_flag & _IOWRT) { mode[0] = 'a'; mode[1] = 0; } - else if(((FILE*)pf)->_flag & _IORW) { + else if((pf)->_flag & _IORW) { mode[0] = 'r'; mode[1] = '+'; mode[2] = 0; @@ -832,11 +831,11 @@ PerlStdIOFdupopen(struct IPerlStdIO* piPerl, PerlIO* pf) * file descriptor so binmode files will be handled * correctly */ - pfdup = (PerlIO*)win32_fdopen(fileno, mode); + pfdup = win32_fdopen(fileno, mode); /* move the file pointer to the same position */ - if (!fgetpos((FILE*)pf, &pos)) { - fsetpos((FILE*)pfdup, &pos); + if (!fgetpos(pf, &pos)) { + fsetpos(pfdup, &pos); } return pfdup; } @@ -869,7 +868,7 @@ struct IPerlStdIO perlStdIO = PerlStdIOSetBuf, PerlStdIOSetVBuf, PerlStdIOSetCnt, - PerlStdIOSetPtrCnt, + PerlStdIOSetPtr, PerlStdIOSetlinebuf, PerlStdIOPrintf, PerlStdIOVprintf, @@ -1586,13 +1585,13 @@ PerlProcPopen(struct IPerlProc* piPerl, const char *command, const char *mode) { dTHXo; PERL_FLUSHALL_FOR_CHILD; - return (PerlIO*)win32_popen(command, mode); + return win32_popen(command, mode); } int PerlProcPclose(struct IPerlProc* piPerl, PerlIO *stream) { - return win32_pclose((FILE*)stream); + return win32_pclose(stream); } int diff --git a/win32/perllib.c b/win32/perllib.c index 3b57efb..1a9fa9f 100644 --- a/win32/perllib.c +++ b/win32/perllib.c @@ -1,8 +1,7 @@ /* * "The Road goes ever on and on, down from the door where it began." */ - - +#define PERLIO_NOT_STDIO 0 #include "EXTERN.h" #include "perl.h" diff --git a/win32/win32.h b/win32/win32.h index 5b6062c..c75566f 100644 --- a/win32/win32.h +++ b/win32/win32.h @@ -544,6 +544,10 @@ EXTERN_C _CRTIMP ioinfo* __pioinfo[]; #endif #endif +#define PERLIO_NOT_STDIO 0 + +#include "perlio.h" + /* * This provides a layer of functions and macros to ensure extensions will * get to use the same RTL functions as the core. diff --git a/win32/win32iop.h b/win32/win32iop.h index d7c2ac4..5629bab 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -72,8 +72,8 @@ DllExport void win32_abort(void); DllExport int win32_fstat(int fd,struct stat *sbufptr); DllExport int win32_stat(const char *name,struct stat *sbufptr); DllExport int win32_pipe( int *phandles, unsigned int psize, int textmode ); -DllExport FILE* win32_popen( const char *command, const char *mode ); -DllExport int win32_pclose( FILE *pf); +DllExport PerlIO* win32_popen( const char *command, const char *mode ); +DllExport int win32_pclose( PerlIO *pf); DllExport int win32_rename( const char *oname, const char *newname); DllExport int win32_setmode( int fd, int mode); DllExport long win32_lseek( int fd, long offset, int origin); diff --git a/win32/win32thread.h b/win32/win32thread.h index a52118b..1f8840c 100644 --- a/win32/win32thread.h +++ b/win32/win32thread.h @@ -170,7 +170,7 @@ END_EXTERN_C #define ALLOC_THREAD_KEY \ STMT_START { \ if ((PL_thr_key = TlsAlloc()) == TLS_OUT_OF_INDEXES) { \ - fprintf(stderr,"panic: TlsAlloc"); \ + PerlIO_printf(PerlIO_stderr(),"panic: TlsAlloc"); \ exit(1); \ } \ } STMT_END