1 /* 2 * bitops.h: Bit string operations on the m68k 3 */ 4 5 #ifndef _M68K_BITOPS_H 6 #define _M68K_BITOPS_H 7 8 #include <asm/byteorder.h> 9 #include <asm-generic/bitops/fls.h> 10 #include <asm-generic/bitops/__fls.h> 11 #include <asm-generic/bitops/fls64.h> 12 #include <asm-generic/bitops/__ffs.h> 13 14 extern void set_bit(int nr, volatile void *addr); 15 extern void clear_bit(int nr, volatile void *addr); 16 extern void change_bit(int nr, volatile void *addr); 17 extern int test_and_set_bit(int nr, volatile void *addr); 18 extern int test_and_clear_bit(int nr, volatile void *addr); 19 extern int test_and_change_bit(int nr, volatile void *addr); 20 21 #ifdef __KERNEL__ 22 23 24 extern inline int test_bit(int nr, __const__ volatile void *addr) 25 { 26 __const__ unsigned int *p = (__const__ unsigned int *) addr; 27 28 return (p[nr >> 5] & (1UL << (nr & 31))) != 0; 29 } 30 31 extern inline int test_and_set_bit(int nr, volatile void *vaddr) 32 { 33 char retval; 34 35 volatile char *p = &((volatile char *)vaddr)[(nr^31) >> 3]; 36 __asm__ __volatile__ ("bset %2,(%4); sne %0" 37 : "=d" (retval), "=m" (*p) 38 : "di" (nr & 7), "m" (*p), "a" (p)); 39 40 return retval; 41 } 42 43 #define __ffs(x) (ffs(x) - 1) 44 45 /* 46 * * hweightN: returns the hamming weight (i.e. the number 47 * * of bits set) of a N-bit word 48 * */ 49 50 #define hweight32(x) generic_hweight32(x) 51 #define hweight16(x) generic_hweight16(x) 52 #define hweight8(x) generic_hweight8(x) 53 54 #endif /* __KERNEL__ */ 55 56 #endif /* _M68K_BITOPS_H */ 57