qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC PATCH v2 10/15] cpu-model/s390: Add cpu class init


From: Richard Henderson
Subject: Re: [Qemu-devel] [RFC PATCH v2 10/15] cpu-model/s390: Add cpu class initialization routines
Date: Fri, 20 Feb 2015 10:11:55 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 02/17/2015 06:24 AM, Michael Mueller wrote:
> +static inline uint64_t big_endian_bit(unsigned long nr)
> +{
> +    return 1ul << (BITS_PER_LONG - (nr % BITS_PER_LONG));
> +};

This is buggy.  NR=0 should map to 63, not 64.

> +    return !!(*ptr & big_endian_bit(nr));

Personally I dislike !! as an idiom.  Given that big_endian_bit isn't used
anywhere else, can we integrate it and change this to

static inline int test_facility(unsigned long nr, uint64_t *fac_list)
{
  unsigned long word = nr / BITS_PER_LONG;
  unsigned long be_bit = 63 - (nr % BITS_PER_LONG);
  return (fac_list[word] >> be_bit) & 1;
}


r~



reply via email to

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