This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Need help from C/POSIX gurus.
- To: gcc at gcc dot gnu dot org
- Subject: Need help from C/POSIX gurus.
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- Date: Fri, 13 Jul 2001 11:54:56 +0200
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
L.S.,
g77-3.1 on Solaris 2.[78] shows several regressions (io0.f and io1.f)
obviously related to my 64-bit file size/offset update of libf2c/libI77.
Brad Lucier kindly ran the attached C program for me. When compiled:
1. Using -D_XOPEN_SOURCE=500L
it printed "GOOD".
2. Using -D_XOPEN_SOURCE=500L -D_FILE_OFFSET_BITS=64
it printed "BAD".
First question:
Is this the correct way to test whether fopen/fseeko/ftello
work together with ftruncate when asking for 64-bit file
sizes/offsets ?
Second question:
If so, how do I convert this to a configure test to selectively
enable/disable -D_FILE_OFFSET_BITS=64 ?
Thanks in advance,
--
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)
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int main()
{
int c;
off_t o;
FILE* f;
if (!(f = fopen("blah","w+b")))
abort ();
c = '1';
fputc(c,f);
c = '2';
fputc(c,f);
fseeko(f,-1,SEEK_CUR);
o = ftello(f);
ftruncate(fileno(f),o);
fseeko(f,0,SEEK_SET);
if ((c = fgetc(f)) == EOF)
abort ();
if ((c = fgetc(f)) == EOF)
fprintf(stderr, "GOOD\n");
else
fprintf(stderr, "BAD\n");
fclose(f);
return 0;
}