find.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_GENERIC_BITOPS_FIND_H_
  3. #define _ASM_GENERIC_BITOPS_FIND_H_
  4. #ifndef find_next_bit
  5. /**
  6. * find_next_bit - find the next set bit in a memory region
  7. * @addr: The address to base the search on
  8. * @offset: The bitnumber to start searching at
  9. * @size: The bitmap size in bits
  10. *
  11. * Returns the bit number for the next set bit
  12. * If no bits are set, returns @size.
  13. */
  14. extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
  15. size, unsigned long offset);
  16. #endif
  17. #ifndef find_next_and_bit
  18. /**
  19. * find_next_and_bit - find the next set bit in both memory regions
  20. * @addr1: The first address to base the search on
  21. * @addr2: The second address to base the search on
  22. * @offset: The bitnumber to start searching at
  23. * @size: The bitmap size in bits
  24. *
  25. * Returns the bit number for the next set bit
  26. * If no bits are set, returns @size.
  27. */
  28. extern unsigned long find_next_and_bit(const unsigned long *addr1,
  29. const unsigned long *addr2, unsigned long size,
  30. unsigned long offset);
  31. #endif
  32. #ifndef find_next_zero_bit
  33. /**
  34. * find_next_zero_bit - find the next cleared bit in a memory region
  35. * @addr: The address to base the search on
  36. * @offset: The bitnumber to start searching at
  37. * @size: The bitmap size in bits
  38. *
  39. * Returns the bit number of the next zero bit
  40. * If no bits are zero, returns @size.
  41. */
  42. extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned
  43. long size, unsigned long offset);
  44. #endif
  45. #ifdef CONFIG_GENERIC_FIND_FIRST_BIT
  46. /**
  47. * find_first_bit - find the first set bit in a memory region
  48. * @addr: The address to start the search at
  49. * @size: The maximum number of bits to search
  50. *
  51. * Returns the bit number of the first set bit.
  52. * If no bits are set, returns @size.
  53. */
  54. extern unsigned long find_first_bit(const unsigned long *addr,
  55. unsigned long size);
  56. /**
  57. * find_first_zero_bit - find the first cleared bit in a memory region
  58. * @addr: The address to start the search at
  59. * @size: The maximum number of bits to search
  60. *
  61. * Returns the bit number of the first cleared bit.
  62. * If no bits are zero, returns @size.
  63. */
  64. extern unsigned long find_first_zero_bit(const unsigned long *addr,
  65. unsigned long size);
  66. #else /* CONFIG_GENERIC_FIND_FIRST_BIT */
  67. #ifndef find_first_bit
  68. #define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
  69. #endif
  70. #ifndef find_first_zero_bit
  71. #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
  72. #endif
  73. #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
  74. #endif /*_ASM_GENERIC_BITOPS_FIND_H_ */