0001
0002
0003 #ifndef __ASM_CSKY_BITOPS_H
0004 #define __ASM_CSKY_BITOPS_H
0005
0006 #include <linux/compiler.h>
0007 #include <asm/barrier.h>
0008
0009
0010
0011
0012 static inline int ffs(int x)
0013 {
0014 if (!x)
0015 return 0;
0016
0017 asm volatile (
0018 "brev %0\n"
0019 "ff1 %0\n"
0020 "addi %0, 1\n"
0021 : "=&r"(x)
0022 : "0"(x));
0023 return x;
0024 }
0025
0026
0027
0028
0029 static __always_inline unsigned long __ffs(unsigned long x)
0030 {
0031 asm volatile (
0032 "brev %0\n"
0033 "ff1 %0\n"
0034 : "=&r"(x)
0035 : "0"(x));
0036 return x;
0037 }
0038
0039
0040
0041
0042 static __always_inline int fls(unsigned int x)
0043 {
0044 asm volatile(
0045 "ff1 %0\n"
0046 : "=&r"(x)
0047 : "0"(x));
0048
0049 return (32 - x);
0050 }
0051
0052
0053
0054
0055 static __always_inline unsigned long __fls(unsigned long x)
0056 {
0057 return fls(x) - 1;
0058 }
0059
0060 #include <asm-generic/bitops/ffz.h>
0061 #include <asm-generic/bitops/fls64.h>
0062
0063 #ifndef _LINUX_BITOPS_H
0064 #error only <linux/bitops.h> can be included directly
0065 #endif
0066
0067 #include <asm-generic/bitops/sched.h>
0068 #include <asm-generic/bitops/hweight.h>
0069 #include <asm-generic/bitops/lock.h>
0070 #include <asm-generic/bitops/atomic.h>
0071
0072
0073
0074
0075 #include <asm-generic/bitops/non-atomic.h>
0076
0077 #include <asm-generic/bitops/le.h>
0078 #include <asm-generic/bitops/ext2-atomic.h>
0079 #endif