[Vm-dev] latest sources removal platforms/unix/vm/sunos.h

K K Subbu kksubbu.ml at gmail.com
Sun Nov 8 16:55:52 UTC 2020

On 08/11/20 3:30 pm, stes at PANDORA.BE wrote:

> #ifndef __sun__
> #define ftell(s) ftello(s)
> #define fseek(s,o,w) fseeko(s,o,w)
> #endif /* __sun__ */
> I don't know what the reasoning behind that was.

It dates back to a transitional period when 32-bit kernels just started 
handling 64-bit file sizes. ISO C99 specified 32-bit offsets in 
ftell/fseek while POSIX large file extensions mapped them to calls with 
64-bit offsets. I doubt if these are required anymore because modern 
toolchains use POSIX LFS by default.


> Also there exists a lseek64() function.
> I have no idea whether this is correct, but if I change:
> - --- a/platforms/unix/vm/sqImageFileAccess.h
> +++ b/platforms/unix/vm/sqImageFileAccess.h
> @@ -108,7 +108,7 @@ sqImageFileWrite(void *ptr_arg, size_t sz, size_t count, sqImageFile f)
>   static inline off_t
>   sqImageFilePosition(sqImageFile f)
>   {
> - -       off_t pos = lseek(f, 0, SEEK_CUR);
> .....
> Then the VM compiles in 32bit mode (as before) but now it succesfully loads
> a 32bit VM image.

But it will use 32-bit offsets and can't handle images larger than 2GB :-(.

This shouldn't be required if compiles use -D_FILE_OFFSET_BITS=64 
through autoconf or make scripts. The description for _FILE_OFFSET_BITS 
in the URL above has more detail.

HTH .. Subbu

More information about the Vm-dev mailing list