forked from agroce/testfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbitmap.h
executable file
·38 lines (31 loc) · 1.29 KB
/
bitmap.h
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
#ifndef _BITMAP_H_
#define _BITMAP_H_
/*
* Fixed-size array of bits. (Intended for storage management.)
*
* Functions:
* bitmap_create - allocate a new_ bitmap object.
* Returns NULL on error.
* bitmap_getdata - return pointer to raw bit data (for I/O).
* bitmap_alloc - locate a cleared bit, set it, and return its index.
* bitmap_mark - set a clear bit by its index.
* bitmap_unmark - clear a set bit by its index.
* bitmap_isset - return whether a particular bit is set or not.
* bitmap_destroy - destroy bitmap.
*/
#include <sys/types.h>
#include <limits.h>
#define BITS_PER_WORD (CHAR_BIT)
#define WORD_TYPE unsigned char
#define WORD_ALLBITS (0xff)
struct bitmap; /* Opaque. */
int bitmap_create(u_int32_t nbits, struct bitmap **bp);
void *bitmap_getdata(struct bitmap *);
int bitmap_alloc(struct bitmap *, u_int32_t *index);
void bitmap_mark(struct bitmap *, u_int32_t index);
void bitmap_unmark(struct bitmap *, u_int32_t index);
int bitmap_isset(struct bitmap *, u_int32_t index);
void bitmap_destroy(struct bitmap *);
int bitmap_equal(struct bitmap *, struct bitmap *);
int bitmap_nr_allocated(struct bitmap *);
#endif /* _BITMAP_H_ */