qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 01/14] memory: Define API for MemoryRegionOps to


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 01/14] memory: Define API for MemoryRegionOps to take attrs and return status
Date: Thu, 9 Apr 2015 10:04:39 +0100

On 9 April 2015 at 09:55, Edgar E. Iglesias <address@hidden> wrote:
> Did you consider using a struct here?
> e.g:
>
> typedef struct MemTxAttrs {
>     unsigned int secure : 1;
>     unsigned int master_id : 10;
>     unsigned int etc : 1;
> } MemTxAttrs;
>
> I think you could still pass it by value and my understanding is
> that the compiler will generate similar code.

We discussed this last time round, I think. Whether structs get
passed in registers depends on the host CPU ABI/calling convention.

> I find it more readable, you ca go:
>
> attrs.secure = 1;
> attrs.master_id = 0x77;
> if (!attrs.secure)
>
> instead of:
>
> attrs |= MEMTXATTRS_SECURE
> if (!(attrs & MEMTXATTRS_SECURE))
>
> etc...
>
> Or do you see any disadvantages with this?

I prefer the traditional integer-and-bitops approach, then you
know what you're getting everywhere...

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]