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

Re: [Xen-devel] [PATCH mini-os enhancements for vtpm 3/8] add endian support to mini-os




On 09/17/2012 06:12 PM, Samuel Thibault wrote:
> Matthew Fioravante, le Mon 17 Sep 2012 17:57:11 -0400, a écrit :
>> diff --git a/extras/mini-os/include/byteorder.h
>> b/extras/mini-os/include/byteorder.h
>> --- /dev/null
>> +++ b/extras/mini-os/include/byteorder.h
> Ok.
>
>> -static inline uint16_t bswap_16(uint16_t x)
>> -{
>> -    return
>> -    ((((x) & 0xff00) >> 8) | (((x) & 0xff) << 8));
>> -}
>> -
>> +#define bswap_16(x) ((uint16_t)(                         \
>> +             (((uint16_t)(x) & (uint16_t)0x00ffU) << 8)
>> |                  \
>> +             (((uint16_t)(x) & (uint16_t)0xff00U) >> 8)))
> Why replacing the inline with a macro?  AIUI, inlines provide the same
> efficiency while providing some minimal type checking (and safety
> against things like bswap_16(x++).
With a macro you can do this:

const uint16_t foo = bswap_16(4000);

Not possible with inline. From what I've seen in other system heads
(linux in particular), they tend to be implemented as macros or compiler
builtins.
>
>> diff --git a/extras/mini-os/include/endian.h
>> diff --git a/extras/mini-os/include/ia64/arch_endian.h
>> diff --git a/extras/mini-os/include/ia64/arch_wordsize.h
>> diff --git a/extras/mini-os/include/x86/arch_endian.h
>> diff --git a/extras/mini-os/include/x86/x86_32/arch_wordsize.h
>> diff --git a/extras/mini-os/include/x86/x86_64/arch_wordsize.h
> Ok.
>
> Samuel


Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

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

 


Rackspace

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