SYS/BIOS  7.00
HeapMin.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, Texas Instruments Incorporated - https://www.ti.com
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
46 /*
47  * ======== HeapMin.h ========
48  */
49 
50 #ifndef ti_sysbios_heaps_HeapMin__include
51 #define ti_sysbios_heaps_HeapMin__include
52 
53 #include <stdbool.h>
54 #include <stddef.h>
55 #include <stdint.h>
56 
57 #include <ti/sysbios/knl/Queue.h>
58 
62 
64 /* BIOS 6.x compatibility, use -Dxdc_std__include to disable */
65 #include <xdc/std.h>
66 
67 #define ti_sysbios_heaps_HeapMin_long_names
68 #include "HeapMin_defs.h"
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74 
78 #define HeapMin_A_zeroSize "heap size must be > 0"
79 
86 #define HeapMin_E_freeError "free() invalid in growth-only HeapMin"
87 
88 typedef struct {
89  IHeap_Object iheap;
91  size_t remainSize;
92  size_t startSize;
101  char *buf;
103 
105 typedef struct {
106  Queue_Struct objQ;
107 } HeapMin_Module_State;
110 typedef struct {
119  char *buf;
132  size_t size;
134 
135 
143 #define HeapMin_Handle_upCast(handle) ((IHeap_Handle)(handle))
144 
151 extern void * HeapMin_alloc(void *handle, size_t size, size_t align, Error_Block *eb);
152 
160 extern void HeapMin_free(void *handle, void * buf, size_t size);
161 
171 extern bool HeapMin_isBlocking(void *handle);
172 
179 extern void HeapMin_getStats(void *handle, Memory_Stats *statBuf);
180 
193 extern HeapMin_Handle HeapMin_create(const HeapMin_Params *params, Error_Block *eb);
194 
206 extern HeapMin_Handle HeapMin_construct(HeapMin_Struct *obj, const HeapMin_Params *params);
207 
216 extern void HeapMin_delete(HeapMin_Handle *handle);
217 
223 extern void HeapMin_destruct(HeapMin_Struct *obj);
224 
236 extern void HeapMin_Params_init(HeapMin_Params *prms);
237 
246 extern HeapMin_Handle HeapMin_Object_first(void);
247 
258 extern HeapMin_Handle HeapMin_Object_next(HeapMin_Handle heap);
259 
261 extern void HeapMin_init(void);
262 
263 static inline HeapMin_Handle HeapMin_handle(HeapMin_Struct *str)
264 {
265  return ((HeapMin_Handle)str);
266 }
267 
268 static inline HeapMin_Struct * HeapMin_struct(HeapMin_Handle h)
269 {
270  return ((HeapMin_Struct *)h);
271 }
272 
273 #define HeapMin_module ((HeapMin_Module_State *) &(HeapMin_Module_state))
274 
276 #ifdef __cplusplus
277 }
278 #endif
279 
280 #endif /* ti_sysbios_heaps_HeapMin__include */
281 
283 #undef ti_sysbios_heaps_HeapMin_long_names
284 #include "HeapMin_defs.h"
size_t remainSize
Definition: HeapMin.h:91
void HeapMin_free(void *handle, void *buf, size_t size)
Free a block of memory back to the heap.
IHeap_Object iheap
Definition: HeapMin.h:89
bool HeapMin_isBlocking(void *handle)
Can this heap block the caller.
struct HeapMin_Struct HeapMin_Object
void * HeapMin_alloc(void *handle, size_t size, size_t align, Error_Block *eb)
Allocate a block of memory from the heap.
Static and run-time memory manager.
void HeapMin_delete(HeapMin_Handle *handle)
Delete a HeapMin heap.
struct HeapMin_Struct * HeapMin_Handle
void HeapMin_destruct(HeapMin_Struct *obj)
Destruct a HeapMin heap.
Queue_Elem objElem
Definition: HeapMin.h:90
Opaque queue element.
Definition: Queue.h:204
HeapMin_Handle HeapMin_Object_first(void)
return handle of the first HeapMin on HeapMin list
Runtime error manager.
Queue Manager.
char * buf
Buffer that will be managed by the heap instance.
Definition: HeapMin.h:119
Error block.
Definition: Error.h:152
size_t startSize
Definition: HeapMin.h:92
void HeapMin_Params_init(HeapMin_Params *prms)
Initialize the HeapMin_Params structure with default values.
char * buf
Buffer that will be managed by the heap instance.
Definition: HeapMin.h:101
Definition: HeapMin.h:88
Interface to heap functions.
Definition: HeapMin.h:110
Memory heap statistics.
Definition: Memory.h:94
size_t size
Size (in MADUs) of the heap.
Definition: HeapMin.h:132
HeapMin_Handle HeapMin_construct(HeapMin_Struct *obj, const HeapMin_Params *params)
Construct a HeapMin heap.
HeapMin_Handle HeapMin_create(const HeapMin_Params *params, Error_Block *eb)
Create a HeapMin heap.
void HeapMin_getStats(void *handle, Memory_Stats *statBuf)
get memory stats for a HeapMin object
HeapMin_Handle HeapMin_Object_next(HeapMin_Handle heap)
return handle of the next HeapMin on HeapMin list
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale