bitops for handling 32 bits

2015-07-28 Thread Kevin Wilson
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@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: bitops for handling 32 bits

2015-07-28 Thread Manavendra Nath Manav
On Tue 28 Jul, 2015 20:24 Kevin Wilson wkev...@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@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.
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: bitops for handling 32 bits

2015-07-28 Thread Anish Kumar




 On Jul 28, 2015, at 10:46 PM, Kevin Wilson wkev...@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.

Did you try using it? The code is generic.
 
 Any ideas ?
 
 Regards,
 Kevin
 
 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies