[Vm-dev] egg sucking alert

Eliot Miranda eliot.miranda at gmail.com
Wed Dec 10 23:13:13 UTC 2014


Hi All,

    just a simple message about 64-bit code.  Don't use int.  Please use
long, unsigned long, sqInt or usqInt for variables that are of the
machine's natural word length (sqInt is a synonym for long and usqInt is a
synonym for unsigned long).  On most, if not all 64-bit C compilers int is
a 32-bit datatype.  Therefore code that tries to pass a pointer through an
int parameter will end up truncating the pointer, with potentially
disastrous results.  Here's an example I'm fixing now.

In the AsynchFilePlugin the standard header defines everything as int:

int asyncFileClose(AsyncFile *f);
int asyncFileOpen(AsyncFile *f, int fileNamePtr, int fileNameSize, int
writeFlag, int semaIndex);
int asyncFileRecordSize();
int asyncFileReadResult(AsyncFile *f, int bufferPtr, int bufferSize);
int asyncFileReadStart(AsyncFile *f, int fPosition, int count);
int asyncFileWriteResult(AsyncFile *f);
int asyncFileWriteStart(AsyncFile *f, int fPosition, int bufferPtr, int
bufferSize);

but the fileNamePtr and bufferPtr parameters are really pointers passed as
integers.  These should be declared as "long", "sqInt", et al.  long is
defines as an integral type large enough to hold a pointer.

If every variable had been declared as sqInt no change would be necessary.
As it is I'm changing just those two parameters to long, to avoid the noise.

Our code base is littered with such issues.  Hence before I can get a
64-bit Spur stack VM running I have to hack, hack, hack.
-- 
cheers,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20141210/21d4525a/attachment.htm


More information about the Vm-dev mailing list