ubinos
bitmap.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 Sung Ho Park
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef UBICLIB_BITMAP_H_
8 #define UBICLIB_BITMAP_H_
9 
10 #ifdef __cplusplus
11 extern "C"
12 {
13 #endif
14 
23 #include <ubinos_config.h>
24 #include <ubinos/type.h>
25 
30 #define BITMAP_DEPTH_MAX 4
31 
33 typedef struct _bitmap_t
34 {
35  unsigned int bitsize;
36  unsigned int * map;
37  unsigned int map_bytesize;
38  unsigned int level_depth;
41 
43 typedef bitmap_t * bitmap_pt;
44 
46 #define BITMAP_INITVALUE(bitsize) { \
47  bitsize, \
48  NULL, \
49  0, \
50  0, \
51  {0, } \
52 }
53 
72 int bitmap_init(bitmap_pt bitmap, unsigned int bitsize, unsigned char * buf,
73  unsigned int bufsize);
74 
82 unsigned int bitmap_getmemsize(unsigned int bitsize);
83 
91 unsigned int bitmap_getmapsize(unsigned int bitsize);
92 
105 int bitmap_create(bitmap_pt * bitmap_p, unsigned int bitsize);
106 
118 int bitmap_delete(bitmap_pt * bitmap_p);
119 
132 int bitmap_getbit(bitmap_pt bitmap, unsigned int index);
133 
148 int bitmap_setbit(bitmap_pt bitmap, unsigned int index, int value);
149 
162 int bitmap_setbitall(bitmap_pt bitmap, int value);
163 
171 unsigned int bitmap_getlsb(bitmap_pt bitmap);
172 
182 unsigned int bitmap_getlsb2(bitmap_pt bitmap, unsigned int index);
183 
191 unsigned int bitmap_getmsb(bitmap_pt bitmap);
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 
197 #endif /* UBICLIB_BITMAP_H_ */
int bitmap_setbit(bitmap_pt bitmap, unsigned int index, int value)
unsigned int bitmap_getmapsize(unsigned int bitsize)
int bitmap_create(bitmap_pt *bitmap_p, unsigned int bitsize)
unsigned int bitmap_getmsb(bitmap_pt bitmap)
#define BITMAP_DEPTH_MAX
Definition: bitmap.h:30
int bitmap_init(bitmap_pt bitmap, unsigned int bitsize, unsigned char *buf, unsigned int bufsize)
unsigned int bitmap_getlsb(bitmap_pt bitmap)
unsigned int bitmap_getmemsize(unsigned int bitsize)
int bitmap_getbit(bitmap_pt bitmap, unsigned int index)
unsigned int bitmap_getlsb2(bitmap_pt bitmap, unsigned int index)
int bitmap_setbitall(bitmap_pt bitmap, int value)
struct _bitmap_t bitmap_t
int bitmap_delete(bitmap_pt *bitmap_p)
bitmap_t * bitmap_pt
Definition: bitmap.h:43
Definition: bitmap.h:34
unsigned int level_depth
Definition: bitmap.h:38
unsigned int * map
Definition: bitmap.h:36
unsigned int level_offset_a[BITMAP_DEPTH_MAX]
Definition: bitmap.h:39
unsigned int bitsize
Definition: bitmap.h:35
unsigned int map_bytesize
Definition: bitmap.h:37
ubinos basic data type