bitops.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/bitops.h>
  3. #include <linux/find.h>
  4. __rust_helper
  5. void rust_helper___set_bit(unsigned long nr, unsigned long *addr)
  6. {
  7. __set_bit(nr, addr);
  8. }
  9. __rust_helper
  10. void rust_helper___clear_bit(unsigned long nr, unsigned long *addr)
  11. {
  12. __clear_bit(nr, addr);
  13. }
  14. __rust_helper
  15. void rust_helper_set_bit(unsigned long nr, volatile unsigned long *addr)
  16. {
  17. set_bit(nr, addr);
  18. }
  19. __rust_helper
  20. void rust_helper_clear_bit(unsigned long nr, volatile unsigned long *addr)
  21. {
  22. clear_bit(nr, addr);
  23. }
  24. /*
  25. * The rust_helper_ prefix is intentionally omitted below so that the
  26. * declarations in include/linux/find.h are compatible with these helpers.
  27. *
  28. * Note that the below #ifdefs mean that the helper is only created if C does
  29. * not provide a definition.
  30. */
  31. #ifdef find_first_zero_bit
  32. __rust_helper
  33. unsigned long _find_first_zero_bit(const unsigned long *p, unsigned long size)
  34. {
  35. return find_first_zero_bit(p, size);
  36. }
  37. #endif /* find_first_zero_bit */
  38. #ifdef find_next_zero_bit
  39. __rust_helper
  40. unsigned long _find_next_zero_bit(const unsigned long *addr,
  41. unsigned long size, unsigned long offset)
  42. {
  43. return find_next_zero_bit(addr, size, offset);
  44. }
  45. #endif /* find_next_zero_bit */
  46. #ifdef find_first_bit
  47. __rust_helper
  48. unsigned long _find_first_bit(const unsigned long *addr, unsigned long size)
  49. {
  50. return find_first_bit(addr, size);
  51. }
  52. #endif /* find_first_bit */
  53. #ifdef find_next_bit
  54. __rust_helper
  55. unsigned long _find_next_bit(const unsigned long *addr, unsigned long size,
  56. unsigned long offset)
  57. {
  58. return find_next_bit(addr, size, offset);
  59. }
  60. #endif /* find_next_bit */