1 /*******************************************************************************
2 ################################################################################
3 # Copyright (c) [2017-2019] [Radisys] #
5 # Licensed under the Apache License, Version 2.0 (the "License"); #
6 # you may not use this file except in compliance with the License. #
7 # You may obtain a copy of the License at #
9 # http://www.apache.org/licenses/LICENSE-2.0 #
11 # Unless required by applicable law or agreed to in writing, software #
12 # distributed under the License is distributed on an "AS IS" BASIS, #
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
14 # See the License for the specific language governing permissions and #
15 # limitations under the License. #
16 ################################################################################
17 *******************************************************************************/
19 /********************************************************************20**
21 Name: common memory allocation library
29 *********************************************************************21*/
34 /* Hash defines for alignment bytes */
35 #define CM_ALIGNBOUNDARY_FOUR 4 /* Align 32 bit */
36 #define CM_ALIGNBOUNDARY_EIGHT 8 /* Align 64 bit */
38 /* Macro Definitions */
40 #define CM_INIT_MEMCP(_memCp,_maxSize,_sMem) \
42 _memCp->first = NULLP; \
43 _memCp->last = NULLP; \
45 _memCp->memCb.maxSize = _maxSize;\
46 _memCp->memCb.memAllocated = 0; \
47 _memCp->memCb.initPtr = NULLP; \
48 _memCp->memCb.runPtr = NULLP; \
49 _memCp->memCb.sMem.region = _sMem->region; \
50 _memCp->memCb.sMem.pool = _sMem->pool; \
53 #define CM_INIT_MEMCPVAR(_memCp) \
55 _memCp->first = NULLP; \
56 _memCp->last = NULLP; \
58 _memCp->memCb.memAllocated = 0; \
59 _memCp->memCb.initPtr = NULLP; \
60 _memCp->memCb.runPtr = NULLP; \
64 #define CM_ALIGN_SIZE(_size) \
66 if( (_size % CM_ALIGNBOUNDARY_EIGHT) ) \
67 _size = _size + ( CM_ALIGNBOUNDARY_EIGHT - \
68 (_size % CM_ALIGNBOUNDARY_EIGHT)); \
71 #define CM_ALIGN_SIZE(_size) \
73 if( (_size % CM_ALIGNBOUNDARY_FOUR) ) \
74 _size = _size + ( CM_ALIGNBOUNDARY_FOUR - \
75 (_size % CM_ALIGNBOUNDARY_FOUR)); \
77 #endif /* ALIGN_64BIT */
79 #define CMCHKUNPKPTR(func, val, ptr, mBuf) \
82 if ((ret = func(val, ptr, mBuf)) != ROK) \
86 #define CMGETMBLK(ptr, size, pptr) \
89 ret = cmGetMem( ptr, size, pptr); \
96 #endif /* __CMMBLKH__ */
99 /********************************************************************30**
102 **********************************************************************/