[Vm-dev] What a surface mess !!!

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Fri Nov 11 23:27:10 UTC 2016


Hi,
I'm looking at various surface plugins... It's a mess.

There is a mix of int/long/void * in the various declarations.
What is very nice, is that they are all of equal size in ILP32 convention,
so we can be very careless and ignore all the compiler warnings.
Well, until we try to port to LP64 or LLP64...

When trying to untangle that mess, I see there is the handle/pointer/ID
confusion.

SurfacePlugin.h expects a surfaceHandle to be a void *, and declare that it
will pass that type to the four functions
(getSurfaceFormat,lockSurface,unlockSurface,showSurface).

Of course, the comment a few lines below does not quite agrees, it says
it's rather a long.

The functions defined in end of same file and which are used by
interpreterProxy interface declare the surfaceHandle as long...

And sqMacWindow.c uses an int handle!!! It's used as an ID.
I would have thought that the conversion SurfaceID -> SurfaceHandle would
have occured a bit sooner, but here no.

Same mess for the other parameters, x,y,w,h,pitch,isMSB, they are either
declared int or long... It may work by pure luck on little endian machines
when we pass args by registers, and SYSV X64 convention uses a lot of
these, or when each arg passed thru stack is 8-bytes aligned, and when the
caller has the longer type. But that's dramatically wrong when we pass a
pointer to such data, we'll then get pure UB related to uninitialized MSB...

I'm going to fix that, don't be amazed if you see a bit of traffic in the
next hours.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20161112/788c63ae/attachment.html>


More information about the Vm-dev mailing list