xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH mini-os enhancements for vtpm 3/8] add endian support to mini-os
Date: Tue, 18 Sep 2012 13:45:08 -0400	[thread overview]
Message-ID: <5058B324.9090802@jhuapl.edu> (raw)
In-Reply-To: <20120917221209.GH5110@type.youpi.perso.aquilenet.fr>


[-- Attachment #1.1: Type: text/plain, Size: 1436 bytes --]



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 #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 1459 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

  reply	other threads:[~2012-09-18 17:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-17 21:57 [PATCH mini-os enhancements for vtpm 3/8] add endian support to mini-os Matthew Fioravante
2012-09-17 22:12 ` Samuel Thibault
2012-09-18 17:45   ` Matthew Fioravante [this message]
2012-09-18 17:52     ` Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5058B324.9090802@jhuapl.edu \
    --to=matthew.fioravante@jhuapl.edu \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).