bitops for handling 32 bits

Manavendra Nath Manav mnm.kernel at gmail.com
Tue Jul 28 11:10:11 EDT 2015


On Tue 28 Jul, 2015 20:24 Kevin Wilson <wkevils at gmail.com> wrote:

> Hi all,
> Is there a kernel API for handling 32 bits ?
> I see a macro like BIT(nr)
> http://lxr.free-electrons.com/source/include/linux/bitops.h#L6
>
> #define BIT(nr)                 (1UL << (nr))
>
> and also
> #define BIT_ULL(nr)             (1ULL << (nr))
>
> However, these macros are using 64 bit semantics, so if I will use
> them with 32 bits values
> the results will  be wrong.
>
> Any ideas ?
>
> Regards,
> Kevin
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
The macros don't do type checking so it will work for both 32-bit and
64-bit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150728/21a5b5ed/attachment.html 


More information about the Kernelnewbies mailing list