ubinos
bitmap.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 Sung Ho Park
3  Contact: ubinos.org@gmail.com
4 
5  This file is part of the itf_ubinos component of the Ubinos.
6 
7  GNU General Public License Usage
8  This file may be used under the terms of the GNU
9  General Public License version 3.0 as published by the Free Software
10  Foundation and appearing in the file license_gpl3.txt included in the
11  packaging of this file. Please review the following information to
12  ensure the GNU General Public License version 3.0 requirements will be
13  met: http://www.gnu.org/copyleft/gpl.html.
14 
15  GNU Lesser General Public License Usage
16  Alternatively, this file may be used under the terms of the GNU Lesser
17  General Public License version 2.1 as published by the Free Software
18  Foundation and appearing in the file license_lgpl.txt included in the
19  packaging of this file. Please review the following information to
20  ensure the GNU Lesser General Public License version 2.1 requirements
21  will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22 
23  Commercial Usage
24  Alternatively, licensees holding valid commercial licenses may
25  use this file in accordance with the commercial license agreement
26  provided with the software or, alternatively, in accordance with the
27  terms contained in a written agreement between you and rightful owner.
28  */
29 
30 #ifndef UBICLIB_BITMAP_H_
31 #define UBICLIB_BITMAP_H_
32 
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37 
46 #include <ubinos_config.h>
47 #include <ubinos/type.h>
48 
53 #define BITMAP_DEPTH_MAX 4
54 
56 typedef struct _bitmap_t
57 {
58  unsigned int bitsize;
59  unsigned int * map;
60  unsigned int map_bytesize;
61  unsigned int level_depth;
63 } bitmap_t;
64 
66 typedef bitmap_t * bitmap_pt;
67 
69 #define BITMAP_INITVALUE(bitsize) { \
70  bitsize, \
71  NULL, \
72  0, \
73  0, \
74  {0, } \
75 }
76 
95 int bitmap_init(bitmap_pt bitmap, unsigned int bitsize, unsigned char * buf,
96  unsigned int bufsize);
97 
105 unsigned int bitmap_getmemsize(unsigned int bitsize);
106 
114 unsigned int bitmap_getmapsize(unsigned int bitsize);
115 
128 int bitmap_create(bitmap_pt * bitmap_p, unsigned int bitsize);
129 
141 int bitmap_delete(bitmap_pt * bitmap_p);
142 
155 int bitmap_getbit(bitmap_pt bitmap, unsigned int index);
156 
171 int bitmap_setbit(bitmap_pt bitmap, unsigned int index, int value);
172 
185 int bitmap_setbitall(bitmap_pt bitmap, int value);
186 
194 unsigned int bitmap_getlsb(bitmap_pt bitmap);
195 
205 unsigned int bitmap_getlsb2(bitmap_pt bitmap, unsigned int index);
206 
214 unsigned int bitmap_getmsb(bitmap_pt bitmap);
215 
216 #ifdef __cplusplus
217 }
218 #endif
219 
220 #endif /* UBICLIB_BITMAP_H_ */
bitmap_getmapsize
unsigned int bitmap_getmapsize(unsigned int bitsize)
bitmap_delete
int bitmap_delete(bitmap_pt *bitmap_p)
bitmap_setbitall
int bitmap_setbitall(bitmap_pt bitmap, int value)
bitmap_getlsb
unsigned int bitmap_getlsb(bitmap_pt bitmap)
bitmap_create
int bitmap_create(bitmap_pt *bitmap_p, unsigned int bitsize)
_bitmap_t::map
unsigned int * map
Definition: bitmap.h:59
bitmap_getmemsize
unsigned int bitmap_getmemsize(unsigned int bitsize)
type.h
ubinos basic data type
_bitmap_t::level_offset_a
unsigned int level_offset_a[BITMAP_DEPTH_MAX]
Definition: bitmap.h:62
BITMAP_DEPTH_MAX
#define BITMAP_DEPTH_MAX
Definition: bitmap.h:53
bitmap_t
struct _bitmap_t bitmap_t
_bitmap_t::level_depth
unsigned int level_depth
Definition: bitmap.h:61
bitmap_getbit
int bitmap_getbit(bitmap_pt bitmap, unsigned int index)
_bitmap_t
Definition: bitmap.h:56
bitmap_getlsb2
unsigned int bitmap_getlsb2(bitmap_pt bitmap, unsigned int index)
bitmap_getmsb
unsigned int bitmap_getmsb(bitmap_pt bitmap)
bitmap_setbit
int bitmap_setbit(bitmap_pt bitmap, unsigned int index, int value)
bitmap_init
int bitmap_init(bitmap_pt bitmap, unsigned int bitsize, unsigned char *buf, unsigned int bufsize)
bitmap_pt
bitmap_t * bitmap_pt
Definition: bitmap.h:66
_bitmap_t::map_bytesize
unsigned int map_bytesize
Definition: bitmap.h:60
_bitmap_t::bitsize
unsigned int bitsize
Definition: bitmap.h:58