Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __ASM_GENERIC_BITS_PER_LONG
0003 #define __ASM_GENERIC_BITS_PER_LONG
0004 
0005 #include <uapi/asm-generic/bitsperlong.h>
0006 
0007 
0008 #ifdef CONFIG_64BIT
0009 #define BITS_PER_LONG 64
0010 #else
0011 #define BITS_PER_LONG 32
0012 #endif /* CONFIG_64BIT */
0013 
0014 /*
0015  * FIXME: The check currently breaks x86-64 build, so it's
0016  * temporarily disabled. Please fix x86-64 and reenable
0017  */
0018 #if 0 && BITS_PER_LONG != __BITS_PER_LONG
0019 #error Inconsistent word size. Check asm/bitsperlong.h
0020 #endif
0021 
0022 #ifndef BITS_PER_LONG_LONG
0023 #define BITS_PER_LONG_LONG 64
0024 #endif
0025 
0026 /*
0027  * small_const_nbits(n) is true precisely when it is known at compile-time
0028  * that BITMAP_SIZE(n) is 1, i.e. 1 <= n <= BITS_PER_LONG. This allows
0029  * various bit/bitmap APIs to provide a fast inline implementation. Bitmaps
0030  * of size 0 are very rare, and a compile-time-known-size 0 is most likely
0031  * a sign of error. They will be handled correctly by the bit/bitmap APIs,
0032  * but using the out-of-line functions, so that the inline implementations
0033  * can unconditionally dereference the pointer(s).
0034  */
0035 #define small_const_nbits(nbits) \
0036     (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG && (nbits) > 0)
0037 
0038 #endif /* __ASM_GENERIC_BITS_PER_LONG */