Path: blob/master/tools/perf/util/include/linux/bitops.h
10825 views
#ifndef _PERF_LINUX_BITOPS_H_1#define _PERF_LINUX_BITOPS_H_23#include <linux/kernel.h>4#include <linux/compiler.h>5#include <asm/hweight.h>67#define BITS_PER_LONG __WORDSIZE8#define BITS_PER_BYTE 89#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))1011static inline void set_bit(int nr, unsigned long *addr)12{13addr[nr / BITS_PER_LONG] |= 1UL << (nr % BITS_PER_LONG);14}1516static inline void clear_bit(int nr, unsigned long *addr)17{18addr[nr / BITS_PER_LONG] &= ~(1UL << (nr % BITS_PER_LONG));19}2021static __always_inline int test_bit(unsigned int nr, const unsigned long *addr)22{23return ((1UL << (nr % BITS_PER_LONG)) &24(((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0;25}2627static inline unsigned long hweight_long(unsigned long w)28{29return sizeof(w) == 4 ? hweight32(w) : hweight64(w);30}3132#endif333435