[Vm-dev] Why StandardFileStream fileID is 16 bytes in Linux while 20 bytes in OSX?

Eliot Miranda eliot.miranda at gmail.com
Sun Jan 10 01:02:40 UTC 2016


Hi David, file size is orthogonal. One needs to define something like -D_FILESIZE=64 or some such. I'm on my phone so don't have the details but if you have a look at an mvm under build.linux32* you'll see the correct incantation.

_,,,^..^,,,_ (phone)

> On Jan 9, 2016, at 3:49 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> 
> 
>> On Sat, Jan 09, 2016 at 07:46:28PM -0300, Mariano Martinez Peck wrote:
>> 
>> On Sat, Jan 9, 2016 at 12:45 PM, Eliot Miranda <eliot.miranda at gmail.com>
>> wrote:
>> 
>>> 
>>> My guess is that the VM is being built, wrongly, without 64-bit file
>>> sizes.  In the Squeak VM this is definitely not 16 bytes.
>> Hi Eliot,
>> 
>> Thank you very much!! You nailed it :)  It is indeed that the fileSize in
>> Linux VM is 4 bytes and not 8 as for OSX.
> 
> I don't think so. Details below.
> 
>> 
>> You said that in the SqueakVM it is 64 bits. By SqueakVM you mean your Cog
>> (and not our Pharo builds) or you mean the old interpreter VM?
> 
> There are two other factors at work here. In earlier days, sizof(SQFile)
> on a 32-bit host system was 16. At some point, the isStdioStream member got
> added to the data structure (<OT>horrible, what were we thinking?</OT>) and
> the size became 20, which is what you will now see with any recent VM on a
> 32-bit host.
> 
> If you are using a VM for which the size is 16, this suggests that it
> is a VM that was compiled from a code base that does not include the
> isStdioStream member in the data structure.
> 
> The other factor is pointer size on the host platform. If you compile a
> VM in 64-bit mode, then sizeof(SQFile) is 32.
> 
> On a non-Spur 64-bit image on 64-bit host, the size is also 32. So you
> should expect this to be the case for 64-bit Spur (because the VM for
> 64-bit Spur will also be compiled in 64-bit mode).
> 
> The size of 32 is what I see on my Linux system, and it is probably what
> you will see on most other systems. But there is no guarantee, the compiler
> is free to organize data structures as it sees fit, and it is certainly
> possible that factors such as word alignment optimizations might lead to
> different results on different platforms.
> 
>> 
>> Should I open an issue somewhere so that we can make it 64 bits file size?
> 
> Probably not. This looks like normal expected variation that is (and should
> be) under the control of the host platform and compiler. If the VM that you
> are using is compiled from outdated platforms source code, that might be
> a concern, but even so there should be no expectation that sizeof(SQFile) is
> the same on all platforms. That definitely is not the case.
> 
> Compiling for 64-bit file size does not have any impact on sizeof(SQFile).
> If I compile a Linux VM with or without that option, the size of SQFile
> is the same in either case.
> 
> Dave
> 
>> Thanks advance,
>> 
>> 
>> _,,,^..^,,,_ (phone)
>>> 
>>> On Jan 9, 2016, at 7:06 AM, Mariano Martinez Peck <marianopeck at gmail.com>
>>> wrote:
>>> 
>>> Hi guys,
>>> 
>>> In OSX, StandardFileStream byteID size is 20, while in Linux, it is 16. I
>>> see this definition in  ./Cross/plugins/FilePlugin/FilePlugin.h
>>> 
>>> 
>>> /* squeak file record; see sqFilePrims.c for details */
>>> typedef struct {
>>>  int                    sessionID;     /* ikp: must be first */
>>>  void                  *file;
>>>  squeakFileOffsetType   fileSize;      /* 64-bits we hope. */
>>> #if defined(ACORN)
>>> // ACORN has to have 'lastOp' as at least a 32 bit field in order to work
>>>  int lastOp; // actually used to save file position
>>>  char writable;
>>>  char lastChar;
>>>  char isStdioStream;
>>> #else
>>>  char                   writable;
>>>  char                   lastOp; /* 0 = uncommitted, 1 = read, 2 = write */
>>>  char                   lastChar;
>>>  char                   isStdioStream;
>>> #endif
>>> } SQFile;
>>> 
>>> And I see no override from UNIX platform code. So...how can that be 16
>>> bytes in Linux?
>>> 
>>> Thanks in advance,
>>> 
>>> --
>>> Mariano
>>> http://marianopeck.wordpress.com
> 


More information about the Vm-dev mailing list