OpenClovis Logo

clHeapApi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2012 OpenClovis Solutions Inc. All Rights Reserved.
3  *
4  * This file is available under a commercial license from the
5  * copyright holder or the GNU General Public License Version 2.0.
6  *
7  * The source code for this program is not published or otherwise
8  * divested of its trade secrets, irrespective of what has been
9  * deposited with the U.S. Copyright office.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * For more information, see the file COPYING provided with this
17  * material.
18  */
19 
32 #ifndef _CL_HEAP_API_H_
33 #define _CL_HEAP_API_H_
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #include <clPoolIpi.h>
40 #include <clMemStats.h>
41 
45 typedef enum {
50 
55 
61 
62 } ClHeapModeT;
63 
68 typedef struct {
74 
88  ClBoolT lazy;
89 
93  ClPoolConfigT *pPoolConfig;
94 
98  ClUint32T numPools;
100 
101 /*****************************************************************************
102  * Functions
103  *****************************************************************************/
104 
136 ClPtrT clHeapAllocate(CL_IN ClUint32T size);
161 void clHeapFree(CL_IN ClPtrT pAddress);
188 ClPtrT clHeapCalloc(CL_IN ClUint32T numChunks,CL_IN ClUint32T chunkSize);
189 /*****************************************************************************/
190 
191 #ifndef __KERNEL__
192 /*****************************************************************************/
229 /*****************************************************************************/
230 
259 /*****************************************************************************/
260 ClRcT clHeapInit(void);
261 /*****************************************************************************/
262 ClRcT clHeapExit(void);
263 /*****************************************************************************/
264 
304 ClPtrT clHeapRealloc(CL_IN ClPtrT pAddress,CL_IN ClUint32T size);
305 /*****************************************************************************/
306 
332 ClRcT clHeapShrink(CL_IN const ClPoolShrinkOptionsT *pShrinkOptions);
333 /*****************************************************************************/
334 
362 /*****************************************************************************/
363 
387 ClRcT clHeapStatsGet(CL_OUT ClMemStatsT *pHeapStats);
388 /*****************************************************************************/
389 
426 ClRcT clHeapPoolStatsGet(CL_IN ClUint32T numPools,CL_OUT ClUint32T *pPoolSize,CL_OUT ClPoolStatsT *pHeapPoolStats);
427 /*****************************************************************************/
428 
463 /*****************************************************************************/
464 
498 /*****************************************************************************/
499 
543 ClRcT clHeapHooksRegister(CL_IN ClPtrT (*allocHook) (ClUint32T),
544  CL_IN ClPtrT (*reallocHook)(ClPtrT ,ClUint32T),
545  CL_IN ClPtrT (*callocHook)(ClUint32T,ClUint32T),
546  CL_IN void (*freeHook)(ClPtrT )
547  );
548 /*****************************************************************************/
549 
584 /*****************************************************************************/
585 
586 #endif
587 
588 #ifdef __cplusplus
589 }
590 #endif
591 
592 #endif
593 
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
#define CL_OUT
CL_OUT macro assists in clearly defining arguments of an API, but has no actual meaning.
Definition: clCommon.h:110
#define CL_IN
CL_IN macro assists in clearly defining arguments of an API, but has no actual meaning.
Definition: clCommon.h:106
ClRcT clHeapHooksDeregister(void)
De-registers the hooks registered for CL_HEAP_CUSTOM_MODE.
ClRcT clHeapModeGet(CL_OUT ClHeapModeT *pMode)
Returns the mode set during configuration.
ClRcT clHeapHooksRegister(CL_IN ClPtrT(*allocHook)(ClUint32T), CL_IN ClPtrT(*reallocHook)(ClPtrT, ClUint32T), CL_IN ClPtrT(*callocHook)(ClUint32T, ClUint32T), CL_IN void(*freeHook)(ClPtrT))
Register functions to be used in CL_HEAP_CUSTOM_MODE.
void clHeapFree(CL_IN ClPtrT pAddress)
Frees a pre-allocated memory.
ClPtrT clHeapAllocate(CL_IN ClUint32T size)
Allocates memory of the requested size.
ClRcT clHeapLibCustomInitialize(const ClHeapConfigT *pHeapConfig)
Customizes the initialization of heap library in CL_HEAP_CUSTOM_MODE.
ClRcT clHeapLibCustomFinalize(void)
Customizes the finalization of heap library in CL_HEAP_CUSTOM_MODE.
ClPtrT clHeapRealloc(CL_IN ClPtrT pAddress, CL_IN ClUint32T size)
Changes the size of the memory block (chunk).
ClRcT clHeapStatsGet(CL_OUT ClMemStatsT *pHeapStats)
Returns the statistics collected by heap module.
ClRcT clHeapLibInitialize(CL_IN const ClHeapConfigT *pHeapConfig)
Initializes the heap library.
ClRcT clHeapPoolStatsGet(CL_IN ClUint32T numPools, CL_OUT ClUint32T *pPoolSize, CL_OUT ClPoolStatsT *pHeapPoolStats)
Returns the statistics collected by heap library for an individual pool.
ClHeapModeT
Heap Allocation modes.
Definition: clHeapApi.h:45
ClPtrT clHeapCalloc(CL_IN ClUint32T numChunks, CL_IN ClUint32T chunkSize)
Allocates memory for an array and initializes it to zero.
ClRcT clHeapShrink(CL_IN const ClPoolShrinkOptionsT *pShrinkOptions)
Shrinks the configured pools of memory.
ClRcT clHeapLibFinalize(void)
Finalizes the heap library.
@ CL_HEAP_PREALLOCATED_MODE
OpenClovis implementation of the memory management library.
Definition: clHeapApi.h:49
@ CL_HEAP_NATIVE_MODE
Native C mode.
Definition: clHeapApi.h:54
@ CL_HEAP_CUSTOM_MODE
Custom pools.
Definition: clHeapApi.h:60
ClHeapConfigT to be fetched by EO and contains the configuration of the heap library.
Definition: clHeapApi.h:68
ClHeapModeT mode
Allocation mode.
Definition: clHeapApi.h:73
ClPoolConfigT * pPoolConfig
Array of pool configurations.
Definition: clHeapApi.h:93
ClUint32T numPools
Number of pools in the pPoolConfig array.
Definition: clHeapApi.h:98
ClBoolT lazy
A pool can grow even after it exhausts its current allocation.
Definition: clHeapApi.h:88

Generated on Tue Jan 10 10:29:15 PST 2012 for OpenClovis SDK using Doxygen