[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH v3 06/19] range: Introduce range_get_last_bit()
From: |
Duan, Zhenzhong |
Subject: |
RE: [PATCH v3 06/19] range: Introduce range_get_last_bit() |
Date: |
Tue, 30 Apr 2024 09:58:01 +0000 |
>-----Original Message-----
>From: Cédric Le Goater <clg@redhat.com>
>Subject: Re: [PATCH v3 06/19] range: Introduce range_get_last_bit()
>
>On 4/29/24 08:50, Zhenzhong Duan wrote:
>> This helper get the highest 1 bit position of the upper bound.
>>
>> If the range is empty or upper bound is zero, -1 is returned.
>>
>> Suggested-by: Cédric Le Goater <clg@redhat.com>
>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>> ---
>> include/qemu/range.h | 11 +++++++++++
>> 1 file changed, 11 insertions(+)
>>
>> diff --git a/include/qemu/range.h b/include/qemu/range.h
>> index 205e1da76d..8e05bc1d9f 100644
>> --- a/include/qemu/range.h
>> +++ b/include/qemu/range.h
>> @@ -20,6 +20,8 @@
>> #ifndef QEMU_RANGE_H
>> #define QEMU_RANGE_H
>>
>> +#include "qemu/bitops.h"
>> +
>> /*
>> * Operations on 64 bit address ranges.
>> * Notes:
>> @@ -217,6 +219,15 @@ static inline int ranges_overlap(uint64_t first1,
>uint64_t len1,
>> return !(last2 < first1 || last1 < first2);
>> }
>>
>> +/* Get highest non-zero bit position of a range */
>> +static inline int range_get_last_bit(Range *range)
>> +{
>> + if (range_is_empty(range) || !range->upb) {
>> + return -1;
>> + }
>> + return find_last_bit(&range->upb, sizeof(range->upb));
>
>This breaks builds on 32-bit host systems.
Oh, I missed 32bit build. Thanks, will fix.
Thanks
zhenzhong
>
>
>Thanks,
>
>C.
>
>
>> +}
>> +
>> /*
>> * Return -1 if @a < @b, 1 @a > @b, and 0 if they touch or overlap.
>> * Both @a and @b must not be empty.
- RE: [PATCH v3 02/19] vfio/container: Introduce HostIOMMUDeviceLegacyVFIO device, (continued)
- [PATCH v3 03/19] backends/iommufd: Introduce abstract HostIOMMUDeviceIOMMUFD device, Zhenzhong Duan, 2024/04/29
- [PATCH v3 04/19] vfio/iommufd: Introduce HostIOMMUDeviceIOMMUFDVFIO device, Zhenzhong Duan, 2024/04/29
- [PATCH v3 05/19] backends/host_iommu_device: Introduce HostIOMMUDeviceCaps, Zhenzhong Duan, 2024/04/29
- [PATCH v3 06/19] range: Introduce range_get_last_bit(), Zhenzhong Duan, 2024/04/29
- [PATCH v3 07/19] vfio/container: Implement HostIOMMUDeviceClass::realize() handler, Zhenzhong Duan, 2024/04/29
- [PATCH v3 08/19] backends/iommufd: Introduce helper function iommufd_backend_get_device_info(), Zhenzhong Duan, 2024/04/29
- [PATCH v3 09/19] vfio/iommufd: Implement HostIOMMUDeviceClass::realize() handler, Zhenzhong Duan, 2024/04/29
- [PATCH v3 12/19] vfio: Introduce VFIOIOMMUClass::hiod_typename attribute, Zhenzhong Duan, 2024/04/29
- [PATCH v3 11/19] backends/iommufd: Implement HostIOMMUDeviceClass::check_cap() handler, Zhenzhong Duan, 2024/04/29