<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div>I remember we replaced  the fseek() with an fseeko()  because we ran into a bug where we were trying to seek to a large offset (in r.terracost).   </div><div><br></div><div>No objection to removing the 2 includes, given that it still compiles w/o them  on other platforms. </div><div><br></div><div>-Laura </div><div><br></div><br><div><div>On Oct 6, 2008, at 9:18 PM, <a href="mailto:grass-dev-request@lists.osgeo.org">grass-dev-request@lists.osgeo.org</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Message: 4</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Date: Tue, 7 Oct 2008 00:12:10 +0100 (BST)</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">From: Paul Kelly &lt;<a href="mailto:paul-grass@stjohnspoint.co.uk">paul-grass@stjohnspoint.co.uk</a>></font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Subject: Re: [GRASS-dev] fseeko() in libiostream</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">To: Andrew Danner &lt;<a href="mailto:adanner@cs.swarthmore.edu">adanner@cs.swarthmore.edu</a>></font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Cc: <a href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a></font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Message-ID: &lt;<a href="mailto:Pine.LNX.4.62.0810070005140.2785@vortex.ukshells.co.uk">Pine.LNX.4.62.0810070005140.2785@vortex.ukshells.co.uk</a>></font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">On Mon, 6 Oct 2008, Andrew Danner wrote:</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <blockquote type="cite"><p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">fseek is not the same as fseeko.</font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">int fseek(FILE *stream, long offset, int whence);</font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">int fseeko(FILE *stream, off_t offset, int whence);</font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">If large file support is enabled, fseeko will convert off_t to a 64 bit type<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">even on a 32-bit OS. I'm not sure if long will be 64 bit on a 64-bit OS for<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">fseek.</font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">r.in.xyz may work with large files using plain old fseek as long as r.in.xyz<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">doesn't make long seeks. ami_stream.h could potentially make long seeks<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">(e.g., skip the first 8GB of a 30GB file), though in practice, I'm not sure<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">that code that uses ami_stream (r.terraflow) actually uses this kind of<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">fseek. Still the interface is designed to potentially use long seeks and I<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">would be reluctant to simply replace fseeko with fseek in ami_stream.h.</font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">you may to add a #define to check the compiler type and use fseek only if<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 10.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">fseeko does not exist.</font></p> </blockquote><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Right - I was vaguely aware of some configure checks for fseeko() but as<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">ami_stream.h was the only file in GRASS using fseeko() I wasn't sure if it<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">had been made redundant by something else. But looking closely at<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">include/config.h, I see that we can conditionalise fseeko() on</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">#ifdef HAVE_LARGEFILES. After doing that, on Windows fseeko() is redefined<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">to fseeko64() and all then works well.</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">A couple of further Windows compile errors in lib/iostream though:</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">sh-2.04$ make</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">c++ -I/c/grass/grass7/dist.i686-pc-mingw32/include -I/c/grass/extra/include -O2 -s -I/c/grass/extra/include<span class="Apple-converted-space">  </span>-D_FILE_OFFSET_BITS=64 -DPACKAGE=\""grasslibs"\" <span class="Apple-converted-space">  </span>-I/c/grass/grass7/dist.i686-pc-mingw32/include -o OBJ.i686-pc-mingw32/mm_utils.o -c mm_utils.cc</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">mm_utils.cc:38:22: sys/mman.h: No such file or directory</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">make: *** [OBJ.i686-pc-mingw32/mm_utils.o] Error 1</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">sh-2.04$ make</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">c++ -I/c/grass/grass7/dist.i686-pc-mingw32/include -I/c/grass/extra/include -O2 -s -I/c/grass/extra/include<span class="Apple-converted-space">  </span>-D_FILE_OFFSET_BITS=64 -DPACKAGE=\""grasslibs"\" <span class="Apple-converted-space">  </span>-I/c/grass/grass7/dist.i686-pc-mingw32/include -o OBJ.i686-pc-mingw32/mm_utils.o -c mm_utils.cc</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">c++ -I/c/grass/grass7/dist.i686-pc-mingw32/include -I/c/grass/extra/include -O2 -s -I/c/grass/extra/include<span class="Apple-converted-space">  </span>-D_FILE_OFFSET_BITS=64 -DPACKAGE=\""grasslibs"\" <span class="Apple-converted-space">  </span>-I/c/grass/grass7/dist.i686-pc-mingw32/include -o OBJ.i686-pc-mingw32/rtimer.o -c rtimer.cc</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">rtimer.cc:38:26: sys/resource.h: No such file or directory</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">make: *** [OBJ.i686-pc-mingw32/rtimer.o] Error 1</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">In the two respective cases I commented out the #includes for sys/mman.h<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">and sys/resource.h and everything compiled fine. r.terraflow compiles fine<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">too. So I'll simply remove those two #includes unless there's any<span class="Apple-converted-space"> </span></font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">objection?</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Thanks for the feedback,</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Paul</font></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> <p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px"><br></p> </blockquote></div><br></body></html>