Re: [Patch v2] lib: test get_count_order/long in test_bitops.c

From: Wei Yang
Date: Fri Jun 05 2020 - 19:06:16 EST


On Thu, Jun 04, 2020 at 02:51:40PM +0200, Geert Uytterhoeven wrote:
>Hi Wei,
>
>On Thu, Jun 4, 2020 at 2:28 PM Wei Yang <richard.weiyang@xxxxxxxxx> wrote:
[...]
>>
>> You mean
>>
>> {0x0000000000000003, 2},
>> {0x0000000000000004, 2},
>> {0x0000000000001fff, 13},
>> {0x0000000000002000, 13},
>> {0x0000000050000000, 31},
>> {0x0000000080000000, 31},
>> {0x0000000080003000, 32},
>
>Yes, those values. And those should work with get_count_order_long()
>on both 32-bit and 64-bit.

Hi, Geert

To be frank, I am afraid I lack some of the skill to achieve this. Maybe you
could give some guide.

get_count_order_long() takes one parameter, which is of type unsigned long.
This one has different size on 32bit and 64bit platform. On 32bit platform,
those value would be truncated.

Would you mind giving me a hint on this?

What we may achieve is like the implementation of fls_long(). This one check
the size of unsigned long on running, and choose different function. We could
use ifdef to check the size of unsigned long and use different data to feed
get_count_order_long(). But I don't find a way to feed get_count_order_long()
with 64bit data on 32bit platform.

>
>Gr{oetje,eeting}s,
>
> Geert
>
>--
>Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
>
>In personal conversations with technical people, I call myself a hacker. But
>when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds

--
Wei Yang
Help you, Help me