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