WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Casting 64-bit pointers to integers

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] Casting 64-bit pointers to integers
From: Michael David Crawford <mdc@xxxxxxxxx>
Date: Fri, 22 May 2009 02:30:35 -0700
Delivery-date: Fri, 22 May 2009 02:30:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Prgmr.com
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)
In building on my 64-bit Xeon box, I see a lot of warnings about casting between pointers and integers of different sizes.

Sometimes it can cause fatal compiler error.

Is there a reasonably portable way to make such casts?

The conventional wisdom is that ints are supposed to be the natural machine word size. But even that isn't always the case - much gnashing of teeth resulted in the two most popular compilers for the 68000 Macintosh having different int sizes.

There are typedefs for integers with specific numbers of bits, but that's not what we want. If we're building for 32-bit, we want a 32-bit integer, and if we're building for 64-bit, we want a 64-bit integer.

Is there any kind of standardized integer type which is guaranteed to be the same size as a pointer?

What might even be worse is that the mismatch is on purpose for some reason, say that some structure has a field that simply *must* be 32-bits, but we're trying to wedge a 64-bit pointer into it.

Mike
--
Michael David Crawford
mdc@xxxxxxxxx

   prgmr.com - We Don't Assume You Are Stupid.

      Xen-Powered Virtual Private Servers: http://prgmr.com/xen

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>