blob: b6446efa2a8da45db79095426a6ea583d5ae5883 [file] [log] [blame]
Mike Frysinger1fd98e02005-05-09 22:10:42 +00001/*
2 * bitops.h --- Bitmap frobbing code. The byte swapping routines are
3 * also included here.
4 *
5 * Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
6 *
7 * %Begin-Header%
8 * This file may be redistributed under the terms of the GNU Public
9 * License.
10 * %End-Header%
11 *
12 * i386 bitops operations taken from <asm/bitops.h>, Copyright 1992,
13 * Linus Torvalds.
14 */
15
Mike Frysingerf98f5e32005-06-11 00:11:46 +000016#include <strings.h>
Mike Frysinger1fd98e02005-05-09 22:10:42 +000017
18extern int ext2fs_set_bit(int nr,void * addr);
19extern int ext2fs_clear_bit(int nr, void * addr);
20extern int ext2fs_test_bit(int nr, const void * addr);
21extern __u16 ext2fs_swab16(__u16 val);
22extern __u32 ext2fs_swab32(__u32 val);
23
24#ifdef WORDS_BIGENDIAN
25#define ext2fs_cpu_to_le32(x) ext2fs_swab32((x))
26#define ext2fs_le32_to_cpu(x) ext2fs_swab32((x))
27#define ext2fs_cpu_to_le16(x) ext2fs_swab16((x))
28#define ext2fs_le16_to_cpu(x) ext2fs_swab16((x))
29#define ext2fs_cpu_to_be32(x) ((__u32)(x))
30#define ext2fs_be32_to_cpu(x) ((__u32)(x))
31#define ext2fs_cpu_to_be16(x) ((__u16)(x))
32#define ext2fs_be16_to_cpu(x) ((__u16)(x))
33#else
34#define ext2fs_cpu_to_le32(x) ((__u32)(x))
35#define ext2fs_le32_to_cpu(x) ((__u32)(x))
36#define ext2fs_cpu_to_le16(x) ((__u16)(x))
37#define ext2fs_le16_to_cpu(x) ((__u16)(x))
38#define ext2fs_cpu_to_be32(x) ext2fs_swab32((x))
39#define ext2fs_be32_to_cpu(x) ext2fs_swab32((x))
40#define ext2fs_cpu_to_be16(x) ext2fs_swab16((x))
41#define ext2fs_be16_to_cpu(x) ext2fs_swab16((x))
42#endif
43
44/*
45 * EXT2FS bitmap manipulation routines.
46 */
47
48/* Support for sending warning messages from the inline subroutines */
49extern const char *ext2fs_block_string;
50extern const char *ext2fs_inode_string;
51extern const char *ext2fs_mark_string;
52extern const char *ext2fs_unmark_string;
53extern const char *ext2fs_test_string;
54extern void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,
55 const char *description);
56extern void ext2fs_warn_bitmap2(ext2fs_generic_bitmap bitmap,
57 int code, unsigned long arg);
58
59extern int ext2fs_mark_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
60extern int ext2fs_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
61 blk_t block);
62extern int ext2fs_test_block_bitmap(ext2fs_block_bitmap bitmap, blk_t block);
63
64extern int ext2fs_mark_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
65extern int ext2fs_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
66 ext2_ino_t inode);
67extern int ext2fs_test_inode_bitmap(ext2fs_inode_bitmap bitmap, ext2_ino_t inode);
68
69extern void ext2fs_fast_mark_block_bitmap(ext2fs_block_bitmap bitmap,
70 blk_t block);
71extern void ext2fs_fast_unmark_block_bitmap(ext2fs_block_bitmap bitmap,
72 blk_t block);
73extern int ext2fs_fast_test_block_bitmap(ext2fs_block_bitmap bitmap,
74 blk_t block);
75
76extern void ext2fs_fast_mark_inode_bitmap(ext2fs_inode_bitmap bitmap,
77 ext2_ino_t inode);
78extern void ext2fs_fast_unmark_inode_bitmap(ext2fs_inode_bitmap bitmap,
79 ext2_ino_t inode);
80extern int ext2fs_fast_test_inode_bitmap(ext2fs_inode_bitmap bitmap,
81 ext2_ino_t inode);
82extern blk_t ext2fs_get_block_bitmap_start(ext2fs_block_bitmap bitmap);
83extern ext2_ino_t ext2fs_get_inode_bitmap_start(ext2fs_inode_bitmap bitmap);
84extern blk_t ext2fs_get_block_bitmap_end(ext2fs_block_bitmap bitmap);
85extern ext2_ino_t ext2fs_get_inode_bitmap_end(ext2fs_inode_bitmap bitmap);
86
87extern void ext2fs_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
88 blk_t block, int num);
89extern void ext2fs_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
90 blk_t block, int num);
91extern int ext2fs_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
92 blk_t block, int num);
93extern void ext2fs_fast_mark_block_bitmap_range(ext2fs_block_bitmap bitmap,
94 blk_t block, int num);
95extern void ext2fs_fast_unmark_block_bitmap_range(ext2fs_block_bitmap bitmap,
96 blk_t block, int num);
97extern int ext2fs_fast_test_block_bitmap_range(ext2fs_block_bitmap bitmap,
98 blk_t block, int num);
99extern void ext2fs_set_bitmap_padding(ext2fs_generic_bitmap map);
100
101/* These two routines moved to gen_bitmap.c */
102extern int ext2fs_mark_generic_bitmap(ext2fs_generic_bitmap bitmap,
103 __u32 bitno);
104extern int ext2fs_unmark_generic_bitmap(ext2fs_generic_bitmap bitmap,
105 blk_t bitno);