[Top][All Lists]

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

Re: [Pnet-developers] Use of ILNativeUInt vs. unsigned long in pointer c

From: Rhys Weatherley
Subject: Re: [Pnet-developers] Use of ILNativeUInt vs. unsigned long in pointer casting and manipulation
Date: Thu, 23 Sep 2004 07:57:27 +1000
User-agent: KMail/1.4.3

On Wednesday 22 September 2004 03:35 pm, Peter Colson wrote:

> In include/il_types.h, though, the various IL_TypeFrom/To macros use
> unsigned long as the intermediate type. This resolves to a 4 byte
> entity in my environment, so an obvious problem here.

Probably a bug that we haven't noticed till now.  Easy to fix.

> When I look through the code I see other instances of, say,
> ILType_FromElement being used on a 'value' var that is returned as an
> unsigned long from ILMetaUncompressData().

ILType_FromElement takes an integer value and converts it into a pointer.  It 
doesn't really matter what integer type is used as long as it is at least 
32-bits.  This one is probably the more correct of those macros.  An explicit 
cast to ILNativeUInt may be warranted to get around dingbat compilers.

> My question is: How widespread is the use of unsigned long to
> hold/return pointers and wouldn't it be more portable to be using
> ILNativeUInt for this as per method_cache.c?

It isn't widespread.  il_types.h is a very, very, very, old file, dating back 
to the earliest versions of pnet.  Back then, I wasn't aware that some 
platforms have "sizeof(long) != sizeof(void *)" and it just got forgotten 
later.  We fix them as we find them, which I'll do now in this case.



reply via email to

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