diff options
Diffstat (limited to 'include/nvgpu/posix/bitops.h')
-rw-r--r-- | include/nvgpu/posix/bitops.h | 95 |
1 files changed, 0 insertions, 95 deletions
diff --git a/include/nvgpu/posix/bitops.h b/include/nvgpu/posix/bitops.h deleted file mode 100644 index e8c663b..0000000 --- a/include/nvgpu/posix/bitops.h +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #ifndef __NVGPU_POSIX_BITOPS_H__ | ||
24 | #define __NVGPU_POSIX_BITOPS_H__ | ||
25 | |||
26 | #include <nvgpu/types.h> | ||
27 | |||
28 | /* | ||
29 | * Assume an 8 bit byte, of course. | ||
30 | */ | ||
31 | #define BITS_PER_BYTE 8UL | ||
32 | #define BITS_PER_LONG (__SIZEOF_LONG__ * BITS_PER_BYTE) | ||
33 | #define BITS_TO_LONGS(bits) \ | ||
34 | (bits + (BITS_PER_LONG - 1) / BITS_PER_LONG) | ||
35 | |||
36 | /* | ||
37 | * Deprecated; use the explicit BITxx() macros instead. | ||
38 | */ | ||
39 | #define BIT(i) BIT64(i) | ||
40 | |||
41 | #define GENMASK(h, l) \ | ||
42 | (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) | ||
43 | |||
44 | #define DECLARE_BITMAP(bmap, bits) \ | ||
45 | unsigned long bmap[BITS_TO_LONGS(bits)] | ||
46 | |||
47 | #define for_each_set_bit(bit, addr, size) \ | ||
48 | for ((bit) = find_first_bit((addr), (size)); \ | ||
49 | (bit) < (size); \ | ||
50 | (bit) = find_next_bit((addr), (size), (bit) + 1)) | ||
51 | |||
52 | #define ffs(word) __ffs(word) | ||
53 | #define ffz(word) __ffs(~(word)) | ||
54 | #define fls(word) __fls(word) | ||
55 | |||
56 | /* | ||
57 | * Clashes with symbols in libc it seems. | ||
58 | */ | ||
59 | #define __ffs(word) __nvgpu_posix_ffs(word) | ||
60 | #define __fls(word) __nvgpu_posix_fls(word) | ||
61 | |||
62 | unsigned long __nvgpu_posix_ffs(unsigned long word); | ||
63 | unsigned long __nvgpu_posix_fls(unsigned long word); | ||
64 | |||
65 | unsigned long find_first_bit(const unsigned long *addr, unsigned long size); | ||
66 | unsigned long find_next_bit(const unsigned long *addr, unsigned long size, | ||
67 | unsigned long offset); | ||
68 | unsigned long find_first_zero_bit(const unsigned long *addr, | ||
69 | unsigned long size); | ||
70 | |||
71 | bool test_bit(int nr, const volatile unsigned long *addr); | ||
72 | bool test_and_set_bit(int nr, volatile unsigned long *addr); | ||
73 | bool test_and_clear_bit(int nr, volatile unsigned long *addr); | ||
74 | |||
75 | /* | ||
76 | * These two are atomic. | ||
77 | */ | ||
78 | void set_bit(int nr, volatile unsigned long *addr); | ||
79 | void clear_bit(int nr, volatile unsigned long *addr); | ||
80 | |||
81 | void bitmap_set(unsigned long *map, unsigned int start, int len); | ||
82 | void bitmap_clear(unsigned long *map, unsigned int start, int len); | ||
83 | unsigned long bitmap_find_next_zero_area_off(unsigned long *map, | ||
84 | unsigned long size, | ||
85 | unsigned long start, | ||
86 | unsigned int nr, | ||
87 | unsigned long align_mask, | ||
88 | unsigned long align_offset); | ||
89 | unsigned long bitmap_find_next_zero_area(unsigned long *map, | ||
90 | unsigned long size, | ||
91 | unsigned long start, | ||
92 | unsigned int nr, | ||
93 | unsigned long align_mask); | ||
94 | |||
95 | #endif | ||