[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2] bitops.h: Add field32() and field64() functi
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH v2] bitops.h: Add field32() and field64() functions to extract bitfields |
Date: |
Wed, 27 Jun 2012 14:22:36 +0100 |
On 27 June 2012 14:15, Avi Kivity <address@hidden> wrote:
> I suggest adding the analogous functions for writing. I believe the
> common naming is extract/deposit.
>
> static inline uint64_t deposit64(uint64_t *pvalue, unsigned start,
> unsigned length, uint64_t fieldval)
> {
> uint64_t mask = (((uint64_t)1 << length) - 1) << start;
> *pvalue = (*pvalue & ~mask) | ((fieldval << start) & mask);
> }
>
> Useful for setting a bit to a specific value.
Do you have a use case in mind for this one?
-- PMM