[ODE] AMD64: OPCODE cast from 64 bits pointer to 32 bits integer (patch included, second try)

Tanguy Fautre tanguy.fautre at spaceapplications.com
Mon Feb 28 15:19:10 MST 2005


Ok,

I took your comments into account and posted an updated patch on 
http://users.telenet.be/tfautre/ode-0.5_OPCODE64.patch2


res wrote:

> Thoughts:
> - There's a type uintptr_t that's supposed to be an unsigned int the 
> size of a pointer. While size_t probably does the job, too, it looks a 
> bit odd (imo).

uintptr_t is C99, so it cannot be used in C++98, otherwise yes it would 
have been better.

>> udword Index = (size_t(current->GetPrimitives()) - 
>> size_t(Data->mBase))/sizeof(size_t);
>
> Sure the division by sizeof(size_t) is correct? AFAICS GetPrimitives() 
> returns a udword*, so the divisor should probably stay sizeof(udword).

You seem to be right, I dunno OPCODE internals enough to be sure. I 
changed it back to sizeof(udword)

> - You changed:
>
>> if(element)    element = (SAP_Element*)(udword(element) + delta);
>
> to:
>
>> if(element)    element = (SAP_Element*)(element + delta);
>
> This is a semantic change. The function description says delta is a 
> byte offset; with your change, it will be an offset of actually 
> SAP_Elements.
>
Now it's size_t(element). :-)


Greetings,

Tanguy





More information about the ODE mailing list