[GRASSLIST:778] Re: Problem GRASS-6.0.2

Glynn Clements glynn at gclements.plus.com
Thu Apr 20 06:30:12 EDT 2006


Mâris Narti-B¹s wrote:-A

> Q. to dev's: Is there any short how-to how check large file support in
> GRASS module and how to enable it (which variables and functions
> should be checked etc.)?

If the --enable-largefile configure option is used, the header
<grass/config.h> will define some macros which cause off_t to be
defined as a 64-bit type and the I/O functions declared in <unistd.h>
to be the 64-bit versions (open64 etc).

If a module only does sequential file access (open, read/write,
close), including <grass/config.h> before any other headers will be
sufficient (note that <grass/gis.h> includes <grass/config.h>).

OTOH, if the module uses lseek(), you need to modify the code so that
offsets are computed and stored as off_t rather than int or long.
Apart from changing variables and fields to have type off_t, you also
need to ensure that calculations such as:

	offset = row * cols * bytes;

are promoted to off_t, e.g.:

	offset = (off_t) row * cols * bytes;

If a file uses the ANSI fseek/ftell functions, the situation is more
complex. Those functions are defined to use the C long type for
offsets. C99 has fseeko/ftello, which use off_t, but those aren't
available on all platforms, so you would need to add configure tests
and only use them if they are available.

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




More information about the grass-user mailing list