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

Re: [Xen-devel] libxc: Casting of xen virtual address type xen_vaddr_t to signed int64 type: (int64_t)vaddr



>>> On 20.05.19 at 11:17, <viktor.mitin.19@xxxxxxxxx> wrote:
>> > Mean that result of "(int64_t)vaddr >> 63" can be 0 or 1.
>> > So the next code may not work properly in case of another 
> 'implementations'.
>> > With another compiler (i.e. clang, etc) this code may introduce bugs
>> > which are hard to find.
>> >
>> > ((int64_t)vaddr >> 47) == ((int64_t)vaddr >> 63)
>> >
>> > For this reason it is better to avoid implementation-defined code.
>>
>> Well, ideally we'd like to get away without using implementation
>> defined behavior. But I'm afraid we're quite far from that, and
>> we'd not always be willing to accept the worse source and/or
>> binary code that would be needed to avoid it.
> 
> How about using the next one-liner to avoid implementation-defined code :
> 
> //Returns true in case when the top left 17 bits are all zero or are all one
> return ((!(vaddr >> 47)) || (((vaddr >> 47)&0x1FFFF) == 0x1FFFF))

Note how, in my first reply, I said "preferably with just a single comparison".

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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