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

Re: [Xen-devel] [PATCH 2/3] xen/types: Correct the definition of uintptr_t



On 01/08/16 16:51, Jan Beulich wrote:
>>>> On 01.08.16 at 15:14, <andrew.cooper3@xxxxxxxxxx> wrote:
>> uintptr_t is specified as unsigned int in 32bit, not unsigned long.  This is
>> why, when copying inttypes.h from GCC, the use of PRIxPTR and similar is
>> broken for 32bit builds.
> I don't think this is strictly the case, i.e. doing it this way still ties
> us to internal workings of the compiler (as there is room for targets
> to customize base types used for derived ones). Could you try
> whether ...

This is the entire point I am trying to make that what we are doing is
currently unsafe if we are not using the header files to match the
compiler in use.

>
>> --- a/xen/include/xen/types.h
>> +++ b/xen/include/xen/types.h
>> @@ -59,7 +59,11 @@ typedef __u32 __be32;
>>  typedef __u64 __le64;
>>  typedef __u64 __be64;
>>  
>> +#if BITS_PER_LONG == 64
>>  typedef unsigned long uintptr_t;
>> +#elif BITS_PER_LONG == 32
>> +typedef unsigned int uintptr_t;
>> +#endif
> ...
>
> typedef unsigned int __attribute__((__mode__(__pointer__))) uintptr_t;
>
> works both ways (32- and 64-bit)?

It does appear to work.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.