xref: /aosp_15_r20/external/e2fsprogs/lib/ext2fs/bitops.h (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker /*
2*6a54128fSAndroid Build Coastguard Worker  * bitops.h --- Bitmap frobbing code.  The byte swapping routines are
3*6a54128fSAndroid Build Coastguard Worker  * 	also included here.
4*6a54128fSAndroid Build Coastguard Worker  *
5*6a54128fSAndroid Build Coastguard Worker  * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
6*6a54128fSAndroid Build Coastguard Worker  *
7*6a54128fSAndroid Build Coastguard Worker  * %Begin-Header%
8*6a54128fSAndroid Build Coastguard Worker  * This file may be redistributed under the terms of the GNU Library
9*6a54128fSAndroid Build Coastguard Worker  * General Public License, version 2.
10*6a54128fSAndroid Build Coastguard Worker  * %End-Header%
11*6a54128fSAndroid Build Coastguard Worker  */
12*6a54128fSAndroid Build Coastguard Worker 
13*6a54128fSAndroid Build Coastguard Worker #ifdef WORDS_BIGENDIAN
14*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_le64(x) ((__force __le64)ext2fs_swab64((__u64)(x)))
15*6a54128fSAndroid Build Coastguard Worker #define ext2fs_le64_to_cpu(x) ext2fs_swab64((__force __u64)(__le64)(x))
16*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_le32(x) ((__force __le32)ext2fs_swab32((__u32)(x)))
17*6a54128fSAndroid Build Coastguard Worker #define ext2fs_le32_to_cpu(x) ext2fs_swab32((__force __u32)(__le32)(x))
18*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_le16(x) ((__force __le16)ext2fs_swab16((__u16)(x)))
19*6a54128fSAndroid Build Coastguard Worker #define ext2fs_le16_to_cpu(x) ext2fs_swab16((__force __u16)(__le16)(x))
20*6a54128fSAndroid Build Coastguard Worker 
21*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_be64(x) ((__force __be64)(__u64)(x))
22*6a54128fSAndroid Build Coastguard Worker #define ext2fs_be64_to_cpu(x) ((__force __u64)(__be64)(x))
23*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_be32(x) ((__force __be32)(__u32)(x))
24*6a54128fSAndroid Build Coastguard Worker #define ext2fs_be32_to_cpu(x) ((__force __u32)(__be32)(x))
25*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_be16(x) ((__force __be16)(__u16)(x))
26*6a54128fSAndroid Build Coastguard Worker #define ext2fs_be16_to_cpu(x) ((__force __u16)(__be16)(x))
27*6a54128fSAndroid Build Coastguard Worker #else
28*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_le64(x) ((__force __le64)(__u64)(x))
29*6a54128fSAndroid Build Coastguard Worker #define ext2fs_le64_to_cpu(x) ((__force __u64)(__le64)(x))
30*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_le32(x) ((__force __le32)(__u32)(x))
31*6a54128fSAndroid Build Coastguard Worker #define ext2fs_le32_to_cpu(x) ((__force __u32)(__le32)(x))
32*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_le16(x) ((__force __le16)(__u16)(x))
33*6a54128fSAndroid Build Coastguard Worker #define ext2fs_le16_to_cpu(x) ((__force __u16)(__le16)(x))
34*6a54128fSAndroid Build Coastguard Worker 
35*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_be64(x) ((__force __be64)ext2fs_swab64((__u64)(x)))
36*6a54128fSAndroid Build Coastguard Worker #define ext2fs_be64_to_cpu(x) ext2fs_swab64((__force __u64)(__be64)(x))
37*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_be32(x) ((__force __be32)ext2fs_swab32((__u32)(x)))
38*6a54128fSAndroid Build Coastguard Worker #define ext2fs_be32_to_cpu(x) ext2fs_swab32((__force __u32)(__be32)(x))
39*6a54128fSAndroid Build Coastguard Worker #define ext2fs_cpu_to_be16(x) ((__force __be16)ext2fs_swab16((__u16)(x)))
40*6a54128fSAndroid Build Coastguard Worker #define ext2fs_be16_to_cpu(x) ext2fs_swab16((__force __u16)(__be16)(x))
41*6a54128fSAndroid Build Coastguard Worker #endif
42*6a54128fSAndroid Build Coastguard Worker 
43*6a54128fSAndroid Build Coastguard Worker /*
44*6a54128fSAndroid Build Coastguard Worker  * EXT2FS bitmap manipulation routines.
45*6a54128fSAndroid Build Coastguard Worker  */
46*6a54128fSAndroid Build Coastguard Worker 
47*6a54128fSAndroid Build Coastguard Worker /* Support for sending warning messages from the inline subroutines */
48*6a54128fSAndroid Build Coastguard Worker extern const char *ext2fs_block_string;
49*6a54128fSAndroid Build Coastguard Worker extern const char *ext2fs_inode_string;
50*6a54128fSAndroid Build Coastguard Worker extern const char *ext2fs_mark_string;
51*6a54128fSAndroid Build Coastguard Worker extern const char *ext2fs_unmark_string;
52*6a54128fSAndroid Build Coastguard Worker extern const char *ext2fs_test_string;
53*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
54*6a54128fSAndroid Build Coastguard Worker 			       const char *description);
55*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
56*6a54128fSAndroid Build Coastguard Worker 				int code, unsigned long arg);
57*6a54128fSAndroid Build Coastguard Worker 
58*6a54128fSAndroid Build Coastguard Worker #ifdef NO_INLINE_FUNCS
59*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_set_bit(unsigned int nr,void * addr);
60*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_clear_bit(unsigned int nr, void * addr);
61*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_set_bit64(__u64 nr,void * addr);
62*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_clear_bit64(__u64 nr, void * addr);
63*6a54128fSAndroid Build Coastguard Worker extern __u16 ext2fs_swab16(__u16 val);
64*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_swab32(__u32 val);
65*6a54128fSAndroid Build Coastguard Worker extern __u64 ext2fs_swab64(__u64 val);
66*6a54128fSAndroid Build Coastguard Worker 
67*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
68*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
69*6a54128fSAndroid Build Coastguard Worker 				       blk_t block);
70*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
71*6a54128fSAndroid Build Coastguard Worker 
72*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
73*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
74*6a54128fSAndroid Build Coastguard Worker 				       ext2_ino_t inode);
75*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
76*6a54128fSAndroid Build Coastguard Worker 
77*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
78*6a54128fSAndroid Build Coastguard Worker 					  blk_t block);
79*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
80*6a54128fSAndroid Build Coastguard Worker 					    blk_t block);
81*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
82*6a54128fSAndroid Build Coastguard Worker 					 blk_t block);
83*6a54128fSAndroid Build Coastguard Worker 
84*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
85*6a54128fSAndroid Build Coastguard Worker 					  ext2_ino_t inode);
86*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
87*6a54128fSAndroid Build Coastguard Worker 					    ext2_ino_t inode);
88*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
89*6a54128fSAndroid Build Coastguard Worker 					 ext2_ino_t inode);
90*6a54128fSAndroid Build Coastguard Worker extern blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap);
91*6a54128fSAndroid Build Coastguard Worker extern ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap);
92*6a54128fSAndroid Build Coastguard Worker extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap);
93*6a54128fSAndroid Build Coastguard Worker extern ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap);
94*6a54128fSAndroid Build Coastguard Worker 
95*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
96*6a54128fSAndroid Build Coastguard Worker 						blk_t block, int num);
97*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
98*6a54128fSAndroid Build Coastguard Worker 						  blk_t block, int num);
99*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
100*6a54128fSAndroid Build Coastguard Worker 					       blk_t block, int num);
101*6a54128fSAndroid Build Coastguard Worker #endif
102*6a54128fSAndroid Build Coastguard Worker 
103*6a54128fSAndroid Build Coastguard Worker /* These functions routines moved to gen_bitmap.c */
104*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
105*6a54128fSAndroid Build Coastguard Worker 					   blk_t block, int num);
106*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
107*6a54128fSAndroid Build Coastguard Worker 					     blk_t block, int num);
108*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
109*6a54128fSAndroid Build Coastguard Worker 					  blk_t block, int num);
110*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_inode_bitmap_range(ext2fs_inode_bitmap bitmap,
111*6a54128fSAndroid Build Coastguard Worker 					  ext2_ino_t inode, int num);
112*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
113*6a54128fSAndroid Build Coastguard Worker 					 __u32 bitno);
114*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
115*6a54128fSAndroid Build Coastguard Worker 					   blk_t bitno);
116*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_generic_bitmap(ext2fs_generic_bitmap bitmap,
117*6a54128fSAndroid Build Coastguard Worker 				      blk_t bitno);
118*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
119*6a54128fSAndroid Build Coastguard Worker 					  blk_t block, int num);
120*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
121*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_get_generic_bitmap_start(ext2fs_generic_bitmap bitmap);
122*6a54128fSAndroid Build Coastguard Worker extern __u32 ext2fs_get_generic_bitmap_end(ext2fs_generic_bitmap bitmap);
123*6a54128fSAndroid Build Coastguard Worker 
124*6a54128fSAndroid Build Coastguard Worker /* 64-bit versions */
125*6a54128fSAndroid Build Coastguard Worker 
126*6a54128fSAndroid Build Coastguard Worker #ifdef NO_INLINE_FUNCS
127*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
128*6a54128fSAndroid Build Coastguard Worker 				     blk64_t block);
129*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
130*6a54128fSAndroid Build Coastguard Worker 				       blk64_t block);
131*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
132*6a54128fSAndroid Build Coastguard Worker 				     blk64_t block);
133*6a54128fSAndroid Build Coastguard Worker 
134*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
135*6a54128fSAndroid Build Coastguard Worker 				     ext2_ino_t inode);
136*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
137*6a54128fSAndroid Build Coastguard Worker 				       ext2_ino_t inode);
138*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
139*6a54128fSAndroid Build Coastguard Worker 				     ext2_ino_t inode);
140*6a54128fSAndroid Build Coastguard Worker 
141*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
142*6a54128fSAndroid Build Coastguard Worker 					   blk64_t block);
143*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
144*6a54128fSAndroid Build Coastguard Worker 					     blk64_t block);
145*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
146*6a54128fSAndroid Build Coastguard Worker 					  blk64_t block);
147*6a54128fSAndroid Build Coastguard Worker 
148*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
149*6a54128fSAndroid Build Coastguard Worker 					   ext2_ino_t inode);
150*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
151*6a54128fSAndroid Build Coastguard Worker 					    ext2_ino_t inode);
152*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
153*6a54128fSAndroid Build Coastguard Worker 					  ext2_ino_t inode);
154*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
155*6a54128fSAndroid Build Coastguard Worker 						      blk64_t start,
156*6a54128fSAndroid Build Coastguard Worker 						      blk64_t end,
157*6a54128fSAndroid Build Coastguard Worker 						      blk64_t *out);
158*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
159*6a54128fSAndroid Build Coastguard Worker 						      ext2_ino_t start,
160*6a54128fSAndroid Build Coastguard Worker 						      ext2_ino_t end,
161*6a54128fSAndroid Build Coastguard Worker 						      ext2_ino_t *out);
162*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
163*6a54128fSAndroid Build Coastguard Worker 						     blk64_t start,
164*6a54128fSAndroid Build Coastguard Worker 						     blk64_t end,
165*6a54128fSAndroid Build Coastguard Worker 						     blk64_t *out);
166*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
167*6a54128fSAndroid Build Coastguard Worker 						      ext2_ino_t start,
168*6a54128fSAndroid Build Coastguard Worker 						      ext2_ino_t end,
169*6a54128fSAndroid Build Coastguard Worker 						      ext2_ino_t *out);
170*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap);
171*6a54128fSAndroid Build Coastguard Worker extern ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap);
172*6a54128fSAndroid Build Coastguard Worker extern blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap);
173*6a54128fSAndroid Build Coastguard Worker extern ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap);
174*6a54128fSAndroid Build Coastguard Worker 
175*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
176*6a54128fSAndroid Build Coastguard Worker 						blk64_t block,
177*6a54128fSAndroid Build Coastguard Worker 						unsigned int num);
178*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
179*6a54128fSAndroid Build Coastguard Worker 						 blk64_t block,
180*6a54128fSAndroid Build Coastguard Worker 						 unsigned int num);
181*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
182*6a54128fSAndroid Build Coastguard Worker 						   blk64_t block,
183*6a54128fSAndroid Build Coastguard Worker 						   unsigned int num);
184*6a54128fSAndroid Build Coastguard Worker #endif
185*6a54128fSAndroid Build Coastguard Worker 
186*6a54128fSAndroid Build Coastguard Worker /* These routines moved to gen_bitmap64.c */
187*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap bitmap);
188*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_compare_generic_bmap(errcode_t neq,
189*6a54128fSAndroid Build Coastguard Worker 					     ext2fs_generic_bitmap bm1,
190*6a54128fSAndroid Build Coastguard Worker 					     ext2fs_generic_bitmap bm2);
191*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_set_generic_bmap_padding(ext2fs_generic_bitmap bmap);
192*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_mark_generic_bmap(ext2fs_generic_bitmap bitmap,
193*6a54128fSAndroid Build Coastguard Worker 				    blk64_t bitno);
194*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_unmark_generic_bmap(ext2fs_generic_bitmap bitmap,
195*6a54128fSAndroid Build Coastguard Worker 				      blk64_t bitno);
196*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap bitmap,
197*6a54128fSAndroid Build Coastguard Worker 				    blk64_t bitno);
198*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
199*6a54128fSAndroid Build Coastguard Worker 					   blk64_t block, unsigned int num);
200*6a54128fSAndroid Build Coastguard Worker extern __u64 ext2fs_get_generic_bmap_start(ext2fs_generic_bitmap bitmap);
201*6a54128fSAndroid Build Coastguard Worker extern __u64 ext2fs_get_generic_bmap_end(ext2fs_generic_bitmap bitmap);
202*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
203*6a54128fSAndroid Build Coastguard Worker 					   blk64_t block, unsigned int num);
204*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
205*6a54128fSAndroid Build Coastguard Worker 					    blk64_t block, unsigned int num);
206*6a54128fSAndroid Build Coastguard Worker extern void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
207*6a54128fSAndroid Build Coastguard Worker 					      blk64_t block, unsigned int num);
208*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitmap,
209*6a54128fSAndroid Build Coastguard Worker 						     __u64 start, __u64 end,
210*6a54128fSAndroid Build Coastguard Worker 						     __u64 *out);
211*6a54128fSAndroid Build Coastguard Worker extern errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap,
212*6a54128fSAndroid Build Coastguard Worker 						    __u64 start, __u64 end,
213*6a54128fSAndroid Build Coastguard Worker 						    __u64 *out);
214*6a54128fSAndroid Build Coastguard Worker 
215*6a54128fSAndroid Build Coastguard Worker /*
216*6a54128fSAndroid Build Coastguard Worker  * The inline routines themselves...
217*6a54128fSAndroid Build Coastguard Worker  *
218*6a54128fSAndroid Build Coastguard Worker  * If NO_INLINE_FUNCS is defined, then we won't try to do inline
219*6a54128fSAndroid Build Coastguard Worker  * functions at all; they will be included as normal functions in
220*6a54128fSAndroid Build Coastguard Worker  * inline.c
221*6a54128fSAndroid Build Coastguard Worker  */
222*6a54128fSAndroid Build Coastguard Worker 
223*6a54128fSAndroid Build Coastguard Worker #if (defined(INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
224*6a54128fSAndroid Build Coastguard Worker #ifdef INCLUDE_INLINE_FUNCS
225*6a54128fSAndroid Build Coastguard Worker #if (__STDC_VERSION__ >= 199901L)
226*6a54128fSAndroid Build Coastguard Worker #define _INLINE_ extern inline
227*6a54128fSAndroid Build Coastguard Worker #else
228*6a54128fSAndroid Build Coastguard Worker #define _INLINE_ inline
229*6a54128fSAndroid Build Coastguard Worker #endif
230*6a54128fSAndroid Build Coastguard Worker #else /* !INCLUDE_INLINE FUNCS */
231*6a54128fSAndroid Build Coastguard Worker #if (__STDC_VERSION__ >= 199901L)
232*6a54128fSAndroid Build Coastguard Worker #define _INLINE_ inline
233*6a54128fSAndroid Build Coastguard Worker #else /* not C99 */
234*6a54128fSAndroid Build Coastguard Worker #ifdef __GNUC__
235*6a54128fSAndroid Build Coastguard Worker #define _INLINE_ extern __inline__
236*6a54128fSAndroid Build Coastguard Worker #else				/* For Watcom C */
237*6a54128fSAndroid Build Coastguard Worker #define _INLINE_ extern inline
238*6a54128fSAndroid Build Coastguard Worker #endif /* __GNUC__ */
239*6a54128fSAndroid Build Coastguard Worker #endif /* __STDC_VERSION__ >= 199901L */
240*6a54128fSAndroid Build Coastguard Worker #endif /* INCLUDE_INLINE_FUNCS */
241*6a54128fSAndroid Build Coastguard Worker 
242*6a54128fSAndroid Build Coastguard Worker /*
243*6a54128fSAndroid Build Coastguard Worker  * Fast bit set/clear functions that doesn't need to return the
244*6a54128fSAndroid Build Coastguard Worker  * previous bit value.
245*6a54128fSAndroid Build Coastguard Worker  */
246*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_set_bit(unsigned int nr,void * addr)247*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_set_bit(unsigned int nr,void * addr)
248*6a54128fSAndroid Build Coastguard Worker {
249*6a54128fSAndroid Build Coastguard Worker 	unsigned char	*ADDR = (unsigned char *) addr;
250*6a54128fSAndroid Build Coastguard Worker 
251*6a54128fSAndroid Build Coastguard Worker 	ADDR += nr >> 3;
252*6a54128fSAndroid Build Coastguard Worker 	*ADDR |= (unsigned char) (1 << (nr & 0x07));
253*6a54128fSAndroid Build Coastguard Worker }
254*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_clear_bit(unsigned int nr,void * addr)255*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_clear_bit(unsigned int nr, void * addr)
256*6a54128fSAndroid Build Coastguard Worker {
257*6a54128fSAndroid Build Coastguard Worker 	unsigned char	*ADDR = (unsigned char *) addr;
258*6a54128fSAndroid Build Coastguard Worker 
259*6a54128fSAndroid Build Coastguard Worker 	ADDR += nr >> 3;
260*6a54128fSAndroid Build Coastguard Worker 	*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
261*6a54128fSAndroid Build Coastguard Worker }
262*6a54128fSAndroid Build Coastguard Worker 
263*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_set_bit64(__u64 nr,void * addr)264*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_set_bit64(__u64 nr, void * addr)
265*6a54128fSAndroid Build Coastguard Worker {
266*6a54128fSAndroid Build Coastguard Worker 	unsigned char	*ADDR = (unsigned char *) addr;
267*6a54128fSAndroid Build Coastguard Worker 
268*6a54128fSAndroid Build Coastguard Worker 	ADDR += nr >> 3;
269*6a54128fSAndroid Build Coastguard Worker 	*ADDR |= (unsigned char) (1 << (nr & 0x07));
270*6a54128fSAndroid Build Coastguard Worker }
271*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_clear_bit64(__u64 nr,void * addr)272*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_clear_bit64(__u64 nr, void * addr)
273*6a54128fSAndroid Build Coastguard Worker {
274*6a54128fSAndroid Build Coastguard Worker 	unsigned char	*ADDR = (unsigned char *) addr;
275*6a54128fSAndroid Build Coastguard Worker 
276*6a54128fSAndroid Build Coastguard Worker 	ADDR += nr >> 3;
277*6a54128fSAndroid Build Coastguard Worker 	*ADDR &= (unsigned char) ~(1 << (nr & 0x07));
278*6a54128fSAndroid Build Coastguard Worker }
279*6a54128fSAndroid Build Coastguard Worker 
ext2fs_swab16(__u16 val)280*6a54128fSAndroid Build Coastguard Worker _INLINE_ __u16 ext2fs_swab16(__u16 val)
281*6a54128fSAndroid Build Coastguard Worker {
282*6a54128fSAndroid Build Coastguard Worker 	return (val >> 8) | (__u16) (val << 8);
283*6a54128fSAndroid Build Coastguard Worker }
284*6a54128fSAndroid Build Coastguard Worker 
ext2fs_swab32(__u32 val)285*6a54128fSAndroid Build Coastguard Worker _INLINE_ __u32 ext2fs_swab32(__u32 val)
286*6a54128fSAndroid Build Coastguard Worker {
287*6a54128fSAndroid Build Coastguard Worker 	return ((val>>24) | ((val>>8)&0xFF00) |
288*6a54128fSAndroid Build Coastguard Worker 		((val<<8)&0xFF0000) | (val<<24));
289*6a54128fSAndroid Build Coastguard Worker }
290*6a54128fSAndroid Build Coastguard Worker 
ext2fs_swab64(__u64 val)291*6a54128fSAndroid Build Coastguard Worker _INLINE_ __u64 ext2fs_swab64(__u64 val)
292*6a54128fSAndroid Build Coastguard Worker {
293*6a54128fSAndroid Build Coastguard Worker 	return (ext2fs_swab32((__u32) (val >> 32)) |
294*6a54128fSAndroid Build Coastguard Worker 		(((__u64)ext2fs_swab32(val & 0xFFFFFFFFUL)) << 32));
295*6a54128fSAndroid Build Coastguard Worker }
296*6a54128fSAndroid Build Coastguard Worker 
ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)297*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap,
298*6a54128fSAndroid Build Coastguard Worker 				       blk_t block)
299*6a54128fSAndroid Build Coastguard Worker {
300*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
301*6a54128fSAndroid Build Coastguard Worker 					  block);
302*6a54128fSAndroid Build Coastguard Worker }
303*6a54128fSAndroid Build Coastguard Worker 
ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)304*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
305*6a54128fSAndroid Build Coastguard Worker 					 blk_t block)
306*6a54128fSAndroid Build Coastguard Worker {
307*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
308*6a54128fSAndroid Build Coastguard Worker 					    block);
309*6a54128fSAndroid Build Coastguard Worker }
310*6a54128fSAndroid Build Coastguard Worker 
ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)311*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap,
312*6a54128fSAndroid Build Coastguard Worker 				       blk_t block)
313*6a54128fSAndroid Build Coastguard Worker {
314*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
315*6a54128fSAndroid Build Coastguard Worker 					  block);
316*6a54128fSAndroid Build Coastguard Worker }
317*6a54128fSAndroid Build Coastguard Worker 
ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)318*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
319*6a54128fSAndroid Build Coastguard Worker 				       ext2_ino_t inode)
320*6a54128fSAndroid Build Coastguard Worker {
321*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
322*6a54128fSAndroid Build Coastguard Worker 					  inode);
323*6a54128fSAndroid Build Coastguard Worker }
324*6a54128fSAndroid Build Coastguard Worker 
ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)325*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
326*6a54128fSAndroid Build Coastguard Worker 					 ext2_ino_t inode)
327*6a54128fSAndroid Build Coastguard Worker {
328*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap,
329*6a54128fSAndroid Build Coastguard Worker 				     inode);
330*6a54128fSAndroid Build Coastguard Worker }
331*6a54128fSAndroid Build Coastguard Worker 
ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)332*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
333*6a54128fSAndroid Build Coastguard Worker 				       ext2_ino_t inode)
334*6a54128fSAndroid Build Coastguard Worker {
335*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
336*6a54128fSAndroid Build Coastguard Worker 					  inode);
337*6a54128fSAndroid Build Coastguard Worker }
338*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)339*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
340*6a54128fSAndroid Build Coastguard Worker 					    blk_t block)
341*6a54128fSAndroid Build Coastguard Worker {
342*6a54128fSAndroid Build Coastguard Worker 	ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
343*6a54128fSAndroid Build Coastguard Worker }
344*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)345*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
346*6a54128fSAndroid Build Coastguard Worker 					      blk_t block)
347*6a54128fSAndroid Build Coastguard Worker {
348*6a54128fSAndroid Build Coastguard Worker 	ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, block);
349*6a54128fSAndroid Build Coastguard Worker }
350*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,blk_t block)351*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
352*6a54128fSAndroid Build Coastguard Worker 					    blk_t block)
353*6a54128fSAndroid Build Coastguard Worker {
354*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
355*6a54128fSAndroid Build Coastguard Worker 					  block);
356*6a54128fSAndroid Build Coastguard Worker }
357*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)358*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
359*6a54128fSAndroid Build Coastguard Worker 					    ext2_ino_t inode)
360*6a54128fSAndroid Build Coastguard Worker {
361*6a54128fSAndroid Build Coastguard Worker 	ext2fs_mark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
362*6a54128fSAndroid Build Coastguard Worker }
363*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)364*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
365*6a54128fSAndroid Build Coastguard Worker 					      ext2_ino_t inode)
366*6a54128fSAndroid Build Coastguard Worker {
367*6a54128fSAndroid Build Coastguard Worker 	ext2fs_unmark_generic_bitmap((ext2fs_generic_bitmap) bitmap, inode);
368*6a54128fSAndroid Build Coastguard Worker }
369*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)370*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
371*6a54128fSAndroid Build Coastguard Worker 					   ext2_ino_t inode)
372*6a54128fSAndroid Build Coastguard Worker {
373*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_test_generic_bitmap((ext2fs_generic_bitmap) bitmap,
374*6a54128fSAndroid Build Coastguard Worker 					  inode);
375*6a54128fSAndroid Build Coastguard Worker }
376*6a54128fSAndroid Build Coastguard Worker 
ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap)377*6a54128fSAndroid Build Coastguard Worker _INLINE_ blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap)
378*6a54128fSAndroid Build Coastguard Worker {
379*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
380*6a54128fSAndroid Build Coastguard Worker }
381*6a54128fSAndroid Build Coastguard Worker 
ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap)382*6a54128fSAndroid Build Coastguard Worker _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap)
383*6a54128fSAndroid Build Coastguard Worker {
384*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_get_generic_bitmap_start((ext2fs_generic_bitmap) bitmap);
385*6a54128fSAndroid Build Coastguard Worker }
386*6a54128fSAndroid Build Coastguard Worker 
ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap)387*6a54128fSAndroid Build Coastguard Worker _INLINE_ blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap)
388*6a54128fSAndroid Build Coastguard Worker {
389*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
390*6a54128fSAndroid Build Coastguard Worker }
391*6a54128fSAndroid Build Coastguard Worker 
ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap)392*6a54128fSAndroid Build Coastguard Worker _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap)
393*6a54128fSAndroid Build Coastguard Worker {
394*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_get_generic_bitmap_end((ext2fs_generic_bitmap) bitmap);
395*6a54128fSAndroid Build Coastguard Worker }
396*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,blk_t block,int num)397*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
398*6a54128fSAndroid Build Coastguard Worker 						 blk_t block, int num)
399*6a54128fSAndroid Build Coastguard Worker {
400*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_test_block_bitmap_range(bitmap, block, num);
401*6a54128fSAndroid Build Coastguard Worker }
402*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,blk_t block,int num)403*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
404*6a54128fSAndroid Build Coastguard Worker 						  blk_t block, int num)
405*6a54128fSAndroid Build Coastguard Worker {
406*6a54128fSAndroid Build Coastguard Worker 	ext2fs_mark_block_bitmap_range(bitmap, block, num);
407*6a54128fSAndroid Build Coastguard Worker }
408*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,blk_t block,int num)409*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
410*6a54128fSAndroid Build Coastguard Worker 						    blk_t block, int num)
411*6a54128fSAndroid Build Coastguard Worker {
412*6a54128fSAndroid Build Coastguard Worker 	ext2fs_unmark_block_bitmap_range(bitmap, block, num);
413*6a54128fSAndroid Build Coastguard Worker }
414*6a54128fSAndroid Build Coastguard Worker 
415*6a54128fSAndroid Build Coastguard Worker /* 64-bit versions */
416*6a54128fSAndroid Build Coastguard Worker 
ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)417*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
418*6a54128fSAndroid Build Coastguard Worker 				       blk64_t block)
419*6a54128fSAndroid Build Coastguard Worker {
420*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
421*6a54128fSAndroid Build Coastguard Worker 					block);
422*6a54128fSAndroid Build Coastguard Worker }
423*6a54128fSAndroid Build Coastguard Worker 
ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)424*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
425*6a54128fSAndroid Build Coastguard Worker 					 blk64_t block)
426*6a54128fSAndroid Build Coastguard Worker {
427*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
428*6a54128fSAndroid Build Coastguard Worker }
429*6a54128fSAndroid Build Coastguard Worker 
ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)430*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_test_block_bitmap2(ext2fs_block_bitmap bitmap,
431*6a54128fSAndroid Build Coastguard Worker 				       blk64_t block)
432*6a54128fSAndroid Build Coastguard Worker {
433*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
434*6a54128fSAndroid Build Coastguard Worker 					block);
435*6a54128fSAndroid Build Coastguard Worker }
436*6a54128fSAndroid Build Coastguard Worker 
ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)437*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
438*6a54128fSAndroid Build Coastguard Worker 				       ext2_ino_t inode)
439*6a54128fSAndroid Build Coastguard Worker {
440*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap,
441*6a54128fSAndroid Build Coastguard Worker 					inode);
442*6a54128fSAndroid Build Coastguard Worker }
443*6a54128fSAndroid Build Coastguard Worker 
ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)444*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
445*6a54128fSAndroid Build Coastguard Worker 					 ext2_ino_t inode)
446*6a54128fSAndroid Build Coastguard Worker {
447*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap,
448*6a54128fSAndroid Build Coastguard Worker 					  inode);
449*6a54128fSAndroid Build Coastguard Worker }
450*6a54128fSAndroid Build Coastguard Worker 
ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)451*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
452*6a54128fSAndroid Build Coastguard Worker 				       ext2_ino_t inode)
453*6a54128fSAndroid Build Coastguard Worker {
454*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
455*6a54128fSAndroid Build Coastguard Worker 					inode);
456*6a54128fSAndroid Build Coastguard Worker }
457*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)458*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_mark_block_bitmap2(ext2fs_block_bitmap bitmap,
459*6a54128fSAndroid Build Coastguard Worker 					     blk64_t block)
460*6a54128fSAndroid Build Coastguard Worker {
461*6a54128fSAndroid Build Coastguard Worker 	ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
462*6a54128fSAndroid Build Coastguard Worker }
463*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)464*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_unmark_block_bitmap2(ext2fs_block_bitmap bitmap,
465*6a54128fSAndroid Build Coastguard Worker 					       blk64_t block)
466*6a54128fSAndroid Build Coastguard Worker {
467*6a54128fSAndroid Build Coastguard Worker 	ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, block);
468*6a54128fSAndroid Build Coastguard Worker }
469*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t block)470*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_fast_test_block_bitmap2(ext2fs_block_bitmap bitmap,
471*6a54128fSAndroid Build Coastguard Worker 					    blk64_t block)
472*6a54128fSAndroid Build Coastguard Worker {
473*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
474*6a54128fSAndroid Build Coastguard Worker 					block);
475*6a54128fSAndroid Build Coastguard Worker }
476*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)477*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_mark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
478*6a54128fSAndroid Build Coastguard Worker 					     ext2_ino_t inode)
479*6a54128fSAndroid Build Coastguard Worker {
480*6a54128fSAndroid Build Coastguard Worker 	ext2fs_mark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
481*6a54128fSAndroid Build Coastguard Worker }
482*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)483*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_unmark_inode_bitmap2(ext2fs_inode_bitmap bitmap,
484*6a54128fSAndroid Build Coastguard Worker 					       ext2_ino_t inode)
485*6a54128fSAndroid Build Coastguard Worker {
486*6a54128fSAndroid Build Coastguard Worker 	ext2fs_unmark_generic_bmap((ext2fs_generic_bitmap) bitmap, inode);
487*6a54128fSAndroid Build Coastguard Worker }
488*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t inode)489*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_fast_test_inode_bitmap2(ext2fs_inode_bitmap bitmap,
490*6a54128fSAndroid Build Coastguard Worker 					    ext2_ino_t inode)
491*6a54128fSAndroid Build Coastguard Worker {
492*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_test_generic_bmap((ext2fs_generic_bitmap) bitmap,
493*6a54128fSAndroid Build Coastguard Worker 					inode);
494*6a54128fSAndroid Build Coastguard Worker }
495*6a54128fSAndroid Build Coastguard Worker 
ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t start,blk64_t end,blk64_t * out)496*6a54128fSAndroid Build Coastguard Worker _INLINE_ errcode_t ext2fs_find_first_zero_block_bitmap2(ext2fs_block_bitmap bitmap,
497*6a54128fSAndroid Build Coastguard Worker 							blk64_t start,
498*6a54128fSAndroid Build Coastguard Worker 							blk64_t end,
499*6a54128fSAndroid Build Coastguard Worker 							blk64_t *out)
500*6a54128fSAndroid Build Coastguard Worker {
501*6a54128fSAndroid Build Coastguard Worker 	__u64 o;
502*6a54128fSAndroid Build Coastguard Worker 	errcode_t rv;
503*6a54128fSAndroid Build Coastguard Worker 
504*6a54128fSAndroid Build Coastguard Worker 	rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
505*6a54128fSAndroid Build Coastguard Worker 						 start, end, &o);
506*6a54128fSAndroid Build Coastguard Worker 	if (!rv)
507*6a54128fSAndroid Build Coastguard Worker 		*out = o;
508*6a54128fSAndroid Build Coastguard Worker 	return rv;
509*6a54128fSAndroid Build Coastguard Worker }
510*6a54128fSAndroid Build Coastguard Worker 
ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t start,ext2_ino_t end,ext2_ino_t * out)511*6a54128fSAndroid Build Coastguard Worker _INLINE_ errcode_t ext2fs_find_first_zero_inode_bitmap2(ext2fs_inode_bitmap bitmap,
512*6a54128fSAndroid Build Coastguard Worker 							ext2_ino_t start,
513*6a54128fSAndroid Build Coastguard Worker 							ext2_ino_t end,
514*6a54128fSAndroid Build Coastguard Worker 							ext2_ino_t *out)
515*6a54128fSAndroid Build Coastguard Worker {
516*6a54128fSAndroid Build Coastguard Worker 	__u64 o;
517*6a54128fSAndroid Build Coastguard Worker 	errcode_t rv;
518*6a54128fSAndroid Build Coastguard Worker 
519*6a54128fSAndroid Build Coastguard Worker 	rv = ext2fs_find_first_zero_generic_bmap((ext2fs_generic_bitmap) bitmap,
520*6a54128fSAndroid Build Coastguard Worker 						 start, end, &o);
521*6a54128fSAndroid Build Coastguard Worker 	if (!rv)
522*6a54128fSAndroid Build Coastguard Worker 		*out = (ext2_ino_t) o;
523*6a54128fSAndroid Build Coastguard Worker 	return rv;
524*6a54128fSAndroid Build Coastguard Worker }
525*6a54128fSAndroid Build Coastguard Worker 
ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,blk64_t start,blk64_t end,blk64_t * out)526*6a54128fSAndroid Build Coastguard Worker _INLINE_ errcode_t ext2fs_find_first_set_block_bitmap2(ext2fs_block_bitmap bitmap,
527*6a54128fSAndroid Build Coastguard Worker 						       blk64_t start,
528*6a54128fSAndroid Build Coastguard Worker 						       blk64_t end,
529*6a54128fSAndroid Build Coastguard Worker 						       blk64_t *out)
530*6a54128fSAndroid Build Coastguard Worker {
531*6a54128fSAndroid Build Coastguard Worker 	__u64 o;
532*6a54128fSAndroid Build Coastguard Worker 	errcode_t rv;
533*6a54128fSAndroid Build Coastguard Worker 
534*6a54128fSAndroid Build Coastguard Worker 	rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
535*6a54128fSAndroid Build Coastguard Worker 						start, end, &o);
536*6a54128fSAndroid Build Coastguard Worker 	if (!rv)
537*6a54128fSAndroid Build Coastguard Worker 		*out = o;
538*6a54128fSAndroid Build Coastguard Worker 	return rv;
539*6a54128fSAndroid Build Coastguard Worker }
540*6a54128fSAndroid Build Coastguard Worker 
ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,ext2_ino_t start,ext2_ino_t end,ext2_ino_t * out)541*6a54128fSAndroid Build Coastguard Worker _INLINE_ errcode_t ext2fs_find_first_set_inode_bitmap2(ext2fs_inode_bitmap bitmap,
542*6a54128fSAndroid Build Coastguard Worker 						       ext2_ino_t start,
543*6a54128fSAndroid Build Coastguard Worker 						       ext2_ino_t end,
544*6a54128fSAndroid Build Coastguard Worker 						       ext2_ino_t *out)
545*6a54128fSAndroid Build Coastguard Worker {
546*6a54128fSAndroid Build Coastguard Worker 	__u64 o;
547*6a54128fSAndroid Build Coastguard Worker 	errcode_t rv;
548*6a54128fSAndroid Build Coastguard Worker 
549*6a54128fSAndroid Build Coastguard Worker 	rv = ext2fs_find_first_set_generic_bmap((ext2fs_generic_bitmap) bitmap,
550*6a54128fSAndroid Build Coastguard Worker 						start, end, &o);
551*6a54128fSAndroid Build Coastguard Worker 	if (!rv)
552*6a54128fSAndroid Build Coastguard Worker 		*out = (ext2_ino_t) o;
553*6a54128fSAndroid Build Coastguard Worker 	return rv;
554*6a54128fSAndroid Build Coastguard Worker }
555*6a54128fSAndroid Build Coastguard Worker 
ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap)556*6a54128fSAndroid Build Coastguard Worker _INLINE_ blk64_t ext2fs_get_block_bitmap_start2(ext2fs_block_bitmap bitmap)
557*6a54128fSAndroid Build Coastguard Worker {
558*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
559*6a54128fSAndroid Build Coastguard Worker }
560*6a54128fSAndroid Build Coastguard Worker 
ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap)561*6a54128fSAndroid Build Coastguard Worker _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_start2(ext2fs_inode_bitmap bitmap)
562*6a54128fSAndroid Build Coastguard Worker {
563*6a54128fSAndroid Build Coastguard Worker 	return (ext2_ino_t) ext2fs_get_generic_bmap_start((ext2fs_generic_bitmap) bitmap);
564*6a54128fSAndroid Build Coastguard Worker }
565*6a54128fSAndroid Build Coastguard Worker 
ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap)566*6a54128fSAndroid Build Coastguard Worker _INLINE_ blk64_t ext2fs_get_block_bitmap_end2(ext2fs_block_bitmap bitmap)
567*6a54128fSAndroid Build Coastguard Worker {
568*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
569*6a54128fSAndroid Build Coastguard Worker }
570*6a54128fSAndroid Build Coastguard Worker 
ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap)571*6a54128fSAndroid Build Coastguard Worker _INLINE_ ext2_ino_t ext2fs_get_inode_bitmap_end2(ext2fs_inode_bitmap bitmap)
572*6a54128fSAndroid Build Coastguard Worker {
573*6a54128fSAndroid Build Coastguard Worker 	return (ext2_ino_t) ext2fs_get_generic_bmap_end((ext2fs_generic_bitmap) bitmap);
574*6a54128fSAndroid Build Coastguard Worker }
575*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,blk64_t block,unsigned int num)576*6a54128fSAndroid Build Coastguard Worker _INLINE_ int ext2fs_fast_test_block_bitmap_range2(ext2fs_block_bitmap bitmap,
577*6a54128fSAndroid Build Coastguard Worker 						  blk64_t block,
578*6a54128fSAndroid Build Coastguard Worker 						  unsigned int num)
579*6a54128fSAndroid Build Coastguard Worker {
580*6a54128fSAndroid Build Coastguard Worker 	return ext2fs_test_block_bitmap_range2(bitmap, block, num);
581*6a54128fSAndroid Build Coastguard Worker }
582*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,blk64_t block,unsigned int num)583*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_mark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
584*6a54128fSAndroid Build Coastguard Worker 						   blk64_t block,
585*6a54128fSAndroid Build Coastguard Worker 						   unsigned int num)
586*6a54128fSAndroid Build Coastguard Worker {
587*6a54128fSAndroid Build Coastguard Worker 	ext2fs_mark_block_bitmap_range2(bitmap, block, num);
588*6a54128fSAndroid Build Coastguard Worker }
589*6a54128fSAndroid Build Coastguard Worker 
ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,blk64_t block,unsigned int num)590*6a54128fSAndroid Build Coastguard Worker _INLINE_ void ext2fs_fast_unmark_block_bitmap_range2(ext2fs_block_bitmap bitmap,
591*6a54128fSAndroid Build Coastguard Worker 						     blk64_t block,
592*6a54128fSAndroid Build Coastguard Worker 						     unsigned int num)
593*6a54128fSAndroid Build Coastguard Worker {
594*6a54128fSAndroid Build Coastguard Worker 	ext2fs_unmark_block_bitmap_range2(bitmap, block, num);
595*6a54128fSAndroid Build Coastguard Worker }
596*6a54128fSAndroid Build Coastguard Worker 
597*6a54128fSAndroid Build Coastguard Worker #undef _INLINE_
598*6a54128fSAndroid Build Coastguard Worker #endif
599*6a54128fSAndroid Build Coastguard Worker 
600*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_set_bit(unsigned int nr,void * addr);
601*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_clear_bit(unsigned int nr, void * addr);
602*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_bit(unsigned int nr, const void * addr);
603*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_set_bit64(__u64 nr,void * addr);
604*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_clear_bit64(__u64 nr, void * addr);
605*6a54128fSAndroid Build Coastguard Worker extern int ext2fs_test_bit64(__u64 nr, const void * addr);
606*6a54128fSAndroid Build Coastguard Worker extern unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes);
607