diff options
-rw-r--r-- | doio.c | 35 | ||||
-rw-r--r-- | embed.h | 18 | ||||
-rwxr-xr-x | embed.pl | 12 | ||||
-rw-r--r-- | perlsdio.h | 12 | ||||
-rw-r--r-- | proto.h | 12 |
5 files changed, 53 insertions, 36 deletions
@@ -2078,7 +2078,6 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp) ** without checking the ungetc buffer. **/ -/* Not very thread-safe? */ static S64_IOB *s64_buffer = (S64_IOB *) NULL; /* initialize the buffer area */ @@ -2088,7 +2087,7 @@ void Perl_do_s64_init_buffer() { } /* get a buffered stream pointer */ -static S64_IOB *S_s64_get_buffer( PerlIO *fp) { +static S64_IOB *S_s64_get_buffer(pTHX_ PerlIO *fp) { S64_IOB *ptr = s64_buffer; while( ptr && ptr->fp != fp) ptr = ptr->next; @@ -2096,7 +2095,7 @@ static S64_IOB *S_s64_get_buffer( PerlIO *fp) { } /* create a buffered stream pointer */ -static S64_IOB *S_s64_create_buffer( PerlIO *f) { +static S64_IOB *S_s64_create_buffer(pTHX_ PerlIO *f) { S64_IOB *ptr = malloc( sizeof( S64_IOB)); if( ptr) { ptr->fp = f; @@ -2111,8 +2110,8 @@ static S64_IOB *S_s64_create_buffer( PerlIO *f) { } /* delete a buffered stream pointer */ -void Perl_do_s64_delete_buffer( PerlIO *f) { - S64_IOB *ptr = S_s64_get_buffer(f); +void Perl_do_s64_delete_buffer(pTHX_ PerlIO *f) { + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); if( ptr) { /* fix the stream pointer according to the bytes buffered */ /* required, if this is called in a seek-context */ @@ -2128,7 +2127,7 @@ void Perl_do_s64_delete_buffer( PerlIO *f) { /* internal buffer management */ #define _S64_BUFFER_SIZE 32 -static int S_s64_malloc( S64_IOB *ptr) { +static int S_s64_malloc(pTHX_ S64_IOB *ptr) { if( ptr) { if( !ptr->buffer) { ptr->buffer = (int *) calloc( _S64_BUFFER_SIZE, sizeof( int)); @@ -2149,8 +2148,8 @@ static int S_s64_malloc( S64_IOB *ptr) { } /* SOCKS 64 bit getc replacement */ -int Perl_do_s64_getc( PerlIO *f) { - S64_IOB *ptr = S_s64_get_buffer(f); +int Perl_do_s64_getc(pTHX_ PerlIO *f) { + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); if( ptr) { if( ptr->cnt) return( ptr->buffer[--ptr->cnt]); @@ -2159,23 +2158,23 @@ int Perl_do_s64_getc( PerlIO *f) { } /* SOCKS 64 bit ungetc replacement */ -int Perl_do_s64_ungetc( int ch, PerlIO *f) { - S64_IOB *ptr = S_s64_get_buffer(f); +int Perl_do_s64_ungetc(pTHX_ int ch, PerlIO *f) { + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); - if( !ptr) ptr = S_s64_create_buffer(f); + if( !ptr) ptr = S_s64_create_buffer(aTHX_ f); if( !ptr) return( EOF); if( !ptr->buffer || (ptr->buffer && ptr->cnt >= ptr->size)) - if( !S_s64_malloc( ptr)) return( EOF); + if( !S_s64_malloc(aTHX_ ptr)) return( EOF); ptr->buffer[ptr->cnt++] = ch; return( ch); } /* SOCKS 64 bit fread replacement */ -SSize_t Perl_do_s64_fread(void *buf, SSize_t count, PerlIO* f) { +SSize_t Perl_do_s64_fread(pTHX_ void *buf, SSize_t count, PerlIO* f) { SSize_t len = 0; char *bufptr = (char *) buf; - S64_IOB *ptr = S_s64_get_buffer(f); + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); if( ptr) { while( ptr->cnt && count) { *bufptr++ = ptr->buffer[--ptr->cnt]; @@ -2189,8 +2188,8 @@ SSize_t Perl_do_s64_fread(void *buf, SSize_t count, PerlIO* f) { } /* SOCKS 64 bit fseek replacement */ -int Perl_do_s64_seek(PerlIO* f, Off_t offset, int whence) { - S64_IOB *ptr = S_s64_get_buffer(f); +int Perl_do_s64_seek(pTHX_ PerlIO* f, Off_t offset, int whence) { + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); /* Simply clear the buffer and seek if the position is absolute */ if( SEEK_SET == whence || SEEK_END == whence) { @@ -2211,9 +2210,9 @@ int Perl_do_s64_seek(PerlIO* f, Off_t offset, int whence) { } /* SOCKS 64 bit ftell replacement */ -Off_t Perl_do_s64_tell(PerlIO* f) { +Off_t Perl_do_s64_tell(pTHX_ PerlIO* f) { Off_t offset = 0; - S64_IOB *ptr = S_s64_get_buffer(f); + S64_IOB *ptr = S_s64_get_buffer(aTHX_ f); if( ptr) offset = ptr->cnt; return( ftello(f) - offset); @@ -194,6 +194,12 @@ #define do_vecset Perl_do_vecset #define do_vop Perl_do_vop #if defined(SOCKS_64BIT_BUG) +#define do_s64_tell Perl_do_s64_tell +#define do_s64_fread Perl_do_s64_fread +#define do_s64_getc Perl_do_s64_getc +#define do_s64_seek Perl_do_s64_seek +#define do_s64_ungetc Perl_do_s64_ungetc +#define do_s64_delete_buffer Perl_do_s64_delete_buffer #define s64_get_buffer S_s64_get_buffer #define s64_create_buffer S_s64_create_buffer #define s64_malloc S_s64_malloc @@ -1667,6 +1673,12 @@ #define do_vecset(a) Perl_do_vecset(aTHX_ a) #define do_vop(a,b,c,d) Perl_do_vop(aTHX_ a,b,c,d) #if defined(SOCKS_64BIT_BUG) +#define do_s64_tell(a) Perl_do_s64_tell(aTHX_ a) +#define do_s64_fread(a,b,c) Perl_do_s64_fread(aTHX_ a,b,c) +#define do_s64_getc(a) Perl_do_s64_getc(aTHX_ a) +#define do_s64_seek(a,b,c) Perl_do_s64_seek(aTHX_ a,b,c) +#define do_s64_ungetc(a,b) Perl_do_s64_ungetc(aTHX_ a,b) +#define do_s64_delete_buffer(a) Perl_do_s64_delete_buffer(aTHX_ a) #define s64_get_buffer(a) S_s64_get_buffer(aTHX_ a) #define s64_create_buffer(a) S_s64_create_buffer(aTHX_ a) #define s64_malloc(a) S_s64_malloc(aTHX_ a) @@ -3266,11 +3278,17 @@ #define Perl_do_vop CPerlObj::Perl_do_vop #define do_vop Perl_do_vop #if defined(SOCKS_64BIT_BUG) +#define Perl_do_s64_tell CPerlObj::Perl_do_s64_tell #define do_s64_tell Perl_do_s64_tell +#define Perl_do_s64_fread CPerlObj::Perl_do_s64_fread #define do_s64_fread Perl_do_s64_fread +#define Perl_do_s64_getc CPerlObj::Perl_do_s64_getc #define do_s64_getc Perl_do_s64_getc +#define Perl_do_s64_seek CPerlObj::Perl_do_s64_seek #define do_s64_seek Perl_do_s64_seek +#define Perl_do_s64_ungetc CPerlObj::Perl_do_s64_ungetc #define do_s64_ungetc Perl_do_s64_ungetc +#define Perl_do_s64_delete_buffer CPerlObj::Perl_do_s64_delete_buffer #define do_s64_delete_buffer Perl_do_s64_delete_buffer #define do_s64_init_buffer Perl_do_s64_init_buffer #define S_s64_get_buffer CPerlObj::S_s64_get_buffer @@ -1506,12 +1506,12 @@ p |UV |do_vecget |SV* sv|I32 offset|I32 size p |void |do_vecset |SV* sv p |void |do_vop |I32 optype|SV* sv|SV* left|SV* right #if defined(SOCKS_64BIT_BUG) -Ajnop |Off_t |do_s64_tell |PerlIO* fp -Ajnop |SSize_t|do_s64_fread |void *buf|SSize_t count|PerlIO* fp -Ajnop |int |do_s64_getc |PerlIO* fp -Ajnop |int |do_s64_seek |PerlIO* fp|Off_t pos|int whence -Ajnop |int |do_s64_ungetc |int ch|PerlIO* fp -Ajnop |void |do_s64_delete_buffer|PerlIO* fp +p |Off_t |do_s64_tell |PerlIO* fp +p |SSize_t|do_s64_fread |void *buf|SSize_t count|PerlIO* fp +p |int |do_s64_getc |PerlIO* fp +p |int |do_s64_seek |PerlIO* fp|Off_t pos|int whence +p |int |do_s64_ungetc |int ch|PerlIO* fp +p |void |do_s64_delete_buffer|PerlIO* fp Ajnop |void |do_s64_init_buffer s |S64_IOB * |s64_get_buffer |PerlIO *f s |S64_IOB * |s64_create_buffer |PerlIO *f diff --git a/perlsdio.h b/perlsdio.h index 0d6612b533..7895d310b0 100644 --- a/perlsdio.h +++ b/perlsdio.h @@ -19,7 +19,7 @@ #define PerlIO_fdopen fdopen #define PerlIO_reopen freopen #ifdef SOCKS_64BIT_BUG -# define PerlIO_close(f) (Perl_do_s64_delete_buffer(f), fclose(f)) +# define PerlIO_close(f) (Perl_do_s64_delete_buffer(aTHX_ f), fclose(f)) #else # define PerlIO_close(f) fclose(f) #endif @@ -48,10 +48,10 @@ # define PerlIO_tell(f) ftell(f) #else # ifdef SOCKS_64BIT_BUG -# define PerlIO_getc(f) Perl_do_s64_getc(f) -# define PerlIO_ungetc(f,c) Perl_do_s64_ungetc(c,f) -# define PerlIO_read(f,buf,count) Perl_do_s64_fread(buf,count,f) -# define PerlIO_tell(f) Perl_do_s64_tell(f) +# define PerlIO_getc(f) Perl_do_s64_getc(aTHX_ f) +# define PerlIO_ungetc(f,c) Perl_do_s64_ungetc(aTHX_ c,f) +# define PerlIO_read(f,buf,count) Perl_do_s64_fread(aTHX_ buf,count,f) +# define PerlIO_tell(f) Perl_do_s64_tell(aTHX_ f) # else # define PerlIO_getc(f) getc(f) # define PerlIO_ungetc(f,c) ungetc(c,f) @@ -66,7 +66,7 @@ #define PerlIO_clearerr(f) clearerr(f) #define PerlIO_flush(f) Fflush(f) #ifdef SOCKS_64BIT_BUG -# define PerlIO_seek(f,o,w) Perl_do_s64_seek(f,o,w) +# define PerlIO_seek(f,o,w) Perl_do_s64_seek(aTHX_ f,o,w) #else # if defined(VMS) && !defined(__DECC) /* Old VAXC RTL doesn't reset EOF on seek; Perl folk seem to expect this */ @@ -248,12 +248,12 @@ PERL_CALLCONV UV Perl_do_vecget(pTHX_ SV* sv, I32 offset, I32 size); PERL_CALLCONV void Perl_do_vecset(pTHX_ SV* sv); PERL_CALLCONV void Perl_do_vop(pTHX_ I32 optype, SV* sv, SV* left, SV* right); #if defined(SOCKS_64BIT_BUG) -PERL_CALLCONV Off_t Perl_do_s64_tell(PerlIO* fp); -PERL_CALLCONV SSize_t Perl_do_s64_fread(void *buf, SSize_t count, PerlIO* fp); -PERL_CALLCONV int Perl_do_s64_getc(PerlIO* fp); -PERL_CALLCONV int Perl_do_s64_seek(PerlIO* fp, Off_t pos, int whence); -PERL_CALLCONV int Perl_do_s64_ungetc(int ch, PerlIO* fp); -PERL_CALLCONV void Perl_do_s64_delete_buffer(PerlIO* fp); +PERL_CALLCONV Off_t Perl_do_s64_tell(pTHX_ PerlIO* fp); +PERL_CALLCONV SSize_t Perl_do_s64_fread(pTHX_ void *buf, SSize_t count, PerlIO* fp); +PERL_CALLCONV int Perl_do_s64_getc(pTHX_ PerlIO* fp); +PERL_CALLCONV int Perl_do_s64_seek(pTHX_ PerlIO* fp, Off_t pos, int whence); +PERL_CALLCONV int Perl_do_s64_ungetc(pTHX_ int ch, PerlIO* fp); +PERL_CALLCONV void Perl_do_s64_delete_buffer(pTHX_ PerlIO* fp); PERL_CALLCONV void Perl_do_s64_init_buffer(void); STATIC S64_IOB * S_s64_get_buffer(pTHX_ PerlIO *f); STATIC S64_IOB * S_s64_create_buffer(pTHX_ PerlIO *f); |