ubinos
heap.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_HEAP_H_
8 #define UBICLIB_HEAP_H_
9 
10 #ifdef __cplusplus
11 extern "C"
12 {
13 #endif
14 
23 #include <ubinos_config.h>
24 #include <ubinos/type.h>
25 
27 #define HEAP_ERR__POLLUTED_TOP -21
29 #define HEAP_ERR__POLLUTED_BOTTOM -22
31 #define HEAP_ERR__POLLUTED_HEADER -23
33 #define HEAP_ERR__UNSUPPORTED -24
34 
35 
37 #define HEAP_FLAG_NO__TFL_PERSISTENT 0
39 #define HEAP_FLAG_NO__TFL_TEMP 1
41 #define HEAP_FLAG_NO__TFL_RESIZABLE 2
42 
44 typedef struct __heap_tip_t
45 {
46  unsigned int type :8;
47  unsigned int valid :1;
48  unsigned int reserved :7;
49  unsigned int reserved2 :16;
51 
53 typedef _heap_tip_t * heap_pt;
54 
66 
78 
93 int heap_create(heap_pt * heap_p, unsigned int addr, unsigned int size);
94 
125 int heap_create_ext(heap_pt * heap_p, unsigned int addr, unsigned int size,
126  int algorithm0, int locktype0, unsigned int m0, unsigned int fblcount0,
127  int algorithm1, int locktype1, unsigned int m1, unsigned int fblcount1);
128 
140 int heap_delete(heap_pt * heap_p);
141 
156 void * heap_malloc(heap_pt heap, unsigned int size, int dir);
157 
171 int heap_free(heap_pt heap, void * ptr);
172 
187 void * heap_resize(heap_pt heap, void * ptr, unsigned int size);
188 
201 int heap_power_off(heap_pt heap, int dir);
202 
215 int heap_power_on(heap_pt heap, int dir);
216 
268 int heap_checkblockboundary(heap_pt heap, void * ptr);
269 
283 
294 void * heap_get_addr(heap_pt heap);
295 
306 void * heap_get_end(heap_pt heap);
307 
319 
331 
348 int heap_set_flag(heap_pt heap, void * ptr, int flag_no, int flag);
349 
364 int heap_get_flag(heap_pt heap, void * ptr, int flag_no);
365 
379 
393 
406 void * heap_get_next_allocated_block(heap_pt heap, void * ptr);
407 
420 void * heap_get_prev_allocated_block(heap_pt heap, void * ptr);
421 
437 int heap_getblocksize(heap_pt heap, void * ptr, unsigned int * size_p);
438 
454 int heap_getblock_usable_size(heap_pt heap, void * ptr, unsigned int * size_p);
455 
471 int heap_getblock_allocated_size(heap_pt heap, void * ptr, unsigned int * size_p);
472 
486 int heap_getsize(heap_pt heap, unsigned int * size_p);
487 
501 int heap_getexpandablesize(heap_pt heap, unsigned int * size_p);
502 
516 int heap_getrequestedsize(heap_pt heap, unsigned int * size_p);
517 
538 int heap_getrequestedsize_ext(heap_pt heap, unsigned int * size_p,
539  unsigned int * nsize_p, unsigned int * rsize_p);
540 
554 int heap_getrequestedsizemax(heap_pt heap, unsigned int * size_p);
555 
576 int heap_getrequestedsizemax_ext(heap_pt heap, unsigned int * size_p,
577  unsigned int * nsize_p, unsigned int * rsize_p);
578 
592 int heap_getallocatedcount(heap_pt heap, unsigned int * count_p);
593 
614 int heap_getallocatedcount_ext(heap_pt heap, unsigned int * count_p,
615  unsigned int * ncount_p, unsigned int * rcount_p);
616 
630 int heap_getallocatedcountmax(heap_pt heap, unsigned int * count_p);
631 
652 int heap_getallocatedcountmax_ext(heap_pt heap, unsigned int * count_p,
653  unsigned int * ncount_p, unsigned int * rcount_p);
654 
668 int heap_getallocatedsize(heap_pt heap, unsigned int * size_p);
669 
690 int heap_getallocatedsize_ext(heap_pt heap, unsigned int * size_p,
691  unsigned int * nsize_p, unsigned int * rsize_p);
692 
706 int heap_getallocatedsizemax(heap_pt heap, unsigned int * size_p);
707 
728 int heap_getallocatedsizemax_ext(heap_pt heap, unsigned int * size_p,
729  unsigned int * nsize_p, unsigned int * rsize_p);
730 
744 int heap_getfreeblockcount(heap_pt heap, unsigned int * count_p);
745 
766 int heap_getfreeblockcount_ext(heap_pt heap, unsigned int * count_p,
767  unsigned int * ncount_p, unsigned int * rcount_p);
768 
782 int heap_getblockoverhead(heap_pt heap, unsigned int * overhead_p);
783 
796 
808 unsigned int heap_group_calc_fblcount(unsigned int size, unsigned int m);
809 
821 unsigned int heap_group_calc_fblcount_raw(unsigned int size, unsigned int m);
822 
834 unsigned int heap_wbuddy_calc_fblcount(unsigned int size, unsigned int m);
835 
847 unsigned int heap_wbuddy_calc_fblcount_raw(unsigned int size, unsigned int m);
848 
860 unsigned int heap_pgroup_calc_fblcount(unsigned int size, unsigned int m);
861 
873 unsigned int heap_pgroup_calc_fblcount_raw(unsigned int size, unsigned int m);
874 
875 #ifdef __cplusplus
876 }
877 #endif
878 
879 #endif /* UBICLIB_HEAP_H_ */
int heap_get_flag(heap_pt heap, void *ptr, int flag_no)
int heap_create(heap_pt *heap_p, unsigned int addr, unsigned int size)
void * heap_resize(heap_pt heap, void *ptr, unsigned int size)
int heap_getsize(heap_pt heap, unsigned int *size_p)
int heap_checkblockboundaryall(heap_pt heap)
int heap_get_block_overhead(heap_pt heap)
int heap_set_flag(heap_pt heap, void *ptr, int flag_no, int flag)
int heap_getallocatedcount_ext(heap_pt heap, unsigned int *count_p, unsigned int *ncount_p, unsigned int *rcount_p)
int heap_getblockoverhead(heap_pt heap, unsigned int *overhead_p)
void * heap_malloc(heap_pt heap, unsigned int size, int dir)
int heap_printheapinfo(heap_pt heap)
int heap_getallocatedcount(heap_pt heap, unsigned int *count_p)
unsigned int heap_wbuddy_calc_fblcount(unsigned int size, unsigned int m)
unsigned int heap_pgroup_calc_fblcount(unsigned int size, unsigned int m)
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)
void * heap_get_next_allocated_block(heap_pt heap, void *ptr)
_heap_tip_t * heap_pt
Definition: heap.h:53
int heap_getallocatedcountmax(heap_pt heap, unsigned int *count_p)
void * heap_get_last_allocated_block(heap_pt heap, int dir)
int heap_getallocatedsize_ext(heap_pt heap, unsigned int *size_p, unsigned int *nsize_p, unsigned int *rsize_p)
int heap_free(heap_pt heap, void *ptr)
int heap_getexpandablesize(heap_pt heap, unsigned int *size_p)
int heap_getfreeblockcount_ext(heap_pt heap, unsigned int *count_p, unsigned int *ncount_p, unsigned int *rcount_p)
unsigned int heap_wbuddy_calc_fblcount_raw(unsigned int size, unsigned int m)
int heap_delete(heap_pt *heap_p)
unsigned int heap_group_calc_fblcount_raw(unsigned int size, unsigned int m)
void * heap_get_addr(heap_pt heap)
struct __heap_tip_t _heap_tip_t
int heap_getallocatedsizemax(heap_pt heap, unsigned int *size_p)
int heap_getallocatedsizemax_ext(heap_pt heap, unsigned int *size_p, unsigned int *nsize_p, unsigned int *rsize_p)
int heap_getallocatedsize(heap_pt heap, unsigned int *size_p)
int heap_getblocksize(heap_pt heap, void *ptr, unsigned int *size_p)
void * heap_get_first_allocated_block(heap_pt heap, int dir)
int heap_power_off(heap_pt heap, int dir)
int heap_getrequestedsizemax_ext(heap_pt heap, unsigned int *size_p, unsigned int *nsize_p, unsigned int *rsize_p)
int heap_getfreeblockcount(heap_pt heap, unsigned int *count_p)
int heap_getrequestedsizemax(heap_pt heap, unsigned int *size_p)
int heap_getblock_allocated_size(heap_pt heap, void *ptr, unsigned int *size_p)
int heap_get_block_allocated_size_min(heap_pt heap)
unsigned int heap_group_calc_fblcount(unsigned int size, unsigned int m)
void * heap_get_prev_allocated_block(heap_pt heap, void *ptr)
int heap_getallocatedcountmax_ext(heap_pt heap, unsigned int *count_p, unsigned int *ncount_p, unsigned int *rcount_p)
int heap_checkblockboundary(heap_pt heap, void *ptr)
int heap_getrequestedsize_ext(heap_pt heap, unsigned int *size_p, unsigned int *nsize_p, unsigned int *rsize_p)
int heap_power_on(heap_pt heap, int dir)
void * heap_get_end(heap_pt heap)
int ubiclib_heap_comp_init_reent(void)
int heap_getrequestedsize(heap_pt heap, unsigned int *size_p)
int ubiclib_heap_comp_init(void)
int heap_getblock_usable_size(heap_pt heap, void *ptr, unsigned int *size_p)
unsigned int heap_pgroup_calc_fblcount_raw(unsigned int size, unsigned int m)
Definition: heap.h:45
unsigned int reserved2
Definition: heap.h:49
unsigned int type
Definition: heap.h:46
unsigned int reserved
Definition: heap.h:48
unsigned int valid
Definition: heap.h:47
ubinos basic data type