a860a60818
We need the definiton for __always_inline in bitops.h to fix the build on distros where it isn't available or compiler.h doesn't get included indirectly. One of the fixes needed to build perf on RHEL4 systems, for instance. Cc: Eric Dumazet <eric.dumazet@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
33 lines
836 B
C
33 lines
836 B
C
#ifndef _PERF_LINUX_BITOPS_H_
|
|
#define _PERF_LINUX_BITOPS_H_
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/compiler.h>
|
|
#include <asm/hweight.h>
|
|
|
|
#define BITS_PER_LONG __WORDSIZE
|
|
#define BITS_PER_BYTE 8
|
|
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
|
|
|
|
static inline void set_bit(int nr, unsigned long *addr)
|
|
{
|
|
addr[nr / BITS_PER_LONG] |= 1UL << (nr % BITS_PER_LONG);
|
|
}
|
|
|
|
static inline void clear_bit(int nr, unsigned long *addr)
|
|
{
|
|
addr[nr / BITS_PER_LONG] &= ~(1UL << (nr % BITS_PER_LONG));
|
|
}
|
|
|
|
static __always_inline int test_bit(unsigned int nr, const unsigned long *addr)
|
|
{
|
|
return ((1UL << (nr % BITS_PER_LONG)) &
|
|
(((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0;
|
|
}
|
|
|
|
static inline unsigned long hweight_long(unsigned long w)
|
|
{
|
|
return sizeof(w) == 4 ? hweight32(w) : hweight64(w);
|
|
}
|
|
|
|
#endif
|