bitops: Move test_bit() into bitops/atomic.h
Subsystems (2)
PATCH 1/1 bitops: Move test_bit() into bitops/atomic.h
test_bit() is an atomic operation as documented by atomic_bitops.txt. Move the function from bitops/non-atomic.h to bitops/atomic.h and adjust its implementation to align with the other atomic bitops.
--- include/asm-generic/bitops/atomic.h | 6 ++++++ include/asm-generic/bitops/non-atomic.h | 10 ---------- 2 files changed, 6 insertions(+), 10 deletions(-)
Just found this kicking around on a branch from last year!
include/asm-generic/bitops/atomic.h +6 -0
@@ -17,6 +17,12 @@ static inline void set_bit(unsigned int nr, volatile unsigned long *p)atomic_long_or (BIT_MASK (nr), (atomic_long_t *)p); } +static inline int test_bit (unsigned int nr,const volatile unsigned long *p) +{ + p +=BIT_WORD (nr); +return !!(READ_ONCE (*p) &BIT_MASK (nr)); +} +static inline void clear_bit (unsigned int nr,volatile unsigned long *p) { p +=BIT_WORD (nr);
include/asm-generic/bitops/non-atomic.h +0 -10
@@ -96,14 +96,4 @@ static inline int __test_and_change_bit(int nr, return (old & mask) != 0; } -/** -* test_bit - Determine whether a bit is set -* @nr: bit number to test -* @addr: Address to start counting from -*/ -static inline int test_bit (int nr,const volatile unsigned long *addr) -{ -return 1UL & (addr[BIT_WORD (nr)] >> (nr & (BITS_PER_LONG -1 ))); -} -#endif /* _ASM_GENERIC_BITOPS_NON_ATOMIC_H_ */
Signature · 1 line
2.26.2.761.g0e0b3e54be-goog
kbuild test robot
build botI love your patch! Yet something to improve:
Hi Will,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on asm-generic/master linux/master v5.7-rc6 next-20200521] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Will-Deacon/bitops-Move-test_bit-into-bitops-atomic-h/20200521-224744 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git b85051e755b0e9d6dd8f17ef1da083851b83287d config: arm-randconfig-r021-20200522 (attached as .config) compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 3393cc4cebf9969db94dc424b7a2b6195589c33b)
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>, old ones prefixed by <<):
In file included from kernel/bounds.c:10:
In file included from include/linux/page-flags.h:10:
In file included from include/linux/bug.h:5:
In file included from arch/arm/include/asm/bug.h:60:
In file included from include/asm-generic/bug.h:19:
In file included from include/linux/kernel.h:12:
In file included from include/linux/bitops.h:29:
In file included from arch/arm/include/asm/bitops.h:268:
>> include/asm-generic/bitops/le.h:55:9: error: implicit declaration of function 'test_bit' [-Werror,-Wimplicit-function-declaration]
return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
^
1 error generated.
make[2]: *** [scripts/Makefile.build:100: kernel/bounds.s] Error 1 make[2]: Target '__build' not remade because of errors. make[1]: *** [Makefile:1148: prepare0] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:180: sub-make] Error 2
vim +/test_bit +55 include/asm-generic/bitops/le.h
63ab595fb6b342 Akinobu Mita 2011-03-23 52
a56560b3b23323 Akinobu Mita 2011-03-23 53 static inline int test_bit_le(int nr, const void *addr)
a56560b3b23323 Akinobu Mita 2011-03-23 54 {a56560b3b23323 Akinobu Mita 2011-03-23 @55 return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);a56560b3b23323 Akinobu Mita 2011-03-23 56 }a56560b3b23323 Akinobu Mita 2011-03-23 57
:::::: The code at line 55 was first introduced by commit
:::::: a56560b3b233238e85205d4e8d7bded904ac2306 asm-generic: change little-endian bitops to take any pointer types
:::::: TO: Akinobu Mita <[email protected]> :::::: CC: Linus Torvalds <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org