[Fortran, committed to trunk] Preparing libf2c/libI77 for 64-bit file sizes (stage 2).
Toon Moene
toon@moene.indiv.nluug.nl
Fri Jul 6 05:15:00 GMT 2001
L.S.,
I've just committed the following patch [attached] to the trunk that
will bring libf2c/libI77 again closer to supporting >2Gb file sizes on
32-bit targets.
Configure finds out whether fseeko/ftello exists for this target -
subsequently, in fio.h FSEEK and FTELL are defined to either fseeko and
ftello or fseek and ftell depending on configure's findings.
All other changes concern the switch-over from fseek to FSEEK and ftell
to FTELL.
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)
2001-07-06 Toon Moene <toon@moene.indiv.nluug.nl>
Pedro Vazquez <vazquez@penelope.iqm.unicamp.br>
* configure.in: Check for fseeko, ftello.
* configure: Rebuilt.
* config.h.in: Rebuilt.
* fio.h: Define FSEEK to be fseek or fseeko, depending
on configure's findings. Ditto for FTELL and ftell / ftello.
* backspace.c (f_back): Use FSEEK for fseek, FTELL for ftell.
* dfe.c (c_dfe): Ditto.
* due.c (c_due, e_rdue): Ditto.
* endfile.c (t_runc): Ditto.
* err.c (f__nowreading, f__nowwriting): Ditto.
* ftell_.c (G77_ftell_0, G77_fseek_0): Ditto.
* inquire.c (f_inqu): Ditto.
* open.c (f_open): Ditto.
* rdfmt.c (rd_ed): Ditto.
* sue.c (s_wsue, e_wsue, e_rsue): Ditto.
*** configure.in.orig Thu May 17 19:19:19 2001
--- configure.in Fri Jul 6 11:07:47 2001
*************** else
*** 137,140 ****
--- 137,142 ----
fi
+ AC_CHECK_FUNCS(fseeko)
+ AC_CHECK_FUNCS(ftello)
AC_CHECK_FUNCS(ftruncate)
AC_CHECK_FUNCS(mkstemp)
*** fio.h.orig Sun Jul 1 19:53:36 2001
--- fio.h Fri Jul 6 11:11:06 2001
***************
*** 16,19 ****
--- 16,29 ----
#endif
+ /* Only use fseeko/ftello if they are both there. */
+
+ #if defined (HAVE_FSEEKO) && defined (HAVE_FTELLO)
+ #define FSEEK fseeko
+ #define FTELL ftello
+ #else
+ #define FSEEK fseek
+ #define FTELL ftell
+ #endif
+
#if defined (MSDOS) && !defined (GO32)
#ifndef NON_UNIX_STDIO
*** backspace.c.orig Sun Jul 1 12:23:18 2001
--- backspace.c Fri Jul 6 11:14:38 2001
*************** integer f_back(alist *a)
*** 35,63 ****
if(b->url>0)
{
! x=ftell(f);
y = x % b->url;
if(y == 0) x--;
x /= b->url;
x *= b->url;
! (void) fseek(f,x,SEEK_SET);
return(0);
}
if(b->ufmt==0)
! { fseek(f,-(long)sizeof(uiolen),SEEK_CUR);
fread((char *)&n,sizeof(uiolen),1,f);
! fseek(f,-(long)n-2*sizeof(uiolen),SEEK_CUR);
return(0);
}
! w = x = ftell(f);
z = 0;
loop:
while(x) {
x -= x < 64 ? x : 64;
! fseek(f,x,SEEK_SET);
for(y = x; y < w; y++) {
if (getc(f) != '\n')
continue;
! v = ftell(f);
if (v == w) {
if (z)
--- 35,63 ----
if(b->url>0)
{
! x=FTELL(f);
y = x % b->url;
if(y == 0) x--;
x /= b->url;
x *= b->url;
! FSEEK(f,x,SEEK_SET);
return(0);
}
if(b->ufmt==0)
! { FSEEK(f,-(off_t)sizeof(uiolen),SEEK_CUR);
fread((char *)&n,sizeof(uiolen),1,f);
! FSEEK(f,-(off_t)n-2*sizeof(uiolen),SEEK_CUR);
return(0);
}
! w = x = FTELL(f);
z = 0;
loop:
while(x) {
x -= x < 64 ? x : 64;
! FSEEK(f,x,SEEK_SET);
for(y = x; y < w; y++) {
if (getc(f) != '\n')
continue;
! v = FTELL(f);
if (v == w) {
if (z)
*************** integer f_back(alist *a)
*** 70,74 ****
}
break2:
! fseek(f, z, SEEK_SET);
return 0;
}
--- 70,74 ----
}
break2:
! FSEEK(f, z, SEEK_SET);
return 0;
}
*** dfe.c.orig Thu May 17 19:19:19 2001
--- dfe.c Fri Jul 6 11:15:35 2001
*************** c_dfe(cilist *a)
*** 83,87 ****
if(a->cirec <= 0)
err(a->cierr,130,"dfe");
! (void) fseek(f__cf,(long)f__curunit->url * (a->cirec-1),SEEK_SET);
f__curunit->uend = 0;
return(0);
--- 83,87 ----
if(a->cirec <= 0)
err(a->cierr,130,"dfe");
! FSEEK(f__cf,f__curunit->url * (a->cirec-1),SEEK_SET);
f__curunit->uend = 0;
return(0);
*** due.c.orig Thu May 17 19:19:19 2001
--- due.c Fri Jul 6 11:16:33 2001
*************** c_due(cilist *a)
*** 26,30 ****
if(a->cirec <= 0)
err(a->cierr,130,"due");
! fseek(f__cf,(long)(a->cirec-1)*f__curunit->url,SEEK_SET);
f__curunit->uend = 0;
return(0);
--- 26,30 ----
if(a->cirec <= 0)
err(a->cierr,130,"due");
! FSEEK(f__cf,(a->cirec-1)*f__curunit->url,SEEK_SET);
f__curunit->uend = 0;
return(0);
*************** integer e_rdue(Void)
*** 61,66 ****
if(f__curunit->url==1 || f__recpos==f__curunit->url)
return(0);
! fseek(f__cf,(long)(f__curunit->url-f__recpos),SEEK_CUR);
! if(ftell(f__cf)%f__curunit->url)
err(f__elist->cierr,200,"syserr");
return(0);
--- 61,66 ----
if(f__curunit->url==1 || f__recpos==f__curunit->url)
return(0);
! FSEEK(f__cf,(f__curunit->url-f__recpos),SEEK_CUR);
! if(FTELL(f__cf)%f__curunit->url)
err(f__elist->cierr,200,"syserr");
return(0);
*** endfile.c.orig Sun Jul 1 12:26:56 2001
--- endfile.c Fri Jul 6 11:18:27 2001
*************** t_runc(alist *a)
*** 82,88 ****
if(b->url)
return(0); /*don't truncate direct files*/
! loc=ftell(bf = b->ufd);
! fseek(bf,0L,SEEK_END);
! len=ftell(bf);
if (loc >= len || b->useek == 0 || b->ufnm == NULL)
return(0);
--- 82,88 ----
if(b->url)
return(0); /*don't truncate direct files*/
! loc=FTELL(bf = b->ufd);
! FSEEK(bf,0,SEEK_END);
! len=FTELL(bf);
if (loc >= len || b->useek == 0 || b->ufnm == NULL)
return(0);
*************** t_runc(alist *a)
*** 122,126 ****
if (!(bf = fopen(b->ufnm, f__w_mode[3])))
goto bad;
! fseek(bf,0L,SEEK_END);
b->urw = 3;
}
--- 122,126 ----
if (!(bf = fopen(b->ufnm, f__w_mode[3])))
goto bad;
! FSEEK(bf,0,SEEK_END);
b->urw = 3;
}
*** err.c.orig Sun Jul 1 12:29:03 2001
--- err.c Fri Jul 6 11:19:03 2001
*************** f__nowreading(unit *x)
*** 220,224 ****
goto cantread;
ufmt = x->url ? 0 : x->ufmt;
! loc = ftell(x->ufd);
urw = 3;
if (!freopen(x->ufnm, f__w_mode[ufmt|2], x->ufd)) {
--- 220,224 ----
goto cantread;
ufmt = x->url ? 0 : x->ufmt;
! loc = FTELL(x->ufd);
urw = 3;
if (!freopen(x->ufnm, f__w_mode[ufmt|2], x->ufd)) {
*************** f__nowreading(unit *x)
*** 230,234 ****
}
}
! fseek(x->ufd,loc,SEEK_SET);
x->urw = urw;
done:
--- 230,234 ----
}
}
! FSEEK(x->ufd,loc,SEEK_SET);
x->urw = urw;
done:
*************** f__nowwriting(unit *x)
*** 258,262 ****
}
else {
! loc=ftell(x->ufd);
if (!(f__cf = x->ufd =
freopen(x->ufnm, f__w_mode[ufmt |= 2], x->ufd)))
--- 258,262 ----
}
else {
! loc=FTELL(x->ufd);
if (!(f__cf = x->ufd =
freopen(x->ufnm, f__w_mode[ufmt |= 2], x->ufd)))
*************** f__nowwriting(unit *x)
*** 268,272 ****
}
x->urw = 3;
! fseek(x->ufd,loc,SEEK_SET);
}
done:
--- 268,272 ----
}
x->urw = 3;
! FSEEK(x->ufd,loc,SEEK_SET);
}
done:
*** ftell_.c.orig Sun Jul 1 12:30:26 2001
--- ftell_.c Fri Jul 6 11:19:49 2001
*************** G77_ftell_0 (integer *Unit)
*** 23,27 ****
{
FILE *f;
! return (f = unit_chk(*Unit, "ftell")) ? ftell(f) : -1L;
}
--- 23,27 ----
{
FILE *f;
! return (f = unit_chk(*Unit, "ftell")) ? FTELL(f) : -1L;
}
*************** G77_fseek_0 (integer *Unit, integer *off
*** 44,47 ****
#endif
return !(f = unit_chk(*Unit, "fseek"))
! || fseek(f, *offset, w) ? 1 : 0;
}
--- 44,47 ----
#endif
return !(f = unit_chk(*Unit, "fseek"))
! || FSEEK(f, *offset, w) ? 1 : 0;
}
*** inquire.c.orig Wed Jun 13 23:05:26 2001
--- inquire.c Fri Jul 6 11:20:59 2001
*************** integer f_inqu(inlist *a)
*** 101,105 ****
*a->inrecl=p->url;
if(a->innrec!=NULL && p!=NULL && p->url>0)
! *a->innrec=ftell(p->ufd)/p->url+1;
if(a->inblank && p!=NULL && p->ufmt)
if(p->ublnk)
--- 101,105 ----
*a->inrecl=p->url;
if(a->innrec!=NULL && p!=NULL && p->url>0)
! *a->innrec=FTELL(p->ufd)/p->url+1;
if(a->inblank && p!=NULL && p->ufmt)
if(p->ublnk)
*** open.c.orig Thu May 17 19:19:19 2001
--- open.c Fri Jul 6 11:21:28 2001
*************** integer f_open(olist *a)
*** 284,288 ****
rewind(b->ufd);
else if ((s = a->oacc) && (*s == 'a' || *s == 'A')
! && fseek(b->ufd, 0L, SEEK_END))
opnerr(a->oerr,129,"open");
return(0);
--- 284,288 ----
rewind(b->ufd);
else if ((s = a->oacc) && (*s == 'a' || *s == 'A')
! && FSEEK(b->ufd, 0, SEEK_END))
opnerr(a->oerr,129,"open");
return(0);
*** rdfmt.c.orig Thu May 17 19:19:19 2001
--- rdfmt.c Fri Jul 6 11:25:51 2001
*************** rd_ed(struct syl *p, char *ptr, ftnlen l
*** 472,476 ****
}
else if(f__curunit && f__curunit->useek)
! (void) fseek(f__cf,(long) f__cursor,SEEK_CUR);
else
err(f__elist->cierr,106,"fmt");
--- 472,476 ----
}
else if(f__curunit && f__curunit->useek)
! FSEEK(f__cf,(off_t)f__cursor,SEEK_CUR);
else
err(f__elist->cierr,106,"fmt");
*** sue.c.orig Sun Jul 1 12:33:04 2001
--- sue.c Fri Jul 6 11:22:47 2001
*************** integer s_wsue(cilist *a)
*** 63,68 ****
if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
err(a->cierr, errno, "write start");
! f__recloc=ftell(f__cf);
! (void) fseek(f__cf,(long)sizeof(uiolen),SEEK_CUR);
return(0);
}
--- 63,68 ----
if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
err(a->cierr, errno, "write start");
! f__recloc=FTELL(f__cf);
! FSEEK(f__cf,(off_t)sizeof(uiolen),SEEK_CUR);
return(0);
}
*************** integer e_wsue(Void)
*** 75,82 ****
err(f__elist->cierr, errno, "write end");
#endif
! loc=ftell(f__cf);
! fseek(f__cf,f__recloc,SEEK_SET);
fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
! fseek(f__cf,loc,SEEK_SET);
return(0);
}
--- 75,82 ----
err(f__elist->cierr, errno, "write end");
#endif
! loc=FTELL(f__cf);
! FSEEK(f__cf,f__recloc,SEEK_SET);
fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
! FSEEK(f__cf,loc,SEEK_SET);
return(0);
}
*************** integer e_rsue(Void)
*** 84,88 ****
{
f__init = 1;
! (void) fseek(f__cf,(long)(f__reclen-f__recpos+sizeof(uiolen)),SEEK_CUR);
return(0);
}
--- 84,88 ----
{
f__init = 1;
! FSEEK(f__cf,(off_t)(f__reclen-f__recpos+sizeof(uiolen)),SEEK_CUR);
return(0);
}
More information about the Gcc-patches
mailing list