[GRASS-dev] diglib test.c fails on 64bit win

Glynn Clements glynn at gclements.plus.com
Tue May 18 10:13:24 EDT 2010


Markus Metz wrote:

> >> In GRASS, config.h does not know about __MINGW32__ even if __MINGW32__
> >> is (somewhere else) defined, thus off_t is not redefined for mingw32,
> >> and I placed the redefinitions for testing in another header. Looks
> >> like a lot of hacking to get LFS for wingrass.
> >
> > __MINGW32__ is defined by the compiler.
> >
> > But note that the "#ifdef __MINGW32__" block is within a
> > "#ifdef USE_LARGEFILES" block, and USE_LARGEFILES isn't defined as a
> > preprocessor macro (AC_DEFINE), only as a substitution (AC_SUBST), so
> > all of that LFS stuff at the bottom of config.h is ignored.
> >
> Interesting. IOW, "#ifdef USE_LARGEFILES" in config.h.in is
> (unintentionally?) used to disable all that LFS stuff.

Yes. I suspect that it was copied verbatim from cdrtools (that's where
the LFS stuff came from) without entirely understanding it.

> That also means
> that the IOSTREAM library always uses fseek and never fseeko because
> HAVE_LARGEFILES is not defined. IIUC, the largefile test in configure
> is passed for MINGW32 because fseeko64 and ftello64 exist,
> USE_LARGEFILES is defined, LFS flags are set in Grass.make, but LFS is
> not available because these explicit 64bit versions are never
> activated. Wouldn't it make more sense to sync configure.in and
> config.h.in? I think that LFS in grass also for mingw32 would be
> highly appreciated by Windows users.

In 6.x, LFS is enabled for specific libraries or modules using e.g.:

	ifneq ($(USE_LARGEFILES),)
		EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
	endif

in the corresponding Makefile. This needs to be done on a case-by-case
basis because not all modules are LFS-aware, e.g. because they
calculate offsets using "int" or "long" arithmetic, or use
fseek/ftell.

In 7.x, LFS is enabled globally by the following in Grass.make:

	ifdef USE_LARGEFILES
	LFS_CFLAGS = -D_FILE_OFFSET_BITS=64
	endif

POSIX defines 3 feature-test macros:

   _LARGEFILE_SOURCE
   _LARGEFILE64_SOURCE
   _FILE_OFFSET_BITS

Defining _LARGEFILE_SOURCE makes fseeko() and ftello() available.
Defining _LARGEFILE64_SOURCE makes the 64-bit functions (open64(),
lseek64(), etc) available. Defining _FILE_OFFSET_BITS=64 does both of
the above and also "redirects" the standard names to their 64-bit
equivalents.

MinGW doesn't have any of these. Instead, the 64-bit names are visible
unless __NO_MINGW_LFS is defined. There are no fseeko/ftello functions
(only fseeko64/ftello64), and no equivalent of _FILE_OFFSET_BITS.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list