This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Need help from C/POSIX gurus.


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;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]