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