summaryrefslogtreecommitdiff
path: root/rust/helpers/bitops.c
blob: e79ef9e6d98f969e2a0a2a6f62d9fcec3ef0fd72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-License-Identifier: GPL-2.0

#include <linux/bitops.h>
#include <linux/find.h>

void rust_helper___set_bit(unsigned long nr, unsigned long *addr)
{
	__set_bit(nr, addr);
}

void rust_helper___clear_bit(unsigned long nr, unsigned long *addr)
{
	__clear_bit(nr, addr);
}

void rust_helper_set_bit(unsigned long nr, volatile unsigned long *addr)
{
	set_bit(nr, addr);
}

void rust_helper_clear_bit(unsigned long nr, volatile unsigned long *addr)
{
	clear_bit(nr, addr);
}

/*
 * The rust_helper_ prefix is intentionally omitted below so that the
 * declarations in include/linux/find.h are compatible with these helpers.
 *
 * Note that the below #ifdefs mean that the helper is only created if C does
 * not provide a definition.
 */
#ifdef find_first_zero_bit
__rust_helper
unsigned long _find_first_zero_bit(const unsigned long *p, unsigned long size)
{
	return find_first_zero_bit(p, size);
}
#endif /* find_first_zero_bit */

#ifdef find_next_zero_bit
__rust_helper
unsigned long _find_next_zero_bit(const unsigned long *addr,
				  unsigned long size, unsigned long offset)
{
	return find_next_zero_bit(addr, size, offset);
}
#endif /* find_next_zero_bit */

#ifdef find_first_bit
__rust_helper
unsigned long _find_first_bit(const unsigned long *addr, unsigned long size)
{
	return find_first_bit(addr, size);
}
#endif /* find_first_bit */

#ifdef find_next_bit
__rust_helper
unsigned long _find_next_bit(const unsigned long *addr, unsigned long size,
			     unsigned long offset)
{
	return find_next_bit(addr, size, offset);
}
#endif /* find_next_bit */