[Vm-dev] egg sucking alert

Eliot Miranda eliot.miranda at gmail.com
Thu Dec 11 02:01:02 UTC 2014


On Wed, Dec 10, 2014 at 5:48 PM, David T. Lewis <lewis at mail.msen.com> wrote:

>
> On Wed, Dec 10, 2014 at 03:13:13PM -0800, Eliot Miranda wrote:
> >
> > 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).
>
> No, sqInit is *NOT* a synonym for long.
>

Apart from on the weird "64-bit image on 32-bit platform" oddity that I see
no value in maintaining, sqInt == long.

On 32-bit C compilers

        sizeof(int) == 4
        sizeof(long) == 4
        sizeof(sqInt) == 4

On 64-bit C compilers with a 64-bit image

        sizeof(int) == 4
        sizeof(long) == 8
        sizeof(sqInt) == 8

There's an oddity of a 32-bit VM compiled in 64-bit mode on a 64-bit
machine.  I don't know of anyone using it.  But on that config

        sizeof(int) == 4
        sizeof(long) == 8
        sizeof(sqInt) == 4

I'm in the process of providing a real 64-bit system with 61-bit
SmallIntegers, immediate floating point, a segmented memory, etc, etc.  I
am /not/ going to be held up trying to maintain the old 64-bit VM
oddities.  A 32-bit VM on a 32-bit platform and a 64-bit VM on a 64-bit
platform are enough, and expensive enough to maintain.

So yes, use sqInt, usqInt, long and unsigned long.  Do not use int.
Preferably declare pointer parameters as pointer rather than sqInt/long.
But in fixing existing code the easiest thing is to change int to either
sqInt or long, depending on whether that parameter receives an oop or not.


> In particular, it is a 64-bit data type in some circumstances, and a 32-bit
> data type in others. Ditto for usqInt.
>
> If you are working with something where word size matters, declare it as
> such, and do not rely on sqInt and usqInt to do what you expect. They are
> not 32 bit data types.
>
> Some but not all of the plugins are 32/64 bit clean in trunk. But many,
> including FFI, SSL, and plugins that rely on the SurfacePlugin stub, remain
> to be sorted out. By far the worst problem is the assumption that C
> pointers
> fit into 32-bit int data types, but there are various other issues
> remaining
> to be addressed. At the risk of a broad generalization, they all relate to
> missing type declarations and invalid assumptions about word size, such as
> assuming that sqInt is 32-bits in size.
>
> Dave
>
>


-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20141210/4e4b34b1/attachment-0001.htm


More information about the Vm-dev mailing list