2004-02-12 00:47:09 +00:00
|
|
|
/*
|
|
|
|
* bitops.h: Bit string operations on the m68k
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _M68K_BITOPS_H
|
|
|
|
#define _M68K_BITOPS_H
|
|
|
|
|
|
|
|
#include <asm/byteorder.h>
|
2015-11-05 14:43:26 +00:00
|
|
|
#include <asm-generic/bitops/fls.h>
|
|
|
|
#include <asm-generic/bitops/__fls.h>
|
|
|
|
#include <asm-generic/bitops/fls64.h>
|
|
|
|
#include <asm-generic/bitops/__ffs.h>
|
2004-02-12 00:47:09 +00:00
|
|
|
|
|
|
|
extern void set_bit(int nr, volatile void *addr);
|
|
|
|
extern void clear_bit(int nr, volatile void *addr);
|
|
|
|
extern void change_bit(int nr, volatile void *addr);
|
|
|
|
extern int test_and_clear_bit(int nr, volatile void *addr);
|
|
|
|
extern int test_and_change_bit(int nr, volatile void *addr);
|
|
|
|
|
2007-08-05 09:31:18 +00:00
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
2012-03-25 19:18:49 +00:00
|
|
|
|
2015-11-06 12:44:01 +00:00
|
|
|
static inline int test_bit(int nr, __const__ volatile void *addr)
|
2007-08-05 09:31:18 +00:00
|
|
|
{
|
2012-03-25 19:18:49 +00:00
|
|
|
__const__ unsigned int *p = (__const__ unsigned int *) addr;
|
|
|
|
|
|
|
|
return (p[nr >> 5] & (1UL << (nr & 31))) != 0;
|
2007-08-05 09:31:18 +00:00
|
|
|
}
|
2012-03-25 19:18:49 +00:00
|
|
|
|
2015-11-06 12:44:01 +00:00
|
|
|
static inline int test_and_set_bit(int nr, volatile void *vaddr)
|
2012-03-25 19:18:49 +00:00
|
|
|
{
|
|
|
|
char retval;
|
|
|
|
|
|
|
|
volatile char *p = &((volatile char *)vaddr)[(nr^31) >> 3];
|
|
|
|
__asm__ __volatile__ ("bset %2,(%4); sne %0"
|
|
|
|
: "=d" (retval), "=m" (*p)
|
|
|
|
: "di" (nr & 7), "m" (*p), "a" (p));
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2007-08-05 09:31:18 +00:00
|
|
|
#define __ffs(x) (ffs(x) - 1)
|
2012-03-25 19:18:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* * hweightN: returns the hamming weight (i.e. the number
|
|
|
|
* * of bits set) of a N-bit word
|
|
|
|
* */
|
|
|
|
|
|
|
|
#define hweight32(x) generic_hweight32(x)
|
|
|
|
#define hweight16(x) generic_hweight16(x)
|
|
|
|
#define hweight8(x) generic_hweight8(x)
|
2007-08-05 09:31:18 +00:00
|
|
|
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
|
2004-02-12 00:47:09 +00:00
|
|
|
#endif /* _M68K_BITOPS_H */
|