ubinos
heap.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_HEAP_H_
31 #define UBICLIB_HEAP_H_
32 
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37 
46 #include <ubinos_config.h>
47 #include <ubinos/type.h>
48 
50 #define HEAP_ERR__POLLUTED_TOP -21
51 
52 #define HEAP_ERR__POLLUTED_BOTTOM -22
53 
54 #define HEAP_ERR__POLLUTED_HEADER -23
55 
56 #define HEAP_ERR__UNSUPPORTED -24
57 
59 typedef struct __heap_tip_t
60 {
61  unsigned int type :8;
62  unsigned int valid :1;
63  unsigned int reserved :7;
64  unsigned int reserved2 :16;
65 } _heap_tip_t;
66 
68 typedef _heap_tip_t * heap_pt;
69 
85 int ubiclib_heap_comp_init(unsigned int addr, unsigned int size);
86 
98 
113 int heap_create(heap_pt * heap_p, unsigned int addr, unsigned int size);
114 
145 int heap_create_ext(heap_pt * heap_p, unsigned int addr, unsigned int size,
146  int algorithm0, int locktype0, unsigned int m0, unsigned int fblcount0,
147  int algorithm1, int locktype1, unsigned int m1, unsigned int fblcount1);
148 
160 int heap_delete(heap_pt * heap_p);
161 
174 void * heap_malloc(heap_pt heap, unsigned int size);
175 
188 void * heap_mallocn(heap_pt heap, unsigned int size);
189 
202 void * heap_mallocr(heap_pt heap, unsigned int size);
203 
217 int heap_free(heap_pt heap, void * ptr);
218 
270 int heap_checkblockboundary(heap_pt heap, void * ptr);
271 
285 
301 int heap_getblocksize(heap_pt heap, void * ptr, unsigned int * size_p);
302 
312 void * mallocn(size_t size);
313 
323 void * mallocr(size_t size);
324 
338 int heap_getsize(heap_pt heap, unsigned int * size_p);
339 
353 int heap_getrequestedsize(heap_pt heap, unsigned int * size_p);
354 
375 int heap_getrequestedsize_ext(heap_pt heap, unsigned int * size_p,
376  unsigned int * nsize_p, unsigned int * rsize_p);
377 
391 int heap_getrequestedsizemax(heap_pt heap, unsigned int * size_p);
392 
413 int heap_getrequestedsizemax_ext(heap_pt heap, unsigned int * size_p,
414  unsigned int * nsize_p, unsigned int * rsize_p);
415 
429 int heap_getallocatedcount(heap_pt heap, unsigned int * count_p);
430 
451 int heap_getallocatedcount_ext(heap_pt heap, unsigned int * count_p,
452  unsigned int * ncount_p, unsigned int * rcount_p);
453 
467 int heap_getallocatedcountmax(heap_pt heap, unsigned int * count_p);
468 
489 int heap_getallocatedcountmax_ext(heap_pt heap, unsigned int * count_p,
490  unsigned int * ncount_p, unsigned int * rcount_p);
491 
505 int heap_getallocatedsize(heap_pt heap, unsigned int * size_p);
506 
527 int heap_getallocatedsize_ext(heap_pt heap, unsigned int * size_p,
528  unsigned int * nsize_p, unsigned int * rsize_p);
529 
543 int heap_getallocatedsizemax(heap_pt heap, unsigned int * size_p);
544 
565 int heap_getallocatedsizemax_ext(heap_pt heap, unsigned int * size_p,
566  unsigned int * nsize_p, unsigned int * rsize_p);
567 
581 int heap_getfreeblockcount(heap_pt heap, unsigned int * count_p);
582 
603 int heap_getfreeblockcount_ext(heap_pt heap, unsigned int * count_p,
604  unsigned int * ncount_p, unsigned int * rcount_p);
605 
619 int heap_getblockoverhead(heap_pt heap, unsigned int * overhead_p);
620 
632 int heap_printheapinfo(heap_pt heap);
633 
645 unsigned int heap_group_calc_fblcount(unsigned int size, unsigned int m);
646 
658 unsigned int heap_wbuddy_calc_fblcount(unsigned int size, unsigned int m);
659 
671 unsigned int heap_pgroup_calc_fblcount(unsigned int size, unsigned int m);
672 
673 #ifdef __cplusplus
674 }
675 #endif
676 
677 #endif /* UBICLIB_HEAP_H_ */
heap_getsize
int heap_getsize(heap_pt heap, unsigned int *size_p)
heap_getrequestedsizemax_ext
int heap_getrequestedsizemax_ext(heap_pt heap, unsigned int *size_p, unsigned int *nsize_p, unsigned int *rsize_p)
heap_malloc
void * heap_malloc(heap_pt heap, unsigned int size)
heap_getrequestedsize_ext
int heap_getrequestedsize_ext(heap_pt heap, unsigned int *size_p, unsigned int *nsize_p, unsigned int *rsize_p)
_heap_tip_t
struct __heap_tip_t _heap_tip_t
heap_mallocn
void * heap_mallocn(heap_pt heap, unsigned int size)
heap_group_calc_fblcount
unsigned int heap_group_calc_fblcount(unsigned int size, unsigned int m)
__heap_tip_t::type
unsigned int type
Definition: heap.h:61
__heap_tip_t::reserved2
unsigned int reserved2
Definition: heap.h:64
heap_pgroup_calc_fblcount
unsigned int heap_pgroup_calc_fblcount(unsigned int size, unsigned int m)
ubiclib_heap_comp_init
int ubiclib_heap_comp_init(unsigned int addr, unsigned int size)
__heap_tip_t
Definition: heap.h:59
__heap_tip_t::valid
unsigned int valid
Definition: heap.h:62
heap_getallocatedcount_ext
int heap_getallocatedcount_ext(heap_pt heap, unsigned int *count_p, unsigned int *ncount_p, unsigned int *rcount_p)
type.h
ubinos basic data type
heap_mallocr
void * heap_mallocr(heap_pt heap, unsigned int size)
heap_getblocksize
int heap_getblocksize(heap_pt heap, void *ptr, unsigned int *size_p)
heap_getfreeblockcount_ext
int heap_getfreeblockcount_ext(heap_pt heap, unsigned int *count_p, unsigned int *ncount_p, unsigned int *rcount_p)
heap_getallocatedcountmax
int heap_getallocatedcountmax(heap_pt heap, unsigned int *count_p)
heap_create
int heap_create(heap_pt *heap_p, unsigned int addr, unsigned int size)
heap_create_ext
int heap_create_ext(heap_pt *heap_p, unsigned int addr, unsigned int size, int algorithm0, int locktype0, unsigned int m0, unsigned int fblcount0, int algorithm1, int locktype1, unsigned int m1, unsigned int fblcount1)
heap_checkblockboundaryall
int heap_checkblockboundaryall(heap_pt heap)
heap_getfreeblockcount
int heap_getfreeblockcount(heap_pt heap, unsigned int *count_p)
mallocn
void * mallocn(size_t size)
heap_getrequestedsize
int heap_getrequestedsize(heap_pt heap, unsigned int *size_p)
heap_checkblockboundary
int heap_checkblockboundary(heap_pt heap, void *ptr)
heap_getallocatedsizemax
int heap_getallocatedsizemax(heap_pt heap, unsigned int *size_p)
heap_getallocatedsizemax_ext
int heap_getallocatedsizemax_ext(heap_pt heap, unsigned int *size_p, unsigned int *nsize_p, unsigned int *rsize_p)
heap_wbuddy_calc_fblcount
unsigned int heap_wbuddy_calc_fblcount(unsigned int size, unsigned int m)
heap_delete
int heap_delete(heap_pt *heap_p)
mallocr
void * mallocr(size_t size)
heap_free
int heap_free(heap_pt heap, void *ptr)
heap_getrequestedsizemax
int heap_getrequestedsizemax(heap_pt heap, unsigned int *size_p)
heap_getallocatedcount
int heap_getallocatedcount(heap_pt heap, unsigned int *count_p)
heap_getallocatedcountmax_ext
int heap_getallocatedcountmax_ext(heap_pt heap, unsigned int *count_p, unsigned int *ncount_p, unsigned int *rcount_p)
heap_pt
_heap_tip_t * heap_pt
Definition: heap.h:68
heap_getblockoverhead
int heap_getblockoverhead(heap_pt heap, unsigned int *overhead_p)
ubiclib_heap_comp_init_reent
int ubiclib_heap_comp_init_reent(void)
heap_getallocatedsize_ext
int heap_getallocatedsize_ext(heap_pt heap, unsigned int *size_p, unsigned int *nsize_p, unsigned int *rsize_p)
heap_printheapinfo
int heap_printheapinfo(heap_pt heap)
__heap_tip_t::reserved
unsigned int reserved
Definition: heap.h:63
heap_getallocatedsize
int heap_getallocatedsize(heap_pt heap, unsigned int *size_p)