SysLink API Reference  2.21.03.11
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
IHeap.h
Go to the documentation of this file.
1 
61 /*
62  * ============================================================================
63  *
64  * Copyright (c) 2008-2012, Texas Instruments Incorporated
65  *
66  * Redistribution and use in source and binary forms, with or without
67  * modification, are permitted provided that the following conditions
68  * are met:
69  *
70  * * Redistributions of source code must retain the above copyright
71  * notice, this list of conditions and the following disclaimer.
72  *
73  * * Redistributions in binary form must reproduce the above copyright
74  * notice, this list of conditions and the following disclaimer in the
75  * documentation and/or other materials provided with the distribution.
76  *
77  * * Neither the name of Texas Instruments Incorporated nor the names of
78  * its contributors may be used to endorse or promote products derived
79  * from this software without specific prior written permission.
80  *
81  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
82  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
83  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
84  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
85  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
86  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
87  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
88  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
89  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
90  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
91  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
92  * Contact information for paper mail:
93  * Texas Instruments
94  * Post Office Box 655303
95  * Dallas, Texas 75265
96  * Contact information:
97  * http://www-k.ext.ti.com/sc/technical-support/product-information-centers.htm?
98  * DCMP=TIHomeTracking&HQS=Other+OT+home_d_contact
99  * ============================================================================
100  *
101  */
102 
103 
104 
105 #ifndef HEAP_H_0x7033
106 #define HEAP_H_0x7033
107 
108 
109 /* OSAL and utils */
111 #include <ti/syslink/utils/Trace.h>
112 
113 
114 #if defined (__cplusplus)
115 extern "C" {
116 #endif
117 
118 
119 /* =============================================================================
120  * Forward declarations
121  * =============================================================================
122  */
127 
132 
133 
134 /* =============================================================================
135  * Function pointer types for heap operations
136  * =============================================================================
137  */
139 typedef Ptr (*IHeap_allocFxn) (IHeap_Handle handle,
140  SizeT size,
141  SizeT align);
142 
144 typedef Void (*IHeap_freeFxn) (IHeap_Handle handle,
145  Ptr block,
146  SizeT size);
147 
149 typedef Void (*IHeap_getStatsFxn) (IHeap_Handle handle,
150  Memory_Stats * stats);
151 
152 /*
153  * ! @brief Type for function pointer to indicate whether the heap may block
154  * during an alloc or free call
155  */
156 typedef Bool (*IHeap_isBlockingFxn) (IHeap_Handle handle);
157 
159 typedef Ptr (*IHeap_getKnlHandleFxn) (IHeap_Handle handle);
160 
161 
162 /* =============================================================================
163  * Structures & Enums
164  * =============================================================================
165  */
180  Ptr obj;
182 };
183 
184 
185 /* =============================================================================
186  * APIs
187  * =============================================================================
188  */
200 static inline Ptr IHeap_alloc (IHeap_Handle handle,
201  SizeT size,
202  SizeT align)
203 {
204  Ptr buffer;
205 
206  GT_assert (curTrace, (((IHeap_Object *) handle)->alloc != NULL));
207  buffer = ((IHeap_Object *) handle)->alloc (handle, size, align);
208  return (buffer);
209 }
210 
211 
221 static inline Void IHeap_free (IHeap_Handle handle,
222  Ptr block,
223  SizeT size)
224 {
225  GT_assert (curTrace, (((IHeap_Object *) handle)->free != NULL));
226  ((IHeap_Object *) handle)->free (handle, block, size);
227 }
228 
229 
238 static inline Void IHeap_getStats (IHeap_Handle handle,
239  Memory_Stats * stats)
240 {
241  GT_assert (curTrace, (((IHeap_Object *) handle)->getStats != NULL));
242  ((IHeap_Object *) handle)->getStats (handle, stats);
243 }
244 
245 
256 static inline Bool IHeap_isBlocking (IHeap_Handle handle)
257 {
258  Bool isBlocking;
259  GT_assert (curTrace, (((IHeap_Object *) handle)->isBlocking != NULL));
260  isBlocking = ((IHeap_Object *) handle)->isBlocking (handle);
261  return (isBlocking);
262 }
263 
264 
276 static inline Ptr IHeap_getKnlHandle (IHeap_Handle handle)
277 {
278  Ptr knlHandle;
279  GT_assert (curTrace, (((IHeap_Object *) handle)->getKnlHandle != NULL));
280  knlHandle = ((IHeap_Object *) handle)->getKnlHandle (handle);
281  return (knlHandle);
282 }
283 
284 
285 #if defined (__cplusplus)
286 }
287 #endif /* defined (__cplusplus) */
288 
289 
290 #endif /* HEAP_H_0x7033 */
291 
Copyright 2014, Texas Instruments Incorporated