qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v10 13/13] qemu/bitops.h: Add extract8 and extra


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH v10 13/13] qemu/bitops.h: Add extract8 and extract16
Date: Wed, 8 May 2019 10:37:30 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 5/8/19 7:56 AM, Yoshinori Sato wrote:
> +static inline uint16_t extract16(uint32_t value, int start, int length)

s/uint32_t/uint16_t/

Aside from the possible value of the more restrictive asserts, I'm not sure
what advantage you see in these routines.  All arithmetic in C is promoted to
type "int", which for all supported hosts is 32-bits.

This suggests an implementation for these functions as

    assert(...);
    return extract32(value, start, length);

because otherwise the (32 - length) subexpression might at first glance appear
to be a cut-and-paste bug.  Whereas it's really required by the larger
subexpression.


r~



reply via email to

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