Commit 4ade0818 authored by Yury Norov's avatar Yury Norov
Browse files

tools: sync tools/bitmap with mother linux



Remove tools/include/asm-generic/bitops/find.h and copy
include/linux/bitmap.h to tools. find_*_le() functions are not copied
because not needed in tools.

Signed-off-by: default avatarYury Norov <yury.norov@gmail.com>
Tested-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
parent b5c7e7ec
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -3365,8 +3365,8 @@ F: lib/bitmap.c
F:	lib/find_bit.c
F:	lib/find_bit.c
F:	lib/find_bit_benchmark.c
F:	lib/find_bit_benchmark.c
F:	lib/test_bitmap.c
F:	lib/test_bitmap.c
F:	tools/include/asm-generic/bitops/find.h
F:	tools/include/linux/bitmap.h
F:	tools/include/linux/bitmap.h
F:	tools/include/linux/find.h
F:	tools/lib/bitmap.c
F:	tools/lib/bitmap.c
F:	tools/lib/find_bit.c
F:	tools/lib/find_bit.c
+0 −1
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@
#include <asm-generic/bitops/fls.h>
#include <asm-generic/bitops/fls.h>
#include <asm-generic/bitops/__fls.h>
#include <asm-generic/bitops/__fls.h>
#include <asm-generic/bitops/fls64.h>
#include <asm-generic/bitops/fls64.h>
#include <asm-generic/bitops/find.h>


#ifndef _TOOLS_LINUX_BITOPS_H_
#ifndef _TOOLS_LINUX_BITOPS_H_
#error only <linux/bitops.h> can be included directly
#error only <linux/bitops.h> can be included directly
+4 −3
Original line number Original line Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _PERF_BITOPS_H
#ifndef _TOOLS_LINUX_BITMAP_H
#define _PERF_BITOPS_H
#define _TOOLS_LINUX_BITMAP_H


#include <string.h>
#include <string.h>
#include <linux/bitops.h>
#include <linux/bitops.h>
#include <linux/find.h>
#include <stdlib.h>
#include <stdlib.h>
#include <linux/kernel.h>
#include <linux/kernel.h>


@@ -181,4 +182,4 @@ static inline int bitmap_intersects(const unsigned long *src1,
		return __bitmap_intersects(src1, src2, nbits);
		return __bitmap_intersects(src1, src2, nbits);
}
}


#endif /* _PERF_BITOPS_H */
#endif /* _TOOLS_LINUX_BITMAP_H */
+75 −6
Original line number Original line Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_
#ifndef _TOOLS_LINUX_FIND_H_
#define _TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_
#define _TOOLS_LINUX_FIND_H_

#ifndef _TOOLS_LINUX_BITMAP_H
#error tools: only <linux/bitmap.h> can be included directly
#endif

#include <linux/bitops.h>


extern unsigned long _find_next_bit(const unsigned long *addr1,
extern unsigned long _find_next_bit(const unsigned long *addr1,
		const unsigned long *addr2, unsigned long nbits,
		const unsigned long *addr2, unsigned long nbits,
		unsigned long start, unsigned long invert, unsigned long le);
		unsigned long start, unsigned long invert, unsigned long le);
extern unsigned long _find_first_bit(const unsigned long *addr, unsigned long size);
extern unsigned long _find_first_bit(const unsigned long *addr, unsigned long size);
extern unsigned long _find_first_and_bit(const unsigned long *addr1,
					 const unsigned long *addr2, unsigned long size);
extern unsigned long _find_first_zero_bit(const unsigned long *addr, unsigned long size);
extern unsigned long _find_first_zero_bit(const unsigned long *addr, unsigned long size);
extern unsigned long _find_last_bit(const unsigned long *addr, unsigned long size);
extern unsigned long _find_last_bit(const unsigned long *addr, unsigned long size);


@@ -96,7 +104,6 @@ unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
#endif
#endif


#ifndef find_first_bit
#ifndef find_first_bit

/**
/**
 * find_first_bit - find the first set bit in a memory region
 * find_first_bit - find the first set bit in a memory region
 * @addr: The address to start the search at
 * @addr: The address to start the search at
@@ -116,11 +123,34 @@ unsigned long find_first_bit(const unsigned long *addr, unsigned long size)


	return _find_first_bit(addr, size);
	return _find_first_bit(addr, size);
}
}
#endif

#ifndef find_first_and_bit
/**
 * find_first_and_bit - find the first set bit in both memory regions
 * @addr1: The first address to base the search on
 * @addr2: The second address to base the search on
 * @size: The bitmap size in bits
 *
 * Returns the bit number for the next set bit
 * If no bits are set, returns @size.
 */
static inline
unsigned long find_first_and_bit(const unsigned long *addr1,
				 const unsigned long *addr2,
				 unsigned long size)
{
	if (small_const_nbits(size)) {
		unsigned long val = *addr1 & *addr2 & GENMASK(size - 1, 0);


#endif /* find_first_bit */
		return val ? __ffs(val) : size;
	}


#ifndef find_first_zero_bit
	return _find_first_and_bit(addr1, addr2, size);
}
#endif


#ifndef find_first_zero_bit
/**
/**
 * find_first_zero_bit - find the first cleared bit in a memory region
 * find_first_zero_bit - find the first cleared bit in a memory region
 * @addr: The address to start the search at
 * @addr: The address to start the search at
@@ -142,4 +172,43 @@ unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
}
}
#endif
#endif


#endif /*_TOOLS_LINUX_ASM_GENERIC_BITOPS_FIND_H_ */
#ifndef find_last_bit
/**
 * find_last_bit - find the last set bit in a memory region
 * @addr: The address to start the search at
 * @size: The number of bits to search
 *
 * Returns the bit number of the last set bit, or size.
 */
static inline
unsigned long find_last_bit(const unsigned long *addr, unsigned long size)
{
	if (small_const_nbits(size)) {
		unsigned long val = *addr & GENMASK(size - 1, 0);

		return val ? __fls(val) : size;
	}

	return _find_last_bit(addr, size);
}
#endif

/**
 * find_next_clump8 - find next 8-bit clump with set bits in a memory region
 * @clump: location to store copy of found clump
 * @addr: address to base the search on
 * @size: bitmap size in number of bits
 * @offset: bit offset at which to start searching
 *
 * Returns the bit offset for the next set clump; the found clump value is
 * copied to the location pointed by @clump. If no bits are set, returns @size.
 */
extern unsigned long find_next_clump8(unsigned long *clump,
				      const unsigned long *addr,
				      unsigned long size, unsigned long offset);

#define find_first_clump8(clump, bits, size) \
	find_next_clump8((clump), (bits), (size), 0)


#endif /*__LINUX_FIND_H_ */
+20 −0
Original line number Original line Diff line number Diff line
@@ -96,6 +96,26 @@ unsigned long _find_first_bit(const unsigned long *addr, unsigned long size)
}
}
#endif
#endif


#ifndef find_first_and_bit
/*
 * Find the first set bit in two memory regions.
 */
unsigned long _find_first_and_bit(const unsigned long *addr1,
				  const unsigned long *addr2,
				  unsigned long size)
{
	unsigned long idx, val;

	for (idx = 0; idx * BITS_PER_LONG < size; idx++) {
		val = addr1[idx] & addr2[idx];
		if (val)
			return min(idx * BITS_PER_LONG + __ffs(val), size);
	}

	return size;
}
#endif

#ifndef find_first_zero_bit
#ifndef find_first_zero_bit
/*
/*
 * Find the first cleared bit in a memory region.
 * Find the first cleared bit in a memory region.