dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] CVMWord union and ReadLong Int32/Int64 mismatch?


From: Peter Colson
Subject: [Pnet-developers] CVMWord union and ReadLong Int32/Int64 mismatch?
Date: Fri, 24 Sep 2004 11:18:45 +1000

I'm trying to figure out the meaning (and terminology) of the following code.

In cvm.h the CVMWord union has no mention of Int64's (although, it could be assumed that on a 64-bit arch that void* is equivalent to an Int64):

typedef union
{
    ILInt32     intValue;
    ILUInt32  uintValue;
    void         *ptrValue;
/* Pad this structure to the best alignment on the underlying platform.
       This is usually needed on 64-bit platforms to ensure that stack
words are always aligned on the best boundary. We don't do this for i386 because IL_BEST_ALIGNMENT is sometimes 8, and we need it to be 4 */
#if !defined(__i386) && !defined(__i386__)
    char        padding[IL_BEST_ALIGNMENT];
#endif
} CVMWord;

In cvm.c, the function 'ReadLong' (where long presumably means an integral type) is assumed to be an Int64
taken from the same union above that only contains Int32 integrals:

/*
 * Read a long value from a stack position.
 */
static IL_INLINE ILInt64 ReadLong(CVMWord *stack)
{
#ifdef CVM_LONGS_ALIGNED_WORD
    return *((ILInt64 *)stack);
#else
    ILInt64 temp;
    ILMemCpy(&temp, stack, sizeof(ILInt64));
    return temp;
#endif
}

I don't understand the Int32/Int64 mismatch here?


Regards,
Peter Colson,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]