X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Flinux%2Fbitops.h;h=7b4011f0a30c3e57edf85268dc75ce7beb0d8d06;hb=a69fdc7787bfa2f27eed74c2ee58c28ce932d502;hp=e14e6c7b14fc1ef1595337ae58c1d7985d689d47;hpb=52d61227b66d4099b39c8309ab37cb67ee09a405;p=platform%2Fkernel%2Fu-boot.git diff --git a/include/linux/bitops.h b/include/linux/bitops.h index e14e6c7..7b4011f 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -3,6 +3,21 @@ #include +#define BIT(nr) (1UL << (nr)) +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) + +/* + * Create a contiguous bitmask starting at bit position @l and ending at + * position @h. For example + * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. + */ +#define GENMASK(h, l) \ + (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +#define GENMASK_ULL(h, l) \ + (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + /* * ffs: find first bit set. This is defined the same way as * the libc and compiler builtin ffs routines, therefore @@ -104,26 +119,23 @@ static inline unsigned int generic_hweight8(unsigned int w) return (res & 0x0F) + ((res >> 4) & 0x0F); } -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) - #include /* linux/include/asm-generic/bitops/non-atomic.h */ -#ifndef __set_bit +#ifndef PLATFORM__SET_BIT # define __set_bit generic_set_bit #endif -#ifndef __clear_bit +#ifndef PLATFORM__CLEAR_BIT # define __clear_bit generic_clear_bit #endif -#ifndef ffs +#ifndef PLATFORM_FFS # define ffs generic_ffs #endif -#ifndef fls +#ifndef PLATFORM_FLS # define fls generic_fls #endif