[U-Boot] [PATCH v5] bitops: introduce BIT() definition

Ivan Khoronzhuk ivan.khoronzhuk at linaro.org
Wed Sep 9 20:52:19 CEST 2015



On 09.09.15 19:22, Scott Wood wrote:
> On Tue, 2015-09-08 at 21:01 +0300, ivan.khoronzhuk wrote:
>> Hi, Andreas
>>
>> On 07.09.15 14:43, Andreas Bießmann wrote:
>>> From: Heiko Schocher <hs at denx.de>
>>>
>>> introduce BIT() definition, used in at91_udc gadget
>>> driver.
>>>
>>> Signed-off-by: Heiko Schocher <hs at denx.de>
>>> [remove all other occurrences of BIT(x) definition]
>>> Signed-off-by: Andreas Bießmann <andreas.devel at googlemail.com>
>>> ---
>>> Full buildman is running
>>>
>>
>> ....
>>
>>>
>>> +#define BIT(nr)            (1UL << (nr))
>>
>> Why UL? Why not simply 1 << (nr)?
>
> That would give the wrong result for nr == 31 if used as a 64-bit number, and
Did you mean with 64-bit signed number?
After fast glance seems there is no places,
but if they are, this can add interesting fixes.

> would produce undefined behavior for nr >= 32 (though even with 1UL that
> would be undefined on 32-bit builds).
>
>> What if I need set ULL bit on 32-bit system?
>> Thanks for explanation.
>
> Yes, ULL would be better.
>
> -Scott
>
>

-- 
Regards,
Ivan Khoronzhuk


More information about the U-Boot mailing list