Date: Mon, 9 Oct 2000 06:50:03 -0700 (PDT) From: vazquez@penelope.iqm.unicamp.br To: freebsd-bugs@FreeBSD.org Subject: Re: gnu/21276: libI77 is unable to handle files >2Gbytes Message-ID: <200010091350.GAA66324@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR gnu/21276; it has been noted by GNATS.
From: vazquez@penelope.iqm.unicamp.br
To: freebsd-gnats-submit@FreeBSD.org
Cc:
Subject: Re: gnu/21276: libI77 is unable to handle files >2Gbytes
Date: Mon, 9 Oct 2000 11:44:40 -0200
--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii
The following patch allows random direct access files bigger than >2Gbytes
on FreeBSD/x86, it applies against the netlib libI77 sources. To integrate
this on gcc would require that autoconf tests all the 32 bit target archs
for:
1) The presence of fseeko/ftello or fseek64/ftell64 or...
the appropriate pair of 64bit off_set functions;
2) What argument these functions use: off_t, 'long long';
3) Other targets (16bit, 64bit, linux/x86) should be left
untouched (that is, it seems this patch is specific to *BSD intel)
an alternative way would be to submit these patchs to David Gay at
Bell (the f2c/lib*77 mantainer) and hope this will be imported on
gcc sometime and from there into FreeBSD tree.
Pedro
--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff
Index: Notice
===================================================================
RCS file: /home/Repositorio/libi77/Notice,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: README
===================================================================
RCS file: /home/Repositorio/libi77/README,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: Version.c
===================================================================
RCS file: /home/Repositorio/libi77/Version.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: backspace.c
===================================================================
RCS file: /home/Repositorio/libi77/backspace.c,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- backspace.c 2000/10/06 13:27:42 1.1
+++ backspace.c 2000/10/06 16:15:16 1.3
@@ -6,7 +6,7 @@
integer f_back(alist *a)
#endif
{ unit *b;
- long v, w, x, y, z;
+ f77_offset v, w, x, y, z;
uiolen n;
FILE *f;
@@ -30,31 +30,31 @@
f = b->ufd; /* may have changed in t_runc() */
if(b->url>0)
{
- x=ftell(f);
+ x=FTELL(f);
y = x % b->url;
if(y == 0) x--;
x /= b->url;
x *= b->url;
- (void) fseek(f,x,SEEK_SET);
+ (void) FSEEK(f,x,SEEK_SET);
return(0);
}
if(b->ufmt==0)
- { fseek(f,-(long)sizeof(uiolen),SEEK_CUR);
+ { FSEEK(f,-(long)sizeof(uiolen),SEEK_CUR);
fread((char *)&n,sizeof(uiolen),1,f);
- fseek(f,-(long)n-2*sizeof(uiolen),SEEK_CUR);
+ FSEEK(f,-(f77_offset)n-2*sizeof(uiolen),SEEK_CUR);
return(0);
}
- w = x = ftell(f);
+ w = x = FTELL(f);
z = 0;
loop:
while(x) {
x -= x < 64 ? x : 64;
- fseek(f,x,SEEK_SET);
+ FSEEK(f,x,SEEK_SET);
for(y = x; y < w; y++) {
if (getc(f) != '\n')
continue;
- v = ftell(f);
+ v = FTELL(f);
if (v == w) {
if (z)
goto break2;
@@ -65,6 +65,6 @@
err(a->aerr,(EOF),"backspace")
}
break2:
- fseek(f, z, SEEK_SET);
+ FSEEK(f, z, SEEK_SET);
return 0;
}
Index: close.c
===================================================================
RCS file: /home/Repositorio/libi77/close.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: dfe.c
===================================================================
RCS file: /home/Repositorio/libi77/dfe.c,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- dfe.c 2000/10/06 13:27:42 1.1
+++ dfe.c 2000/10/06 16:15:16 1.3
@@ -81,7 +81,7 @@
f__fmtbuf=a->cifmt;
if(a->cirec <= 0)
err(a->cierr,130,"dfe")
- fseek(f__cf,(long)f__curunit->url * (a->cirec-1),SEEK_SET);
+ FSEEK(f__cf,(f77_offset)f__curunit->url * (a->cirec-1),SEEK_SET);
f__curunit->uend = 0;
return(0);
}
Index: dolio.c
===================================================================
RCS file: /home/Repositorio/libi77/dolio.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: due.c
===================================================================
RCS file: /home/Repositorio/libi77/due.c,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- due.c 2000/10/06 13:27:42 1.1
+++ due.c 2000/10/06 16:15:16 1.3
@@ -21,7 +21,7 @@
if(f__curunit->ufd==NULL) err(a->cierr,114,"cdue")
if(a->cirec <= 0)
err(a->cierr,130,"due")
- fseek(f__cf,(long)(a->cirec-1)*f__curunit->url,SEEK_SET);
+ FSEEK(f__cf,(f77_offset)(a->cirec-1)*f__curunit->url,SEEK_SET);
f__curunit->uend = 0;
return(0);
}
@@ -55,8 +55,8 @@
{
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)
+ FSEEK(f__cf,(f77_offset)(f__curunit->url-f__recpos),SEEK_CUR);
+ if(FTELL(f__cf)%f__curunit->url)
err(f__elist->cierr,200,"syserr");
return(0);
}
Index: endfile.c
===================================================================
RCS file: /home/Repositorio/libi77/endfile.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- endfile.c 2000/10/06 13:27:42 1.1
+++ endfile.c 2000/10/06 13:56:20 1.2
@@ -62,7 +62,7 @@
t_runc(alist *a)
#endif
{
- long loc, len;
+ f77_offset loc, len;
unit *b;
FILE *bf, *tf;
int rc = 0;
@@ -70,9 +70,9 @@
b = &f__units[a->aunit];
if(b->url)
return(0); /*don't truncate direct files*/
- loc=ftell(bf = b->ufd);
- fseek(bf,0L,SEEK_END);
- len=ftell(bf);
+ loc=FTELL(bf = b->ufd);
+ FSEEK(bf,0L,SEEK_END);
+ len=FTELL(bf);
if (loc >= len || b->useek == 0 || b->ufnm == NULL)
return(0);
fclose(b->ufd);
@@ -108,7 +108,7 @@
fclose(bf);
if (!(bf = fopen(b->ufnm, f__w_mode[3])))
goto bad;
- fseek(bf,0L,SEEK_END);
+ FSEEK(bf,0L,SEEK_END);
b->urw = 3;
}
#endif
Index: err.c
===================================================================
RCS file: /home/Repositorio/libi77/err.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- err.c 2000/10/06 13:27:42 1.1
+++ err.c 2000/10/06 13:56:20 1.2
@@ -192,7 +192,7 @@
f__nowreading(unit *x)
#endif
{
- long loc;
+ f77_offset loc;
int ufmt, urw;
extern char *f__r_mode[], *f__w_mode[];
@@ -201,7 +201,7 @@
if (!x->ufnm)
goto cantread;
ufmt = x->url ? 0 : x->ufmt;
- loc = ftell(x->ufd);
+ loc = FTELL(x->ufd);
urw = 3;
if (!freopen(x->ufnm, f__w_mode[ufmt|2], x->ufd)) {
urw = 1;
@@ -211,7 +211,7 @@
return 1;
}
}
- fseek(x->ufd,loc,SEEK_SET);
+ FSEEK(x->ufd,loc,SEEK_SET);
x->urw = urw;
done:
x->uwrt = 0;
@@ -239,7 +239,7 @@
x->urw = 2;
}
else {
- loc=ftell(x->ufd);
+ loc=FTELL(x->ufd);
if (!(f__cf = x->ufd =
freopen(x->ufnm, f__w_mode[ufmt |= 2], x->ufd)))
{
@@ -249,7 +249,7 @@
return(1);
}
x->urw = 3;
- fseek(x->ufd,loc,SEEK_SET);
+ FSEEK(x->ufd,loc,SEEK_SET);
}
done:
x->uwrt = 1;
Index: f2c.h
===================================================================
RCS file: /home/Repositorio/libi77/f2c.h,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- f2c.h 2000/10/06 16:20:44 1.1
+++ f2c.h 2000/10/09 12:59:52 1.3
@@ -6,7 +6,14 @@
#ifndef F2C_INCLUDE
#define F2C_INCLUDE
+#include <unistd.h>
+#ifndef F77_OFFSET
+typedef int f77_offset;
+#else
+typedef F77_OFFSET f77_offset;
+#endif
+
typedef long int integer;
typedef unsigned long uinteger;
typedef char *address;
@@ -36,6 +43,14 @@
/* I/O stuff */
+#ifndef FSEEK
+#define FSEEK fseek
+#endif
+
+#ifndef FTELL
+#define FTELL ftell
+#endif
+
#ifdef f2c_i2
/* for -i2 */
typedef short flag;
@@ -117,7 +132,7 @@
char *inunf;
ftnlen inunflen;
ftnint *inrecl;
- ftnint *innrec;
+ f77_offset *innrec;
char *inblank;
ftnlen inblanklen;
} inlist;
Index: f2ch.add
===================================================================
RCS file: /home/Repositorio/libi77/f2ch.add,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: fio.h
===================================================================
RCS file: /home/Repositorio/libi77/fio.h,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: fmt.c
===================================================================
RCS file: /home/Repositorio/libi77/fmt.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: fmt.h
===================================================================
RCS file: /home/Repositorio/libi77/fmt.h,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: fmtlib.c
===================================================================
RCS file: /home/Repositorio/libi77/fmtlib.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: fp.h
===================================================================
RCS file: /home/Repositorio/libi77/fp.h,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: ftell_.c
===================================================================
RCS file: /home/Repositorio/libi77/ftell_.c,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- ftell_.c 2000/10/06 13:27:42 1.1
+++ ftell_.c 2000/10/06 16:15:16 1.3
@@ -13,22 +13,23 @@
return f__units[Unit].ufd;
}
- integer
+f77_offset
+/* integer*/
#ifdef KR_headers
-ftell_(Unit) integer *Unit;
+FTELL_(Unit) integer *Unit;
#else
-ftell_(integer *Unit)
+FTELL_(integer *Unit)
#endif
{
FILE *f;
- return (f = unit_chk(*Unit, "ftell")) ? ftell(f) : -1L;
+ return (f = unit_chk(*Unit, "FTELL")) ? FTELL(f) : -1L;
}
int
#ifdef KR_headers
-fseek_(Unit, offset, whence) integer *Unit, *offset, *whence;
+FSEEK_(Unit, offset, whence) integer *Unit, f77_offset *offset, integer *whence;
#else
-fseek_(integer *Unit, integer *offset, integer *whence)
+FSEEK_(integer *Unit, f77_offset *offset, integer *whence)
#endif
{
FILE *f;
@@ -41,6 +42,6 @@
#ifdef SEEK_SET
w = wohin[w];
#endif
- return !(f = unit_chk(*Unit, "fseek"))
- || fseek(f, *offset, w) ? 1 : 0;
+ return !(f = unit_chk(*Unit, "FSEEK"))
+ || FSEEK(f, *offset, w) ? 1 : 0;
}
Index: iio.c
===================================================================
RCS file: /home/Repositorio/libi77/iio.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: ilnw.c
===================================================================
RCS file: /home/Repositorio/libi77/ilnw.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: inquire.c
===================================================================
RCS file: /home/Repositorio/libi77/inquire.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- inquire.c 2000/10/06 13:27:42 1.1
+++ inquire.c 2000/10/06 13:56:20 1.2
@@ -100,7 +100,7 @@
if(a->inrecl!=NULL && p!=NULL)
*a->inrecl=p->url;
if(a->innrec!=NULL && p!=NULL && p->url>0)
- *a->innrec=ftell(p->ufd)/p->url+1;
+ *a->innrec=FTELL(p->ufd)/p->url+1;
if(a->inblank && p!=NULL && p->ufmt)
if(p->ublnk)
b_char("ZERO",a->inblank,a->inblanklen);
Index: libI77.xsum
===================================================================
RCS file: /home/Repositorio/libi77/libI77.xsum,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: lio.h
===================================================================
RCS file: /home/Repositorio/libi77/lio.h,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: lread.c
===================================================================
RCS file: /home/Repositorio/libi77/lread.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: lwrite.c
===================================================================
RCS file: /home/Repositorio/libi77/lwrite.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: makefile
===================================================================
RCS file: /home/Repositorio/libi77/makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- makefile 2000/10/06 13:27:42 1.1
+++ makefile 2000/10/09 12:59:52 1.2
@@ -5,7 +5,7 @@
# compile, then strip unnecessary symbols
.c.o:
- $(CC) -c -DSkip_f2c_Undefs $(CFLAGS) $*.c
+ $(CC) -c -DFSEEK=fseeko -DLSEEK=lseeko -DF77OFF=off_t -DSkip_f2c_Undefs $(CFLAGS) $*.c
ld -r -x -o $*.xxx $*.o
mv $*.xxx $*.o
## Under Solaris (and other systems that do not understand ld -x),
Index: open.c
===================================================================
RCS file: /home/Repositorio/libi77/open.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- open.c 2000/10/06 13:27:42 1.1
+++ open.c 2000/10/06 13:56:20 1.2
@@ -266,7 +266,7 @@
if (a->orl)
rewind(b->ufd);
else if ((s = a->oacc) && (*s == 'a' || *s == 'A')
- && fseek(b->ufd, 0L, SEEK_END))
+ && FSEEK(b->ufd, 0L, SEEK_END))
opnerr(a->oerr,129,"open");
return(0);
}
Index: rawio.h
===================================================================
RCS file: /home/Repositorio/libi77/rawio.h,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: rdfmt.c
===================================================================
RCS file: /home/Repositorio/libi77/rdfmt.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: rewind.c
===================================================================
RCS file: /home/Repositorio/libi77/rewind.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: rsfe.c
===================================================================
RCS file: /home/Repositorio/libi77/rsfe.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: rsli.c
===================================================================
RCS file: /home/Repositorio/libi77/rsli.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: rsne.c
===================================================================
RCS file: /home/Repositorio/libi77/rsne.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: sfe.c
===================================================================
RCS file: /home/Repositorio/libi77/sfe.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: sue.c
===================================================================
RCS file: /home/Repositorio/libi77/sue.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sue.c 2000/10/06 13:27:42 1.1
+++ sue.c 2000/10/06 13:56:20 1.2
@@ -1,7 +1,7 @@
#include "f2c.h"
#include "fio.h"
extern uiolen f__reclen;
-long f__recloc;
+f77_offset f__recloc;
#ifdef KR_headers
c_sue(a) cilist *a;
@@ -59,25 +59,25 @@
f__reclen=0;
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);
+ f__recloc=FTELL(f__cf);
+ (void) FSEEK(f__cf,(long)sizeof(uiolen),SEEK_CUR);
return(0);
}
integer e_wsue(Void)
-{ long loc;
+{ f77_offset loc;
fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
#ifdef ALWAYS_FLUSH
if (fflush(f__cf))
err(f__elist->cierr, errno, "write end");
#endif
- loc=ftell(f__cf);
- fseek(f__cf,f__recloc,SEEK_SET);
+ 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);
+ FSEEK(f__cf,loc,SEEK_SET);
return(0);
}
integer e_rsue(Void)
{
- (void) fseek(f__cf,(long)(f__reclen-f__recpos+sizeof(uiolen)),SEEK_CUR);
+ (void) FSEEK(f__cf,(long)(f__reclen-f__recpos+sizeof(uiolen)),SEEK_CUR);
return(0);
}
Index: typesize.c
===================================================================
RCS file: /home/Repositorio/libi77/typesize.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: uio.c
===================================================================
RCS file: /home/Repositorio/libi77/uio.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: util.c
===================================================================
RCS file: /home/Repositorio/libi77/util.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: wref.c
===================================================================
RCS file: /home/Repositorio/libi77/wref.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: wrtfmt.c
===================================================================
RCS file: /home/Repositorio/libi77/wrtfmt.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: wsfe.c
===================================================================
RCS file: /home/Repositorio/libi77/wsfe.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: wsle.c
===================================================================
RCS file: /home/Repositorio/libi77/wsle.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: wsne.c
===================================================================
RCS file: /home/Repositorio/libi77/wsne.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: xwsne.c
===================================================================
RCS file: /home/Repositorio/libi77/xwsne.c,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
--oyUTqETQ0mS9luUI--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200010091350.GAA66324>
