Coda Distributed File System
bitmap7.h
Go to the documentation of this file.
1/* BLURB gpl
2
3 Coda File System
4 Release 8
5
6 Copyright (c) 1987-2025 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU General Public Licence Version 2, as shown in the
11file LICENSE. The technical and financial contributors to Coda are
12listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19#ifndef _BITMAP7_H_
20#define _BITMAP7_H_ 1
21/*
22 * bitmap7.h
23 * Created Feb 13, 1992 -- Puneet Kumar
24 * Declaration of a bitmap class
25 */
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#include <stddef.h>
32#include <stdint.h>
33#include <stdio.h>
34
35#ifdef __cplusplus
36}
37#endif
38
39#include <coda_tsa.h>
40
41#define ALLOCMASK 255
42#define HIGHBIT 128
43/* Bitmap for keeping status of N elements of an array.
44 * The class keeps an array of size = 1/8th N
45 * Each elements status is stored in a bit
46 * 1 --> that element is not free
47 * 0 --> that element is free
48 */
49
50/* Values of bitmap7::malloced; must be 8 bits so can't use enums */
51#define BITMAP_NOTVIANEW 193 /* must be on stack */
52#define BITMAP_VIANEW 221 /* on heap, via operator new */
53
54class bitmap7 {
55 // friend ostream& operator<<(ostream& s, bitmap7 *b);
56 uint8_t recoverable;
57 uint8_t malloced;
58 int mapsize;
59 int indexsize;
60 char *map;
68 inline void SetValue(int index, int value) TRANSACTION_OPTIONAL;
69
77 void SetRangeValue(int start, int len, int value) TRANSACTION_OPTIONAL;
78
79public:
88 void *operator new(size_t size, int recable = 0) TRANSACTION_OPTIONAL;
89
96 void operator delete(void *ptr) TRANSACTION_OPTIONAL;
97
104 bitmap7(int inputmapsize = 0, int recable = 0);
105
109 ~bitmap7();
110
116 void Resize(int newsize) TRANSACTION_OPTIONAL;
117
123 void Grow(int newsize);
124
131
137 void FreeIndex(int index);
138
145 void FreeRange(int start, int len);
146
152 void SetIndex(int index) TRANSACTION_OPTIONAL;
153
160 void SetRange(int start, int len);
161
169 void CopyRange(int start, int len, bitmap7 &b) TRANSACTION_OPTIONAL;
170
177 int Value(int index);
178
184 int Count();
185
191 int Size();
192
197
204
211 int operator!=(bitmap7 &b); // test for inequality
212
216 void print();
217
223 void print(FILE *fp);
224
230 void print(int fd);
231};
232
233#endif /* _BITMAP7_H_ */
Definition: bitmap7.h:54
void purge() TRANSACTION_OPTIONAL
Definition: bitmap7.cc:365
int GetFreeIndex() TRANSACTION_OPTIONAL
Definition: bitmap7.cc:198
int Value(int index)
Definition: bitmap7.cc:332
void FreeRange(int start, int len)
Definition: bitmap7.cc:327
void print()
Definition: bitmap7.cc:430
void CopyRange(int start, int len, bitmap7 &b) TRANSACTION_OPTIONAL
Definition: bitmap7.cc:245
void SetIndex(int index) TRANSACTION_OPTIONAL
Definition: bitmap7.cc:312
int Count()
Definition: bitmap7.cc:346
~bitmap7()
Definition: bitmap7.cc:120
bitmap7(int inputmapsize=0, int recable=0)
Definition: bitmap7.cc:87
void Grow(int newsize)
Definition: bitmap7.cc:191
void FreeIndex(int index)
Definition: bitmap7.cc:322
int operator!=(bitmap7 &b)
Definition: bitmap7.cc:413
void SetRange(int start, int len)
Definition: bitmap7.cc:317
int Size()
Definition: bitmap7.cc:358
void operator=(bitmap7 &b) TRANSACTION_OPTIONAL
Definition: bitmap7.cc:379
void Resize(int newsize) TRANSACTION_OPTIONAL
Definition: bitmap7.cc:139
unsigned char uint8_t
Definition: coda.h:101
#define TRANSACTION_OPTIONAL
Definition: coda_tsa.h:109